Opengl ES 2.0:获取纹理大小和其他信息

Opengl ES 2.0 : Get texture size and other info(Opengl ES 2.0:获取纹理大小和其他信息)
本文介绍了Opengl ES 2.0:获取纹理大小和其他信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题的上下文是 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() 获得的值,即纹理的 FILTERWRAP 参数.

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:获取纹理大小和其他信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

OpenGl error Validation Failed: No vertex array object bound(OpenGL错误验证失败:未绑定顶点数组对象)
Why do I get error INVALID_OPERATION when I call glMultiDrawElementsIndirect(为什么在调用glMultiDrawElementsInDirect时出现INVALID_OPERATION错误)
find out instantiating object in the constructor of a class(在类的构造函数中找出实例化对象)
Implementing trapezoidal sprites in LibGDX(在 LibGDX 中实现梯形精灵)
Drawing a gradient in Libgdx(在 Libgdx 中绘制渐变)
OpenGL is not supported by the video driver(视频驱动程序不支持 OpenGL)