Opengl ES 2.0 : Get texture size and other info

后端 未结 3 1476
自闭症患者
自闭症患者 2021-01-13 05:49

The context of the question is OpenGL ES 2.0 in the Android environment. I have a texture. No problem to display or use it.

Is there a method to know its width and

3条回答
  •  感情败类
    2021-01-13 06:25

    I'll suggest a hack for doing this. Use ESSL's textureSize function. To access its result from the CPU side you're going to have to pass the texture as an uniform to a shader, and output the texture size as the r & g components of your shader output. Apply this shader to an 1x1px primitive drawn to a 1x1px FBO, then readback the drawn value from the GPU with glReadPixels.

    You'll have to be careful with rounding, clamping and FBO formats. You may need a 16-bit integer FBO format.

提交回复
热议问题