sculpto
Main Page
Namespaces
Classes
Files
File List
File Members
platform
opengl
gl.h
Go to the documentation of this file.
1
/*!****************************************************************/
/*!*
2
* \file opengl.h
3
* \brief OpenGL context class definition module.
4
*
5
* \author Sabitov Kirill
6
* \date 26 June 2022
7
*********************************************************************/
8
9
#pragma once
10
11
#define GLEW_STATIC
12
#include <glew.h>
13
14
#include "
core/render/render_context.h
"
15
16
namespace
scl
17
{
19
class
shader_program;
20
22
class
gl
:
public
render_context
23
{
24
25
private
:
26
vec4
ClearColor { 0 };
27
bool
IsWireframe {};
28
bool
IsVSync {};
29
render_cull_face_mode
CullingMode {
render_cull_face_mode::BACK
};
30
31
static
shared<shader_program>
single_color_material_shader;
32
static
shared<shader_program>
phong_geometry_shader;
33
static
shared<shader_program>
phong_lighting_shader;
34
static
shared<shader_program>
shadow_pass_shader;
35
static
shared<shader_program>
tone_mapping_pass_shader;
36
static
shared<shader_program>
gaussian_blur_pass_shader;
37
static
shared<shader_program>
texture_add_pass_shader;
38
39
#ifdef SCL_PLATFORM_WINDOWS
40
HGLRC hGLRC;
41
HDC hDC;
42
const
HWND *hWnd;
43
#else
44
# error Other platforms currently dont support OpenGL
45
#endif
46
47
public
:
49
const
vec4
&
GetClearColor
()
const override
;
51
bool
GetWireframeMode
()
const override
;
53
render_cull_face_mode
GetCullingMode
()
const override
;
55
bool
GetVSync
()
const override
;
56
58
void
SetClearColor
(
const
vec4
&ClearColor)
override
;
60
void
SetWireframeMode
(
bool
IsWireframe)
override
;
62
void
SetCullingMode
(
render_cull_face_mode
CullingMode)
override
;
64
void
SetVSync
(
bool
VSync);
65
66
/*!*
67
* Get OpenGL primitive type by mesh type function.
68
*
69
* \param MeshType - mesh type to get OpenGL primitive type according to.
70
* \return OpenGL primitive type.
71
*/
72
static
GLenum
GetGLPrimitiveType
(
mesh_type
MeshType);
73
74
/*!*
75
* Get OpenGL shader variable type function.
76
*
77
* \param Type - top-level api shader variable.
78
* \return OpenGL shader variable type.
79
*/
80
static
GLenum
GetGLShaderVariableType
(
shader_variable_type
Type);
81
82
public
:
83
/*!*
84
* Render system type constructor.
85
*
86
* \param hAppWnd - window handle.
87
* \param W, H - window size.
88
* \param VSync - vertical syncronisation enable flag.
89
* \return None.
90
*/
91
void
CreateContext
(
const
HWND &hAppWnd,
int
W
,
int
H
,
bool
VSync);
92
93
/*!*
94
* Render context initialisation function.
95
*
96
* \param None.
97
* \return None.
98
*/
99
void
Init
()
override
;
100
101
/*!*
102
* Render context deinitialisation function.
103
*
104
* \param None.
105
* \return None.
106
*/
107
void
Close
()
override
;
108
109
/*!*
110
* Swap frame buffers function.
111
*
112
* \param None.
113
* \return None.
114
*/
115
void
SwapBuffers
()
override
;
116
117
/*!*
118
* Draw vertices function.
119
*
120
* \param VertexArray - mesh, containing vertices and vertex indices to draw.
121
* \return None.
122
*/
123
void
DrawIndices
(
const
shared<vertex_array>
&VertexArray)
override
;
124
125
/*!*
126
* Draw vertices instanced function.
127
*
128
* \param VertexArray - mesh, containing vertices and vertex indices to draw.
129
* \return None.
130
*/
131
void
DrawIndicesInstanced
(
const
shared<vertex_array>
&VertexArray,
int
InstanceCount)
override
;
132
133
public
:
135
shared<shader_program>
GetSingleColorMaterialShader
()
const override
;
137
shared<shader_program>
GetPhongGeometryShader
()
const override
;
139
shared<shader_program>
GetPhongLightingShader
()
const override
;
141
shared<shader_program>
GetShadowPassShader
()
const override
;
143
shared<shader_program>
GetToneMappingPassShader
()
const override
;
145
shared<shader_program>
GetGaussianBlurPassShader
()
const override
;
147
shared<shader_program>
GetTextureAddPassShader
()
const override
;
148
};
149
}
scl::gl
Definition:
gl.h:23
scl::gl::DrawIndices
void DrawIndices(const shared< vertex_array > &VertexArray) override
Definition:
gl.cpp:234
scl::gl::GetGLShaderVariableType
static GLenum GetGLShaderVariableType(shader_variable_type Type)
Definition:
gl.cpp:150
scl::gl::GetClearColor
const vec4 & GetClearColor() const override
Definition:
gl.cpp:82
scl::gl::GetShadowPassShader
shared< shader_program > GetShadowPassShader() const override
Definition:
gl_built_in_objects.cpp:45
scl::gl::GetToneMappingPassShader
shared< shader_program > GetToneMappingPassShader() const override
Definition:
gl_built_in_objects.cpp:52
scl::gl::DrawIndicesInstanced
void DrawIndicesInstanced(const shared< vertex_array > &VertexArray, int InstanceCount) override
Definition:
gl.cpp:246
scl::gl::SetClearColor
void SetClearColor(const vec4 &ClearColor) override
Definition:
gl.cpp:102
scl::gl::GetGaussianBlurPassShader
shared< shader_program > GetGaussianBlurPassShader() const override
Definition:
gl_built_in_objects.cpp:59
scl::gl::SetCullingMode
void SetCullingMode(render_cull_face_mode CullingMode) override
Definition:
gl.cpp:114
scl::gl::Init
void Init() override
Definition:
gl.cpp:205
scl::gl::GetPhongGeometryShader
shared< shader_program > GetPhongGeometryShader() const override
Definition:
gl_built_in_objects.cpp:31
scl::gl::SetWireframeMode
void SetWireframeMode(bool IsWireframe) override
Definition:
gl.cpp:108
scl::gl::GetCullingMode
render_cull_face_mode GetCullingMode() const override
Definition:
gl.cpp:92
scl::gl::GetWireframeMode
bool GetWireframeMode() const override
Definition:
gl.cpp:87
scl::gl::GetPhongLightingShader
shared< shader_program > GetPhongLightingShader() const override
Definition:
gl_built_in_objects.cpp:38
scl::gl::GetTextureAddPassShader
shared< shader_program > GetTextureAddPassShader() const override
Definition:
gl_built_in_objects.cpp:66
scl::gl::GetSingleColorMaterialShader
shared< shader_program > GetSingleColorMaterialShader() const override
Definition:
gl_built_in_objects.cpp:24
scl::gl::GetVSync
bool GetVSync() const override
Definition:
gl.cpp:97
scl::gl::SwapBuffers
void SwapBuffers() override
Definition:
gl.cpp:226
scl::gl::GetGLPrimitiveType
static GLenum GetGLPrimitiveType(mesh_type MeshType)
Definition:
gl.cpp:135
scl::gl::CreateContext
void CreateContext(const HWND &hAppWnd, int W, int H, bool VSync)
Definition:
gl.cpp:178
scl::gl::Close
void Close() override
Definition:
gl.cpp:219
scl::gl::SetVSync
void SetVSync(bool VSync)
Definition:
gl.cpp:127
scl::math::vec4< float >
scl::render_context
Definition:
render_context.h:55
scl
Definition:
base.h:33
scl::shared
std::shared_ptr< T > shared
Definition:
smart_ptr.h:15
scl::shader_variable_type
shader_variable_type
Definition:
render_context.h:24
scl::mesh_type
mesh_type
Definition:
vertex_array.h:18
scl::render_cull_face_mode
render_cull_face_mode
Definition:
render_context.h:40
scl::render_cull_face_mode::BACK
@ BACK
scl::keycode::W
@ W
scl::keycode::H
@ H
render_context.h
Base, abstract, backend render api independent render context class implementation module.
Generated by
1.9.4