Mountain  1.0.0
Simple C++ 2D Game Framework
shader_base.hpp
1 #pragma once
2 
3 #include <unordered_set>
4 
5 #include "Mountain/core.hpp"
8 
9 namespace Mountain
10 {
11  class ShaderBase : public Resource
12  {
13  public:
15  std::unordered_set<std::filesystem::path> dependentShaderFiles;
16 
17  using Resource::Resource;
18 
20  MOUNTAIN_API void SetUniform(const char_t* keyName, int32_t value) const;
21 
23  MOUNTAIN_API void SetUniform(const char_t* keyName, uint32_t value) const;
24 
26  MOUNTAIN_API void SetUniform(const char_t* keyName, bool_t value) const;
27 
29  MOUNTAIN_API void SetUniform(const char_t* keyName, float_t value) const;
30 
32  MOUNTAIN_API void SetUniform(const char_t* keyName, Vector2i value) const;
33 
35  MOUNTAIN_API void SetUniform(const char_t* keyName, Vector2 value) const;
36 
38  MOUNTAIN_API void SetUniform(const char_t* keyName, const Vector3& value) const;
39 
41  MOUNTAIN_API void SetUniform(const char_t* keyName, const Vector4& value) const;
42 
44  MOUNTAIN_API void SetUniform(const char_t* keyName, const Color& value) const;
45 
47  MOUNTAIN_API void SetUniform(const char_t* keyName, const Matrix2& value) const;
48 
50  MOUNTAIN_API void SetUniform(const char_t* keyName, const Matrix3& value) const;
51 
53  MOUNTAIN_API void SetUniform(const char_t* keyName, const Matrix& value) const;
54 
56  [[nodiscard]]
57  MOUNTAIN_API uint32_t GetId() const;
58 
59  protected:
60  uint32_t m_Id = 0;
61 
62  bool_t CheckCompileError(uint32_t id, std::string_view type, const std::string& code) const; // NOLINT(modernize-use-nodiscard)
63  bool_t CheckLinkError() const; // NOLINT(modernize-use-nodiscard)
64 
65  [[nodiscard]]
66  int32_t GetUniformLocation(const char_t* keyName) const;
67 
68  static void ReplaceIncludes(std::string& code, const std::filesystem::path& path, std::unordered_set<std::filesystem::path>& replacedFiles);
69  };
70 }
MOUNTAIN_API uint32_t GetId() const
Gets the internal id of the shader.
MOUNTAIN_API void SetUniform(const char_t *keyName, int32_t value) const
Sets an int (signed, 32 bits) variable in a shader.
Defines the Mountain::Resource class.
Defines multiple color structs.
std::unordered_set< std::filesystem::path > dependentShaderFiles
List of files that are included in this shader file.
Definition: shader_base.hpp:15
The Color struct represents a color in RGBA color space.
Definition: color.hpp:26
Contains all declarations of the Mountain Framework.
Definition: audio.hpp:22