Skip to main content
gamedev.net
🔒 Locked

Win32 GDI DoubleBuffering question

Started by justinrwalsh Jun 12, 2005 at 10:50 PM 5 replies 2.8k views
Original Post
justinrwalsh
justinrwalsh
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!!!
NoMonkey
NoMonkey
That previous post was from me. Again, I hope it helps you out.
justinrwalsh
justinrwalsh
Thank you, that was exactly what i was looking for.

thanks again.
Ravyne
Ravyne
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.
throw table_exception("(? ???)? ? ???");
justinrwalsh
justinrwalsh
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.