SleakEngine 1.0.0
C++23 multi-backend game engine
Loading...
Searching...
No Matches
OpenGLShader.hpp
Go to the documentation of this file.
1#ifndef OPENGLSHADER_HPP_
2#define OPENGLSHADER_HPP_
3
5#include <glad/glad.h>
6
7namespace Sleak {
8namespace RenderEngine {
9
10/// GLSL shader program compiled from either a combined source file or separate vertex/fragment files.
11class ENGINE_API OpenGLShader : public Shader {
12public:
14 ~OpenGLShader() override;
15
16 /// Splits a combined shader file into vertex/fragment stages and links them.
17 bool compile(const std::string& shaderPath) override;
18 /// Compiles and links separate vertex and fragment shader files.
19 bool compile(const std::string& vert, const std::string& frag) override;
20 void bind() override;
21
22 GLuint GetProgram() const { return m_program; }
23
24private:
25 /// Compiles a single shader stage from source text.
26 bool CompileShaderSource(const std::string& source, GLenum type,
27 GLuint& shader);
28 std::string ReadFile(const std::string& path);
29
30 GLuint m_program = 0;
31};
32
33} // namespace RenderEngine
34} // namespace Sleak
35
36#endif // OPENGLSHADER_HPP_
void bind() override
Binds this program as the active shader for subsequent draws.
bool compile(const std::string &shaderPath) override
Splits a combined shader file into vertex/fragment stages and links them.
Backend-agnostic compiled shader program.
Definition Shader.hpp:11
Backend-facing rendering layer shared by the four graphics backends.
Root namespace for everything the engine exposes.
Definition Camera.hpp:10