Sign in to follow this  

SOLVED - dx flashes backbuffer before exit?

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

we've all seen it,

 

you exit a fullscreen directx windows title, and the screen flashes some junk, just before the desktop appears. a final present or some such thing.

 

to avoid this, i display a "Closing Caveman..." message on a black screen, twice in a row (clear, render, and present twice) to make sure both buffers contain that screen.

 

seemed to work ok at first, but now i'm getting the last screenshot taken, or the last 3d scene rendered. it flashes just once, after confirming quit to desktop, and before the desktop appears.

 

these are the present parameters i'm using:

 
void Zsetparams(int w,int h)
{
ZeroMemory(&Zparams,sizeof(D3DPRESENT_PARAMETERS));
Zparams.AutoDepthStencilFormat = D3DFMT_D24X8;
Zparams.BackBufferCount=1;
Zparams.BackBufferFormat = D3DFMT_A8R8G8B8;              // set the back buffer format to 32-bit      // turn these on for fullscreen
Zparams.BackBufferWidth = (unsigned)w;                          //width;    // set the width of the buffer
Zparams.BackBufferHeight = (unsigned)h;                          //height;    // set the height of the buffer
Zparams.EnableAutoDepthStencil = TRUE;                   // automatically run the z-buffer for us
Zparams.Flags=0;
Zparams.FullScreen_RefreshRateInHz=D3DPRESENT_INTERVAL_DEFAULT;
Zparams.hDeviceWindow=Zprogram_window_handle;
Zparams.MultiSampleQuality=0;
Zparams.MultiSampleType=D3DMULTISAMPLE_NONE;
Zparams.PresentationInterval=D3DPRESENT_INTERVAL_DEFAULT;
Zparams.SwapEffect = D3DSWAPEFFECT_COPY;                 //D3DSWAPEFFECT_DISCARD;
Zparams.Windowed = FALSE;                                // TRUE for windowed, FALSE for fullscreen
}
 

Share this post


Link to post
Share on other sites

code blocks clipped the post again!

 

continuing from last post....

 

and these are the device creation parameters...

 

result=d3d_obj_ptr->CreateDevice(
D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
Zprogram_window_handle,
D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_PUREDEVICE,
&Zparams,
&Zd3d_device_ptr);
 
any ideas what's going on?

Share this post


Link to post
Share on other sites

A shot in the dark, but could it have anything to do with the order in which you release stuff when closing down?

 

 

release order should have nothing to do with the graphics engine flashing an old buffer to the screen after you've done your final present call...

 

titlescreen();
runprog();
#ifdef demo
demo_ending();
#endif
//  make sure screen goes black before quitting...
Zclearscreen(0,0,0);
Zbeginscene();
tx(700,400,"Closing Caveman...");
showscene();
Zclearscreen(0,0,0);
Zbeginscene();
tx(700,400,"Closing Caveman...");
showscene();
//  ok, now shutdown...
deactivate_all_controllers();
unload_all_skinned_meshes();
Zshutdown_font();
Zshutdown_audio();
Zshutdown();
PostQuitMessage(0);
return(0);
 

 

 

 

'   releases font textures
fn v Zshutdown_font
i a
for (a=0; a<Znum_font_textures; a++) Zfont_tex[a].tex->Release();
.
 

 

 

// shutdown Z game engine
void Zshutdown()
{
int a;
Zsprite->Release();
pFont->Release();
pFont2->Release();
pFont3->Release();
for (a=0; a<DBnummeshes; a++)             //  mesh[a].mesh->Release();
    {
    mesh[a].mesh2.vb->Release();
    mesh[a].mesh2.ib->Release();
    }
for (a=0; a<numtextures; a++) Ztex[a].tex->Release();
Zd3d_device_ptr->Release();    // close and release the 3D device
d3d_obj_ptr->Release();    // close and release Direct3D object
}
 

 

 

after the last call to showscene(), there are no calls to present(), just a bunch of calls to release().

Edited by Norman Barrows

Share this post


Link to post
Share on other sites

Does it still go wrong if you call _exit(0) immediately after you display your shutdown message?

 

Note the leading underscore on the function name, which bypasses the standard cleanup routines like atexit() and global destructors.

 

If it does still goes wrong when you do that, then the problem probably isn't in your code - it could be down to the graphics driver.

Edited by Adam_42

Share this post


Link to post
Share on other sites

This topic is 827 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this