Advertisement

Buffering Windows GDI

Started by August 18, 2001 12:48 AM
4 comments, last by Galileo430 23 years, 6 months ago
I''ve tryed to double buffer window GDI and so far it''s not working. I created one memory HDC and StrechBlt and Blt bitmaps on to it. I then Blt / Stretch Blt it onto the Screen DC. But I never get anything on screen. Do I have to set up a clipper or something? Anyone have a good weblink on Windows GDI? FYI: I know DDraw is 90000 times faster / better. No, I can''t use it for this.
------------------------------------------------------------I wrote the best video game ever, then I woke up...
Lets see some code
D.V.Carpe Diem
Advertisement
You don't need a clipper, Windows pretty much keeps you from having to do any work at all (part of the reason GDI is so slow). It would be helpful to see your code.

But, basically, you could do this:

      //Inside WndProcHDC hWindowDC, hMemoryDC;PAINTSTRUCT ps;HBITMAP hbitmap;RECT rect;switch(message){//...//WM_PAINTcase WM_PAINT:hWindowDC = BeginPaint(hwnd, &ps);hMemoryDC = CreateCompatibleDC(hWindowDC);GetClientRect(hwnd, ▭);hbitmap = CreateCompatibleBitmap(hWindowDC, rect.right, rect.bottom);SelectObject(hMemoryDC, hbitmap);PatBlt(hMemoryDC , 0, 0, rect.right, rect.bottom, WHITENESS);//DRAW STUFF USING MEMORYDCDrawWhatever(hMemoryDC);   //This can be anything,                           //just always use hMemoryDC                           //(not hWindowDC)//DONE DRAWINGBitBlt(hWindowDC, 0, 0, rect.right, rect.bottom, hMemoryDC, 0, 0, SRCCOPY);EndPaint(hwnd, &ps);DeleteDC(hmc);DeleteObject(hbitmap);break;//...default:return DefWindowProc(hwnd, message, wParam, lParam);}      


Edited by - Midnight Coder on August 18, 2001 2:19:22 AM
These are the basics of it..

  void CRender::SetRender(){	m_nRender = g_EngineData.m_opt_nRender;	// Do Operation Specific Start Up	if (m_nRender == RN_GDI)	{		m_gdiBackBuffer = ::CreateCompatibleDC(NULL);	}}void CRender::ClearScreen(){	if (m_nRender == RN_GDI)	{		CBrush Background;		HDC dcMem = ::CreateCompatibleDC(NULL);		SelectObject(dcMem, g_EngineData.m_gdiBitmaps[0]);		BitBlt(m_gdiBackBuffer, 0, 0, 320, 240, dcMem, 0, 0, SRCCOPY);	}}void CRender::SwapBuffers(HDC ScreenDC, RECT rctClient){	if (m_nRender == RN_GDI)	{		BitBlt(ScreenDC, 0, 0, 320, 240, m_gdiBackBuffer, 0, 0, SRCCOPY); // Rect use not implemented	}}  
------------------------------------------------------------I wrote the best video game ever, then I woke up...
I''ve made my own Paint-type drawing program using techniques like this, but I is too f***ing slow! To be honest with you, whatever you''re trying to do, I would use something else. (I would use DirectX, but maybe thats just me.)



~ There''s no substitute for failure ~
You need to select a bitmap into the temp DC.

This topic is closed to new replies.

Advertisement