OpenGL 中的快速纹素设置
我需要在 OpenGL 中渲染影响图。目前,我有 100 x 100 四边形渲染,并使用设定的颜色来表示地图上每个点的影响。有人建议我将渲染方法更改为带有纹理的四边形,然后让渲染管道接管速度。
基本测试表明 glTexSubImage2D 对于设置每帧 10,000 个纹素来说太慢。您有什么建议吗?每帧创建一个全新的纹理会更好吗?我的影响图采用标准化浮点数(0.0 到 1.0),并转换为灰度颜色(1.0f = 白色)。
谢谢:D
I'm in need of rendering an influence map in OpenGL. At present I have 100 x 100 quads rendering with a set color to represent the influence at each point on the map. I've been recommended to change my rendering method to one quad with a texture, then allowing the rendering pipeline to take over in speed.
Basic testing has shown that glTexSubImage2D is too slow for setting 10,000 texels per frame. Do you have any suggestions? Would it better to create an entirely new texture each frame? My influence map is in normalized floats (0.0 to 1.0) and that is converted to grayscale colors (1.0f = white).
Thanks :D
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您当前是否分别更新 10000 个纹素中的每一个,并调用 10000 次 glTexSubImage2D?
只需在 RAM 中使用一个 100x100 灰度浮点纹理(10000 个浮点的数组),直接更新值,然后通过一次 glTexImage2D 调用将整个数据发送到 GPU。您还可以使用缓冲区对象来允许在后台进行传输,但这应该是不必要的,因为您没有移动大量数据。
Are you currently updating each of the 10000 texels separately, with 10000 calls of glTexSubImage2D?
Just use one 100x100 grayscale float texture (array of 10000 floats) in RAM, update values directly to that and then send the whole data to GPU with one glTexImage2D call. You could also use buffer objects to allow the transfer happen on background, but it should be unnecessary since you are not moving very large amounts of data.