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
57  RenderTarget& getDefaultRenderTarget();
58  GeometryBuffer& createGeometryBuffer();
59  void destroyGeometryBuffer(const GeometryBuffer& buffer);
60  void destroyAllGeometryBuffers();
61  TextureTarget* createTextureTarget();
62  void destroyTextureTarget(TextureTarget* target);
63  void destroyAllTextureTargets();
64  Texture& createTexture(const String& name);
65  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);
71  void destroyAllTextures();
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 
131  void restoreTextures();
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 
167  virtual const mat4Pimpl* getViewProjectionMatrix();
168 
176  virtual void setViewProjectionMatrix(const mat4Pimpl* viewProjectionMatrix);
177 
185  const CEGUI::Rectf& getActiveViewPort();
186 
194  void setActiveRenderTarget(RenderTarget* renderTarget);
195 
203  RenderTarget* getActiveRenderTarget();
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 
250  virtual ~OpenGLRendererBase();
251 
253  static void logTextureCreation(const String& name);
255  static void logTextureDestruction(const String& name);
256 
258  void initialiseMaxTextureSize();
259 
261  void initialiseDisplaySizeWithViewportSize();
262 
264  virtual OpenGLGeometryBufferBase* createGeometryBuffer_impl() = 0;
265 
267  virtual TextureTarget* createTextureTarget_impl() = 0;
268 
270  static String d_rendererID;
272  Sizef d_displaySize;
274  Vector2f d_displayDPI;
276  RenderTarget* d_defaultTarget;
278  typedef std::vector<TextureTarget*> TextureTargetList;
280  TextureTargetList d_textureTargets;
282  typedef std::vector<OpenGLGeometryBufferBase*> GeometryBufferList;
284  GeometryBufferList d_geometryBuffers;
286  typedef std::map<String, OpenGLTexture*, StringFastLessCompare
287  CEGUI_MAP_ALLOC(String, OpenGLTexture*)> TextureMap;
289  TextureMap d_textures;
291  uint d_maxTextureSize;
293  bool d_initExtraStates;
295  BlendMode d_activeBlendMode;
297  mat4Pimpl* d_viewProjectionMatrix;
299  RenderTarget* d_activeRenderTarget;
300 };
301 
310  public AllocatedObject<OGLTextureTargetFactory>
311 {
312 public:
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::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:5600
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:64
CEGUI::AllocatedObject
Definition: MemoryAllocatedObject.h:131
CEGUI::Vector2< float >
CEGUI::mat4Pimpl
Definition: GlmPimpl.h:56
CEGUI::Texture
Abstract base class specifying the required interface for Texture objects.
Definition: Texture.h:75
CEGUI::OpenGLGeometryBufferBase
OpenGL based implementation of the GeometryBuffer interface.
Definition: GeometryBufferBase.h:73
CEGUI::BlendMode
BlendMode
Enumerated type that contains the valid options that specify the type of blending that is to be perfo...
Definition: Renderer.h:83
CEGUI::RenderTarget
Defines interface to some surface that can be rendered to. Concrete instances of objects that impleme...
Definition: RenderTarget.h:77
CEGUI::Size< float >
CEGUI::TextureTarget
Specialisation of RenderTarget interface that should be used as the base class for RenderTargets that...
Definition: TextureTarget.h:60
CEGUI::String
String class used within the GUI system.
Definition: String.h:83
CEGUI::Rect< float >
CEGUI::OpenGLRendererBase
Common base class used for other OpenGL (desktop or ES) based renderer modules.
Definition: RendererBase.h:74
CEGUI::OGLTextureTargetFactory
Definition: RendererBase.h:330