Jump to content
  • Advertisement
Sign in to follow this  
Sventevith

glTexSubImage2D - problem

This topic is 4973 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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".

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
glTexSubImage2D only modifies one mip level, right? Could that be the problem?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!