Sign in to follow this  
Absolution

Fastest way to set a pixel

Recommended Posts

What is the fastest way to set a pixel in a windows app? That is, what are my options if I just want direct control over the video memory in a fullscreen application? Is going with old school DirectDraw the best option? The GDI seems like it would be slow, and does it support fullscreen anyway? I basically want the lowest level control over the video memory (just to play around with blitting and such old school style.)

Share this post


Link to post
Share on other sites
Unless you are writing graphics card drivers, you can no longer have full control over the video memory like you used to in the old days.

The fastest way with GDI I've ever found to manipulate pixels is to create an array of RGBQUADs in normal memory, manipulate that then copy it to a device with SetDIBits.

I'm pretty sure (although not 100% on this) that even with DirectDraw, when you Lock(), it copies the surface into system memory, then copies it back when you Unlock(), so even that is not really direct access to the video memory.

You can't even directly access the video memory of a command-prompt console at 0xB8000000 like you used to be able to with 16 bit applications.

Share this post


Link to post
Share on other sites
What is the goal you wish to achieve? Want to write some kind of software renderer?
If so, you don't EVER call functions for setting individual pixels. You make dedicated functions for manipulating the buffer directly to draw horizontal line spans. Then you call this multiple times to draw a triangle etc.

I don't bother with DD in my software renderer yet. I just draw to a DIB and use the GDI to blit that to screen. DD would be better though.

Share this post


Link to post
Share on other sites
Ya, I realize I can no longer directly access the memory outside of kernel mode, I just wanted to know the fastest way to basically draw to a full screen window. The RGBQUADs array sounds like a simple and easy way. Thanks for the help.

Share this post


Link to post
Share on other sites
The fastest way to have a surface you can simply set pixels on is to use Direct3D/OpenGL and create a single texture to cover your entire screen. Lock/CopyTexSubImage the texture, then map it onto a single window sized quad.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this