Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/shader/shader.h

Go to the documentation of this file.
00001 // Filename: shader.h
00002 // Created by:  mike (09Jan97)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 #ifndef SHADER_H
00019 #define SHADER_H
00020 //
00021 ////////////////////////////////////////////////////////////////////
00022 // Includes
00023 ////////////////////////////////////////////////////////////////////
00024 #include <pandabase.h>
00025 
00026 #include <configurable.h>
00027 #include <namedNode.h>
00028 #include <lensNode.h>
00029 #include <typedReferenceCount.h>
00030 #include <graphicsStateGuardian.h>
00031 #include <allAttributesWrapper.h>
00032 #include <allTransitionsWrapper.h>
00033 #include <pointerTo.h>
00034 
00035 ////////////////////////////////////////////////////////////////////
00036 // Defines
00037 ////////////////////////////////////////////////////////////////////
00038 
00039 ////////////////////////////////////////////////////////////////////
00040 //       Class : Shader
00041 // Description : Renders an effect on a list of receiving objects
00042 ////////////////////////////////////////////////////////////////////
00043 class EXPCL_SHADER Shader : public ReferenceCount, public Configurable
00044 {
00045 protected:
00046 
00047   Shader();
00048 
00049   int _priority;
00050   bool _multipass_on;
00051 
00052 public:
00053 
00054   virtual ~Shader(void) { }
00055 
00056   virtual void pre_apply(Node *, const AllAttributesWrapper &,
00057                          const AllTransitionsWrapper &,
00058                          GraphicsStateGuardian *);
00059 
00060 
00061   virtual void apply(Node *, const AllAttributesWrapper &,
00062                      const AllTransitionsWrapper &,
00063                      GraphicsStateGuardian *);
00064 
00065   virtual void set_priority(int priority);
00066   virtual int get_priority(void) const;
00067   virtual void set_multipass(bool on);
00068 
00069 public:
00070 
00071   // This is used to visualize partial results, for debugging (and demos)
00072   class EXPCL_SHADER Visualize {
00073   public:
00074     Visualize(void);
00075     virtual ~Visualize(void);
00076     virtual void DisplayTexture(PT(Texture)&, Shader*) = 0;
00077     virtual void DisplayPixelBuffer(PT(PixelBuffer)&, Shader*) = 0;
00078     virtual void Flush(void) = 0;
00079   };
00080 
00081   static INLINE Visualize* get_viz(void);
00082   static INLINE void set_viz(Visualize*);
00083 
00084   static TypeHandle get_class_type() {
00085     return _type_handle;
00086   }
00087   static void init_type() {
00088     ReferenceCount::init_type();
00089     Configurable::init_type();
00090     register_type(_type_handle, "Shader",
00091                   ReferenceCount::get_class_type(),
00092                   Configurable::get_class_type());
00093   }
00094   virtual TypeHandle get_type() const {
00095     return get_class_type();
00096   }
00097   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00098 
00099   static Visualize* _viz;
00100 
00101 private:
00102 
00103   static TypeHandle _type_handle;
00104 };
00105 
00106 ////////////////////////////////////////////////////////////////////
00107 //       Class : FrustumShader
00108 // Description : Shader that computes effect based on a frustum
00109 //               (most often a light or a camera) for a list of
00110 //               receiving objects
00111 ////////////////////////////////////////////////////////////////////
00112 class EXPCL_SHADER FrustumShader : public Shader
00113 {
00114 protected:
00115 
00116   FrustumShader(void) : Shader() { }
00117 
00118 public:
00119 
00120   virtual ~FrustumShader(void) { }
00121 
00122   INLINE int get_num_frusta(void) const { return _frusta.size(); }
00123   INLINE int add_frustum(LensNode* frust);
00124   INLINE int remove_frustum(LensNode* frust);
00125 
00126   typedef pvector<LensNode *> LensVector;
00127 
00128 protected:
00129 
00130   LensVector                      _frusta;
00131 
00132 public:
00133 
00134   static TypeHandle get_class_type() {
00135     return _type_handle;
00136   }
00137   static void init_type() {
00138     Shader::init_type();
00139     register_type(_type_handle, "FrustumShader",
00140                   Shader::get_class_type());
00141   }
00142   virtual TypeHandle get_type() const {
00143     return get_class_type();
00144   }
00145 
00146 private:
00147 
00148   static TypeHandle _type_handle;
00149 };
00150 
00151 #include "shader.I"
00152 
00153 #endif

Generated on Fri May 2 00:44:02 2003 for Panda by doxygen1.3