Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
CEGUIRenderer.h
Go to the documentation of this file.
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#pragma once
29#ifndef DVD_CEGUIRenderer_Divide_h_
30#define DVD_CEGUIRenderer_Divide_h_
31
32#include "CEGUI/Base.h"
33#include "CEGUI/Renderer.h"
34#include "CEGUI/Size.h"
35#include "CEGUI/Vector.h"
36#include "CEGUI/Rect.h"
37#include "CEGUI/TextureTarget.h"
38
39#include "CEGUI/Config.h"
40
41#include <glm/mat4x4.hpp>
42
43#if defined(_MSC_VER)
44# pragma warning(push)
45# pragma warning(disable : 4251)
46#endif
47
48namespace Divide
49{
50 class Texture;
51 class Pipeline;
52 class GFXDevice;
53 class ShaderProgram;
54
55 namespace GFX
56 {
57 class CommandBuffer;
58 struct MemoryBarrierCommand;
59 }
60};
61
62namespace CEGUI
63{
64
65class DVDTexture;
66class DVDGeometryBuffer;
67class CEGUIRenderer;
68
69class CEGUIRenderer final : public Renderer
70{
71public:
73 {
78 COUNT
79 };
80
81private:
87 using TextureMap = std::map<String, DVDTexture*, StringFastLessCompare CEGUI_MAP_ALLOC( String, DVDTexture* )>;
90
91public:
92 static CEGUIRenderer& create( Divide::GFXDevice& context, Divide::Handle<Divide::ShaderProgram> shader, CEGUI::Sizef resolution, int abi = CEGUI_VERSION_ABI );
93 static void destroy( CEGUIRenderer& renderer );
94
95#pragma region Renderer Interface
96 void beginRendering() override;
97 void endRendering() override;
98
99 void destroyGeometryBuffer(const GeometryBuffer& buffer) override;
100 void destroyAllGeometryBuffers() override;
101 void destroyTextureTarget(TextureTarget* target) override;
102 void destroyAllTextureTargets() override;
103 void destroyTexture(Texture& texture) override;
104 void destroyTexture(const String& name) override;
105 void destroyAllTextures() override;
106 void setDisplaySize(const Sizef& sz) override;
107
108 [[nodiscard]] RenderTarget& getDefaultRenderTarget() override;
109 [[nodiscard]] GeometryBuffer& createGeometryBuffer() override;
110 [[nodiscard]] TextureTarget* createTextureTarget() override;
111 [[nodiscard]] Texture& createTexture(const String& name) override;
112 [[nodiscard]] Texture& createTexture(const String& name, const String& filename, const String& resourceGroup) override;
113 [[nodiscard]] Texture& createTexture(const String& name, const Sizef& size) override;
114 [[nodiscard]] Texture& getTexture(const String& name) const override;
115 [[nodiscard]] bool isTextureDefined(const String& name) const override;
116 [[nodiscard]] const Sizef& getDisplaySize() const override;
117 [[nodiscard]] const Vector2f& getDisplayDPI() const override;
118 [[nodiscard]] uint getMaxTextureSize() const override;
119 [[nodiscard]] const String& getIdentifierString() const override;
120#pragma endregion
121
122 Texture& createTexture(const String& name, const Divide::Handle<Divide::Texture> tex, const Sizef& sz);
123 void setViewProjectionMatrix(const glm::mat4& viewProjectionMatrix);
124 void setActiveRenderTarget(RenderTarget* renderTarget);
125
127 void bindDefaultState( bool scissor, BlendMode mode, const glm::mat4& viewProjMat );
128
129 [[nodiscard]] const Rectf& getActiveViewPort() const;
131 [[nodiscard]] Divide::GFXDevice& context();
132 [[nodiscard]] bool flipClippingHeight() const noexcept;
133 [[nodiscard]] Divide::GFX::CommandBuffer* cmdBuffer() const;
134 [[nodiscard]] Divide::GFX::MemoryBarrierCommand* memCmd() const;
135 [[nodiscard]] const glm::mat4& getViewProjectionMatrix() const noexcept;
136
137private:
138 CEGUIRenderer( Divide::GFXDevice& context, Divide::Handle<Divide::ShaderProgram> shader, CEGUI::Sizef resolution);
139 virtual ~CEGUIRenderer() override;
140
142 static void LogTextureCreation(const String& name);
144 static void LogTextureDestruction(const String& name);
145
146private:
150 Divide::GFXDevice& _context;
152 Divide::GFX::CommandBuffer* _bufferInOut{nullptr};
156 static String s_rendererID;
160 Vector2f _displayDPI{};
162 RenderTarget* _defaultTarget{nullptr};
172 RenderTarget* _activeRenderTarget{nullptr};
177};
178
179}
180
181#if defined(_MSC_VER)
182# pragma warning(pop)
183#endif
184
185#endif //DVD_CEGUIRenderer_Divide_h_
186
187#include "CEGUIRenderer.inl"
void beginRendering() override
Texture & createTexture(const String &name) override
void destroyTexture(Texture &texture) override
bool isTextureDefined(const String &name) const override
void setActiveRenderTarget(RenderTarget *renderTarget)
static void LogTextureCreation(const String &name)
Helper to safely log the creation of a named texture.
Divide::Handle< Divide::Texture > getTextureTarget() const
void setViewProjectionMatrix(const glm::mat4 &viewProjectionMatrix)
void destroyAllTextures() override
static String s_rendererID
String holding the renderer identification text.
void destroyGeometryBuffer(const GeometryBuffer &buffer) override
Divide::GFXDevice & _context
Parent app's graphics context.
GeometryBuffer & createGeometryBuffer() override
Divide::GFX::CommandBuffer * cmdBuffer() const
const Vector2f & getDisplayDPI() const override
TextureMap _textures
Container used to track textures.
RenderTarget * _activeRenderTarget
The active RenderTarget.
Divide::GFXDevice & context()
std::map< String, DVDTexture *, StringFastLessCompare CEGUI_MAP_ALLOC(String, DVDTexture *)> TextureMap
container type used to hold Textures we create.
Definition: CEGUIRenderer.h:87
void destroyTextureTarget(TextureTarget *target) override
void setDisplaySize(const Sizef &sz) override
Texture & getTexture(const String &name) const override
Divide::vector< DVDGeometryBuffer * > GeometryBufferList
container type used to hold GeometryBuffers created.
Definition: CEGUIRenderer.h:85
std::array< Divide::Pipeline *, Divide::to_base(PipelineType::COUNT)> PipelineContainer
container type used to hold our various compiled pipelines needed for rendering
Definition: CEGUIRenderer.h:89
const String & getIdentifierString() const override
RenderTarget & getDefaultRenderTarget() override
RenderTarget * _defaultTarget
The default RenderTarget.
PipelineType _activePipelineType
Active pipeline type bound for rendering. Used to index into the "_pipelines" container.
bool flipClippingHeight() const noexcept
uint getMaxTextureSize() const override
Vector2f _displayDPI
What the renderer considers to be the current display DPI resolution.
const bool _flipClippingHeight
Clipping direction is the only thing we need to manually adjust between rendering APIs....
TextureTarget * createTextureTarget() override
const Rectf & getActiveViewPort() const
void destroyAllTextureTargets() override
Divide::GFX::MemoryBarrierCommand * _memCmdInOut
Memory command from the parent app used to protected geometry buffer updates.
PipelineContainer _pipelines
Container used to store our compiled pipelines.
Divide::GFX::MemoryBarrierCommand * memCmd() const
const Sizef & getDisplaySize() const override
static void LogTextureDestruction(const String &name)
Helper to safely log the destruction of a named texture.
void endRendering() override
glm::mat4 _viewProjectionMatrix
View projection matrix.
Sizef _displaySize
What the renderer considers to be the current display size.
const glm::mat4 & getViewProjectionMatrix() const noexcept
static void destroy(CEGUIRenderer &renderer)
TextureTargetList _textureTargets
Container used to track texture targets.
Divide::vector< TextureTarget * > TextureTargetList
container type used to hold TextureTargets we create.
Definition: CEGUIRenderer.h:83
static CEGUIRenderer & create(Divide::GFXDevice &context, Divide::Handle< Divide::ShaderProgram > shader, CEGUI::Sizef resolution, int abi=CEGUI_VERSION_ABI)
Divide::GFX::CommandBuffer * _bufferInOut
Command buffer from the parent app used to queue up rendering commands.
GeometryBufferList _geometryBuffers
Container used to track geometry buffers.
void bindDefaultState(bool scissor, BlendMode mode, const glm::mat4 &viewProjMat)
void destroyAllGeometryBuffers() override
Rough around the edges Adapter pattern abstracting the actual rendering API and access to the GPU.
Definition: GFXDevice.h:215
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
uint8_t U8
eastl::vector< Type > vector
Definition: Vector.h:42
constexpr auto to_base(const Type value) -> Type