David Stone
David Stone

Reputation: 1162

Updating only a horizontal subregion of a texture in OpenGL ES 2.0

This question is specific to OpenGL ES 2.0 on Android, but there may be work-arounds that use common GL functionality so I'm tagging this as "opengl".

tl;dr: is there another way to specify glPixelStorei(GL_UNPACK_ROW_LENGTH) in OpenGL ES 2.0? Because according to the spec, the GL_UNPACK_ROW_LENGTH doesn't exist in OpenGL ES 2.0.

I have a texture that I update frequently by calling glTexImage2D, from a fixed region of client memory that is being updated independently. In some cases I know only a subregion of the image has changed. I can limit the number of rows that are updated by calling glTexSubImage2d and specifying only the top half of the texture (for example). This results in significant performance improvement.

But when I tried to also limit the number of columns updated (say I want to update only the upper-left quadrant of the texture), I noticed that there is no stride parameter to glTexSubImage2d. Since for my application the area of client memory that is the source for all glTexImage2d/glTexSubImage2d has the full width of the image, I need to specify that as the stride if I call glTexSubImage2d.

glPixelStorei(GL_UNPACK_ROW_LENGTH,stride) seems to be the way to do this, but GL_UNPACK_ROW_LENGTH isn't supported in OpenGL 2.0 ES. So is there a way to update a horizontal subregion of a texture in OpenGL ES 2.0?

Upvotes: 2

Views: 946

Answers (1)

Nicol Bolas
Nicol Bolas

Reputation: 474336

In OpenGL ES 2.0? Nope. There's an extension for it though; I have no idea how widely implemented it is. And ES 3.0 has full support for it.

Upvotes: 3

Related Questions