drawing in Win32

Started by
3 comments, last by uglybdavis 11 years, 4 months ago
Hey everyone,
I'm just having some fun with reinventing many wheels. laugh.png
I just love to understand the low level programming!

So here is what I want to do: basically I want to make my own pixel drawing system.
I want to create a pixel class which stores a color. After I make an array of [640][480] which will be my "screen".
When I gave all pixels a color I want to draw every pixel on the screen.

How can I draw all pixels on the screen? SetPixel is a very slow method so I want to avoid that.
Is it possible to directly connect my pixels to the screen pixels?
How does the GDI communicate with the screen pixels?
How can I communicate with the screen pixels without using the GDI or SetPixel? Is it even possible?


Kind regards,
Jonathan
Advertisement
Copying over this data by yourself would require you to write to video memory yourself, which is a no-go.

Just use GDI or a library like D2D to get your image rendered.
GDI should provide functions to blit bitmaps to the screen, so there's no messing with pixels individually.

I gets all your texture budgets!

CreateDIBSection with BitBlt/StretchDIBits/SetDIBitsToDevice is the fastest method as i know. Here: http://sol.gfxile.net/wintut/ch3.html you can find a great tutorial for it.

How can I communicate with the screen pixels without using the GDI or SetPixel? Is it even possible?


This is fundamentally impossible in win32. In fact that's why api's like GDI and Directx were invented.

History lesson:

DOS allowed a programmer direct access to all hardware on your machine, when windows 95 came along it used protected mode so as a result programmers could not directly write to the video memory. Microsoft then devised a solution to this problem and came up with api's like DirectDraw and GDI.
What sk8beast said. This was my first experiment with software rendering: https://www.dropbox.com/s/eal3z9ypngftw1b/ssr.zip

This topic is closed to new replies.

Advertisement