Search code examples
androidopengl-estexturespbo

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?


Solution

  • Since I answered it in a comment here is a more direct answer:

    // width and height is 256 and max is 512
    // texture coordinates
    float uMax = (width / max);
    float vMax = (height / max);
    
    _texCoords[0] = 0.0; _texCoords[1] =  vMax;
    _texCoords[2] = uMax; _texCoords[3] =  vMax;
    _texCoords[4] = 0.0; _texCoords[5] =  0.0;
    _texCoords[6] = uMax; _texCoords[7] =  0.0;
    

    Now use these texcoords to render and you can stick a 256x256 texture in a 512x512 buffer. The width and height you want to use can be any size equal to or below your max size.