Jump to content
  • Advertisement
Sign in to follow this  
Macin Software

Rows in glTexSubImage2D?

This topic is 653 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 am doing Quake2-like dynamic lighting. Technically it works, but its a bit slow. Problem with that was that glTexSubImage2D function doesnt work correctly when I just want to update w*h portion of lightmap image. It does only the first line good, and then it breaks the texture - this is caused by glTexSubImage2D just replacing the linear sequence in big lightmap, so it doesnt anyhow check if it is in rectangle - it just goes linear. What I am doing now, is that I call many glTexSubImage2Ds for each line with height=1. But if I did just one glTexSubImage2D, it would be faster on some comps. It would be awesome if there existed some thing that fixes the problem, or at least stores the big lightmap somehow in linear way to work good with this function, and yet still be usable in rendering without artifacts.

Please dont suggest me shaders or persuade me to use them, I intentionally do it this way.

Share this post


Link to post
Share on other sites
Advertisement

You need glPixelStorei (GL_UNPACK_ROW_LENGTH for this.

As a general rule, when using glTexSubImage, fewer large updates will always be faster than many small updates.  Don't be fooled into thinking that using GL_RGB will be better because it uses less memory; using GL_RGB will actually force a format conversion in the driver which can grind you down to single-digit framerates on some hardware.  Use GL_BGRA instead, and GL_UNSIGNED_INT_8_8_8_8_REV for maximum performance across all hardware.

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!