What is preD3DReset() and postD3DReset() to do?

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

qingye5x
Just popping in
Just popping in
Posts: 2
Joined: Tue Nov 17, 2009 02:50

What is preD3DReset() and postD3DReset() to do?

Postby qingye5x » Tue Nov 17, 2009 03:04

In the new Render Moduel, i notify there are tow functions is class :
Direct3D9Render , Direct3D9Texture and Direct3D9TextureTarget

In preD3DReset() the class do some d3d release operation , and is postD3DReset() the class do some initialize and allocate operation.
Such as

void Direct3D9Renderer::preD3DReset()
{
// perform pre-reset on texture targets
TextureTargetList::iterator target_iterator = d_textureTargets.begin();
for (; target_iterator != d_textureTargets.end(); ++target_iterator)
static_cast<Direct3D9TextureTarget*>(*target_iterator)->preD3DReset();

// perform pre-reset on textures
TextureList::iterator texture_iterator = d_textures.begin();
for (; texture_iterator != d_textures.end(); ++texture_iterator)
(*texture_iterator)->preD3DReset();
}

void Direct3D9Texture::preD3DReset()
{
// if already saved surface info, or we have no texture, do nothing
if (d_savedSurfaceDescValid || !d_texture)
return;

// get info about our texture
d_texture->GetLevelDesc(0, &d_savedSurfaceDesc);

// if texture is managed, we have nothing more to do
if (d_savedSurfaceDesc.Pool == D3DPOOL_MANAGED)
return;

// otherwise release texture.
d_texture->Release();
d_texture = 0;
d_savedSurfaceDescValid = true;
}

I guess when reset D3D i should first call preD3DReset() , when D3D is reset completely I should call postD3DReset()
the question is , where these function to be used? and when i should use them, i think may be the D3DDevice is lost?

thanks for your attention and bear my so pool English, thanks a lot~ :D

qingye5x
Just popping in
Just popping in
Posts: 2
Joined: Tue Nov 17, 2009 02:50

Re: What is preD3DReset() and postD3DReset() to do?

Postby qingye5x » Tue Nov 17, 2009 03:16

// handle D3D lost device stuff
coop = pimpl->d_3DDevice->TestCooperativeLevel();

if (coop == D3DERR_DEVICELOST)
{
Sleep(500);
continue;
}
else if (coop == D3DERR_DEVICENOTRESET)
{
if (!resetDirect3D())
{
continue;
}
}

I found it , in CEGuiD3D9BaseApplication.cpp, as i guess when the device is lost these two function are called.

Thanks all the same~~ :D


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 11 guests