Archived

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

fireking

Windowed Mode: Flipping, Back Buffers, FastBlt

Recommended Posts

Im using directdraw 7 Is it possible to Flip in windowed mode? Is it possible to FastBlt in windowed mode? Do you create a back buffer like this in windowed mode?
    
LPDIRECTDRAWSURFACE lpDDSPrimary;
DDURFACEDESC ddsd;
HRESULT ddrval;

//Clear all fields in structure

memset( &&ddsd, 0, sizeof(ddsd) );

//Set flags in structure

ddsd.dwSize = sizeof( ddsd );
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
ddsd.dwBackBufferCount = 1;

//Create Surface

ddrval = lpDD->CreateSurface( &ddsd, &lpDDSPrimary, NULL );
if( ddrval != DD_OK )
{
    //Do error checking here

}
DDSCAPS ddscaps;

LPDIRECTDRAWSURFACE lpDDSBack; ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
ddrval = lpDDSPrimary->GetAttachedSurface( &ddscaps, &lpDDSBack );
if( ddrval != DD_OK )
{
    //Do error checking here

}
    
?? Thanks, --Fireking Owner/Leader Genetics 3rd Dimension Development [edited by - fireking on October 2, 2002 12:24:05 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I dont'' know about DX7, but in DX8, you can present(flip buffer) even in a window. So I don''t see why not.

Share this post


Link to post
Share on other sites
1) No you cannot use Flip in Windowed mode... you should use Blt or FastBlt
2) Yes you can use FastBlt in Windowed mode
3) No... the Backbuffer in Widowed mode is a separate surface compared to the fullscreen backbuffer... heres some code


  
Result = m_DD7->SetCooperativeLevel(m_hWnd, DDSCL_NORMAL);

// Create Primary Surface

ZeroMemory(&sd, sizeof(sd));

sd.dwSize = sizeof(sd);
sd.dwFlags = DDSD_CAPS;
sd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;

Result = m_DD7->CreateSurface(&sd, &m_Primary, NULL);

// Create Back Buffer

ZeroMemory(&sd, sizeof(sd));

sd.dwSize = sizeof(sd);
sd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
sd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
sd.dwWidth = m_Width; // Width of BackBuffer

sd.dwHeight = m_Height; // Height of BackBuffer


Result = m_DD7->CreateSurface(&sd, &m_Back, NULL);

IDirectDrawClipper *Clipper;

Result = m_DD7->CreateClipper(0, &Clipper, NULL);

Result = Clipper->SetHWnd(0, m_hWnd);

Result = m_Primary->SetClipper(Clipper);


Hope that code helps out

-Ximmer

Share this post


Link to post
Share on other sites
ok thanks ximmer! thats what i had originally, just double checking

can you use colorkeying with fast blt?

whats the difference between fast blt and blt? all i know of is stretching, and i wont be doing any of that

also, i love how dx automatically makes the surface look exactly the same on all resolutions, with minor changes (like if you are in 640x480 mode running a 800x600 bitmap, things are made smaller but its still the same size theoritcally), will using blt fast change that?

thanks again,


--Fireking

Owner/Leader
Genetics 3rd Dimension Development

Share this post


Link to post
Share on other sites
I not exactly sure... but I think the only difference between Blt and FastBlt is that Blt can do some special effects... (I have yet to use these special effects)... also if Blt isn't implemented in hardware by the driver it's said to be 10% slower than FastBlt... but that shouldn't be a problem with todays video cards.

Ohh and you can use color keying with FastBlt by useing the DDBLTFAST_SRCCOLORKEY flag... Also, you have to call SetColorKey on your surface.

Not to sure about what you mean on the last part about the display resolutions... but if you use a Blt when Blitting from the BackBuffer to the Primary surface you can stretch your backbuffer to whatever size the Window (Or Screen) is.

-Ximmer

[edited by - Ximmer on October 3, 2002 2:03:29 AM]

[edited by - Ximmer on October 3, 2002 2:07:30 AM]

Share this post


Link to post
Share on other sites
Flip in window mode is used in one of the directdraw examples that comes with directx 8(not sure if the program is in directx 7 too). The program is called WindowMode it just shows a whole bunch of directx symbols bouncing around in a window.

The thing is the primary buffer, back buffer(allocation) and flip code are in the ddutil file.

I am not sure how they did it, but it works : )

Share this post


Link to post
Share on other sites