Browse Source

Allow Shader parameter in ShaderAttrib::make

rdb 11 năm trước cách đây
mục cha
commit
cc35d0dd41

+ 7 - 2
panda/src/pgraph/shaderAttrib.cxx

@@ -52,13 +52,18 @@ make_off() {
 //               set.
 //               set.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 CPT(RenderAttrib) ShaderAttrib::
 CPT(RenderAttrib) ShaderAttrib::
-make() {
+make(const Shader *shader) {
   static CPT(RenderAttrib) _null_attrib;
   static CPT(RenderAttrib) _null_attrib;
   if (_null_attrib == 0) {
   if (_null_attrib == 0) {
     ShaderAttrib *attrib = new ShaderAttrib;
     ShaderAttrib *attrib = new ShaderAttrib;
     _null_attrib = return_new(attrib);
     _null_attrib = return_new(attrib);
   }
   }
-  return _null_attrib;
+
+  if (shader == NULL) {
+    return _null_attrib;
+  } else {
+    return DCAST(ShaderAttrib, _null_attrib)->set_shader(shader);
+  }
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////

+ 2 - 2
panda/src/pgraph/shaderAttrib.h

@@ -43,10 +43,10 @@ private:
   INLINE ShaderAttrib(const ShaderAttrib &copy);
   INLINE ShaderAttrib(const ShaderAttrib &copy);
 
 
 PUBLISHED:
 PUBLISHED:
-  static CPT(RenderAttrib) make();
+  static CPT(RenderAttrib) make(const Shader *shader = NULL);
   static CPT(RenderAttrib) make_off();
   static CPT(RenderAttrib) make_off();
   static CPT(RenderAttrib) make_default();
   static CPT(RenderAttrib) make_default();
-  
+
   enum {
   enum {
     F_disable_alpha_write = 0,  // Suppress writes to color buffer alpha channel.
     F_disable_alpha_write = 0,  // Suppress writes to color buffer alpha channel.
     F_subsume_alpha_test  = 1,  // Shader promises to subsume the alpha test using TEXKILL
     F_subsume_alpha_test  = 1,  // Shader promises to subsume the alpha test using TEXKILL