Win32: fix double cg function unloading

This commit is contained in:
OV2 2011-04-10 16:06:24 +02:00
parent 2f2d92a9da
commit 9f22745fa5
2 changed files with 20 additions and 10 deletions

View File

@ -305,6 +305,14 @@ void CDirect3D::DeInitialize()
DestroyDrawSurface();
SetShader(NULL);
if(cgContext) {
cgDestroyContext(cgContext);
cgContext = NULL;
}
if(cgAvailable)
cgD3D9SetDevice(NULL);
if(vertexBuffer) {
vertexBuffer->Release();
vertexBuffer = NULL;
@ -320,21 +328,14 @@ void CDirect3D::DeInitialize()
pD3D = NULL;
}
if(cgContext) {
cgDestroyContext(cgContext);
cgContext = NULL;
}
if(cgAvailable)
cgD3D9SetDevice(NULL);
init_done = false;
afterRenderWidth = 0;
afterRenderHeight = 0;
quadTextureSize = 0;
fullscreen = false;
filterScale = 0;
unloadCgLibrary();
if(cgAvailable)
unloadCgLibrary();
cgAvailable = false;
}
@ -943,6 +944,10 @@ bool CDirect3D::ResetDevice()
//release prior to reset
DestroyDrawSurface();
if(cgAvailable) {
cgD3D9SetDevice(NULL);
}
if(effect)
effect->OnLostDevice();
@ -975,6 +980,10 @@ bool CDirect3D::ResetDevice()
if(effect)
effect->OnResetDevice();
if(cgAvailable) {
cgD3D9SetDevice(pDevice);
}
if(GUI.BilinearFilter) {
pDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
pDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);

View File

@ -318,7 +318,8 @@ void COpenGL::DeInitialize()
afterRenderHeight = 0;
shaderFunctionsLoaded = false;
shader_type = OGL_SHADER_NONE;
unloadCgLibrary();
if(cgAvailable)
unloadCgLibrary();
cgAvailable = false;
}