00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00026 #ifndef VEE_CG_GL_RENDERER_H
00027 #define VEE_CG_GL_RENDERER_H
00028
00029 #include <vee_gl_renderer.h>
00030
00031 #include <vee_reference_object.h>
00032
00033 #include <Cg/cgGL.h>
00034
00035 class VEE_CgGlRenderer;
00036
00037 enum VEE_CgParam {
00039 VEE_CGP_MODELVIEW_PROJECTION,
00041 VEE_CGP_CAMPOS,
00043 VEE_CGP_AGE,
00045 VEE_CGP_COLOR,
00047 VEE_CGP_ADDITIVE,
00049 VEE_CGP_LOCATION,
00051 VEE_CGP_VELOCITY,
00053 VEE_CGP_CORNER_UV,
00055 VEE_CGP_SCREEN_SCALE,
00056 VEE_CGP_SIZEOF
00057 };
00058
00059 extern const char * VEE_CgParamNames[];
00060
00063 class VEE_CgGlDriver
00064 {
00065 public:
00066 VEE_CgGlDriver();
00067 virtual ~VEE_CgGlDriver();
00068
00069 bool createProgram(const char *program,
00070 CGcontext context,
00072 CGprofile vp,
00074 CGprofile fp);
00075
00076 virtual bool bindProgram(VEE_CgGlRenderer *);
00077
00078 virtual void renderParticle(VEE_Particle *, VEE_CgGlRenderer *);
00079
00080
00081 CGparameter m_params[VEE_CGP_SIZEOF];
00082
00083 CGprogram m_vertexProgram;
00084 CGprogram m_fragmentProgram;
00085
00086 std::string m_programName;
00087 };
00088
00091
00092 class VEE_CgGlRenderer : public VEE_GlRenderer
00093 {
00094 public:
00095 VEE_CgGlRenderer(VEE_SceneBox *box = 0);
00096 virtual ~VEE_CgGlRenderer();
00097
00098 virtual void initializeGL();
00099 virtual void endGlMode();
00100 virtual void renderParticle(VEE_Particle *p);
00101
00102 void disableCg();
00103 void enableCg();
00104
00105 void loadShaders();
00106
00107 static bool debug() { return m_debug; }
00108
00109 CGprofile cgVertexProfile() { return m_cgVertexProfile; }
00110 CGprofile cgFragmentProfile() { return m_cgFragmentProfile; }
00111
00112 protected:
00113
00114 CGcontext m_cgContext;
00115 CGprofile m_cgVertexProfile, m_cgFragmentProfile;
00116
00117 std::map<int, VEE_SafePtr<VEE_CgGlDriver> > m_drivers;
00118 typedef std::map<int, VEE_SafePtr<VEE_CgGlDriver> >::iterator driver_iter;
00119
00120 VEE_CgGlDriver * m_currentDriver;
00121
00122 int m_currentShader;
00123
00124 static bool m_debug;
00125 };
00126
00127 #endif