You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.5 KiB
52 lines
1.5 KiB
|
|
#pragma once |
|
|
|
#include <SDL2/SDL.h> |
|
//Using SDL, SDL OpenGL, standard IO, and, strings |
|
|
|
#include <GL/glew.h> |
|
#include <SDL2/SDL_opengl.h> |
|
#include <GL/glu.h> |
|
#include <string> |
|
#include <iostream> |
|
#include <optional> |
|
|
|
#include <glm/vec3.hpp> |
|
#include <glm/matrix.hpp> |
|
#include <glm/gtc/type_ptr.hpp> |
|
|
|
class Shader { |
|
std::string filename_vertex; |
|
std::optional<std::string> filename_fragment; |
|
std::optional<GLuint> compile_shader(GLuint type, std::string filename); |
|
bool handle_error(std::string &filename, GLuint shader); |
|
bool link(); |
|
bool errored = false; |
|
|
|
public: |
|
GLuint shader_vert = 0; |
|
GLuint shader_frag = 0; |
|
GLuint program = 0; |
|
|
|
Shader(); |
|
Shader(std::string filename); |
|
Shader(std::string filename, std::string filename2); |
|
~Shader(); |
|
Shader(Shader &&) = default; |
|
Shader(Shader &) = default; |
|
|
|
void use(); |
|
void reload(); |
|
GLuint add_shader(GLuint type, std::string filename); |
|
|
|
void set(const std::string &name, float value); |
|
void set(const std::string &name, bool value); |
|
void set(const std::string &name, int value); |
|
void setFloat(const std::string &name, float value); |
|
void setBool(const std::string &name, bool value); |
|
void setInt(const std::string &name, int value); |
|
void setVec3(const std::string &name, glm::vec3 vec); |
|
void setMat4(const std::string &name, glm::mat4 mat); |
|
GLint get_attrib(std::string attribute_name); |
|
GLint get_uniform(std::string uniform_name); |
|
};
|
|
|