我想将数据从CPU上传到OpenGL中的多重采样2D纹理。 对于2D纹理,我可以使用该功能:
void glTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels);将数据从像素推送到纹理。 如何对多重采样2D纹理做同样的事情?
I want to upload data from CPU to a multisample 2D texture in OpenGL. For 2D texture I could use the function:
void glTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels);to push data from pixels to the texture. How can I do the same thing for multisample 2D texture?
最满意答案
您无法通过OpenGL的客户端访问多重采样纹理的图像数据。 唯一的方法是使用着色器和/或FBO。
从概念上讲,您可以将全屏四边形渲染为多重采样纹理,并在片段着色器中使用gl_SampleID来确定您当前正在写入的样本。 与gl_FragCoord结合使用,您可以例如索引到TBO,该TBO包含要存储在纹理中的原始每样本值。
但是,由于样品位置完全受GL控制,因此该操作是否有用是值得怀疑的。 因人而异。
You can't acces the image data of multisample textures via the client side of OpenGL. The only way around that is by using shaders and/or FBOs.
Conceptually, you can render a full-screen quad to a multisample texture and in the fragment shader, use gl_SampleID to determine which sample you are currently writing to. In combination with the gl_FragCoord, you can for example index into an TBO which holds the raw per-sample value you want to store in the texture.
However, as the sample locations are completely under the GL's control it is questionable if this operation is of any use. YMMV.
更多推荐
发布评论