Hi,
I'm new to OpenGL.
I have an image loaded from a JPEG file into a char array(8 bit depth).
I'm using this pice of code to paint a texture on a rectangle just to show the image:
Code:
glTexImage2D(GL_TEXTURE_2D,0,1,iWidth,iHeight,0,GL_LUMINANCE,GL_UNSIGNED_BYTE,pcData); glBegin(GL_QUADS); //glTexCoord2f(0.0f, 1.0f); glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f); //glTexCoord2f(1.0f, 1.0f); glTexCoord2f(1.0f, 0.0f); glVertex2f(float(width()), 0.0f); //glTexCoord2f(1.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex2f(float(width()), float(height())); //glTexCoord2f(0.0f, 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, float(height())); glEnd(); glFlush();
If I use the uncommented "glTexCoord2f" functions, the image that I can see is inverted. I think that JPEG files store every line inverted(don't really know why but I think bmps also do this).
If I use the commented "glTexCoord2f" functions, the image is well shown but really don't understand why because I don't understand how "glTexCoord2f" works.
Can anyone tell me this simple question? Thanks,