# SOLVED - dx flashes backbuffer before exit?

This topic is 902 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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.Windowed = FALSE;                                // TRUE for windowed, FALSE for fullscreen
}



##### 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(
D3DDEVTYPE_HAL,
Zprogram_window_handle,
D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_PUREDEVICE,
&Zparams,
&Zd3d_device_ptr);

any ideas what's going on?

##### 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?

##### 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();
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 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.

##### Share on other sites

it could be down to the graphics driver.

yes, i was thinking that might be it.

lemme see what _exit(0) does....

##### Share on other sites

ok, testing reproduce-ability,  it looks like its flashing whatever the last screenshot taken was.

quitting without taking any screenshots works fine...

##### Share on other sites

still does it with _exit(0).

so its the driver.

i think i'll turn off the "Closing Caveman..." screens.  not much point in having them if the driver's going to behave that way.

mark this one solved i guess.

thanks for the help!