Crazy Eddie's GUI System  0.8.3
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
RendererBase.h
1 /***********************************************************************
2  filename: RendererBase.h
3  created: Tue Apr 30 2013
4  authors: Paul D Turner <paul@cegui.org.uk>
5  Lukas E Meindl
6 *************************************************************************/
7 /***************************************************************************
8  * Copyright (C) 2004 - 2013 Paul D Turner & The CEGUI Development Team
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining
11  * a copy of this software and associated documentation files (the
12  * "Software"), to deal in the Software without restriction, including
13  * without limitation the rights to use, copy, modify, merge, publish,
14  * distribute, sublicense, and/or sell copies of the Software, and to
15  * permit persons to whom the Software is furnished to do so, subject to
16  * the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be
19  * included in all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27  * OTHER DEALINGS IN THE SOFTWARE.
28  ***************************************************************************/
29 #ifndef _CEGUIRendererBase_h_
30 #define _CEGUIRendererBase_h_
31 
32 #include "../../Base.h"
33 #include "../../Renderer.h"
34 #include "../../Size.h"
35 #include "../../Vector.h"
36 #include "../../Rect.h"
37 #include "../../TextureTarget.h"
38 #include "CEGUI/RendererModules/OpenGL/GL.h"
39 #include <vector>
40 #include <map>
41 
42 #if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC)
43 # ifdef CEGUIOPENGLRENDERER_EXPORTS
44 # define OPENGL_GUIRENDERER_API __declspec(dllexport)
45 # else
46 # define OPENGL_GUIRENDERER_API __declspec(dllimport)
47 # endif
48 #else
49 # define OPENGL_GUIRENDERER_API
50 #endif
51 
52 #if defined(_MSC_VER)
53 # pragma warning(push)
54 # pragma warning(disable : 4251)
55 #endif
56 
57 namespace CEGUI
58 {
59 class OpenGLTexture;
60 class OpenGLGeometryBufferBase;
61 struct mat4Pimpl;
62 
64 class OPENGL_GUIRENDERER_API OpenGLRendererBase : public Renderer
65 {
66 public:
67  // implement Renderer interface
68  RenderTarget& getDefaultRenderTarget();
69  GeometryBuffer& createGeometryBuffer();
70  void destroyGeometryBuffer(const GeometryBuffer& buffer);
71  void destroyAllGeometryBuffers();
72  TextureTarget* createTextureTarget();
73  void destroyTextureTarget(TextureTarget* target);
74  void destroyAllTextureTargets();
75  Texture& createTexture(const String& name);
76  Texture& createTexture(const String& name,
77  const String& filename,
78  const String& resourceGroup);
79  Texture& createTexture(const String& name, const Sizef& size);
80  void destroyTexture(Texture& texture);
81  void destroyTexture(const String& name);
82  void destroyAllTextures();
83  Texture& getTexture(const String& name) const;
84  bool isTextureDefined(const String& name) const;
85  void setDisplaySize(const Sizef& sz);
86  const Sizef& getDisplaySize() const;
87  const Vector2f& getDisplayDPI() const;
88  uint getMaxTextureSize() const;
89  const String& getIdentifierString() const;
90 
113  Texture& createTexture(const String& name, GLuint tex, const Sizef& sz);
114 
126  void enableExtraStateSettings(bool setting);
127 
135  void grabTextures();
136 
142  void restoreTextures();
143 
155  virtual Sizef getAdjustedTextureSize(const Sizef& sz) const;
156 
162  static float getNextPOTSize(const float f);
163 
165  virtual void setupRenderingBlendMode(const BlendMode mode,
166  const bool force = false) = 0;
167 
169  virtual bool isS3TCSupported() const = 0;
170 
178  virtual const mat4Pimpl* getViewProjectionMatrix();
179 
187  virtual void setViewProjectionMatrix(const mat4Pimpl* viewProjectionMatrix);
188 
196  const CEGUI::Rectf& getActiveViewPort();
197 
205  void setActiveRenderTarget(RenderTarget* renderTarget);
206 
214  RenderTarget* getActiveRenderTarget();
215 
216 protected:
218 
226  OpenGLRendererBase(const Sizef& display_size);
227 
229  virtual ~OpenGLRendererBase();
230 
232  static void logTextureCreation(const String& name);
234  static void logTextureDestruction(const String& name);
235 
237  void initialiseMaxTextureSize();
238 
240  void initialiseDisplaySizeWithViewportSize();
241 
243  virtual OpenGLGeometryBufferBase* createGeometryBuffer_impl() = 0;
244 
246  virtual TextureTarget* createTextureTarget_impl() = 0;
247 
257  typedef std::vector<TextureTarget*> TextureTargetList;
261  typedef std::vector<OpenGLGeometryBufferBase*> GeometryBufferList;
265  typedef std::map<String, OpenGLTexture*, StringFastLessCompare
266  CEGUI_MAP_ALLOC(String, OpenGLTexture*)> TextureMap;
279 };
280 
289  public AllocatedObject<OGLTextureTargetFactory>
290 {
291 public:
293  virtual ~OGLTextureTargetFactory() {}
294  virtual TextureTarget* create(OpenGLRendererBase&) const
295  { return 0; }
296 };
297 
298 }
299 
300 #if defined(_MSC_VER)
301 # pragma warning(pop)
302 #endif
303 
304 #endif
305