KeosOGLRenderSystem.h

Go to the documentation of this file.
00001 /*
00002  * This source file is part of KEOS (Free 3D Engine)
00003  * For the latest info, see http://www.keosengine.org/
00004  * E-mails : thierry.vouriot@keosengine.org, yeri@keosengine.org
00005  *
00006  * This program is free software; you can redistribute it and/or modify it under
00007  * the terms of the GNU Lesser General Public License as published by the Free Software
00008  * Foundation; either version 2 of the License, or (at your option) any later
00009  * version.
00010  *
00011  * This program is distributed in the hope that it will be useful, but WITHOUT
00012  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00013  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public License along with
00016  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00017  * Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00018  * http://www.gnu.org/copyleft/lesser.txt.
00019  *
00020  */
00021 
00022 #ifndef KEOS_OGLRENDERSYSTEM_H
00023 #define KEOS_OGLRENDERSYSTEM_H
00024 
00025 #include "KeosOGLPrerequisites.h"
00026 #include "KeosRenderSystem.h"
00027 #include "KeosRenderWindow.h"
00028 
00029 namespace Keos
00030 {
00031 #define BUFFER_OFFSET(n) ((char*)NULL + (n))
00032 
00033   //-----------------------------------------------------------------------
00037   class COGLRenderSystem : public IRenderSystem
00038   {
00039   public :
00040 
00043     COGLRenderSystem();
00044 
00047     ~COGLRenderSystem();
00048 
00051     const String& GetName(void) const;
00052 
00055     IRenderWindow* CreateRenderWindow(const String &strName, uint nWidth, uint nHeight, uint nColourDepth, bool bFullScreen);
00056 
00059     IRenderWindow* Initialise(bool bAutoCreateWindow, const String& strWindowTitle = "KEOS Render Window");
00060 
00063     void Reinitialise(void); // Used if settings changed mid-rendering
00064 
00067     void Shutdown(void);
00068 
00069     void InitGL(void);
00070 
00073     virtual void BeginScene(void) const;
00074 
00077     virtual void EndScene(void) const;
00078 
00081     virtual void PrintInfo(void) const;
00082 
00085     virtual IBufferBase* _CreateVB(ulong nSize, ulong nStride, ulong nFlags) const;
00086 
00089     virtual IBufferBase* _CreateIB(ulong nSize, ulong nStride, ulong nFlags) const;
00090 
00093     virtual IDeclaration* CreateDeclaration(const TDeclarationElement* Elements, size_t nCount) const;
00094 
00097     virtual void _SetVB(uint nStream, const IBufferBase* pBuffer, ulong nStride, ulong nMinVertex, ulong nMaxVertex);
00098 
00101     virtual void _SetIB(const IBufferBase* pBuffer, ulong nStride);
00102 
00105     virtual void SetDeclaration(const IDeclaration* Declaration);
00106 
00109     virtual void DrawPrimitives(TPrimitiveType Type, ulong nFirstVertex, ulong nCount) const;
00110 
00113     virtual void DrawIndexedPrimitives(TPrimitiveType Type, ulong nFirstIndex, ulong nCount) const;
00114 
00117     virtual void PushMatrix(TMatrixType Type);
00118 
00121     virtual void PopMatrix(TMatrixType Type);
00122 
00125     virtual void LoadMatrix(TMatrixType Type, const CMatrix4& Matrix);
00126 
00129     virtual void LoadMatrixMult(TMatrixType Type, const CMatrix4& Matrix);
00130 
00133     virtual void GetMatrix(TMatrixType Type, CMatrix4& Matrix) const;
00134 
00137     virtual ulong ConvertColor(const CColor& Color) const;
00138 
00141     virtual ITextureBase* CreateTexture(const TVector2I& Size, TPixelFormat Format, ulong nFlags = 0) const;
00142 
00145     virtual void SetTexture(uint nUnit, const ITextureBase* pTexture) const;
00146 
00149     virtual void SetupAlphaBlending(TBlend Src, TBlend Dest) const;
00150 
00153     virtual void SetupTextureUnit(uint nUnit, TTextureOp Op, TTextureArg Arg1, TTextureArg Arg2 = TXA_DIFFUSE, const CColor& Constant = 0x00) const;
00154 
00157     virtual void Enable(TRenderParameter Param, bool bValue) const;
00158 
00161     virtual IShaderBase* CreateShader(CGprogram Program, TShaderType Type) const;
00162 
00165     virtual void SetVertexShader(const IShaderBase* pShader);
00166 
00169     virtual void SetPixelShader(const IShaderBase* pShader);
00170 
00173     virtual void SetClearColor(const CColor& Color);
00174 
00177     virtual void SetLight(uint nIndex, CLight* pLight);
00178 
00181     virtual void SetFillMode(TFillMode Mode);
00182 
00183 
00184     // OpenGL extensions
00185     static PFNGLBINDBUFFERARBPROC               glBindBufferARB;
00186     static PFNGLDELETEBUFFERSARBPROC            glDeleteBuffersARB;
00187     static PFNGLGENBUFFERSARBPROC               glGenBuffersARB;
00188     static PFNGLBUFFERDATAARBPROC               glBufferDataARB;
00189     static PFNGLBUFFERSUBDATAARBPROC            glBufferSubDataARB;
00190     static PFNGLGETBUFFERSUBDATAARBPROC         glGetBufferSubDataARB;
00191     static PFNGLMAPBUFFERARBPROC                glMapBufferARB;
00192     static PFNGLUNMAPBUFFERARBPROC              glUnmapBufferARB;
00193     static PFNGLACTIVETEXTUREARBPROC            glActiveTextureARB;
00194     static PFNGLCLIENTACTIVETEXTUREARBPROC      glClientActiveTextureARB;
00195     static PFNGLCOMPRESSEDTEXIMAGE2DARBPROC     glCompressedTexImage2DARB;
00196     static PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC  glCompressedTexSubImage2DARB;
00197 
00198   private:
00199 
00203     bool CheckExtension(const String& strExtension) const;
00204 
00207     void LoadExtensions(void);
00208 
00210     const COGLDeclaration* m_CurrentDeclaration;
00211 
00213     ulong m_nIndexStride;
00214 
00216     String m_strExtensions;
00217 
00219     bool m_bGLInitialized;
00220   };
00221 
00222 } // namespace Keos
00223 
00224 
00225 #endif // KEOS_OGLRENDERSYSTEM_H

Generated on Fri Mar 9 14:29:04 2007 for Keos by  doxygen 1.5.1-p1