Sign in to follow this  
SirGorthon

int array to HDC?!

Recommended Posts

SirGorthon    180
Howdy ya'll! First off I'd like to apologize if this topic has already been addressed! The search isn't working for me, and the HDC topics I've seen haven't really answered my question! Anywho, my situation is that I'm moving an engine of mine over to work in a window, and I've got an array of ints that store the colors to be displayed. My problem is that I have no idea how to go from an int array to an HDC, or if that's what I'm even supposed to do! I tried using SetPixel and SetPixelV 1024*768 times per frame, and the results weren't that great. (I wasn't expecting much, since that many function calls is never a good thing - I just wanted something to make sure everything up until the display part was working OK) I'm very new to Windows programming, and the places I've looked haven't really answered my question! Thanks bunches! Gorth

Share this post


Link to post
Share on other sites
mumpo    534
Using GDI (the rendering system that HDCs are a part of) for game graphics is a bad idea. Instead, use DirectX, OpenGL, SDL, or Allegro. Any of them will be much faster than GDI for what you are doing, plus some of them do more than just graphics, and all of them will allow you to make a fullscreen application, take advantage of hardware acceleration in some form, etc.. That said, if you really, really want to use GDI, the way I would do it would be to create a bitmap and memcpy() the values from your array to it each frame, then draw it on the window. This will still be very slow, it will just be a lot faster than using SetPixel() (I think...).

Share this post


Link to post
Share on other sites
Wan    1366
I agree Mumpo when it comes to using these libraries.
If you still want to use GDI, you can create an offscreen memory DC from the bitmap and bitblt this on the window's DC.

Share this post


Link to post
Share on other sites
Anon Mike    1098
If you do want to use then you need to keep your bitmap data in a format that GDI works with and then you can use BitBlt and friends instead of copying each pixel one-by-one. Your best bet is probably to use a DIB section.

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