Panda3D

shaderInput.h

00001 // Filename: shaderInput.h
00002 // Created by: jyelon (01Sep05)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef SHADERINPUT_H
00016 #define SHADERINPUT_H
00017 
00018 #include "pandabase.h"
00019 #include "typedWritableReferenceCount.h"
00020 #include "pointerTo.h"
00021 #include "nodePath.h"
00022 #include "texture.h"
00023 #include "internalName.h"
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //       Class : ShaderInput
00027 // Description : This is a small container class that can hold any
00028 //               one of the value types that can be passed as input
00029 //               to a shader.
00030 ////////////////////////////////////////////////////////////////////
00031 
00032 class EXPCL_PANDA_PGRAPH ShaderInput: public TypedWritableReferenceCount {
00033 public:
00034   INLINE ~ShaderInput();
00035 
00036 PUBLISHED:
00037   static const ShaderInput *get_blank();
00038   INLINE ShaderInput(InternalName *id, int priority=0);
00039   INLINE ShaderInput(InternalName *id, const NodePath &np, int priority=0);
00040   INLINE ShaderInput(InternalName *id, const LVector4f &v, int priority=0);
00041   INLINE ShaderInput(InternalName *id, Texture  *tex,      int priority=0);
00042   
00043   enum ShaderInputType {
00044     M_invalid = 0,
00045     M_texture,
00046     M_nodepath,
00047     M_vector
00048   };
00049   
00050   INLINE InternalName *get_name() const;
00051   
00052   INLINE int               get_value_type() const;
00053   INLINE int               get_priority() const;
00054   INLINE Texture          *get_texture() const;
00055   INLINE const NodePath   &get_nodepath() const;
00056   INLINE const LVector4f  &get_vector() const;
00057 
00058 public:
00059   static void register_with_read_factory();
00060 
00061 private:
00062   PT(InternalName) _name;
00063   int _type;
00064   int _priority;
00065   PT(Texture) _stored_texture;
00066   NodePath    _stored_nodepath;
00067   LVector4f   _stored_vector;
00068 
00069 public:
00070   static TypeHandle get_class_type() {
00071     return _type_handle;
00072   }
00073   static void init_type() {
00074     ReferenceCount::init_type();
00075     register_type(_type_handle, "ShaderInput",
00076                   TypedWritableReferenceCount::get_class_type());
00077   }
00078   virtual TypeHandle get_type() const {
00079     return get_class_type();
00080   }
00081   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00082 
00083 private:
00084   static TypeHandle _type_handle;
00085 };
00086 
00087 
00088 #include "shaderInput.I"
00089 
00090 #endif  // SHADERINPUT_H
00091 
 All Classes Functions Variables Enumerations