Jump to content
  • Advertisement

Archived

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

backbuffers - windowed ddraw

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

I can''t figure out how to blit to a back buffer using DirectDraw in windowed mode. The literature I''ve found on the subject is all either obsolete, too confusing (some make liberal use of HDCs, others rects, and so on without actually explaining what they do) or not thorough enough. Any help would be appreciated. A side question - anyone else think more work than it ought to be to get a simple windowed DX app running?

Share this post


Link to post
Share on other sites
Advertisement
You can''t have a true back buffer in windowed mode. What you can do is create a plain offscreen surface that''s the size of you window''s client area. Then you draw to the "back" buffer, and blit to your primary surface. There''s an in depth artice somewhere on gamedev about.

Share this post


Link to post
Share on other sites
Yeah, I'm creating my backbuffer as a regular surface, blitting my images onto it, then blitting the backbuffer onto the primary surface.

I did a search on gamedev and came up with this - I tried implementing what he had with points and rects but it didnt work. Here's my original code:

void directDraw::blit(LPDIRECTDRAWSURFACE7 image[], const int &numObjects){	
RECT rect;
GetWindowRect(ddhWnd, &rect); //fills the rectangle with the window dimensions


DDBLTFX ddbltfx;
ddbltfx.dwSize = sizeof(DDBLTFX);
ddbltfx.dwDDFX = DDBLTFX_NOTEARING;

HDC surfaceDC = NULL;
ddBackBuffer->GetDC(&surfaceDC);

for(int i = 0; i < numObjects; i++){
image[i]->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
SelectObject(ddHDC, ddsd.lpSurface);
if(FAILED(BitBlt(surfaceDC, 0, 0, 800, 600, ddHDC, 0, 0, SRCCOPY)))
MessageBox(NULL, "Back buffer blit failed.", "Error", MB_OK);
image[i]->Unlock(NULL);
}
ddBackBuffer->ReleaseDC(surfaceDC);

if(FAILED(ddSurface->Blt(&rect, ddBackBuffer , NULL, DDBLT_KEYSRC | DDBLT_WAIT, &ddbltfx)))
MessageBox(NULL, "Primary surface blit failed.", "Error", MB_OK);


}


Here's my drawing function. I'm not even sure if I'm using the DCs and SelectObject function correctly for this kind of situation. It fails to draw onto the backbuffer, but doesn't raise an error - it's probably garbage (the "Primary Surface Blit Failed" message gets raised).

Am I doing this all the wrong way?

[edited by - Odoacer on January 24, 2004 5:44:29 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!