Crazy Eddie's GUI System
0.8.4
|
00001 /*********************************************************************** 00002 created: Sun Jan 11 2009 00003 author: Paul D Turner 00004 *************************************************************************/ 00005 /*************************************************************************** 00006 * Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team 00007 * 00008 * Permission is hereby granted, free of charge, to any person obtaining 00009 * a copy of this software and associated documentation files (the 00010 * "Software"), to deal in the Software without restriction, including 00011 * without limitation the rights to use, copy, modify, merge, publish, 00012 * distribute, sublicense, and/or sell copies of the Software, and to 00013 * permit persons to whom the Software is furnished to do so, subject to 00014 * the following conditions: 00015 * 00016 * The above copyright notice and this permission notice shall be 00017 * included in all copies or substantial portions of the Software. 00018 * 00019 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00020 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00021 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00022 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00023 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00024 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00025 * OTHER DEALINGS IN THE SOFTWARE. 00026 ***************************************************************************/ 00027 #ifndef _CEGUIOpenGLESRenderer_h_ 00028 #define _CEGUIOpenGLESRenderer_h_ 00029 00030 #include "CEGUI/Base.h" 00031 #include "CEGUI/Renderer.h" 00032 #include "CEGUI/Size.h" 00033 #include "CEGUI/Vector.h" 00034 #include "CEGUI/RendererModules/OpenGLES/GLES.h" 00035 #include <vector> 00036 #include <map> 00037 00038 #if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC) 00039 # ifdef CEGUIOPENGLESRENDERER_EXPORTS 00040 # define OPENGLES_GUIRENDERER_API __declspec(dllexport) 00041 # else 00042 # define OPENGLES_GUIRENDERER_API __declspec(dllimport) 00043 # endif 00044 #else 00045 # define OPENGLES_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 OpenGLESTexture; 00058 class OpenGLESTextureTarget; 00059 class OpenGLESGeometryBuffer; 00060 class OGLTextureTargetFactory; 00061 00066 class OPENGLES_GUIRENDERER_API OpenGLESRenderer : public Renderer 00067 { 00068 public: 00070 enum TextureTargetType 00071 { 00073 TTT_AUTO, 00075 TTT_FBO, 00077 TTT_PBUFFER, 00079 TTT_NONE 00080 }; 00081 00105 static OpenGLESRenderer& bootstrapSystem( 00106 const TextureTargetType tt_type = TTT_AUTO, 00107 const int abi = CEGUI_VERSION_ABI); 00108 00135 static OpenGLESRenderer& bootstrapSystem( 00136 const Sizef& display_size, 00137 const TextureTargetType tt_type = TTT_AUTO, 00138 const int abi = CEGUI_VERSION_ABI); 00139 00155 static void destroySystem(); 00156 00168 static OpenGLESRenderer& create(const TextureTargetType tt_type = TTT_AUTO, 00169 const int abi = CEGUI_VERSION_ABI); 00170 00185 static OpenGLESRenderer& create(const Sizef& display_size, 00186 const TextureTargetType tt_type = TTT_AUTO, 00187 const int abi = CEGUI_VERSION_ABI); 00188 00196 static void destroy(OpenGLESRenderer& renderer); 00197 00206 static bool isGLExtensionSupported( const char* extension ); 00207 00208 // implement Renderer interface 00209 RenderTarget& getDefaultRenderTarget(); 00210 GeometryBuffer& createGeometryBuffer(); 00211 void destroyGeometryBuffer(const GeometryBuffer& buffer); 00212 void destroyAllGeometryBuffers(); 00213 TextureTarget* createTextureTarget(); 00214 void destroyTextureTarget(TextureTarget* target); 00215 void destroyAllTextureTargets(); 00216 Texture& createTexture(const String& name); 00217 Texture& createTexture(const String& name, 00218 const String& filename, 00219 const String& resourceGroup); 00220 Texture& createTexture(const String& name, const Sizef& size); 00221 void destroyTexture(Texture& texture); 00222 void destroyTexture(const String& name); 00223 void destroyAllTextures(); 00224 Texture& getTexture(const String& name) const; 00225 bool isTextureDefined(const String& name) const; 00226 void beginRendering(); 00227 void endRendering(); 00228 void setDisplaySize(const Sizef& sz); 00229 const Sizef& getDisplaySize() const; 00230 const Vector2f& getDisplayDPI() const; 00231 uint getMaxTextureSize() const; 00232 const String& getIdentifierString() const; 00233 00248 Texture& createTexture(const String& name, GLuint tex, const Sizef& sz); 00249 00261 void enableExtraStateSettings(bool setting); 00262 00270 void grabTextures(); 00271 00277 void restoreTextures(); 00278 00290 Sizef getAdjustedTextureSize(const Sizef& sz) const; 00291 00297 static float getNextPOTSize(const float f); 00298 00299 private: 00308 OpenGLESRenderer(const TextureTargetType tt_type); 00309 00321 OpenGLESRenderer(const Sizef& display_size, const TextureTargetType tt_type); 00322 00327 virtual ~OpenGLESRenderer(); 00328 00330 void setupExtraStates(); 00331 00333 void cleanupExtraStates(); 00334 00336 void initialiseTextureTargetFactory(const TextureTargetType tt_type); 00337 00339 void logTextureDestruction(const String& name); 00340 00342 struct RenderStates 00343 { 00344 GLboolean glScissorTest; 00345 GLboolean texturing; 00346 GLboolean blend; 00347 GLint arrayBuffer; 00348 GLint texture; 00349 GLint texEnvParam; 00350 } glPreRenderStates; 00351 00353 static String d_rendererID; 00355 Sizef d_displaySize; 00357 Vector2f d_displayDPI; 00359 RenderTarget* d_defaultTarget; 00361 typedef std::vector<TextureTarget*> TextureTargetList; 00363 TextureTargetList d_textureTargets; 00365 typedef std::vector<OpenGLESGeometryBuffer*> GeometryBufferList; 00367 GeometryBufferList d_geometryBuffers; 00369 typedef std::map<String, OpenGLESTexture*, StringFastLessCompare 00370 CEGUI_MAP_ALLOC(String, OpenGLESTexture*)> TextureMap; 00372 TextureMap d_textures; 00374 uint d_maxTextureSize; 00376 bool d_initExtraStates; 00378 OGLTextureTargetFactory* d_textureTargetFactory; 00379 }; 00380 00381 } // End of CEGUI namespace section 00382 00383 #if defined(_MSC_VER) 00384 # pragma warning(pop) 00385 #endif 00386 00387 #endif // end of guard _CEGUIOpenGLESRenderer_h_ 00388