Crazy Eddie's GUI System  0.8.7
RendererBase.h
1 /***********************************************************************
2  created: Tue Apr 30 2013
3  authors: Paul D Turner <paul@cegui.org.uk>
4  Lukas E Meindl
5 *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2013 Paul D Turner & The CEGUI Development Team
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining
10  * a copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26  * OTHER DEALINGS IN THE SOFTWARE.
27  ***************************************************************************/
28 #ifndef _CEGUIRendererBase_h_
29 #define _CEGUIRendererBase_h_
30 
31 #include "../../Base.h"
32 #include "../../Renderer.h"
33 #include "../../Size.h"
34 #include "../../Vector.h"
35 #include "../../Rect.h"
36 #include "../../TextureTarget.h"
37 #include "CEGUI/RendererModules/OpenGL/GL.h"
38 #include <vector>
39 #include <map>
40 
41 #if defined(_MSC_VER)
42 # pragma warning(push)
43 # pragma warning(disable : 4251)
44 #endif
45 
46 namespace CEGUI
47 {
48 class OpenGLTexture;
49 class OpenGLGeometryBufferBase;
50 struct mat4Pimpl;
51 
53 class OPENGL_GUIRENDERER_API OpenGLRendererBase : public Renderer
54 {
55 public:
56  // implement Renderer interface
64  Texture& createTexture(const String& name);
66  const String& filename,
67  const String& resourceGroup);
68  Texture& createTexture(const String& name, const Sizef& size);
69  void destroyTexture(Texture& texture);
70  void destroyTexture(const String& name);
72  Texture& getTexture(const String& name) const;
73  bool isTextureDefined(const String& name) const;
74  void setDisplaySize(const Sizef& sz);
75  const Sizef& getDisplaySize() const;
76  const Vector2f& getDisplayDPI() const;
77  uint getMaxTextureSize() const;
78  const String& getIdentifierString() const;
79 
102  Texture& createTexture(const String& name, GLuint tex, const Sizef& sz);
103 
115  void enableExtraStateSettings(bool setting);
116 
124  void grabTextures();
125 
132 
144  virtual Sizef getAdjustedTextureSize(const Sizef& sz) const;
145 
151  static float getNextPOTSize(const float f);
152 
154  virtual void setupRenderingBlendMode(const BlendMode mode,
155  const bool force = false) = 0;
156 
158  virtual bool isS3TCSupported() const = 0;
159 
168 
176  virtual void setViewProjectionMatrix(const mat4Pimpl* viewProjectionMatrix);
177 
186 
194  void setActiveRenderTarget(RenderTarget* renderTarget);
195 
204 
220  bool isTexCoordSystemFlipped() const { return true; }
221 
222 protected:
224 
232  OpenGLRendererBase(const Sizef& display_size);
233 
234  OpenGLRendererBase(bool set_glew_experimental);
235 
245  OpenGLRendererBase(const Sizef& display_size, bool set_glew_experimental);
246 
247  void init (bool init_glew=false, bool set_glew_experimental=false);
248 
251 
253  static void logTextureCreation(const String& name);
255  static void logTextureDestruction(const String& name);
256 
259 
262 
265 
268 
278  typedef std::vector<TextureTarget*> TextureTargetList;
282  typedef std::vector<OpenGLGeometryBufferBase*> GeometryBufferList;
286  typedef std::map<String, OpenGLTexture*, StringFastLessCompare
287  CEGUI_MAP_ALLOC(String, OpenGLTexture*)> TextureMap;
300 };
301 
310  public AllocatedObject<OGLTextureTargetFactory>
311 {
312 public:
314  virtual ~OGLTextureTargetFactory() {}
315  virtual TextureTarget* create(OpenGLRendererBase&) const
316  { return 0; }
317 };
318 
319 }
320 
321 #if defined(_MSC_VER)
322 # pragma warning(pop)
323 #endif
324 
325 #endif
326 
CEGUI::GeometryBuffer
Abstract class defining the interface for objects that buffer geometry for later rendering.
Definition: GeometryBuffer.h:44
CEGUI::OpenGLRendererBase::getIdentifierString
const String & getIdentifierString() const
Return identification string for the renderer module.
CEGUI::OpenGLRendererBase::getActiveViewPort
const CEGUI::Rectf & getActiveViewPort()
Helper to get the viewport.
CEGUI::OpenGLRendererBase::setupRenderingBlendMode
virtual void setupRenderingBlendMode(const BlendMode mode, const bool force=false)=0
set the render states for the specified BlendMode.
CEGUI::OpenGLRendererBase::initialiseDisplaySizeWithViewportSize
void initialiseDisplaySizeWithViewportSize()
helper to set display size with current viewport size.
CEGUI::OpenGLRendererBase::OpenGLRendererBase
OpenGLRendererBase(const Sizef &display_size, bool set_glew_experimental)
Constructor.
CEGUI::OpenGLRendererBase::d_textureTargets
TextureTargetList d_textureTargets
Container used to track texture targets.
Definition: RendererBase.h:280
CEGUI::OpenGLRendererBase::createTexture
Texture & createTexture(const String &name, const String &filename, const String &resourceGroup)
Create a Texture object using the given image file.
CEGUI::StringFastLessCompare
Functor that can be used as comparator in a std::map with String keys. It's faster than using the def...
Definition: String.h:5580
CEGUI::OpenGLRendererBase::createTextureTarget
TextureTarget * createTextureTarget()
Create a TextureTarget that can be used to cache imagery; this is a RenderTarget that does not lose i...
CEGUI::OpenGLRendererBase::setActiveRenderTarget
void setActiveRenderTarget(RenderTarget *renderTarget)
Helper to set the active render target.
CEGUI::OpenGLRendererBase::~OpenGLRendererBase
virtual ~OpenGLRendererBase()
Destructor!
CEGUI::OpenGLRendererBase::createTexture
Texture & createTexture(const String &name)
Create a 'null' Texture object.
CEGUI::OpenGLRendererBase::OpenGLRendererBase
OpenGLRendererBase(const Sizef &display_size)
Constructor.
CEGUI::OpenGLRendererBase::createGeometryBuffer_impl
virtual OpenGLGeometryBufferBase * createGeometryBuffer_impl()=0
return some appropriate OpenGLGeometryBufferBase subclass instance.
CEGUI::OpenGLRendererBase::d_maxTextureSize
uint d_maxTextureSize
What the renderer thinks the max texture size is.
Definition: RendererBase.h:291
CEGUI::OpenGLRendererBase::d_geometryBuffers
GeometryBufferList d_geometryBuffers
Container used to track geometry buffers.
Definition: RendererBase.h:284
CEGUI::OpenGLRendererBase::enableExtraStateSettings
void enableExtraStateSettings(bool setting)
Tells the renderer to initialise some extra states beyond what it directly needs itself for CEGUI.
CEGUI
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
CEGUI::OpenGLTexture
Texture implementation for the OpenGLRenderer.
Definition: RendererModules/OpenGL/Texture.h:45
CEGUI::OpenGLRendererBase::createTextureTarget_impl
virtual TextureTarget * createTextureTarget_impl()=0
return some appropriate TextureTarget subclass instance.
CEGUI::OpenGLRendererBase::getDefaultRenderTarget
RenderTarget & getDefaultRenderTarget()
Returns the default RenderTarget object. The default render target is is typically one that targets t...
CEGUI::OpenGLRendererBase::d_activeBlendMode
BlendMode d_activeBlendMode
What blend mode we think is active.
Definition: RendererBase.h:295
CEGUI::OpenGLRendererBase::TextureTargetList
std::vector< TextureTarget * > TextureTargetList
container type used to hold TextureTargets we create.
Definition: RendererBase.h:278
CEGUI::OpenGLRendererBase::getAdjustedTextureSize
virtual Sizef getAdjustedTextureSize(const Sizef &sz) const
Helper to return a valid texture size according to reported OpenGL capabilities.
CEGUI::OpenGLRendererBase::destroyTexture
void destroyTexture(Texture &texture)
Destroy a Texture object that was previously created by calling the createTexture functions.
CEGUI::AllocatedObject
Definition: MemoryAllocatedObject.h:110
CEGUI::Vector2< float >
CEGUI::OpenGLRendererBase::destroyAllTextures
void destroyAllTextures()
Destroy all Texture objects created by this Renderer.
CEGUI::OpenGLRendererBase::restoreTextures
void restoreTextures()
Restores all the loaded textures from the local data buffers previously created by 'grabTextures'.
CEGUI::OpenGLRendererBase::isTextureDefined
bool isTextureDefined(const String &name) const
Return whether a texture with the given name exists.
CEGUI::OpenGLRendererBase::getViewProjectionMatrix
virtual const mat4Pimpl * getViewProjectionMatrix()
Helper to return view projection matrix.
CEGUI::mat4Pimpl
Definition: GlmPimpl.h:37
CEGUI::OpenGLRendererBase::setDisplaySize
void setDisplaySize(const Sizef &sz)
Set the size of the display or host window in pixels for this Renderer object.
CEGUI::OpenGLRendererBase::destroyGeometryBuffer
void destroyGeometryBuffer(const GeometryBuffer &buffer)
Destroy a GeometryBuffer that was returned when calling the createGeometryBuffer function....
CEGUI::OpenGLRendererBase::getDisplaySize
const Sizef & getDisplaySize() const
Return the size of the display or host window in pixels.
CEGUI::OpenGLRendererBase::d_rendererID
static String d_rendererID
String holding the renderer identification text.
Definition: RendererBase.h:270
CEGUI::OpenGLRendererBase::setViewProjectionMatrix
virtual void setViewProjectionMatrix(const mat4Pimpl *viewProjectionMatrix)
Helper to set the view projection matrix.
CEGUI::OpenGLRendererBase::destroyTexture
void destroyTexture(const String &name)
Destroy a Texture object that was previously created by calling the createTexture functions.
CEGUI::OpenGLRendererBase::d_displayDPI
Vector2f d_displayDPI
What the renderer considers to be the current display DPI resolution.
Definition: RendererBase.h:274
CEGUI::Texture
Abstract base class specifying the required interface for Texture objects.
Definition: Texture.h:54
CEGUI::OpenGLRendererBase::destroyAllTextureTargets
void destroyAllTextureTargets()
Destory all TextureTarget objects created by this Renderer.
CEGUI::OpenGLRendererBase::logTextureDestruction
static void logTextureDestruction(const String &name)
helper to safely log the destruction of a named texture
CEGUI::OpenGLRendererBase::logTextureCreation
static void logTextureCreation(const String &name)
helper to safely log the creation of a named texture
CEGUI::OpenGLRendererBase::destroyTextureTarget
void destroyTextureTarget(TextureTarget *target)
Function that cleans up TextureTarget objects created with the createTextureTarget function.
CEGUI::OpenGLRendererBase::d_initExtraStates
bool d_initExtraStates
option of whether to initialise extra states that may not be at default
Definition: RendererBase.h:293
CEGUI::OpenGLRendererBase::d_defaultTarget
RenderTarget * d_defaultTarget
The default RenderTarget.
Definition: RendererBase.h:276
CEGUI::OpenGLGeometryBufferBase
OpenGL based implementation of the GeometryBuffer interface.
Definition: GeometryBufferBase.h:53
CEGUI::BlendMode
BlendMode
Enumerated type that contains the valid options that specify the type of blending that is to be perfo...
Definition: Renderer.h:62
CEGUI::OpenGLRendererBase::d_displaySize
Sizef d_displaySize
What the renderer considers to be the current display size.
Definition: RendererBase.h:272
CEGUI::OpenGLRendererBase::createTexture
Texture & createTexture(const String &name, const Sizef &size)
Create a Texture object with the given pixel dimensions as specified by size.
CEGUI::OpenGLRendererBase::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::OpenGLRendererBase::TextureMap
std::map< String, OpenGLTexture *, StringFastLessCompare CEGUI_MAP_ALLOC(String, OpenGLTexture *)> TextureMap
container type used to hold Textures we create.
Definition: RendererBase.h:287
CEGUI::OpenGLRendererBase::isTexCoordSystemFlipped
bool isTexCoordSystemFlipped() const
Returns if the texture coordinate system is vertically flipped or not. The original of a texture coor...
Definition: RendererBase.h:220
CEGUI::OpenGLRendererBase::createTexture
Texture & createTexture(const String &name, GLuint tex, const Sizef &sz)
Create a texture that uses an existing OpenGL texture with the specified size. Note that it is your r...
CEGUI::RenderTarget
Defines interface to some surface that can be rendered to. Concrete instances of objects that impleme...
Definition: RenderTarget.h:60
CEGUI::OpenGLRendererBase::getTexture
Texture & getTexture(const String &name) const
Return a Texture object that was previously created by calling the createTexture functions.
CEGUI::OpenGLRendererBase::isS3TCSupported
virtual bool isS3TCSupported() const =0
CEGUI::Size< float >
CEGUI::OpenGLRendererBase::getActiveRenderTarget
RenderTarget * getActiveRenderTarget()
Helper to get the active render target.
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::OpenGLRendererBase::GeometryBufferList
std::vector< OpenGLGeometryBufferBase * > GeometryBufferList
container type used to hold GeometryBuffers created.
Definition: RendererBase.h:282
CEGUI::OpenGLRendererBase::grabTextures
void grabTextures()
Grabs all the loaded textures from Texture RAM and stores them in a local data buffer....
CEGUI::Rect< float >
CEGUI::OpenGLRendererBase::getDisplayDPI
const Vector2f & getDisplayDPI() const
Return the resolution of the display or host window in dots per inch.
CEGUI::Renderer
Abstract class defining the basic required interface for Renderer objects.
Definition: Renderer.h:84
CEGUI::OpenGLRendererBase::initialiseMaxTextureSize
void initialiseMaxTextureSize()
helper to set (rough) max texture size.
CEGUI::OpenGLRendererBase
Common base class used for other OpenGL (desktop or ES) based renderer modules.
Definition: RendererBase.h:54
CEGUI::OpenGLRendererBase::createGeometryBuffer
GeometryBuffer & createGeometryBuffer()
Create a new GeometryBuffer and return a reference to it. You should remove the GeometryBuffer from a...
CEGUI::OpenGLRendererBase::getMaxTextureSize
uint getMaxTextureSize() const
Return the pixel size of the maximum supported texture.
CEGUI::OpenGLRendererBase::destroyAllGeometryBuffers
void destroyAllGeometryBuffers()
Destroy all GeometryBuffer objects created by this Renderer.
CEGUI::OpenGLRendererBase::d_textures
TextureMap d_textures
Container used to track textures.
Definition: RendererBase.h:289
CEGUI::OpenGLRendererBase::d_activeRenderTarget
RenderTarget * d_activeRenderTarget
The active RenderTarget.
Definition: RendererBase.h:299
CEGUI::OpenGLRendererBase::d_viewProjectionMatrix
mat4Pimpl * d_viewProjectionMatrix
View projection matrix.
Definition: RendererBase.h:297
CEGUI::OGLTextureTargetFactory
Definition: RendererBase.h:311