vee_gl_sl_renderer.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 /* COPYRIGHT
00004  *
00005  * This file is part of the Visual Effects Engine - VEE
00006  *
00007  * Read the "VEE-LICENSE" file for the license.
00008  *
00009  * Authors & Copyright:   
00010  *
00011  * Tommi Ilmonen, Tuukka Heikura, Marko Myllymaa and 
00012  * Janne Kontkanen 2001-2004
00013  *
00014  * Additional copyrights: Tekes 2003-2004
00015  *
00016  * firstname.lastname@hut.fi
00017  *
00018  */
00019 
00026 #ifndef VEE_GL_SL_RENDERER_H
00027 #define VEE_GL_SL_RENDERER_H
00028 
00029 #ifndef HAVE_GLSL_ARB
00030 #error "Must have OpenGL SL ARB extensions to compile GLSL code !!"
00031 #endif
00032 
00033 #include <vee_gl_renderer.h>
00034 
00035 #include <vee_reference_object.h>
00036 
00037 #ifdef __OS_LINUX__
00038 // Fix the broken NVidia headers:
00039 #define GL_GLEXT_PROTOTYPES 1
00040 #define GLAPI
00041 #endif // __OS_LINUX__
00042 
00043 #include <GL/glext.h>
00044 
00045 class VEE_GlSlRenderer;
00046 
00047 enum VEE_GlSlParam {
00049   VEE_SLP_PARTICLE_SIZE,
00051   VEE_SLP_CAMPOS,
00053   VEE_SLP_WINDOW_SIZE,
00056   VEE_SLP_DEPTH_PARAMS,
00058   VEE_SLP_AGE,
00060   VEE_SLP_COLOR,
00062   VEE_SLP_ADDITIVE,
00064   VEE_SLP_LOCATION,
00066   VEE_SLP_VELOCITY,
00068   VEE_SLP_CORNER_UV,
00070   VEE_SLP_TEX,
00072   VEE_SLP_DEPTH_MAP,
00073   
00074   VEE_SLP_SIZEOF
00075 };
00076 
00077 extern const char * VEE_SlParamNames[];
00078 
00079 char * VEE_loadFile(const char * fileName);
00080 
00087 class VEE_GlSlDriver
00088 {
00089 public:
00090   VEE_GlSlDriver();
00091   virtual ~VEE_GlSlDriver();
00092 
00093   virtual bool loadShadersFromFile(const char * fileNameBase);
00094   virtual void deleteShaders();
00095 
00096   virtual bool bindProgram(VEE_GlSlRenderer *);
00097 
00098   virtual void renderParticle(VEE_Particle *, VEE_GlSlRenderer *);
00099 
00100   static std::string infoLog(GLhandleARB);
00101 
00102 protected:
00103 
00104   int m_params[VEE_SLP_SIZEOF];
00105 
00106   GLhandleARB m_vertexShader;
00107   GLhandleARB m_fragmentShader;
00109   GLhandleARB m_program;
00110 
00111   std::string m_programName;
00112 };
00113 
00116 
00123 class VEE_GlSlRenderer : public VEE_GlRenderer
00124 {
00125 public:
00126   VEE_GlSlRenderer(VEE_SceneBox *box = 0);
00127   virtual ~VEE_GlSlRenderer();
00128   
00129   virtual void initializeGL();
00130   virtual void endGlMode();
00131   virtual void renderParticle(VEE_Particle *p);
00132 
00133   void disableSl();
00134   void enableSl();
00135 
00136   void loadShaders();
00137 
00138   void setUseShaders(bool use) { m_useShaders = use; }
00139   bool useShaders() const { return m_useShaders; }
00140 
00141   static bool debug() { return m_debug; }
00142   
00143 protected:
00144 
00145   std::map<int, VEE_SafePtr<VEE_GlSlDriver> > m_drivers;
00146   typedef std::map<int, VEE_SafePtr<VEE_GlSlDriver> >::iterator driver_iter;
00147 
00148   VEE_GlSlDriver * m_currentDriver;
00149   
00150   int         m_currentShader;
00151   bool        m_useShaders;
00152 
00153   static bool m_debug;
00154 };
00155 
00156 #endif

Generated on Mon Mar 12 21:09:00 2007 for VEE - The Visual Effects Engine by  doxygen 1.4.6