OpenGL ES 2.0的:获取纹理尺寸和其他信息 [英] Opengl ES 2.0 : Get texture size and other info
问题描述
问题的背景是OpenGL ES 2.0的在Android环境。我有质感。没问题,显示或使用它。
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.
是否有一个以了解它的宽度和高度等信息(如内部格式)简单地从它的结合的id启动方法
Is there a method to know its width and height and other info (like internal format) simply starting from its binding id?
我需要保存的质感不知道纹理尺寸为位图。
I need to save texture to bitmap without knowing the texture size.
推荐答案
不在ES 2.0。它实际上是一种令人惊讶的功能是不存在的。就可以得到一个渲染的大小,但不是一个纹理,这似乎不一致的尺寸。
Not in ES 2.0. It's actually kind of surprising that the functionality is not there. You can get the size of a renderbuffer, but not the size of a texture, which seems inconsistent.
唯一可用的东西,你可以用 glGetTexParameteriv()
,这是过滤器
和获取值 WRAP
参数质感。
The only thing available are the values you can get with glGetTexParameteriv()
, which are the FILTER
and WRAP
parameters for the texture.
现在还没有ES 3.0两种。只有在ES 3.1, glGetTexLevelParameteriv()
加入,使您可以访问到所有你要找的值。例如,以获得当前绑定纹理的宽度和高度:
It's still not in ES 3.0 either. Only in ES 3.1, glGetTexLevelParameteriv()
was added, which gives you access to all the values you're looking for. For example to get the width and height of the currently bound texture:
int[] texDims = new int[2];
GLES31.glGetTexLevelParameteriv(GLES31.GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, texDims, 0);
GLES31.glGetTexLevelParameteriv(GLES31.GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, texDims, 1);
这篇关于OpenGL ES 2.0的:获取纹理尺寸和其他信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!