Sign in to follow this  
EngineProgrammer

drawing in Win32

Recommended Posts

Hey everyone,
I'm just having some fun with reinventing many wheels. [img]http://public.gamedev.net//public/style_emoticons/default/laugh.png[/img]
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

Share this post


Link to post
Share on other sites
Radikalizm    4807
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.

Share this post


Link to post
Share on other sites
sk8beast    1532
CreateDIBSection with BitBlt/StretchDIBits/SetDIBitsToDevice is the fastest method as i know. Here: [url="http://sol.gfxile.net/wintut/ch3.html"]http://sol.gfxile.net/wintut/ch3.html[/url] you can find a great tutorial for it.

Share this post


Link to post
Share on other sites
ic0de    1012
[quote name='EngineProgrammer' timestamp='1354958425' post='5008447']
How can I communicate with the screen pixels without using the GDI or SetPixel? Is it even possible?
[/quote]

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 [url="http://en.wikipedia.org/wiki/Protected_mode"]protected mode[/url] 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.

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