Crazy Eddie's GUI System  0.8.7
RendererModules/OpenGLES/Renderer.h
1 /***********************************************************************
2  created: Sun Jan 11 2009
3  author: Paul D Turner
4 *************************************************************************/
5 /***************************************************************************
6  * Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining
9  * a copy of this software and associated documentation files (the
10  * "Software"), to deal in the Software without restriction, including
11  * without limitation the rights to use, copy, modify, merge, publish,
12  * distribute, sublicense, and/or sell copies of the Software, and to
13  * permit persons to whom the Software is furnished to do so, subject to
14  * the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  ***************************************************************************/
27 #ifndef _CEGUIOpenGLESRenderer_h_
28 #define _CEGUIOpenGLESRenderer_h_
29 
30 #include "CEGUI/Base.h"
31 #include "CEGUI/Renderer.h"
32 #include "CEGUI/Size.h"
33 #include "CEGUI/Vector.h"
34 #include "CEGUI/RendererModules/OpenGLES/GLES.h"
35 #include <vector>
36 #include <map>
37 
38 #if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC)
39 # ifdef CEGUIOPENGLESRENDERER_EXPORTS
40 # define OPENGLES_GUIRENDERER_API __declspec(dllexport)
41 # else
42 # define OPENGLES_GUIRENDERER_API __declspec(dllimport)
43 # endif
44 #else
45 # define OPENGLES_GUIRENDERER_API
46 #endif
47 
48 #if defined(_MSC_VER)
49 # pragma warning(push)
50 # pragma warning(disable : 4251)
51 #endif
52 
53 
54 // Start of CEGUI namespace section
55 namespace CEGUI
56 {
57 class OpenGLESTexture;
58 class OpenGLESTextureTarget;
59 class OpenGLESGeometryBuffer;
60 class OGLTextureTargetFactory;
61 
66 class OPENGLES_GUIRENDERER_API OpenGLESRenderer : public Renderer
67 {
68 public:
71  {
79  TTT_NONE
80  };
81 
106  const TextureTargetType tt_type = TTT_AUTO,
107  const int abi = CEGUI_VERSION_ABI);
108 
136  const Sizef& display_size,
137  const TextureTargetType tt_type = TTT_AUTO,
138  const int abi = CEGUI_VERSION_ABI);
139 
155  static void destroySystem();
156 
168  static OpenGLESRenderer& create(const TextureTargetType tt_type = TTT_AUTO,
169  const int abi = CEGUI_VERSION_ABI);
170 
185  static OpenGLESRenderer& create(const Sizef& display_size,
186  const TextureTargetType tt_type = TTT_AUTO,
187  const int abi = CEGUI_VERSION_ABI);
188 
196  static void destroy(OpenGLESRenderer& renderer);
197 
206  static bool isGLExtensionSupported( const char* extension );
207 
208  // implement Renderer interface
216  Texture& createTexture(const String& name);
218  const String& filename,
219  const String& resourceGroup);
220  Texture& createTexture(const String& name, const Sizef& size);
221  void destroyTexture(Texture& texture);
222  void destroyTexture(const String& name);
224  Texture& getTexture(const String& name) const;
225  bool isTextureDefined(const String& name) const;
227  void endRendering();
228  void setDisplaySize(const Sizef& sz);
229  const Sizef& getDisplaySize() const;
230  const Vector2f& getDisplayDPI() const;
231  uint getMaxTextureSize() const;
232  const String& getIdentifierString() const;
233 
248  Texture& createTexture(const String& name, GLuint tex, const Sizef& sz);
249 
261  void enableExtraStateSettings(bool setting);
262 
270  void grabTextures();
271 
278 
291 
297  static float getNextPOTSize(const float f);
298 
314  bool isTexCoordSystemFlipped() const { return true; }
315 
316 private:
325  OpenGLESRenderer(const TextureTargetType tt_type);
326 
338  OpenGLESRenderer(const Sizef& display_size, const TextureTargetType tt_type);
339 
344  virtual ~OpenGLESRenderer();
345 
347  void setupExtraStates();
348 
350  void cleanupExtraStates();
351 
353  void initialiseTextureTargetFactory(const TextureTargetType tt_type);
354 
356  void logTextureDestruction(const String& name);
357 
359  struct RenderStates
360  {
361  GLboolean glScissorTest;
362  GLboolean texturing;
363  GLboolean blend;
364  GLint arrayBuffer;
365  GLint texture;
366  GLint texEnvParam;
367  } glPreRenderStates;
368 
370  static String d_rendererID;
372  Sizef d_displaySize;
374  Vector2f d_displayDPI;
376  RenderTarget* d_defaultTarget;
378  typedef std::vector<TextureTarget*> TextureTargetList;
380  TextureTargetList d_textureTargets;
382  typedef std::vector<OpenGLESGeometryBuffer*> GeometryBufferList;
384  GeometryBufferList d_geometryBuffers;
386  typedef std::map<String, OpenGLESTexture*, StringFastLessCompare
387  CEGUI_MAP_ALLOC(String, OpenGLESTexture*)> TextureMap;
389  TextureMap d_textures;
391  uint d_maxTextureSize;
393  bool d_initExtraStates;
395  OGLTextureTargetFactory* d_textureTargetFactory;
396  };
397 
398 } // End of CEGUI namespace section
399 
400 #if defined(_MSC_VER)
401 # pragma warning(pop)
402 #endif
403 
404 #endif // end of guard _CEGUIOpenGLESRenderer_h_
405 
CEGUI::OpenGLESRenderer::createTexture
Texture & createTexture(const String &name, GLuint tex, const Sizef &sz)
Create a texture that uses an existing OpenGLES texture with the specified size. Note that it is your...
CEGUI::GeometryBuffer
Abstract class defining the interface for objects that buffer geometry for later rendering.
Definition: GeometryBuffer.h:44
CEGUI::OpenGLESRenderer::getDisplaySize
const Sizef & getDisplaySize() const
Return the size of the display or host window in pixels.
CEGUI::OpenGLESRenderer::TextureTargetType
TextureTargetType
Enumeration of valid texture target types.
Definition: RendererModules/OpenGLES/Renderer.h:71
CEGUI::OpenGLESRenderer::TTT_AUTO
@ TTT_AUTO
Automatically choose the best type available.
Definition: RendererModules/OpenGLES/Renderer.h:73
CEGUI::OpenGLESRenderer::createGeometryBuffer
GeometryBuffer & createGeometryBuffer()
Create a new GeometryBuffer and return a reference to it. You should remove the GeometryBuffer from a...
CEGUI::OpenGLESRenderer::isTexCoordSystemFlipped
bool isTexCoordSystemFlipped() const
Returns if the texture coordinate system is vertically flipped or not. The original of a texture coor...
Definition: RendererModules/OpenGLES/Renderer.h:314
CEGUI::OpenGLESRenderer::createTexture
Texture & createTexture(const String &name)
Create a 'null' Texture object.
CEGUI::OpenGLESRenderer::destroyTextureTarget
void destroyTextureTarget(TextureTarget *target)
Function that cleans up TextureTarget objects created with the createTextureTarget function.
CEGUI::OpenGLESRenderer::restoreTextures
void restoreTextures()
Restores all the loaded textures from the local data buffers previously created by 'grabTextures'.
CEGUI::OpenGLESRenderer::getNextPOTSize
static float getNextPOTSize(const float f)
Utility function that will return f if it's a power of two, or the next power of two up from f if it'...
CEGUI::OpenGLESRenderer::destroyTexture
void destroyTexture(const String &name)
Destroy a Texture object that was previously created by calling the createTexture functions.
CEGUI::OpenGLESRenderer::enableExtraStateSettings
void enableExtraStateSettings(bool setting)
Tells the renderer to initialise some extra states beyond what it directly needs itself for CEGUI.
CEGUI::OpenGLESRenderer::bootstrapSystem
static OpenGLESRenderer & bootstrapSystem(const TextureTargetType tt_type=TTT_AUTO, const int abi=CEGUI_VERSION_ABI)
Convenience function that creates the required objects to initialise the CEGUI system.
CEGUI
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
CEGUI::OpenGLESRenderer::createTextureTarget
TextureTarget * createTextureTarget()
Create a TextureTarget that can be used to cache imagery; this is a RenderTarget that does not lose i...
CEGUI::OpenGLESRenderer::destroyAllTextures
void destroyAllTextures()
Destroy all Texture objects created by this Renderer.
CEGUI::Vector2< float >
CEGUI::OpenGLESRenderer::grabTextures
void grabTextures()
Grabs all the loaded textures from Texture RAM and stores them in a local data buffer....
CEGUI::OpenGLESRenderer::createTexture
Texture & createTexture(const String &name, const String &filename, const String &resourceGroup)
Create a Texture object using the given image file.
CEGUI::OpenGLESRenderer::bootstrapSystem
static OpenGLESRenderer & bootstrapSystem(const Sizef &display_size, const TextureTargetType tt_type=TTT_AUTO, const int abi=CEGUI_VERSION_ABI)
Convenience function that creates the required objects to initialise the CEGUI system.
CEGUI::OpenGLESRenderer::endRendering
void endRendering()
Perform any operations required to finalise rendering.
CEGUI::OpenGLESRenderer::getIdentifierString
const String & getIdentifierString() const
Return identification string for the renderer module.
CEGUI::OpenGLESRenderer::getTexture
Texture & getTexture(const String &name) const
Return a Texture object that was previously created by calling the createTexture functions.
CEGUI::OpenGLESRenderer::getMaxTextureSize
uint getMaxTextureSize() const
Return the pixel size of the maximum supported texture.
CEGUI::OpenGLESRenderer::destroySystem
static void destroySystem()
Convenience function to cleanup the CEGUI system and related objects that were created by calling the...
CEGUI::OpenGLESRenderer::isTextureDefined
bool isTextureDefined(const String &name) const
Return whether a texture with the given name exists.
CEGUI::OpenGLESRenderer::isGLExtensionSupported
static bool isGLExtensionSupported(const char *extension)
Check if provided extension is supported on current platform. Khronos reference implementation.
CEGUI::OpenGLESRenderer::destroyGeometryBuffer
void destroyGeometryBuffer(const GeometryBuffer &buffer)
Destroy a GeometryBuffer that was returned when calling the createGeometryBuffer function....
CEGUI::Texture
Abstract base class specifying the required interface for Texture objects.
Definition: Texture.h:54
CEGUI::OpenGLESRenderer::beginRendering
void beginRendering()
Perform any operations required to put the system into a state ready for rendering operations to begi...
CEGUI::OpenGLESRenderer::destroyAllTextureTargets
void destroyAllTextureTargets()
Destory all TextureTarget objects created by this Renderer.
CEGUI::OpenGLESRenderer::getAdjustedTextureSize
Sizef getAdjustedTextureSize(const Sizef &sz) const
Helper to return a valid texture size according to reported OpenGLES capabilities.
CEGUI::OpenGLESRenderer::setDisplaySize
void setDisplaySize(const Sizef &sz)
Set the size of the display or host window in pixels for this Renderer object.
CEGUI::OpenGLESRenderer
Renderer class to interface with OpenGLES.
Definition: RendererModules/OpenGLES/Renderer.h:67
CEGUI::OpenGLESRenderer::destroyAllGeometryBuffers
void destroyAllGeometryBuffers()
Destroy all GeometryBuffer objects created by this Renderer.
CEGUI::RenderTarget
Defines interface to some surface that can be rendered to. Concrete instances of objects that impleme...
Definition: RenderTarget.h:60
CEGUI::Size< float >
CEGUI::OpenGLESRenderer::destroyTexture
void destroyTexture(Texture &texture)
Destroy a Texture object that was previously created by calling the createTexture functions.
CEGUI::OpenGLESRenderer::getDefaultRenderTarget
RenderTarget & getDefaultRenderTarget()
Returns the default RenderTarget object. The default render target is is typically one that targets t...
CEGUI::TextureTarget
Specialisation of RenderTarget interface that should be used as the base class for RenderTargets that...
Definition: TextureTarget.h:41
CEGUI::String
String class used within the GUI system.
Definition: String.h:64
CEGUI::OpenGLESRenderer::getDisplayDPI
const Vector2f & getDisplayDPI() const
Return the resolution of the display or host window in dots per inch.
CEGUI::OpenGLESRenderer::createTexture
Texture & createTexture(const String &name, const Sizef &size)
Create a Texture object with the given pixel dimensions as specified by size.
CEGUI::OpenGLESRenderer::TTT_PBUFFER
@ TTT_PBUFFER
Use targets based on pbuffer support if available, else none.
Definition: RendererModules/OpenGLES/Renderer.h:77
CEGUI::OpenGLESRenderer::create
static OpenGLESRenderer & create(const TextureTargetType tt_type=TTT_AUTO, const int abi=CEGUI_VERSION_ABI)
Create an OpenGLESRenderer object.
CEGUI::OpenGLESRenderer::create
static OpenGLESRenderer & create(const Sizef &display_size, const TextureTargetType tt_type=TTT_AUTO, const int abi=CEGUI_VERSION_ABI)
Create an OpenGLESRenderer object.
CEGUI::Renderer
Abstract class defining the basic required interface for Renderer objects.
Definition: Renderer.h:84
CEGUI::OpenGLESRenderer::TTT_FBO
@ TTT_FBO
Use targets based on frame buffer objects if available, else none.
Definition: RendererModules/OpenGLES/Renderer.h:75
CEGUI::OpenGLESRenderer::destroy
static void destroy(OpenGLESRenderer &renderer)
Destroy an OpenGLESRenderer object.