Hello everyone.
In my first tutorials, I had created a function for rendering a given 2D texture. The function is the following.
void renderTheTexture(GLfloat* texture, GLuint textureID, int textureSize)
{
glBindTexture(GL_TEXTURE_2D, textureID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, textureSize, textureSize, 0, GL_RGBA, GL_FLOAT, texture);
glPushMatrix();
glColor3f(1.0f, 1.0f, 1.0f);
glInterleavedArrays(GL_T2F_V3F, 0, texVertices); // Set our Array of elements to be drawn.
glDrawElements(GL_QUADS, 4, GL_UNSIGNED_INT, texIndices); // Draws it.
glPopMatrix();
}
Now I have been trying a FrameBuffer Object and rendering to texture. So I try rendering the image to a texture and then render the texture to the screen. So I changed my function to the following.
void renderTheTexture(GLuint textureID, int textureSize)
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, textureID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, textureSize, textureSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glPushMatrix();
glBegin(GL_QUADS);
glColor3f(1.0f, 1.0f, 1.0f);
glTexCoord2d(0.0, 0.0); glVertex2d(Xstart, Ystart);
glTexCoord2d(1.0, 0.0); glVertex2d(Xend, Ystart);
glTexCoord2d(1.0, 1.0); glVertex2d(Xend, Yend);
glTexCoord2d(0.0, 1.0); glVertex2d(Xstart, Yend);
glEnd();
// glInterleavedArrays(GL_T2F_V3F, 0, texVertices); // Set our Array of elements to be drawn.
// glDrawElements(GL_QUADS, 4, GL_UNSIGNED_INT, texIndices); // Draws it.
glPopMatrix();
glDisable(GL_TEXTURE_2D);
}
The thing is that if I comment out the lines glBegin() - glEnd(), and use the following 2 lines for rendering, I get a Segmentation Fault. The funny thing is that if I include these 2 lines between the glBegin() - glEnd() and comment out only the equivalent glTexCoord/glVertex, I have something rendered in the screen (not what I expect, but no Segm Fault).
Does anyone have any clue, what do I miss here ? Thanx a lot for any help.