Crazy Eddies GUI System: CEGUIOpenGLRenderer.h Source File

Crazy Eddies GUI System 0.7.6

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

CEGUIOpenGLRenderer.h

    00001 /***********************************************************************
    00002     filename:   CEGUIOpenGLRenderer.h
    00003     created:    Sun Jan 11 2009
    00004     author:     Paul D Turner
    00005 *************************************************************************/
    00006 /***************************************************************************
    00007  *   Copyright (C) 2004 - 2010 Paul D Turner & The CEGUI Development Team
    00008  *
    00009  *   Permission is hereby granted, free of charge, to any person obtaining
    00010  *   a copy of this software and associated documentation files (the
    00011  *   "Software"), to deal in the Software without restriction, including
    00012  *   without limitation the rights to use, copy, modify, merge, publish,
    00013  *   distribute, sublicense, and/or sell copies of the Software, and to
    00014  *   permit persons to whom the Software is furnished to do so, subject to
    00015  *   the following conditions:
    00016  *
    00017  *   The above copyright notice and this permission notice shall be
    00018  *   included in all copies or substantial portions of the Software.
    00019  *
    00020  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    00021  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    00022  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
    00023  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
    00024  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
    00025  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
    00026  *   OTHER DEALINGS IN THE SOFTWARE.
    00027  ***************************************************************************/
    00028 #ifndef _CEGUIOpenGLRenderer_h_
    00029 #define _CEGUIOpenGLRenderer_h_
    00030
    00031 #include "../../CEGUIBase.h"
    00032 #include "../../CEGUIRenderer.h"
    00033 #include "../../CEGUISize.h"
    00034 #include "../../CEGUIVector.h"
    00035 #include "CEGUIOpenGL.h"
    00036 #include <vector>
    00037
    00038 #if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC)
    00039 #   ifdef OPENGL_GUIRENDERER_EXPORTS
    00040 #       define OPENGL_GUIRENDERER_API __declspec(dllexport)
    00041 #   else
    00042 #       define OPENGL_GUIRENDERER_API __declspec(dllimport)
    00043 #   endif
    00044 #else
    00045 #   define OPENGL_GUIRENDERER_API
    00046 #endif
    00047
    00048 #if defined(_MSC_VER)
    00049 #   pragma warning(push)
    00050 #   pragma warning(disable : 4251)
    00051 #endif
    00052
    00053
    00054 // Start of CEGUI namespace section
    00055 namespace CEGUI
    00056 {
    00057 class OpenGLTexture;
    00058 class OpenGLTextureTarget;
    00059 class OpenGLGeometryBuffer;
    00060 class OGLTextureTargetFactory;
    00061
    00066 class OPENGL_GUIRENDERER_API OpenGLRenderer : public Renderer
    00067 {
    00068 public:
    00070     enum TextureTargetType
    00071     {
    00073         TTT_AUTO,
    00075         TTT_FBO,
    00077         TTT_PBUFFER,
    00079         TTT_NONE
    00080     };
    00081
    00102     static OpenGLRenderer& bootstrapSystem(
    00103                                     const TextureTargetType tt_type = TTT_AUTO);
    00104
    00128     static OpenGLRenderer& bootstrapSystem(const Size& display_size,
    00129                                   const TextureTargetType tt_type = TTT_AUTO);
    00130
    00146     static void destroySystem();
    00147
    00156     static OpenGLRenderer& create(const TextureTargetType tt_type = TTT_AUTO);
    00157
    00169     static OpenGLRenderer& create(const Size& display_size,
    00170                                   const TextureTargetType tt_type = TTT_AUTO);
    00171
    00179     static void destroy(OpenGLRenderer& renderer);
    00180
    00181     // implement Renderer interface
    00182     RenderingRoot& getDefaultRenderingRoot();
    00183     GeometryBuffer& createGeometryBuffer();
    00184     void destroyGeometryBuffer(const GeometryBuffer& buffer);
    00185     void destroyAllGeometryBuffers();
    00186     TextureTarget* createTextureTarget();
    00187     void destroyTextureTarget(TextureTarget* target);
    00188     void destroyAllTextureTargets();
    00189     Texture& createTexture();
    00190     Texture& createTexture(const String& filename, const String& resourceGroup);
    00191     Texture& createTexture(const Size& size);
    00192     void destroyTexture(Texture& texture);
    00193     void destroyAllTextures();
    00194     void beginRendering();
    00195     void endRendering();
    00196     void setDisplaySize(const Size& sz);
    00197     const Size& getDisplaySize() const;
    00198     const Vector2& getDisplayDPI() const;
    00199     uint getMaxTextureSize() const;
    00200     const String& getIdentifierString() const;
    00201
    00216     Texture& createTexture(GLuint tex, const Size& sz);
    00217
    00229     void enableExtraStateSettings(bool setting);
    00230
    00238     void grabTextures();
    00239
    00245     void restoreTextures();
    00246
    00258     Size getAdjustedTextureSize(const Size& sz) const;
    00259
    00265     static float getNextPOTSize(const float f);
    00266
    00268     void setupRenderingBlendMode(const BlendMode mode, const bool force = false);
    00269
    00270 private:
    00279     OpenGLRenderer(const TextureTargetType tt_type);
    00280
    00292     OpenGLRenderer(const Size& display_size, const TextureTargetType tt_type);
    00293
    00298     virtual ~OpenGLRenderer();
    00299
    00301     void setupExtraStates();
    00302
    00304     void cleanupExtraStates();
    00305
    00307     void initialiseTextureTargetFactory(const TextureTargetType tt_type);
    00308
    00310     static String d_rendererID;
    00312     Size d_displaySize;
    00314     Vector2 d_displayDPI;
    00316     RenderingRoot* d_defaultRoot;
    00318     RenderTarget* d_defaultTarget;
    00320     typedef std::vector<TextureTarget*> TextureTargetList;
    00322     TextureTargetList d_textureTargets;
    00324     typedef std::vector<OpenGLGeometryBuffer*> GeometryBufferList;
    00326     GeometryBufferList d_geometryBuffers;
    00328     typedef std::vector<OpenGLTexture*> TextureList;
    00330     TextureList d_textures;
    00332     uint d_maxTextureSize;
    00334     bool d_initExtraStates;
    00336     OGLTextureTargetFactory* d_textureTargetFactory;
    00338     BlendMode d_activeBlendMode;
    00339   };
    00340
    00341 } // End of  CEGUI namespace section
    00342
    00343 #if defined(_MSC_VER)
    00344 #   pragma warning(pop)
    00345 #endif
    00346
    00347 #endif // end of guard _CEGUIOpenGLRenderer_h_