Advertisement

Bitmaps and back_buffers

Started by February 20, 2002 09:12 PM
0 comments, last by trekey19966 22 years, 8 months ago
I am creating a 2d game but I need help loading 16 bit Bitmaps onto the back_buffer? HELP!!!
David Smithwww.geocities.com/gamespp5004-"If you can't dream it; it can't be done"-David Smith
which platform or API are you planning to use, win32, opengl, dx?

loading bitmap is not that difficult. you can find source code easily I guess (try www.wotsit.org or google)

and back buffer usage changes from API to API..

In Win32 (with simple gdi functions), you CreateCompatibleDC with your current dc (drawing context) and draw there
here is the code I use for initialization
  	// creating a dc compatible with parent window	m_pDC = new CDC;	m_pDC->CreateCompatibleDC(parentDC);	// creating abitmap for the new dc (parentDC is passed to here as a CDC* from the main window)	HBITMAP hbitmap = CreateCompatibleBitmap(parentDC->m_hDC, m_iWidth, m_iHeight);	DeleteObject(SelectObject(m_pDC->m_hDC, hbitmap));	// initializing the new bitmap to all white	m_pDC->BitBlt(0, 0, m_iWidth, m_iHeight, NULL, 0, 0, WHITENESS);  


then I do all my drawing operations on newly created m_pDC.. when I finsih everything, I call
pDC->BitBlt(left, top, m_iWidth, m_iHeight,m_pDC, 0, 0, SRCCOPY);

what you should do is to load your bmp, copy it to backbuffer (m_pDC) ant then BitBlt it to original (active) pDC

in OpenGL, you just initialize your window with back buffer support and call SwapBuffers after you draw your stuff

for dx, I have no idea..

I hope this helps

-----------
my quote is under construction
-----------my quote is under construction

This topic is closed to new replies.

Advertisement