本文介绍了在OpenGL ES 2.0中仅更新纹理的水平子区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题特定于Android上的OpenGL ES 2.0,但可能存在使用通用GL功能的变通办法,因此我将其标记为"opengl".

This question is specific to OpenGL ES 2.0 on Android, but there may be work-arounds that use common GL functionality so I'm tagging this as "opengl".

tl; dr:还有另一种在OpenGL ES 2.0中指定glPixelStorei(GL_UNPACK_ROW_LENGTH)的方法吗?因为根据规范GL_UNPACK_ROW_LENGTH在OpenGL中不存在ES 2.0.

tl;dr: is there another way to specify glPixelStorei(GL_UNPACK_ROW_LENGTH) in OpenGL ES 2.0? Because according to the spec, the GL_UNPACK_ROW_LENGTH doesn't exist in OpenGL ES 2.0.

我有一个纹理,该纹理是通过从独立更新的客户端内存的固定区域中调用glTexImage2D来频繁更新的.在某些情况下,我知道仅图像的一个子区域已更改.我可以限制的数量,方法是调用glTexSubImage2d并仅指定纹理的上半部分(例如).这样可以显着改善性能.

I have a texture that I update frequently by calling glTexImage2D, from a fixed region of client memory that is being updated independently. In some cases I know only a subregion of the image has changed. I can limit the number of rows that are updated by calling glTexSubImage2d and specifying only the top half of the texture (for example). This results in significant performance improvement.

但是当我尝试限制更新的列数时(例如,我只想更新纹理的左上角象限),我注意到没有跨度参数添加到glTexSubImage2d.由于对于我的应用程序来说,作为所有glTexImage2d/glTexSubImage2d来源的客户端内存区域具有图像的全宽度,因此如果我调用glTexSubImage2d,则需要将其指定为跨度.

But when I tried to also limit the number of columns updated (say I want to update only the upper-left quadrant of the texture), I noticed that there is no stride parameter to glTexSubImage2d. Since for my application the area of client memory that is the source for all glTexImage2d/glTexSubImage2d has the full width of the image, I need to specify that as the stride if I call glTexSubImage2d.

glPixelStorei(GL_UNPACK_ROW_LENGTH,stride)似乎是这样做的方法,但是OpenGL 2.0 ES不支持GL_UNPACK_ROW_LENGTH.那么有没有办法在OpenGL ES 2.0中更新纹理的水平子区域?

glPixelStorei(GL_UNPACK_ROW_LENGTH,stride) seems to be the way to do this, but GL_UNPACK_ROW_LENGTH isn't supported in OpenGL 2.0 ES. So is there a way to update a horizontal subregion of a texture in OpenGL ES 2.0?

推荐答案

在OpenGL ES 2.0中?没有.不过,有扩展名;我不知道它的实施范围如何. ES 3.0对此提供了全面的支持.

In OpenGL ES 2.0? Nope. There's an extension for it though; I have no idea how widely implemented it is. And ES 3.0 has full support for it.

这篇关于在OpenGL ES 2.0中仅更新纹理的水平子区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 08:44