Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

# 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
    00175
    00176         // OpenGL extensions
    00177         static PFNGLBINDBUFFERARBPROC               glBindBufferARB;
    00178         static PFNGLDELETEBUFFERSARBPROC            glDeleteBuffersARB;
    00179         static PFNGLGENBUFFERSARBPROC               glGenBuffersARB;
    00180         static PFNGLBUFFERDATAARBPROC               glBufferDataARB;
    00181         static PFNGLBUFFERSUBDATAARBPROC            glBufferSubDataARB;
    00182         static PFNGLGETBUFFERSUBDATAARBPROC         glGetBufferSubDataARB;
    00183         static PFNGLMAPBUFFERARBPROC                glMapBufferARB;
    00184         static PFNGLUNMAPBUFFERARBPROC              glUnmapBufferARB;
    00185         static PFNGLACTIVETEXTUREARBPROC            glActiveTextureARB;
    00186         static PFNGLCLIENTACTIVETEXTUREARBPROC      glClientActiveTextureARB;
    00187         static PFNGLCOMPRESSEDTEXIMAGE2DARBPROC     glCompressedTexImage2DARB;
    00188         static PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC  glCompressedTexSubImage2DARB;
    00189
    00190     private:
    00191
    00195         bool CheckExtension(const String& strExtension) const;
    00196
    00199         void LoadExtensions(void);
    00200
    00202         const COGLDeclaration* m_CurrentDeclaration;
    00203
    00205         ulong m_nIndexStride;
    00206
    00208         String m_strExtensions;
    00209
    00211         bool m_bGLInitialized;
    00212     };
    00213
    00214 } // namespace Keos
    00215
    00216
    00217 #endif // KEOS_OGLRENDERSYSTEM_H