Browse Source

Fix shader issues on D3D Device Reset (resize window, ...)
Do not create a new shader context, but reuse old context and just set the D3D device for Cg.

aignacio_sf 20 years ago
parent
commit
cb90d793d0

+ 2 - 0
panda/src/dxgsg9/config_dxgsg9.cxx

@@ -21,6 +21,7 @@
 #include "dxTextureContext9.h"
 #include "dxVertexBufferContext9.h"
 #include "dxIndexBufferContext9.h"
+#include "dxShaderContext9.h"
 #include "dxGeomMunger9.h"
 #include "graphicsPipeSelection.h"
 #include "wdxGraphicsWindow9.h"
@@ -202,6 +203,7 @@ init_libdxgsg9() {
   DXTextureContext9::init_type();
   DXVertexBufferContext9::init_type();
   DXIndexBufferContext9::init_type();
+  CLP(ShaderContext)::init_type();
   DXGeomMunger9::init_type();
 
   wdxGraphicsPipe9::init_type();

+ 3 - 5
panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx

@@ -2432,15 +2432,13 @@ reset() {
   }
 
 #ifdef HAVE_CGDX9
-  if (_cg_context) {
-    cgD3D9SetDevice (NULL);
-    cgDestroyContext (_cg_context);
-    _cg_context = 0;
-  }
   if (_cg_context == 0) {
     _cg_context = cgCreateContext ( );
     cgD3D9SetDevice (_d3d_device);
   }
+  else {
+    cgD3D9SetDevice (_d3d_device);
+  }
 #endif
 
   _max_vertices_per_array = d3d_caps.MaxVertexIndex;