matf-rg-engine 1.0.0
Base for project for the Computer Graphics course at Faculty of Mathematics, University of Belgrade
Loading...
Searching...
No Matches
ShaderCompiler.hpp
Go to the documentation of this file.
1
6#ifndef SHADER_COMPILER_HPP
7#define SHADER_COMPILER_HPP
10#include <filesystem>
11#include <string>
12
13namespace engine::resources {
19 std::string vertex_shader;
20 std::string fragment_shader;
21 std::string geometry_shader;
22 };
23
49 public:
56 static Shader compile_from_source(std::string shader_name, std::string shader_source);
57
64 static Shader compile_from_file(std::string shader_name, const std::filesystem::path &shader_path);
65
71
72 private:
78
79 ShaderCompiler(std::string shader_name, std::string shader_source) : m_shader_name(
80 std::move(shader_name))
81 , m_sources(std::move(shader_source)) {
82 }
83
89 std::string *now_parsing(ShaderParsingResult &result, const std::string &line);
90
97 uint32_t compile(const std::string &shader_source, ShaderType type);
98
99 std::string m_shader_name;
100 std::string m_sources;
101 };
102}
103#endif //SHADER_COMPILER_HPP
Defines the OpenGL class that serves as the interface for OpenGL.
Defines the Shader class that serves as an abstraction over OpenGL shaders.
uint32_t ShaderProgramId
Definition OpenGL.hpp:38
Compiles GLSL shaders from a single source file. Vertex, Fragment and Geometry shaders are seperated ...
Definition ShaderCompiler.hpp:48
static Shader compile_from_file(std::string shader_name, const std::filesystem::path &shader_path)
Compiles a shader from file.
Definition ShaderCompiler.cpp:78
std::string * now_parsing(ShaderParsingResult &result, const std::string &line)
Returns the output field from the ShaderParsingResult for which to continue appending lines of the m_...
Definition ShaderCompiler.cpp:94
graphics::OpenGL::ShaderProgramId compile(const ShaderParsingResult &shader_sources)
Compile shader sources into a OpenGL shader program.
Definition ShaderCompiler.cpp:22
ShaderCompiler(std::string shader_name, std::string shader_source)
Definition ShaderCompiler.hpp:79
std::string m_shader_name
Definition ShaderCompiler.hpp:99
std::string m_sources
Definition ShaderCompiler.hpp:100
ShaderParsingResult parse_source()
Splits a single shader source string into vertex, fragment, [geometry] shader strings.
Definition ShaderCompiler.cpp:57
static Shader compile_from_source(std::string shader_name, std::string shader_source)
Compiles a shader from source.
Definition ShaderCompiler.cpp:13
Represents a linked shader program object within the OpenGL context.
Definition Shader.hpp:32
Definition GraphicsController.hpp:14
ShaderType
The type of the shader.
Definition Shader.hpp:19
Contains the parsed vertex, fragment, and geometry shaders, since the ShaderCompiler expects a single...
Definition ShaderCompiler.hpp:18
std::string geometry_shader
Definition ShaderCompiler.hpp:21
std::string fragment_shader
Definition ShaderCompiler.hpp:20
std::string vertex_shader
Definition ShaderCompiler.hpp:19