OpenGL的ES图形纹理 [英] Opengl-es Drawing to texture

查看:372
本文介绍了OpenGL的ES图形纹理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在OpenGL-ES 2.0可以在FBO渲染到纹理,使用纹理的目标是大于屏幕?如果是这样,才有可能得出一个纹理四,填补了FBO纹理每个角落?如果不可能是有可能做到这一点在OpenGL-ES另一种方式?我在加载时的一些分层程序产生的图形,我想结合成单一纹理,以业绩保存在绘图时。

In opengl-es 2.0 can a fbo rendering to a texture, use a texture target that is larger than the screen? If so, is it possible to draw a textured quad, filling up the fbo-texture corner to corner? If not possible is it possible to do this in another way in opengl-es? I have some layered procedurally generated graphics at load time that I would like to combine into single textures in order to save on performance at draw time.

推荐答案

是的,绝对。只要质地具有色彩渲染格式(在ES 2.0是唯一 RGBA4 RGB5_A1 RGB565 ),它可以被用作呈现目标。取决于你的GPU的限制,这可以比显示分辨率显著较大

Yes, absolutely. As long as the texture has a color-renderable format (which in ES 2.0 are only RGBA4, RGB5_A1 and RGB565), it can be used as a render target. Depending on the limits of your GPU, this can be significantly larger than the display resolution.

这意味着,你主要是由最大纹理大小的限制。您可以查询与该值 glGetIntegerv(GL_MAX_TEXTURE_SIZE,...)

This means that you are primarily limited by the maximum texture size. You can query that value with glGetIntegerv(GL_MAX_TEXTURE_SIZE, ...).

有就是进场的另一个限制。 GL_MAX_VIEWPORT_DIMS 定义最大视口大小可以设置。你不能渲染到表面比这些值大得多。

There is another limit that comes into play. GL_MAX_VIEWPORT_DIMS defines the maximum viewport size you can set. You can't render to a surface larger than these values.

把他们俩撮合在一起,这将给你可以渲染到纹理的最大尺寸:

Putting these two together, this would give the maximum size of a texture you can render to:

GLint maxTexSize = 0;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize);

GLint maxViewportSize[2] = {0};
glGetIntegerv(GL_MAX_VIEWPORT_DIMS, maxViewportSize);

GLint maxRenderWidth = maxTexSize;
if (maxRenderWidth > maxViewportSize[0]) {
    maxRenderWidth = maxViewportSize[0];
}

GLint maxRenderHeight = maxTexSize;
if (maxRenderHeight > maxViewportSize[1]) {
    maxRenderHeight = maxViewportSize[1];
}

使用这些值,你可以创建一个大小的纹理 maxRenderWidth点¯xmaxRenderHeight ,并把它作为一个FBO附件。记住,你开始渲染之前设置视口大小相同也是如此。

Using these values, you can create a texture of size maxRenderWidth x maxRenderHeight, and use it as an FBO attachment. Remember to set the viewport to the same size as well before you start rendering.

我查了从两个不同的主要供应商的一对夫妇片与GPU的极限。在他们两个,最大纹理尺寸和最大的视区大小是相同的(4096之一,8192的除外)。如果这是很常见的这不会让我感到吃惊,但它绝对不是规格保证。

I checked the limits on a couple of tablets with GPUs from two different major vendors. On both of them, the maximum texture size and maximum viewport size were the same (4096 on one, 8192 on the other). It wouldn't surprise me if this is very common, but it's definitely not guaranteed by the spec.

ES 2.0允许最大纹理尺寸是为64小但你会发现限制是任何事情中途最近大得多。 2048是在你看到任何合理的电流GPU什么下端,并且八千一百九十二分之四千零九十六是常见的。的最大视口尺寸保证是至少作为显示一样大。

ES 2.0 allows the maximum texture size to be as small as 64. But you will find the limit to be much larger on anything halfway recent. 2048 is at the lower end of what you see on any reasonably current GPU, and 4096/8192 is common. The maximum viewport dimensions are guaranteed to be at least as large as the display.

这篇关于OpenGL的ES图形纹理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆