Archived

This topic is now archived and is closed to further replies.

trekey19966

Bitmaps and back_buffers

Recommended Posts

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

Share this post


Link to post
Share on other sites