用数组中的RGB数据重复填充窗口的最快方法是什么? [英] What's the fastest way to repeatedly fill a window with RGB data from an array?
问题描述
我目前正在写一个简单的游戏.我的图形代码每帧运行一次(每秒约30次),然后将RGB数据写入具有640 * 480 = 307200项的数组.
I'm currently writing a simple game. My graphics code runs once per frame (approximately 30 times per second), and writes RGB data to an array with 640 * 480 = 307200 entries.
我创建了一个Win32窗口,其客户区大小恰好为640 x 480像素.使RGB数据显示在否则为空的窗口中的最快方法是什么?
I have created a Win32 window with a client area exactly 640 x 480 pixels in size. What's the fastest way to get my RGB data displayed within the otherwise-empty window?
该窗口将需要每帧更新一次,因此我需要避免闪烁.我应该为此使用GDI吗?还是有使用其他库(例如DirectDraw)的更快方法?
The window will need to be updated every frame, so I need to avoid flickering. Should I use GDI for this? Or is there a faster approach using a different library - say, DirectDraw?
感谢所有答复.首先,让我排除Direct2D作为选项-我需要支持Windows XP.其次,我有3D背景知识,因此Yann Ramin和Ben Voigtto建议的方法(使用Direct3D/OpenGL和单个纹理四边形)是我过去一直这样做的方式.
Thanks for all the replies. Firstly, let me rule out Direct2D as an option - I need to support Windows XP. Secondly, I have a background in 3D so the method suggested by Yann Ramin and Ben Voigtto - use Direct3D/OpenGL and a single textured quad - is how I've always done this in the past.
但是,我很想知道2D API是否会是更好的解决方案.由于没有明确的答案,因此我编写了一个测试程序.该代码只是尽可能快地在屏幕上重复显示帧缓冲区.
However, I was interested to find out whether a 2D API would be a better solution. Since there has been no definite answer, I threw together a test program. The code simply displays a framebuffer on the screen repeatedly, as fast as possible.