Selaa lähdekoodia

fix for new ShaderGenerator stuff

David Rose 16 vuotta sitten
vanhempi
sitoutus
e4e8d3e401
1 muutettua tiedostoa jossa 9 lisäystä ja 1 poistoa
  1. 9 1
      panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx

+ 9 - 1
panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx

@@ -62,6 +62,7 @@
 #include "pStatCollector.h"
 #include "pStatCollector.h"
 #include "wdxGraphicsBuffer9.h"
 #include "wdxGraphicsBuffer9.h"
 #include "config_pgraph.h"
 #include "config_pgraph.h"
+#include "shaderGenerator.h"
 #ifdef HAVE_CG
 #ifdef HAVE_CG
 #include "Cg/cgD3D9.h"
 #include "Cg/cgD3D9.h"
 #endif
 #endif
@@ -3247,7 +3248,14 @@ set_state_and_transform(const RenderState *target,
 
 
   _target_shader = DCAST(ShaderAttrib, _target_rs->get_attrib_def(ShaderAttrib::get_class_slot()));
   _target_shader = DCAST(ShaderAttrib, _target_rs->get_attrib_def(ShaderAttrib::get_class_slot()));
   if (_target_shader->auto_shader()) {
   if (_target_shader->auto_shader()) {
-    _target_shader = _target_rs->get_generated_shader();
+    // If we don't have a generated shader, make sure we have a ShaderGenerator, then generate the shader.
+    if (_target_rs->_generated_shader == NULL) {
+      if (_shader_generator == NULL) {
+        _shader_generator = new ShaderGenerator(this, _scene_setup->get_display_region()->get_window());
+      }
+      const_cast<RenderState*>(_target_rs.p())->_generated_shader = DCAST(ShaderAttrib, _shader_generator->synthesize_shader(_target_rs));
+    }
+    _target_shader = DCAST(ShaderAttrib, _target_rs->_generated_shader);
   }
   }
 
 
   int alpha_test_slot = AlphaTestAttrib::get_class_slot();
   int alpha_test_slot = AlphaTestAttrib::get_class_slot();