• Advertisement

Archived

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

can window mode create back buffer?

This topic is 5792 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

Can window mode create back buffer? I have try the follow code, but it does work. Is window mode cannot create back buffer or some mistakes occur in the program?
  
m_pDD->SetCooperativeLevel(m_hWnd, DDSCL_NORMAL);

DDSURFACEDESC2	ddsd;

ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
ddsd.dwBackBufferCount = 1;

m_pDD->CreateSurface(&ddsd, &m_lpPrimary, NULL);

ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
m_lpPrimary->GetAttachedSurface(&ddsd.ddsCaps, &m_lpBackBuffer);
  

Share this post


Link to post
Share on other sites
Advertisement
check for error values.

or try flipping the back buffer,
it wont work...

{ Stating the obvious never helped any situation !! }

Share this post


Link to post
Share on other sites
Hmm, Im primarily 3D, but when I can''t create a backbuffer it means that the format that Im creating it in isn''t supported by the video card? Can this be a clue?

-------
"Programming is like sex make one mistake, and you have to support it forever."
Homepage: www.ussshrike.com/pcwebvia/

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hi, I suppose you should do something like this:

RECT *r = new RECT;
GetClientRect( m_hWindow, r );
ZeroMemory( &ddsd, sizeof( ddsd ) );
ddsd.dwSize = sizeof( ddsd );
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwWidth = r->right - r->left;
ddsd.dwHeight = r->bottom - r->top;
delete r;
hRetVal = m_lpddDirectDraw->CreateSurface( &ddsd, &m_lpdsBackBuff, NULL );

This code creates a backbuffer on which you can Blt() something later.

Share this post


Link to post
Share on other sites
ic. I can do that. Thank you.
I have another question about display GDI under full screen mode

I have two buttons in a window, i want to display those under fullscreen mode:


  
MyButton button1 = new MyButton(....); //<- This is button class that i made using CreateWindow("Button".....)

MyButton button2 = new MyButton(....);

pDD->CreateClipper(0, &ddClipper, NULL);
ddClipper->SetHWnd(0, hWnd);
pDD->FlipToGDISurface();

void TimerDraw() //<- this function for timer to call

{
lpPrimary->SetClipper(ddClipper);
lpPrimary->Blt(NULL, lpBackBuffer, NULL, DDBLT_WAIT, NULL);
}

i set a timer and it will call TimerDraw function to display content at each second. However, the button can only display one times and then never display. Why? And how can i solve it?

Share this post


Link to post
Share on other sites

  • Advertisement