GlRenderer.hpp

Go to the documentation of this file.
00001 /* COPYRIGHT
00002  *
00003  * This file is part of the Simple Object Loader and Renderer - SOLAR
00004  *
00005  * Read the file "SOLAR-LICENSE" for the license.
00006  *
00007  * Authors & Copyright:
00008  *
00009  * Tommi Ilmonen, 2001-2003, except LWO-code by RJ, 2001-2003
00010  *
00011  * Tommi's email: firstname.lastname@hut.fi
00012  *
00013  */
00014 
00015 #ifndef SOLAR_GL_RENDERER_HPP
00016 #define SOLAR_GL_RENDERER_HPP
00017 
00018 #include <GL/gl.h>
00019 
00020 #ifdef __OS_LINUX__
00021 
00022 // NVidia fixes...
00023 #define GL_GLEXT_PROTOTYPES 1
00024 
00025 #ifndef GLAPI
00026 #define GLAPI 
00027 #endif
00028 
00029 #ifdef APIENTRY
00030 #undef APIENTRY
00031 #endif
00032 
00033 #include <GL/glext.h>
00034 
00035 #endif
00036 
00037 #include <Solar/GlDisplayLists.hpp>
00038 #include <Solar/Renderer.hpp>
00039 
00040 namespace Solar {
00041 
00042   class GlDisplayLists;
00043   class GlMaterialBank;
00044   class GlMaterial;
00045   class Graphic;
00046   class GraphicTriangles;
00047   class Model;
00048 
00061   class GlRenderer : public Renderer
00062   {
00063   public:
00064 
00065     GlRenderer(GlMaterialBank *materials);
00066     GlRenderer();
00067 
00068     virtual ~GlRenderer();
00069   
00070     virtual void prepareToRender();
00071 
00073     void setMaterials(GlMaterialBank *materials) { m_materials = materials; }
00074 
00075     virtual void begin(Model *);
00076     virtual void end();
00077 
00078     virtual void renderTriangles(GraphicTriangles *);
00079     virtual void renderTriangleMesh(GraphicTriangleMesh *);
00080     virtual void renderTriangleStrips(GraphicTriangleStrips *);
00081 
00082     virtual void pushTransform(const Fluid::Matrix3 &,
00083              const Fluid::Vector3 &,
00084              float scale);
00085     virtual void popTransform();
00086 
00087     void initGlState();
00088     void setDisplayLists(GlDisplayLists * lists) { m_displayLists = lists; }
00089 
00090     void applyGlTexture2D(GLuint tex);
00091     void applyGlBlend(bool blend);
00092     void applyGlLighting(bool lighting);
00093     void applyGlSmooth(bool smooth);
00094     void applyGlTwoSided(bool twoSided);
00095 
00096     long listRenderCount() const { return m_listRenderCount; }
00097 
00098   protected:
00099 
00100     enum ListMode {
00101       RENDERED_LIST,
00102       GENERATE_LIST,
00103       NO_LIST
00104     };
00105 
00106     virtual void preRender(Graphic *);
00107     ListMode renderDisplayList(Graphic *);
00108 
00109     GlMaterialBank *m_materials;
00110     const GlMaterial * m_currentMaterial;
00111 
00112     GlDisplayLists *m_displayLists;
00113     GlDisplayLists::List *m_currentList;
00114 
00115     GLuint          m_currentTexture;
00116     bool            m_blend;
00117     bool            m_lighting;
00118     bool            m_smooth;
00119     bool            m_twoSided;
00120     long            m_listRenderCount;
00121   };
00122 
00123 } // namespace Solar
00124 
00125 #endif

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