Crazy Eddie's GUI System  0.8.4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
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( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC)
42 # ifdef CEGUIOPENGLRENDERER_EXPORTS
43 # define OPENGL_GUIRENDERER_API __declspec(dllexport)
44 # else
45 # define OPENGL_GUIRENDERER_API __declspec(dllimport)
46 # endif
47 #else
48 # define OPENGL_GUIRENDERER_API
49 #endif
50 
51 #if defined(_MSC_VER)
52 # pragma warning(push)
53 # pragma warning(disable : 4251)
54 #endif
55 
56 namespace CEGUI
57 {
58 class OpenGLTexture;
59 class OpenGLGeometryBufferBase;
60 struct mat4Pimpl;
61 
63 class OPENGL_GUIRENDERER_API OpenGLRendererBase : public Renderer
64 {
65 public:
66  // implement Renderer interface
67  RenderTarget& getDefaultRenderTarget();
68  GeometryBuffer& createGeometryBuffer();
69  void destroyGeometryBuffer(const GeometryBuffer& buffer);
70  void destroyAllGeometryBuffers();
71  TextureTarget* createTextureTarget();
72  void destroyTextureTarget(TextureTarget* target);
73  void destroyAllTextureTargets();
74  Texture& createTexture(const String& name);
75  Texture& createTexture(const String& name,
76  const String& filename,
77  const String& resourceGroup);
78  Texture& createTexture(const String& name, const Sizef& size);
79  void destroyTexture(Texture& texture);
80  void destroyTexture(const String& name);
81  void destroyAllTextures();
82  Texture& getTexture(const String& name) const;
83  bool isTextureDefined(const String& name) const;
84  void setDisplaySize(const Sizef& sz);
85  const Sizef& getDisplaySize() const;
86  const Vector2f& getDisplayDPI() const;
87  uint getMaxTextureSize() const;
88  const String& getIdentifierString() const;
89 
112  Texture& createTexture(const String& name, GLuint tex, const Sizef& sz);
113 
125  void enableExtraStateSettings(bool setting);
126 
134  void grabTextures();
135 
141  void restoreTextures();
142 
154  virtual Sizef getAdjustedTextureSize(const Sizef& sz) const;
155 
161  static float getNextPOTSize(const float f);
162 
164  virtual void setupRenderingBlendMode(const BlendMode mode,
165  const bool force = false) = 0;
166 
168  virtual bool isS3TCSupported() const = 0;
169 
177  virtual const mat4Pimpl* getViewProjectionMatrix();
178 
186  virtual void setViewProjectionMatrix(const mat4Pimpl* viewProjectionMatrix);
187 
195  const CEGUI::Rectf& getActiveViewPort();
196 
204  void setActiveRenderTarget(RenderTarget* renderTarget);
205 
213  RenderTarget* getActiveRenderTarget();
214 
215 protected:
217 
225  OpenGLRendererBase(const Sizef& display_size);
226 
228  virtual ~OpenGLRendererBase();
229 
231  static void logTextureCreation(const String& name);
233  static void logTextureDestruction(const String& name);
234 
236  void initialiseMaxTextureSize();
237 
239  void initialiseDisplaySizeWithViewportSize();
240 
242  virtual OpenGLGeometryBufferBase* createGeometryBuffer_impl() = 0;
243 
245  virtual TextureTarget* createTextureTarget_impl() = 0;
246 
256  typedef std::vector<TextureTarget*> TextureTargetList;
260  typedef std::vector<OpenGLGeometryBufferBase*> GeometryBufferList;
264  typedef std::map<String, OpenGLTexture*, StringFastLessCompare
265  CEGUI_MAP_ALLOC(String, OpenGLTexture*)> TextureMap;
278 };
279 
288  public AllocatedObject<OGLTextureTargetFactory>
289 {
290 public:
292  virtual ~OGLTextureTargetFactory() {}
293  virtual TextureTarget* create(OpenGLRendererBase&) const
294  { return 0; }
295 };
296 
297 }
298 
299 #if defined(_MSC_VER)
300 # pragma warning(pop)
301 #endif
302 
303 #endif
304