浏览代码

Allow Shader parameter in ShaderAttrib::make

rdb 11 年之前
父节点
当前提交
cc35d0dd41
共有 2 个文件被更改,包括 9 次插入4 次删除
  1. 7 2
      panda/src/pgraph/shaderAttrib.cxx
  2. 2 2
      panda/src/pgraph/shaderAttrib.h

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

@@ -52,13 +52,18 @@ make_off() {
 //               set.
 ////////////////////////////////////////////////////////////////////
 CPT(RenderAttrib) ShaderAttrib::
-make() {
+make(const Shader *shader) {
   static CPT(RenderAttrib) _null_attrib;
   if (_null_attrib == 0) {
     ShaderAttrib *attrib = new ShaderAttrib;
     _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);
 
 PUBLISHED:
-  static CPT(RenderAttrib) make();
+  static CPT(RenderAttrib) make(const Shader *shader = NULL);
   static CPT(RenderAttrib) make_off();
   static CPT(RenderAttrib) make_default();
-  
+
   enum {
     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