I am using glTexImage2D to allocate texture memory, then later specifying the image with glTexSubImage2D, as we discussed a while back. Everything has been working fine, except I’ve discovered some INVALID_OPERATION errors I cannot explain. Consider:
glGenTextures(1,&name); glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB,0); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D,name); glTexImage2D(GL_TEXTURE_2D,0,GL_RGB8,8192,4096,0,GL_RGB,GL_UNSIGNED_BYTE,0x0000); glBindTexture(GL_TEXTURE_2D,name);
Here, glTexImage2D is used to allocate texture memory, but it makes the last call to glBindTexture generate INVALID_OPERATION. Likewise, when glTexSubImage2D is called later (using PBO), it also generates INVALID_OPERATION:
glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB,buffer); glPixelStorei(GL_UNPACK_ALIGNMENT,4); glTexSubImage2D(GL_TEXTURE_2D,0,0,0,8192,4096,GL_BGRA,GL_UNSIGNED_BYTE,0x0000);
The funny thing is everything appears to work, even though I get these INVALID_OPERATION errors on both NVIDIA and ATI. The only thing I can think of is the texture is in an incomplete state or I somehow change the dimensionality with glTexImage2D. But then how does one use glTexImage2D to just allocate texture memory?
I’ve also tried with much smaller textures. I’m sure I’m overlooking something.