Raito 0.1
Loading...
Searching...
No Matches
Renderer.h
Go to the documentation of this file.
1/*
2MIT License
3
4Copyright (c) 2023 Víctor Falcón Zaro
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in all
14copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22SOFTWARE.
23*/
24
25#pragma once
26
27#include "Camera.h"
28#include "GraphicsAPI.h"
29#include "Shader.h"
30#include "Assets/PbrMaterial.h"
31
32namespace Raito
33{
34 namespace Assets
35 {
36 struct Mesh;
37 struct Texture;
38 }
39
40 struct SysWindow;
41
42 namespace Renderer
43 {
44 class Surface
45 {
46 public:
47 constexpr explicit Surface(u32 id) : m_Id(id) {}
48 Surface() = default;
49
50 NODISCARD constexpr u32 Id() const { return m_Id; }
51
52 void Resize(u32 width, u32 height) const;
53 NODISCARD u32 Width() const;
54 NODISCARD u32 Height() const;
55 NODISCARD u32 ColorAttachment(u32 id = 0) const;
56 NODISCARD u32 DeferredAttachment(u32 id = 0) const;
61 void Render() const;
62 private:
63 u32 m_Id;
64 };
65
71
73 {
74 None = 0,
75
76 // Color
77 RGBA8,
78 RGBA16F,
79 RGBA,
81
82 // Depth/stencil
85
86 // Defaults
89 };
90
100
102 {
104 FrameBufferAttachmentData(std::initializer_list<FrameBufferTextureData> attachments)
105 : Attachments(attachments) {}
106
107 std::vector<FrameBufferTextureData> Attachments;
108 };
109
117
118 enum class LightTechnique
119 {
120 Forward = 0,
121 Deferred,
123 };
124
128 bool SetPlatformInterface(API api);
129
132 bool Initialize();
133
136 void Shutdown();
137
141
145 NODISCARD Surface CreateSurface(SysWindow* window);
146
149 void RemoveSurface(u32 id);
150
154 NODISCARD ShaderFileData GetFileData(EngineShader id);
155
158 NODISCARD const std::vector<Shader*>& GetAllShaders();
159
163 NODISCARD u32 CompileShader(const ShaderFileData& data);
164
168 u32 AddMesh(Assets::Mesh* mesh);
169
172 void RemoveMesh(u32 id);
173
178 u32 AddTexture(Assets::Texture* texture, ubyte* data);
179
182 void RemoveTexture(u32 id);
183
187 u32 AddMaterial(const Assets::PbrMaterial& material);
188
195 void SetMaterialValue(u32 id, const Assets::PbrMaterial material);
196
199 void RemoveMaterial(u32 id);
200
206
207
209
210 void SetRenderType(LightTechnique technique);
211
212 NODISCARD Camera& GetMainCamera();
213
214 void SetSSAO(bool value);
215 void SetBloom(bool value);
216 void SetParallaxMapping(bool value);
217 void SetShadows(bool value);
218 void EnableCulling(bool value);
219 void EnableDebugAABB(bool value);
220 }
221}
unsigned char ubyte
Unsigned byte type.
Definition BasicTypes.h:31
unsigned __int32 u32
Unsigned integer 32 bit type.
Definition BasicTypes.h:55
#define NODISCARD
Definition Common.h:80
GLuint Texture
Definition OpenGLPostProcessPass.cpp:29
Definition Renderer.h:45
NODISCARD u32 DeferredLightAttachment(u32 id=0) const
Definition Renderer.cpp:74
void Render() const
Definition Renderer.cpp:93
constexpr Surface(u32 id)
Definition Renderer.h:47
NODISCARD constexpr u32 Id() const
Definition Renderer.h:50
NODISCARD u32 SSAOAttachment() const
Definition Renderer.cpp:88
NODISCARD u32 ColorAttachment(u32 id=0) const
Definition Renderer.cpp:64
void Resize(u32 width, u32 height) const
Definition Renderer.cpp:49
NODISCARD u32 DeferredAttachment(u32 id=0) const
Definition Renderer.cpp:69
NODISCARD u32 DeferredDepth() const
Definition Renderer.cpp:78
NODISCARD u32 DepthAttachment() const
Definition Renderer.cpp:83
NODISCARD u32 Height() const
Definition Renderer.cpp:59
NODISCARD u32 Width() const
Definition Renderer.cpp:54
u32 AddMaterial(const Assets::PbrMaterial &material)
Definition Renderer.cpp:171
void RemoveSurface(u32 id)
Definition Renderer.cpp:131
bool SetPlatformInterface(API api)
Definition Renderer.cpp:99
void SetMaterialValue(u32 id, const Assets::PbrMaterial material)
Definition Renderer.cpp:176
void EnableCulling(bool value)
Definition Renderer.cpp:226
void RemoveMesh(u32 id)
Definition Renderer.cpp:156
void SetParallaxMapping(bool value)
Definition Renderer.cpp:216
ShaderFileData GetFileData(EngineShader id)
Definition Renderer.cpp:136
API
Renderer Api enumerator.
Definition GraphicsAPI.h:31
const char * GetEngineShadersPath(API API)
Definition Renderer.cpp:186
Camera & GetMainCamera()
Definition Renderer.cpp:201
void RemoveTexture(u32 id)
Definition Renderer.cpp:166
bool Initialize()
Definition Renderer.cpp:111
EngineShader
Definition Shader.h:32
void RemoveMaterial(u32 id)
Definition Renderer.cpp:181
u32 AddTexture(Assets::Texture *texture, ubyte *data)
Definition Renderer.cpp:161
void EnableDebugAABB(bool value)
Definition Renderer.cpp:231
const std::vector< Shader * > & GetAllShaders()
Definition Renderer.cpp:141
FrameBufferTextureFormat
Definition Renderer.h:73
u32 CompileShader(const ShaderFileData &data)
Definition Renderer.cpp:146
Surface CreateSurface(SysWindow *window)
Definition Renderer.cpp:126
u32 AddMesh(Assets::Mesh *mesh)
Definition Renderer.cpp:151
LightTechnique
Definition Renderer.h:119
void SetSSAO(bool value)
Definition Renderer.cpp:206
API GetCurrentAPI()
Definition Renderer.cpp:121
void SetBloom(bool value)
Definition Renderer.cpp:211
void SetRenderType(LightTechnique technique)
Definition Renderer.cpp:196
void SetShadows(bool value)
Definition Renderer.cpp:221
void Shutdown()
Definition Renderer.cpp:116
LightTechnique GetCurrentRenderType()
Definition Renderer.cpp:191
Definition AssetImport.cpp:47
Definition Mesh.h:48
Definition PbrMaterial.h:8
Definition Texture.h:45
std::vector< FrameBufferTextureData > Attachments
Definition Renderer.h:107
FrameBufferAttachmentData(std::initializer_list< FrameBufferTextureData > attachments)
Definition Renderer.h:104
Definition Renderer.h:111
u32 Width
Definition Renderer.h:113
FrameBufferAttachmentData Attachments
Definition Renderer.h:112
bool SwapChainTarget
Definition Renderer.h:115
u32 Height
Definition Renderer.h:113
u32 Samples
Definition Renderer.h:114
~FrameBufferTextureData()
Definition Renderer.h:96
FrameBufferTextureData(FrameBufferTextureFormat format)
Definition Renderer.h:94
FrameBufferTextureFormat TextureFormat
Definition Renderer.h:98
Definition Renderer.h:67
SysWindow * Window
Definition Renderer.h:68
Surface Surface
Definition Renderer.h:69
System window structure.
Definition Window.h:50