What's the fastest way to repeatedly fill a window with RGB data from an array?

ⅰ亾dé卋堺 提交于 2019-12-05 10:15:43

The best you can do using GDI is use SetDIBitsToDevice to directly copy the RGB data from your array to the window. Of course, DirectX is the way to go if you need to completely eliminate flickering.

GDI is absolutely not the way to go.

The best cross-windows-version way is to use Direct3D, and simply update the texture on a single full screen quad.

Direct2D is a new API (Win Vista with Service pack and above) which is the preferred mechanism if you do not need to support XP. Direct2d handles fonts and other system level tasks in an accelerated way.

Use DirectDraw. I had a full screen Game of Life which was bottle-necked on pixel drawing when I used GDI and after I switched to DirectDraw I started to pump out 60 fps easily.

The GDI function SetDIBitsToDevice will work fine.

Texturing a quad as suggested by theatrus will work as well, except it doesn't have to be full-screen and OpenGL is by far the most portable option, to make this happen, see glTexSubImage2D

A much more direct way is glDrawPixels

Ideally, though, your graphics code would use GPU-accelerated rendering directly into GPU memory, then you wouldn't need to worry about moving the bits from system memory into the GPU.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!