SGCT master (487fac4)
Simple Graphics Cluster Toolkit
Loading...
Searching...
No Matches
shaderprogram.h
Go to the documentation of this file.
1/*****************************************************************************************
2 * SGCT *
3 * Simple Graphics Cluster Toolkit *
4 * *
5 * Copyright (c) 2012-2026 *
6 * For conditions of distribution and use, see copyright notice in LICENSE.md *
7 ****************************************************************************************/
8
9#ifndef __SGCT__SHADERPROGRAM__H__
10#define __SGCT__SHADERPROGRAM__H__
11
12#include <sgct/sgctexports.h>
13
14#include <string>
15#include <string_view>
16#include <vector>
17
18namespace sgct {
19
24class SGCT_EXPORT ShaderProgram {
25public:
26 ShaderProgram() = default;
27
35 ShaderProgram(std::string name);
36 ShaderProgram(const ShaderProgram&) = delete;
38 ShaderProgram& operator=(const ShaderProgram&) = delete;
39 ShaderProgram& operator=(ShaderProgram&&) noexcept;
40
47
52
60 void addVertexShader(std::string_view src);
61
69 void addFragmentShader(std::string_view src);
70
77
81 void bind() const;
82
86 static void unbind();
87
91 std::string_view name() const;
92
96 unsigned int id() const;
97
98private:
102 void createProgram();
103
105 std::string _name;
107 unsigned int _programId = 0;
108
109 std::vector<unsigned int> _shaders;
110};
111
112} // namespace sgct
113
114#endif // __SGCT__SHADERPROGRAM__H__
static void unbind()
Unset the shader program in the current rendering pipeline.
ShaderProgram(std::string name)
Default only sets the program name.
void addFragmentShader(std::string_view src)
Will create and add a fragment shader to the program.
void addVertexShader(std::string_view src)
Will create and add a vertex shader to the program.
ShaderProgram()=default
ShaderProgram(ShaderProgram &&) noexcept
void createAndLinkProgram()
Will create the program and link the shaders.
void bind() const
Use the shader program in the current rendering pipeline.
std::string_view name() const
void deleteProgram()
Will detach all attached shaders, delete them and then delete the program.
ShaderProgram(const ShaderProgram &)=delete
Definition actions.h:16