first commit
This commit is contained in:
61
lopenglprogram.h
Normal file
61
lopenglprogram.h
Normal file
@@ -0,0 +1,61 @@
|
||||
#pragma once
|
||||
|
||||
#include <glad/glad.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <glm/glm.hpp>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
|
||||
class LOpenGLProgram;
|
||||
class LOpenGLShader {
|
||||
public:
|
||||
typedef enum ShaderTypeBit {
|
||||
Vertex = 0x0001,
|
||||
Fragment = 0x0002,
|
||||
} ShaderType;
|
||||
LOpenGLShader() = delete;
|
||||
LOpenGLShader(LOpenGLShader::ShaderType type);
|
||||
~LOpenGLShader();
|
||||
bool compileShaderFromSource(const char *source);
|
||||
bool compileShaderFromSource(const std::string &source);
|
||||
bool compileShaderFromFile(const std::string &path);
|
||||
bool Compiled() const { return compiled_; }
|
||||
std::string Log() const { return shaderLog_; }
|
||||
|
||||
private:
|
||||
GLuint shaderId_{};
|
||||
std::string shaderSource_;
|
||||
LOpenGLShader::ShaderType shaderType_;
|
||||
bool compiled_;
|
||||
std::string shaderLog_;
|
||||
|
||||
friend class LOpenGLProgram;
|
||||
};
|
||||
|
||||
class LOpenGLProgram {
|
||||
public:
|
||||
LOpenGLProgram();
|
||||
~LOpenGLProgram();
|
||||
|
||||
bool addShader(std::unique_ptr<LOpenGLShader> shader);
|
||||
void removeShader(GLuint id);
|
||||
void Create();
|
||||
bool Link() const;
|
||||
void Use() const;
|
||||
bool Linked() const { return linked_; }
|
||||
|
||||
void setUniformValue(const std::string& name, float value) const;
|
||||
void setUniformValue(const std::string& name, int value) const;
|
||||
void setUniformValue(const std::string& name, bool value) const;
|
||||
void setUniformValue(const std::string& name, glm::vec3 value) const;
|
||||
void setUniformValue(const std::string& name, float x, float y, float z) const;
|
||||
void setUniformValue(const std::string& name, glm::mat4 value) const;
|
||||
|
||||
private:
|
||||
std::list<std::unique_ptr<LOpenGLShader>> shaderList_;
|
||||
GLuint programId_;
|
||||
bool linked_;
|
||||
bool created_;
|
||||
};
|
||||
Reference in New Issue
Block a user