qxLib
include
qx
gl
shaders.h
Go to the documentation of this file.
1
/**
2
3
@file shaders.h
4
@author Khrapov
5
@date 17.06.2019
6
@copyright © Nick Khrapov, 2021. All right reserved.
7
8
**/
9
#pragma once
10
11
#include <
qx/containers/string/string_converters.h
>
12
#include <
qx/macros/copyable_movable.h
>
13
14
#include <glew.h>
15
16
namespace
qx
17
{
18
19
enum class
shader_type
20
{
21
vert
,
//!< vertex
22
tesc
,
//!< tessellation control
23
tese
,
//!< tessellation evaluation
24
geom
,
//!< geometry
25
frag
,
//!< fragment
26
comp
//!< compute
27
};
28
29
/**
30
31
@class shader_base
32
@brief OpenGL base shader
33
@details ~
34
@tparam ShaderType - GL_VERTEX_SHADER, GL_TESS_CONTROL_SHADER,
35
GL_TESS_EVALUATION_SHADER, GL_GEOMETRY_SHADER,
36
GL_FRAGMENT_SHADER, GL_COMPUTE_SHADER
37
@author Khrapov
38
@date 17.06.2019
39
40
**/
41
template
<GLenum ShaderType>
42
class
shader_base
43
{
44
public
:
45
QX_NONCOPYABLE(
shader_base
);
46
QX_MOVABLE(
shader_base
);
47
48
shader_base
() =
default
;
49
~
shader_base
();
50
51
/**
52
@brief Init (compile) shader
53
@param pszShaderCode - string with shader code
54
@retval - error or empty string if init was successful
55
**/
56
string
Init
(
const
GLchar* pszShaderCode);
57
58
/**
59
@brief Get shader name
60
@retval - shader name
61
**/
62
GLuint
GetID
()
const
;
63
64
/**
65
@brief Get shader parameter
66
@param eParameter - shader parameter
67
\see https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glGetProgram.xhtml
68
@retval - shader parameter value
69
**/
70
GLint
GetParameter
(GLenum eParameter)
const
;
71
72
private
:
73
GLuint m_nShader = std::numeric_limits<GLuint>::max();
74
};
75
76
using
shader_vert
=
shader_base<GL_VERTEX_SHADER>
;
77
using
shader_tesc
=
shader_base<GL_TESS_CONTROL_SHADER>
;
78
using
shader_tese
=
shader_base<GL_TESS_EVALUATION_SHADER>
;
79
using
shader_geom
=
shader_base<GL_GEOMETRY_SHADER>
;
80
using
shader_frag
=
shader_base<GL_FRAGMENT_SHADER>
;
81
using
shader_comp
=
shader_base<GL_COMPUTE_SHADER>
;
82
83
}
// namespace qx
84
85
#include <
qx/gl/shaders.inl
>
qx::shader_base
OpenGL base shader.
Definition:
shaders.h:43
qx::shader_base::GetID
GLuint GetID() const
Get shader name.
Definition:
shaders.inl:54
qx::shader_base::GetParameter
GLint GetParameter(GLenum eParameter) const
Get shader parameter.
Definition:
shaders.inl:60
qx::shader_base::Init
string Init(const GLchar *pszShaderCode)
Init (compile) shader.
Definition:
shaders.inl:20
copyable_movable.h
qx::shader_type
shader_type
Definition:
shaders.h:20
qx::shader_type::comp
@ comp
compute
qx::shader_type::frag
@ frag
fragment
qx::shader_type::vert
@ vert
vertex
qx::shader_type::tese
@ tese
tessellation evaluation
qx::shader_type::geom
@ geom
geometry
qx::shader_type::tesc
@ tesc
tessellation control
shaders.inl
string_converters.h
Generated by
1.9.1