問題描述
問題的上下文是 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:獲取紋理大小和其他信息的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!