Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android NDK OpenGL ES 2.0 Texture Pitch

Is there any way to blit a texture in opengl es 2.0 with a pitch that differs from its width. Normally I would fix this by using a PBO or adjusting the GL_PACK_ROW_LENGTH via glPixelStore. However it seems neither GL_PIXEL_UNPACK_BUFFER for binding a buffer to or GL_PACK_ROW_LENGTH exist on the Android platform.

glTex(Sub)Image2D does not support this.

Any tips?

like image 601
Halsafar Avatar asked Jun 13 '11 23:06

Halsafar


1 Answers

Quoting @Halsafar

In some scenarios, this can be solved by adjusting texture coordinates.


Lets say I have a 512 x 512 texture pitched at 512 * bitdepth

but the data I want to use is pitched to 256 * bitdepth

I go ahead and glSubTexImage2D still but adjust the texture coords to be 0 to (256/512)

instead of 0 to 1.

In other words strip off the part of the texture I'm not using.

like image 154
Sherif elKhatib Avatar answered Nov 14 '22 00:11

Sherif elKhatib