Jump to content
  • Advertisement
Sign in to follow this  
s_p_oneil

Odd sizes with glTexSubImage2D

This topic is 4818 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

I am aware of the need to use a power-of-two texture with glTexSubImage2D. However, it really bugs me that the sub-image can't be an odd size. I need to be able to blit odd size patches up to a larger texture (without resampling). So far the only way I can get it to work is to keep a copy of the whole texture in system memory, copy updates into it manually, and then copy the whole thing to video memory each frame. It's a 1024x1024 texture, which makes this very slow. Of course, I could also have a bit mask to determine if a quadrant has changed, updating each quadrant as necessary. Or I could get fancy and implement some sort of quad-tree where I only update the leaves. I just keep thinking that there must be a better way. Is there? Sean

Share this post


Link to post
Share on other sites
Advertisement
Keeping a system-mem resident copy, modifying that and then doing a subimage update is what seems to be commonplace.
look into GL_EXT_pixel_buffer_object for a (theoretically significant) speed increase on GL 2.0 complaint hardware (though the spec is written against GL 1.5).

Share this post


Link to post
Share on other sites
You can use glTexSubImage to update an arbitrary sized region. Only the texture itself is (or was, as mentioned below) required to have a power of two size, but the size you update can be of any size.

Actually, that was before OpenGL 2.0 and the NPOT-texture extension. Now you can use any size of the texture aswell. But you have always been able, even at the pre NPOT-texture time, to update arbitrary regions with glTexSubImage.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Brother Bob
You can use glTexSubImage to update an arbitrary sized region. Only the texture itself is (or was, as mentioned below) required to have a power of two size, but the size you update can be of any size.

Actually, that was before OpenGL 2.0 and the NPOT-texture extension. Now you can use any size of the texture aswell. But you have always been able, even at the pre NPOT-texture time, to update arbitrary regions with glTexSubImage.


Have you tried it recently? I tried it on both nVidia and ATI cards with the latest drivers, and it doesn't work. I'm using a 1024x1024 texture. When I update a 16x16 region, everything works fine. When I update a 17x17, 18x18, or 17x18 region, it breaks.

Share this post


Link to post
Share on other sites
Quote:
Original post by silvermace
Keeping a system-mem resident copy, modifying that and then doing a subimage update is what seems to be commonplace.
look into GL_EXT_pixel_buffer_object for a (theoretically significant) speed increase on GL 2.0 complaint hardware (though the spec is written against GL 1.5).


Do you mean using glDrawPixels with a pixel buffer? If so, I'll take a look into it.

EDIT: That other post was me, too.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
Quote:
Original post by Brother Bob
You can use glTexSubImage to update an arbitrary sized region. Only the texture itself is (or was, as mentioned below) required to have a power of two size, but the size you update can be of any size.

Actually, that was before OpenGL 2.0 and the NPOT-texture extension. Now you can use any size of the texture aswell. But you have always been able, even at the pre NPOT-texture time, to update arbitrary regions with glTexSubImage.


Have you tried it recently? I tried it on both nVidia and ATI cards with the latest drivers, and it doesn't work. I'm using a 1024x1024 texture. When I update a 16x16 region, everything works fine. When I update a 17x17, 18x18, or 17x18 region, it breaks.

Yes I have tried, and it works as it should. Works with any combination of POT and NPOT textures, and POT and NPOT subimage updates.

Have a GF6800 with latest driver.

edit: Just to be complete, I tried it at work on an ATI X300, and it works just as good there. Maybe not the very latest drivers, but quite new ones at least.

[Edited by - Brother Bob on September 26, 2005 2:07:07 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by zedzeek
look into the un/pack pixel transfer settings (default is 4 u want 1) and all that related stuff


This may be causing the problem. It failed on my GeForce 6800 and my Radeon 9600 with the latest drivers, but I'm using the default pixel transfer settings. I'll play around with it tonight and see if I can get it working. Thanks.

Share this post


Link to post
Share on other sites
Quote:
Original post by zedzeek
look into the un/pack pixel transfer settings (default is 4 u want 1) and all that related stuff


That was it. Thanks a bunch.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!