Jump to content
  • Advertisement
Sign in to follow this  
justinrwalsh

Win32 GDI DoubleBuffering question

This topic is 4732 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok im trying to implement double buffering and its not working and i cant find any articles on the toic, so here is what i am doing
HDC screenDC = GetDC(NULL);
HDC backDC = CreateCompatibleDC(screenDC);

TransparentImage( backDC,
		(LONG)posX, (LONG)posY, (LONG)width, (LONG)height, bitmapDC,
		0, 0, (LONG)width, (LONG)height,
		RGB(255, 0, 255));	//Going to make this constant for now

BitBlt(screenDC,
                    0, 0,
                    GetDeviceCaps(screenDC, HORZRES), GetDeviceCaps(screenDC, VERTRES),
                    backDC,
                    0, 0,
                    SRCCOPY);
	ReleaseDC(0, backDC);
Just turns the screen white. my objects do not draw... please help me!!!

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Try changing this:

HDC screenDC = GetDC(NULL);

to this:

HDC screenDC = GetDC(HWND);

Where HWND is the handle to your window.

Hope this helps!

Share this post


Link to post
Share on other sites
Just thought I'd mention that when you do get double-buffering working that it'll only be able to eliminate the flickering; you still may notice some shearing. There's unfortunately no way around this, as there's no way to force windows into copying the backbuffer during the vertical retrace, even though there really should be. You're also out of luck in detecting it yourself and trying to copy manually during the retrace because a) GDI doesn't expose the raster state to applications, and b) even if you knew it was happening, windows is message-based (read: not real-time) so theres no guarantee you'd get the messsage fast enough anyhow. The only way to respond to real-time events is to have the support of something at a lower level, like a device driver as OpenGL and DirectX do. I have seen one successful implimentation (which was a clever hack) which had the application spawning a custom device driver in a thread which implemented a callback to the render function though.

In any event, flickering is the real enemy, shearing isn't too bad and its the same effect you'd see in any game if you have the V-sync disabled.

Share this post


Link to post
Share on other sites
Yeah i havnet noticed too much shearing, this is actually for the pocketPC. I really dont want to right my own blitters and get into the game api so i am going to use GDI stuff for very simple games, like the 80's rerto classics. But so far just double buffering tends to work pretty well, and elimenates the flicker all together.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!