00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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
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
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 }
00342
00343 #if defined(_MSC_VER)
00344 # pragma warning(pop)
00345 #endif
00346
00347 #endif // end of guard _CEGUIOpenGLRenderer_h_