Debian Codegraph @

engine/core/gui/librocket/base/librocketrenderinterface.h

raw
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
52 /** Constructor.
53 */
54 LibRocketRenderInterface();
55
56 /** Destructor.
57 */
58 virtual ~LibRocketRenderInterface();
59
60 /** Called by Rocket when it wants to render geometry that it does not wish to optimise.
61 */
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
64 /** Called by Rocket when it wants to compile geometry it believes will be static for the forseeable future.
65 */
66 virtual Rocket::Core::CompiledGeometryHandle CompileGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rocket::Core::TextureHandle texture);
67
68 /** Called by Rocket when it wants to render application-compiled geometry.
69 */
70 virtual void RenderCompiledGeometry(Rocket::Core::CompiledGeometryHandle geometry, const Rocket::Core::Vector2f& translation);
71
72 /** Called by Rocket when it wants to release application-compiled geometry.
73 */
74 virtual void ReleaseCompiledGeometry(Rocket::Core::CompiledGeometryHandle geometry);
75
76 /** Called by Rocket when it wants to enable or disable scissoring to clip content.
77 */
78 virtual void EnableScissorRegion(bool enable);
79
80 /** Called by Rocket when it wants to change the scissor region.
81 */
82 virtual void SetScissorRegion(int x, int y, int width, int height);
83
84 /** Called by Rocket when a texture is required by the library.
85 */
86 virtual bool LoadTexture(Rocket::Core::TextureHandle& texture_handle, Rocket::Core::Vector2i& texture_dimensions, const Rocket::Core::String& source);
87
88 /** Called by Rocket when a texture is required to be built from an internally-generated sequence of pixels.
89 */
90 virtual bool GenerateTexture(Rocket::Core::TextureHandle& texture_handle, const Rocket::Core::byte* source, const Rocket::Core::Vector2i& source_dimensions);
91
92 /** Called by Rocket when a loaded texture is no longer required.
93 */
94 virtual void ReleaseTexture(Rocket::Core::TextureHandle texture_handle);
95
96 /**
97 * Renders librocket gui.
98 */
99 void render();
100
101 /**
102 * Frees all textures that are no longer needed by librocket.
103 */
104 void freeTextures();
105
106 private:
107
108 RenderBackend* m_renderBackend;
109
110 ImageManager* m_imageManager;
111
112 class GeometryCallData {
113 public:
114 std::vector<GuiVertex> vertices;
115 std::vector<int> indices;
116 ResourceHandle textureHandle;
117 DoublePoint translation;
118 };
119
120 typedef std::queue<GeometryCallData> GeometryCallDataChain;
121
122 class GeometryCall {
123 public:
124
125 GeometryCall()
126 :
127 enableScissorTest(false),
128 hasScissorArea(false)
129 {
130 }
131
132 GeometryCallDataChain callChain;
133 Rect scissorArea;
134 bool enableScissorTest;
135 bool hasScissorArea;
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