glTexSubImage2D - problem
Hi
I use glTexSubImage2D to modify texture, but it doesn't work.
When I display triangle I see unmodified Texture.
glGetError return "No Errors".
I called glGetTexImage and dumped pixels to raw file, when I checked this raw file I saw modifed Texture. But When I display textured objects, Texture is unmodified.
Help Please.
Sounds like something is wrong...
If you want a more detailed answer, I think you better provide a more detailed question. "Doesn't work" is not a detailed description of the problem.
If you want a more detailed answer, I think you better provide a more detailed question. "Doesn't work" is not a detailed description of the problem.
This is my code:
glBindTexture(GL_TEXTURE_2D, iTextureID);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 64, 64, GL_RGBA, GL_UNSIGNED_BYTE,pImage);
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, p);
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glVertexPointer( ...);
glTexCoordPointer( ... );
glDrawArrays( ... );
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
When I display object texture is unmodifiy, but glGetTexImage() returned modified iTextureID.
glGetError return "No Errors".
glBindTexture(GL_TEXTURE_2D, iTextureID);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 64, 64, GL_RGBA, GL_UNSIGNED_BYTE,pImage);
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_UNSIGNED_BYTE, p);
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glVertexPointer( ...);
glTexCoordPointer( ... );
glDrawArrays( ... );
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
When I display object texture is unmodifiy, but glGetTexImage() returned modified iTextureID.
glGetError return "No Errors".
There's nothing wrong with what you posted. Since the texture data is obviously modified, the problem is likely not with the texture being updated or not. Do you really render a completely new image to see the new texture? Could it be something stupid like not swapping buffers after rendering the new image, still showing the old image before the texture was updated?
I found it. It was problem with mip map.
When destation texture is:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexSubImage2D doesn't work.
But when is
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
Everything is o.k.
When destation texture is:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexSubImage2D doesn't work.
But when is
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
Everything is o.k.
no, glSubTexImage2D() is infact working, however you need to regenerate all the mipmap levels for the texture filtering to work properly.
You can either do this by hand (slow) or use automatic mipmap generation (extension : SGIS_generate_mipmaps) to have the driver/hardware do it for you.
Once a proper render to texture solution appears there will also be a function to update mipmaps without using the automatic system.
You can either do this by hand (slow) or use automatic mipmap generation (extension : SGIS_generate_mipmaps) to have the driver/hardware do it for you.
Once a proper render to texture solution appears there will also be a function to update mipmaps without using the automatic system.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement