glTexSubImage2D - problem

Started by
9 comments, last by yjh1982 19 years, 3 months ago
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.
Advertisement
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.
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".

When I display object texture is unmodifiy, but glGetTexImage() returned modified texture.
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?
glTexSubImage2D only modifies one mip level, right? Could that be the problem?
what the AP said is a possibilty
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.

Thx for Help for everybody :)
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.

This topic is closed to new replies.

Advertisement