如何将列表绘制到Pygame的屏幕上?
我正在编写一个程序,该程序在OpenGL着色器中计算一些像素内容。通过该计算,我获得了一个包含需要写入屏幕的每个像素的列表。有没有办法一次绘制所有这些数据,而不是迭代列表并绘制每个像素?我之所以问这个,是因为在列表中迭代包含我屏幕的所有百分比并单独将这些像素写入屏幕的列表非常慢。任何帮助都将不胜感激。谢谢。
I'm writing a program that calculates some pixel stuff in an OpenGL shader. With that calculation, I get a list containing every pixel that needs to be written to the screen. Is there a way I can draw all of this data at once rather than iterating through the list and drawing every pixel? I ask this because it would be extremely slow to iterate through the list that contains all the million pixels for my screen and individually write these pixels to the screen. Any help would be much appreciated. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
参阅如何将Pygame场景保存为jpeg?
请 颜色数据在帧缓冲器中,您可以使用代码> 在更新显示之前(
pygame.display.flip()
或pygame.display.update()
)。使用pygame> pygame.image.image.image.fromstring() >
要从缓冲区创建新表面:
如果数据在纹理中(例如存储在计算着色器中),则可以使用
See How to save pygame scene as jpeg?
If the color data is in the framebuffer you can read it with
glReadPixels
before the display is updated (beforepygame.display.flip()
orpygame.display.update()
). Usepygame.image.fromstring()
to create new Surfaces from the buffer:If the data is in a texture (e.g. stored in a compute shader) you can read it with
glGetTexImage
: