SOLVED - dx flashes backbuffer before exit?

Started by
6 comments, last by Norman Barrows 8 years, 7 months ago

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
}
 

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

Advertisement

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?

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

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

.:vinterberg:.

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

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

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.


it could be down to the graphics driver.

yes, i was thinking that might be it.

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

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

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

quitting without taking any screenshots works fine...

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

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!

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

This topic is closed to new replies.

Advertisement