Sign in to follow this  

Rows in glTexSubImage2D?

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this