问题描述
问题的上下文是 Android 环境中的 OpenGL ES 2.0.我有质感.显示或使用它没有问题.
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()
获得的值,即纹理的 FILTER
和 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:获取纹理大小和其他信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!