Quote:Original post by Tac-Tics
Also, I don't understand the difference between the 3rd and 3rd-from-last parameters in glTexImage2D. What is the difference between "Format" and "Internal Format"? And does "GL_RGB" mean the same as "3" for the internal format.
Third-from-last parameter (together with second-from-last) tells OpenGL what the source format is. You cannot just give OpenGL a pointer and expect it to correctly parse any arbitrary image data. You must tell it what the pointed to data really is.
For example: an RGB image where each component is a byte (GL_RGB and GL_UNSIGNED_BYTE), a greyscale image where each pixel is represented by an integer (GL_LUMINANCE and GL_INT), or an BGRA (watch the component order aswell) image with floatingpoint components (GL_BGRA with GL_FLOAT). Without this information, you cannot say how the image is really stored.
The third parameter tells OpenGL in what format the texture should be stored internally. GL_RGB says you want the image stored as a three-component RGB texture. GL_LUMINANCE means a single component grayscale image. Conversions are done as needed by OpenGL.
For example: you pass an RGB image and say the internal format is RGBA, the alpha channel is automatically added. If you pass an RGBA image and say the internal format is GL_ALPHA, the RGB channels are dropped and only the alpha channel is used.
And yes, 3 and GL_RGB means the same thing when used to specify internal format. But don't use numbers, use the explicit constants instead.
Quote:Original post by Tac-Tics
EDIT:
Durr. I also forgot glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
. I'm not sure 100% what this line actually does either X-(
Default minification filter is
GL_LINEAR_MIPMAP_NEAREST. This minification filter requires a full set of mipmap levels to be a complete texture object. Since you didn't change the default and only uploaded the base level, the texture object is incomplete. An incomplete texture object, when used in rendering, will disable texturing as long as the texture object is bound and incomplete.
Changing the filtering to
GL_LINEAR, mipmaps are no longer required, and the texture object requires only the base level. Since you have uploaded that, the texture object is now complete, and will work as expected.