Skip to main content
GameDev.net gamedev.net
🔒 Locked

Direct Draw Flippable surface

Started by dweeb Oct 12, 2000 at 5:31 AM 8 replies 300+ views
Original Post
dweeb
dweeb
Hi guys Im really trying to like direct-x but so far it''s just caust a lot of problems for me! So i have created two Directx7 surfaces ,front,back I have made the front one to be a complex flippable surface and i have attached the back surface to the front Fine it works.. But when i try to flip it the back surface is totaly fuc***up It totaly scrambled, whats wrong, any guesses. I have re written this stuff like 10 times i''ve almost copyied the sdk''s example but i use lpDDSPrimary->flip(null,wait_blaha); HEEELLLPPP!
______ohh well what the heck lets try it?
Gaiiden
Gaiiden
You HAVE to clear the back buffer surface every time you write to it. This is the order you flip in:

1) clear the back buffer
2) draw to the back buffer
3) flip the surfaces
4) repeat from #1

if you know how to do memory fills using Blt(), then fill the surface with the color black. Otherwise you will have to use memset() or do a line-by-line fill if the surface memory is non-linear.

==============================
\\// live long and prosper; \||/ die short and rot.
==============================
Drew Sikora
Executive Producer
GameDev.net
furby100
furby100
The back surface will look scrambled anyway, because GDI messes up the video memory by using it for windows, and so everyone who doesn''t clear their back surface ends up with scrambled stuff on it.

Also, could you please call them DirectDrawSurfaces and not DirectXSurfaces? A DXSurface is part of the DirectX Transform API, which is a part of DirectMedia, and so to avoid confusion please call it a DirectDrawSurface.

------------------------------
#pragma twice


sharewaregames.20m.com

Ridcully
Ridcully
hmm, ignore this post if i misunderstand the problem, but...
do you know that creating a complex primary surface automatically creates a backbuffer and attaches it to the primary surface? so you don''t need to attach a backbuffer to it manually.

rid
Gaiiden
Gaiiden
Is that true? I don''t think it''s true. How do you then get the pointer to the backbuffer? Where is it defined? There is a reason there is a flag called DDSCAPS_BACKBUFFER you know. It''s so you can create a backbuffer and then attach it to the primary surface. I''ve never heard of the auto-creation thing. Could someone explain that if it exists?

==============================
\\// live long and prosper; \||/ die short and rot.
==============================
Drew Sikora
Executive Producer
GameDev.net
Ironblayde
Ironblayde
No problem Gaiiden, take a look at this:

        
// set up primary DD surface

ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd); // init ddsd

ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; // valid flags

ddsd.dwBackBufferCount = 1; // one back buffer

ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE |
DDSCAPS_COMPLEX | // buffers chained

DDSCAPS_FLIP; // flippable


// create primary surface

if (FAILED(lpdd7->CreateSurface(&ddsd, &lpdd_primary, NULL)))
return(FALSE);


// get attached back buffer

ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
if (FAILED(lpdd_primary->GetAttachedSurface(&ddsd.ddsCaps, &lpdd_back)))
return(FALSE);


So all you need to do is include the dwBackBufferCount member of the DDSURFACEDESC2 structure when you create the primary surface. This creates the appropriate back buffers as well as the primary surface, and you retrieve them using calls to IDirectDraw7::GetAttachedSurface() as shown.

-Ironblayde
 Aeon Software

Edited by - Ironblayde on October 12, 2000 5:08:46 PM
"Your superior intellect is no match for our puny weapons!"
Ridcully
Ridcully
this is what the sdk documentation says about the DDSCAPS_FLIP flag.


This surface is a part of a surface-flipping structure. When this capability is passed to the CreateSurface method, a front buffer and one or more back buffers are created. DirectDraw sets the DDSCAPS_FRONTBUFFER bit on the front-buffer surface and the DDSCAPS_BACKBUFFER bit on the surface adjacent to the front-buffer surface. The dwBackBufferCount member of the DDSURFACEDESC structure must be set to at least 1 for the method call to succeed. The DDSCAPS_COMPLEX capability must always be set when creating multiple surfaces by using the CreateSurface method.


as you can see, ddraw automatically creates backbuffers, as set in the dwBackBufferCount member variable
Gaiiden
Gaiiden
Oooooh. OK, I see what you''re saying now. That''s exactly how I do it, Ironblayde. I just never thought of it as an auto creation. I guess I should have realized that, since you don''t have to call CreateSurface() for the backbuffer *SLAP!*. That never occured to me at all

==============================
\\// live long and prosper; \||/ die short and rot.
==============================
Drew Sikora
Executive Producer
GameDev.net
dweeb
dweeb
Thanx for all your help!!

IT''S WORKING IT''S WORKING!!!!

______________________________
ohh well what the heck lets try it?
______ohh well what the heck lets try it?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.