sculpto
render_context.h
Go to the documentation of this file.
1/*!****************************************************************//*!*
2 * \file render_context.h
3 * \brief Base, abstract, backend render api independent render
4 * context class definition module.
5 *
6 * \author Sabitov Kirill
7 * \date 26 June 2022
8 *********************************************************************/
9
10#pragma once
11
12#include "base.h"
13
14namespace scl
15{
17 class vertex_array;
18 class shader_program;
19 class mesh;
20 enum class mesh_type;
21
24 {
25 BOOL,
26 INT,
27 INT2,
28 INT3,
29 INT4,
30 FLOAT,
31 FLOAT2,
32 FLOAT3,
33 FLOAT4,
34 MATR3,
35 MATR4,
36 };
37
40 {
41 OFF,
42 BACK,
43 FRONT
44 };
45
48 {
49 OpenGL,
51 };
52
55 {
56 private:
57 static render_context_api Api;
59 public:
61 static render_context_api GetApi() { return Api; }
62
64 virtual const vec4 &GetClearColor() const = 0;
66 virtual bool GetWireframeMode() const = 0;
70 virtual bool GetVSync() const = 0;
71
73 virtual void SetClearColor(const vec4 &ClearColor) = 0;
75 virtual void SetWireframeMode(bool IsWireframe) = 0;
77 virtual void SetCullingMode(render_cull_face_mode CullingMode) = 0;
79 virtual void SetVSync(bool VSync) = 0;
80
81 public:
82 /*!*
83 * Get size of specified shader variable type fucntion.
84 *
85 * \param Type - shader variable type to get size of.
86 * \return size of specified type.
87 */
89
90 /*!*
91 * Get components count of specified shader variable type fucntion.
92 *
93 * \param Type - shader variable type to get components count of.
94 * \return components count of specified type.
95 */
97
98 public:
101
103 virtual ~render_context() {};
104
105 /*!*
106 * Render context initialisation function.
107 *
108 * \param None.
109 * \return None.
110 */
111 virtual void Init() = 0;
112
113 /*!*
114 * Render context deinitialisation function.
115 *
116 * \param None.
117 * \return None.
118 */
119 virtual void Close() = 0;
120
121 /*!*
122 * Swap frame buffers function.
123 *
124 * \param None.
125 * \return None.
126 */
127 virtual void SwapBuffers() = 0;
128
129 /*!*
130 * Draw vertices function.
131 *
132 * \param Mesh - mesh, containing vertices and vertex indices to draw.
133 * \return None.
134 */
135 virtual void DrawIndices(const shared<vertex_array> &Mesh) = 0;
136
137 /*!*
138 * Draw vertices instanced function.
139 *
140 * \param Mesh - mesh, containing vertices and vertex indices to draw.
141 * \return None.
142 */
143 virtual void DrawIndicesInstanced(const shared<vertex_array> &Mesh, int InstanceCount) = 0;
144
145 /*!*
146 * Rendering context creation function.
147 *
148 * \param None.
149 * \return pointer to created rendering context.
150 */
152
153 public:
168
169 public:
170 static const int BINDING_POINT_SCENE_DATA = 0;
171 static const int BINDING_POINT_MATERIAL_DATA = 5;
172 static const int BINDING_POINT_LIGHTS_STORAGE = 10;
174 static const int BINDING_POINT_FREE = 20;
175
176 static const int TEXTURE_SLOT_MATERIAL_DIFFUSE = 0;
177 static const int TEXTURE_SLOT_MATERIAL_SPECULAR = 1;
180 static const int TEXTURE_SLOT_SHADOW_MAP = 5;
181 static const int TEXTURE_SLOT_HDR_BUFFER = 6;
182 static const int TEXTURE_SLOT_BLUR_BUFFER = 7;
183 static const int TEXTURE_SLOT_APPLY_SOURCE = 9;
184 static const int TEXTURE_SLOT_APPLY_TEXTURE_ADD = 10;
187 static const int TEXTURE_SLOT_GEOM_PASS_OUT_COLOR = 13;
193
194 static const int LIGHTS_MAX_POINT = 50;
195 static const int LIGHTS_MAX_SPOT = 50;
196
205
206 static const int MESH_RESTART_INDEX = -1;
207 };
208}
Topology object basis class for mesh creating implementation module.
static const int COLOR_ATTACHMENT_LIGHTING_PASS_OUT_BRIGHT_COLOR
virtual bool GetVSync() const =0
static const int TEXTURE_SLOT_GEOM_PASS_OUT_NORMAL
static const int TEXTURE_SLOT_MATERIAL_EMISSION_MAP
static const int TEXTURE_SLOT_APPLY_TEXTURE_ADD
static const int TEXTURE_SLOT_SHADOW_MAP
static const int TEXTURE_SLOT_GEOM_PASS_OUT_PHONG_SPECULAR
virtual bool GetWireframeMode() const =0
virtual void SetClearColor(const vec4 &ClearColor)=0
static const int TEXTURE_SLOT_GEOM_PASS_OUT_PHONG_SHININESS
static const int TEXTURE_SLOT_HDR_BUFFER
static const int COLOR_ATTACHMENT_GEOM_PASS_OUT_PHONG_SPECULAR
virtual void SetCullingMode(render_cull_face_mode CullingMode)=0
virtual const vec4 & GetClearColor() const =0
static const int TEXTURE_SLOT_BLUR_BUFFER
static const int TEXTURE_SLOT_APPLY_SOURCE
static const int TEXTURE_SLOT_GEOM_PASS_OUT_PHONG_DIFFUSE
virtual void SetVSync(bool VSync)=0
static unique< render_context > Create()
virtual void Init()=0
static const int BINDING_POINT_LIGHTS_STORAGE
static const int TEXTURE_SLOT_MATERIAL_NORMAL_MAP
static const int TEXTURE_SLOT_GEOM_PASS_OUT_POSITION
virtual shared< shader_program > GetToneMappingPassShader() const =0
virtual void DrawIndices(const shared< vertex_array > &Mesh)=0
virtual void SwapBuffers()=0
static u32 GetShaderVariableComponentsCount(shader_variable_type Type)
static const int LIGHTS_MAX_POINT
static render_context_api GetApi()
static const int BINDING_POINT_SCENE_DATA
static const int COLOR_ATTACHMENT_GEOM_PASS_OUT_PHONG_DIFFUSE
static const int COLOR_ATTACHMENT_GEOM_PASS_OUT_PHONG_SHININESS
static const int TEXTURE_SLOT_GEOM_PASS_OUT_COLOR
static const int BINDING_POINT_FREE
static const int COLOR_ATTACHMENT_GEOM_PASS_OUT_POSITION
virtual void DrawIndicesInstanced(const shared< vertex_array > &Mesh, int InstanceCount)=0
static const int COLOR_ATTACHMENT_GEOM_PASS_OUT_NORMAL
virtual shared< shader_program > GetSingleColorMaterialShader() const =0
virtual void SetWireframeMode(bool IsWireframe)=0
static const int BINDING_POINT_MATERIAL_DATA
static const int COLOR_ATTACHMENT_GEOM_PASS_OUT_COLOR
virtual shared< shader_program > GetShadowPassShader() const =0
virtual shared< shader_program > GetPhongLightingShader() const =0
virtual shared< shader_program > GetTextureAddPassShader() const =0
static const int TEXTURE_SLOT_MATERIAL_DIFFUSE
static const int TEXTURE_SLOT_MATERIAL_SPECULAR
static const int TEXTURE_SLOT_LIGHTING_PASS_OUT_COLOR
static const int LIGHTS_MAX_SPOT
static u32 GetShaderVariableTypeSize(shader_variable_type Type)
virtual shared< shader_program > GetPhongGeometryShader() const =0
virtual render_cull_face_mode GetCullingMode() const =0
virtual void Close()=0
virtual shared< shader_program > GetGaussianBlurPassShader() const =0
static const int TEXTURE_SLOT_LIGHTING_PASS_OUT_BRIGHT_COLOR
static const int BINDING_POINT_SHADOW_CASTERS_STORAGE
static const int COLOR_ATTACHMENT_LIGHTING_PASS_OUT_COLOR
static const int MESH_RESTART_INDEX
Definition: base.h:33
std::shared_ptr< T > shared
Definition: smart_ptr.h:15
shader_variable_type
mesh_type
Definition: vertex_array.h:18
render_context_api
uint32_t u32
Definition: math_common.h:21
std::unique_ptr< T > unique
Definition: smart_ptr.h:25
render_cull_face_mode
uint8_t u8
Definition: math_common.h:17