Tatooine
shaderstage.h
Go to the documentation of this file.
1#ifndef TATOOINE_GL_SHADERSTAGE_H
2#define TATOOINE_GL_SHADERSTAGE_H
3//==============================================================================
4#include <filesystem>
5#include <variant>
6#include <fstream>
7#include <iostream>
8#include <regex>
9#include <sstream>
10#include <string>
11#include <vector>
12
18//==============================================================================
19namespace tatooine::gl {
20//==============================================================================
21class shaderstage : public id_holder<GLuint> {
22 using path = std::filesystem::path;
23 private:
24 bool m_delete = true;
25
27 std::variant<shadersource, std::filesystem::path> m_source;
28
29 std::vector<GLSLVar> m_glsl_vars;
31
32 static std::regex const regex_nvidia_compiler_error;
33 static std::regex const regex_mesa_compiler_error;
34
35 public:
36 DLL_API static auto type_to_string(GLenum shader_type) -> std::string_view;
37 //----------------------------------------------------------------------------
38 DLL_API shaderstage(GLenum shader_type, shadersource const& shaderfilepath);
39 //----------------------------------------------------------------------------
40 DLL_API shaderstage(GLenum shader_type,
41 std::filesystem::path const& shaderfilepath);
42 //----------------------------------------------------------------------------
43 DLL_API shaderstage(shaderstage&& other);
44 //----------------------------------------------------------------------------
45 DLL_API ~shaderstage();
46 //----------------------------------------------------------------------------
47 DLL_API auto compile(bool use_ansi_color = true) -> void;
48 DLL_API auto delete_stage() -> void;
49 //----------------------------------------------------------------------------
50 auto glsl_vars() const -> auto const& { return m_glsl_vars; }
51 //----------------------------------------------------------------------------
52 auto stage_name() const { return type_to_string(m_shader_type); }
53 auto stage_type() const { return m_shader_type; }
54 auto is_created() const { return id() != 0; }
55
56 protected:
57 DLL_API auto info_log(bool use_ansi_color = true) -> void;
58 DLL_API auto parse_compile_error(std::smatch& match, std::ostream& os,
59 bool use_ansi_color = true) -> void;
60 DLL_API auto print_line(std::filesystem::path const& filename,
61 size_t line_number, std::ostream& os) -> void;
62};
63//==============================================================================
64} // namespace tatooine::gl
65//==============================================================================
66#endif
Definition: shaderstage.h:21
std::variant< shadersource, std::filesystem::path > m_source
Definition: shaderstage.h:27
include_tree m_include_tree
Definition: shaderstage.h:30
std::filesystem::path path
Definition: shaderstage.h:22
DLL_API auto delete_stage() -> void
DLL_API shaderstage(GLenum shader_type, std::filesystem::path const &shaderfilepath)
auto stage_type() const
Definition: shaderstage.h:53
DLL_API auto info_log(bool use_ansi_color=true) -> void
bool m_delete
Definition: shaderstage.h:24
DLL_API auto print_line(std::filesystem::path const &filename, size_t line_number, std::ostream &os) -> void
DLL_API shaderstage(GLenum shader_type, shadersource const &shaderfilepath)
auto is_created() const
Definition: shaderstage.h:54
DLL_API shaderstage(shaderstage &&other)
DLL_API auto compile(bool use_ansi_color=true) -> void
DLL_API auto parse_compile_error(std::smatch &match, std::ostream &os, bool use_ansi_color=true) -> void
static DLL_API auto type_to_string(GLenum shader_type) -> std::string_view
auto glsl_vars() const -> auto const &
Definition: shaderstage.h:50
GLenum m_shader_type
Definition: shaderstage.h:26
std::vector< GLSLVar > m_glsl_vars
Definition: shaderstage.h:29
auto stage_name() const
Definition: shaderstage.h:52
static std::regex const regex_nvidia_compiler_error
Definition: shaderstage.h:32
static std::regex const regex_mesa_compiler_error
Definition: shaderstage.h:33
Definition: ansiformat.h:6
Definition: idholder.h:31
auto id() const
Definition: idholder.h:56
Definition: includetree.h:11
Definition: shadersource.h:8