added files
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
|
||||
#include "GLFunctions.hpp"
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace planetarium {
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Shader
|
||||
//
|
||||
// Thin RAII wrapper around a linked OpenGL program object, compiled from
|
||||
// a vertex + fragment shader pair loaded from disk.
|
||||
// -----------------------------------------------------------------------
|
||||
class Shader {
|
||||
public:
|
||||
Shader() = default;
|
||||
~Shader();
|
||||
|
||||
Shader(const Shader&) = delete;
|
||||
Shader& operator=(const Shader&) = delete;
|
||||
Shader(Shader&& other) noexcept;
|
||||
Shader& operator=(Shader&& other) noexcept;
|
||||
|
||||
// Compiles and links the program. Returns false (and logs to stderr)
|
||||
// on failure; the shader remains unusable but the caller can continue
|
||||
// running with a null program.
|
||||
bool loadFromFiles(const std::string& vertexPath, const std::string& fragmentPath);
|
||||
|
||||
void use() const;
|
||||
GLuint id() const { return program_; }
|
||||
|
||||
void setMat4(const std::string& name, const glm::mat4& m) const;
|
||||
void setVec3(const std::string& name, const glm::vec3& v) const;
|
||||
void setVec4(const std::string& name, const glm::vec4& v) const;
|
||||
void setFloat(const std::string& name, float f) const;
|
||||
void setInt(const std::string& name, int i) const;
|
||||
|
||||
private:
|
||||
GLuint program_ = 0;
|
||||
GLint locationOf(const std::string& name) const;
|
||||
};
|
||||
|
||||
} // namespace planetarium
|
||||
Reference in New Issue
Block a user