Setting up
This commit is contained in:
33
src/shader.h
Normal file
33
src/shader.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
#include <glad/glad.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
|
||||
class Shader
|
||||
{
|
||||
public:
|
||||
// state
|
||||
unsigned int ID;
|
||||
// constructor
|
||||
Shader() { }
|
||||
// sets the current shader as active
|
||||
Shader &Use();
|
||||
// compiles the shader from given source code
|
||||
void Compile(const char *vertexSource, const char *fragmentSource, const char *geometrySource = nullptr); // note: geometry source code is optional
|
||||
// utility functions
|
||||
void SetFloat (const char *name, float value, bool useShader = false);
|
||||
void SetInteger (const char *name, int value, bool useShader = false);
|
||||
void SetVector2f (const char *name, float x, float y, bool useShader = false);
|
||||
void SetVector2f (const char *name, const glm::vec2 &value, bool useShader = false);
|
||||
void SetVector3f (const char *name, float x, float y, float z, bool useShader = false);
|
||||
void SetVector3f (const char *name, const glm::vec3 &value, bool useShader = false);
|
||||
void SetVector4f (const char *name, float x, float y, float z, float w, bool useShader = false);
|
||||
void SetVector4f (const char *name, const glm::vec4 &value, bool useShader = false);
|
||||
void SetMatrix4 (const char *name, const glm::mat4 &matrix, bool useShader = false);
|
||||
private:
|
||||
// checks if compilation or linking failed and if so, print the error logs
|
||||
void checkCompileErrors(unsigned int object, std::string type);
|
||||
};
|
||||
Reference in New Issue
Block a user