Crazy Eddie's GUI System
0.8.4
|
00001 /*********************************************************************** 00002 created: Tue Apr 30 2013 00003 authors: Paul D Turner <paul@cegui.org.uk> 00004 Lukas E Meindl 00005 *************************************************************************/ 00006 /*************************************************************************** 00007 * Copyright (C) 2004 - 2013 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 _CEGUIRendererBase_h_ 00029 #define _CEGUIRendererBase_h_ 00030 00031 #include "../../Base.h" 00032 #include "../../Renderer.h" 00033 #include "../../Size.h" 00034 #include "../../Vector.h" 00035 #include "../../Rect.h" 00036 #include "../../TextureTarget.h" 00037 #include "CEGUI/RendererModules/OpenGL/GL.h" 00038 #include <vector> 00039 #include <map> 00040 00041 #if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC) 00042 # ifdef CEGUIOPENGLRENDERER_EXPORTS 00043 # define OPENGL_GUIRENDERER_API __declspec(dllexport) 00044 # else 00045 # define OPENGL_GUIRENDERER_API __declspec(dllimport) 00046 # endif 00047 #else 00048 # define OPENGL_GUIRENDERER_API 00049 #endif 00050 00051 #if defined(_MSC_VER) 00052 # pragma warning(push) 00053 # pragma warning(disable : 4251) 00054 #endif 00055 00056 namespace CEGUI 00057 { 00058 class OpenGLTexture; 00059 class OpenGLGeometryBufferBase; 00060 struct mat4Pimpl; 00061 00063 class OPENGL_GUIRENDERER_API OpenGLRendererBase : public Renderer 00064 { 00065 public: 00066 // implement Renderer interface 00067 RenderTarget& getDefaultRenderTarget(); 00068 GeometryBuffer& createGeometryBuffer(); 00069 void destroyGeometryBuffer(const GeometryBuffer& buffer); 00070 void destroyAllGeometryBuffers(); 00071 TextureTarget* createTextureTarget(); 00072 void destroyTextureTarget(TextureTarget* target); 00073 void destroyAllTextureTargets(); 00074 Texture& createTexture(const String& name); 00075 Texture& createTexture(const String& name, 00076 const String& filename, 00077 const String& resourceGroup); 00078 Texture& createTexture(const String& name, const Sizef& size); 00079 void destroyTexture(Texture& texture); 00080 void destroyTexture(const String& name); 00081 void destroyAllTextures(); 00082 Texture& getTexture(const String& name) const; 00083 bool isTextureDefined(const String& name) const; 00084 void setDisplaySize(const Sizef& sz); 00085 const Sizef& getDisplaySize() const; 00086 const Vector2f& getDisplayDPI() const; 00087 uint getMaxTextureSize() const; 00088 const String& getIdentifierString() const; 00089 00112 Texture& createTexture(const String& name, GLuint tex, const Sizef& sz); 00113 00125 void enableExtraStateSettings(bool setting); 00126 00134 void grabTextures(); 00135 00141 void restoreTextures(); 00142 00154 virtual Sizef getAdjustedTextureSize(const Sizef& sz) const; 00155 00161 static float getNextPOTSize(const float f); 00162 00164 virtual void setupRenderingBlendMode(const BlendMode mode, 00165 const bool force = false) = 0; 00166 00168 virtual bool isS3TCSupported() const = 0; 00169 00177 virtual const mat4Pimpl* getViewProjectionMatrix(); 00178 00186 virtual void setViewProjectionMatrix(const mat4Pimpl* viewProjectionMatrix); 00187 00195 const CEGUI::Rectf& getActiveViewPort(); 00196 00204 void setActiveRenderTarget(RenderTarget* renderTarget); 00205 00213 RenderTarget* getActiveRenderTarget(); 00214 00215 protected: 00216 OpenGLRendererBase(); 00217 00225 OpenGLRendererBase(const Sizef& display_size); 00226 00228 virtual ~OpenGLRendererBase(); 00229 00231 static void logTextureCreation(const String& name); 00233 static void logTextureDestruction(const String& name); 00234 00236 void initialiseMaxTextureSize(); 00237 00239 void initialiseDisplaySizeWithViewportSize(); 00240 00242 virtual OpenGLGeometryBufferBase* createGeometryBuffer_impl() = 0; 00243 00245 virtual TextureTarget* createTextureTarget_impl() = 0; 00246 00248 static String d_rendererID; 00250 Sizef d_displaySize; 00252 Vector2f d_displayDPI; 00254 RenderTarget* d_defaultTarget; 00256 typedef std::vector<TextureTarget*> TextureTargetList; 00258 TextureTargetList d_textureTargets; 00260 typedef std::vector<OpenGLGeometryBufferBase*> GeometryBufferList; 00262 GeometryBufferList d_geometryBuffers; 00264 typedef std::map<String, OpenGLTexture*, StringFastLessCompare 00265 CEGUI_MAP_ALLOC(String, OpenGLTexture*)> TextureMap; 00267 TextureMap d_textures; 00269 uint d_maxTextureSize; 00271 bool d_initExtraStates; 00273 BlendMode d_activeBlendMode; 00275 mat4Pimpl* d_viewProjectionMatrix; 00277 RenderTarget* d_activeRenderTarget; 00278 }; 00279 00287 class OGLTextureTargetFactory : 00288 public AllocatedObject<OGLTextureTargetFactory> 00289 { 00290 public: 00291 OGLTextureTargetFactory() {} 00292 virtual ~OGLTextureTargetFactory() {} 00293 virtual TextureTarget* create(OpenGLRendererBase&) const 00294 { return 0; } 00295 }; 00296 00297 } 00298 00299 #if defined(_MSC_VER) 00300 # pragma warning(pop) 00301 #endif 00302 00303 #endif 00304