FIFE  be64c707dea6b3250bd4355bf5c825d25920087d
librocketrenderinterface.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2019 by the FIFE team *
3  * http://www.fifengine.net *
4  * This file is part of FIFE. *
5  * *
6  * FIFE is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20  ***************************************************************************/
21 
22 #ifndef FIFE_GUI_LIBROCKETRENDERINTERFACE_H
23 #define FIFE_GUI_LIBROCKETRENDERINTERFACE_H
24 
25 // Standard C++ library includes
26 #include <list>
27 #include <queue>
28 #include <vector>
29 
30 // 3rd party library includes
31 #include <Rocket/Core/RenderInterface.h>
32 
33 // FIFE includes
34 // These includes are split up in two parts, separated by one empty line
35 // First block: files included from the FIFE root src directory
36 // Second block: files included from the same folder
37 #include "util/base/singleton.h"
38 #include "util/resource/resource.h"
39 #include "util/structures/rect.h"
40 #include "util/structures/point.h"
41 #include "video/color.h"
42 #include "video/renderbackend.h"
43 
44 namespace FIFE {
45 
46  class ImageManager;
47  class RenderBackend;
48 
49  class LibRocketRenderInterface : public Rocket::Core::RenderInterface {
50  public:
51 
55 
58  virtual ~LibRocketRenderInterface();
59 
62  virtual void RenderGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rocket::Core::TextureHandle texture, const Rocket::Core::Vector2f& translation);
63 
66  virtual Rocket::Core::CompiledGeometryHandle CompileGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rocket::Core::TextureHandle texture);
67 
70  virtual void RenderCompiledGeometry(Rocket::Core::CompiledGeometryHandle geometry, const Rocket::Core::Vector2f& translation);
71 
74  virtual void ReleaseCompiledGeometry(Rocket::Core::CompiledGeometryHandle geometry);
75 
78  virtual void EnableScissorRegion(bool enable);
79 
82  virtual void SetScissorRegion(int x, int y, int width, int height);
83 
86  virtual bool LoadTexture(Rocket::Core::TextureHandle& texture_handle, Rocket::Core::Vector2i& texture_dimensions, const Rocket::Core::String& source);
87 
90  virtual bool GenerateTexture(Rocket::Core::TextureHandle& texture_handle, const Rocket::Core::byte* source, const Rocket::Core::Vector2i& source_dimensions);
91 
94  virtual void ReleaseTexture(Rocket::Core::TextureHandle texture_handle);
95 
99  void render();
100 
104  void freeTextures();
105 
106  private:
107 
109 
111 
113  public:
114  std::vector<GuiVertex> vertices;
115  std::vector<int> indices;
118  };
119 
120  typedef std::queue<GeometryCallData> GeometryCallDataChain;
121 
122  class GeometryCall {
123  public:
124 
126  :
127  enableScissorTest(false),
128  hasScissorArea(false)
129  {
130  }
131 
132  GeometryCallDataChain callChain;
136  };
137 
138  std::queue<GeometryCall> m_geometryCalls;
139 
140  std::list<ResourceHandle> m_freedTextures;
141  };
142 
143 };
144 
145 #endif // FIFE_GUI_LIBROCKETRENDERINTERFACE_H
std::queue< GeometryCallData > GeometryCallDataChain
virtual bool GenerateTexture(Rocket::Core::TextureHandle &texture_handle, const Rocket::Core::byte *source, const Rocket::Core::Vector2i &source_dimensions)
Called by Rocket when a texture is required to be built from an internally-generated sequence of pixe...
Abstract interface for all the renderbackends.
virtual void ReleaseCompiledGeometry(Rocket::Core::CompiledGeometryHandle geometry)
Called by Rocket when it wants to release application-compiled geometry.
ImageManager.
Definition: imagemanager.h:54
virtual void RenderCompiledGeometry(Rocket::Core::CompiledGeometryHandle geometry, const Rocket::Core::Vector2f &translation)
Called by Rocket when it wants to render application-compiled geometry.
virtual void ReleaseTexture(Rocket::Core::TextureHandle texture_handle)
Called by Rocket when a loaded texture is no longer required.
virtual void SetScissorRegion(int x, int y, int width, int height)
Called by Rocket when it wants to change the scissor region.
std::size_t ResourceHandle
Definition: resource.h:38
std::list< ResourceHandle > m_freedTextures
void freeTextures()
Frees all textures that are no longer needed by librocket.
virtual Rocket::Core::CompiledGeometryHandle CompileGeometry(Rocket::Core::Vertex *vertices, int num_vertices, int *indices, int num_indices, Rocket::Core::TextureHandle texture)
Called by Rocket when it wants to compile geometry it believes will be static for the forseeable futu...
virtual void EnableScissorRegion(bool enable)
Called by Rocket when it wants to enable or disable scissoring to clip content.
virtual ~LibRocketRenderInterface()
Destructor.
std::queue< GeometryCall > m_geometryCalls
virtual bool LoadTexture(Rocket::Core::TextureHandle &texture_handle, Rocket::Core::Vector2i &texture_dimensions, const Rocket::Core::String &source)
Called by Rocket when a texture is required by the library.
virtual void RenderGeometry(Rocket::Core::Vertex *vertices, int num_vertices, int *indices, int num_indices, Rocket::Core::TextureHandle texture, const Rocket::Core::Vector2f &translation)
Called by Rocket when it wants to render geometry that it does not wish to optimise.
void render()
Renders librocket gui.