KlassischeKeplerKriege/game/glclasses.cpp

40 lines
1.1 KiB
C++
Raw Normal View History

2016-09-27 16:07:21 +00:00
#include "glclasses.h"
2016-09-15 15:23:02 +00:00
2016-09-27 15:57:41 +00:00
endofthejedi::VAO::VAO() { glGenVertexArrays(1, &m_name); }
2016-09-15 15:23:02 +00:00
2016-09-27 15:57:41 +00:00
endofthejedi::VAO::~VAO() { glDeleteVertexArrays(1, &m_name); }
2016-09-15 15:23:02 +00:00
2016-09-27 15:57:41 +00:00
void endofthejedi::VAO::bind() { glBindVertexArray(m_name); }
2016-09-15 15:23:02 +00:00
2016-09-27 15:57:41 +00:00
void endofthejedi::VAO::fill(GLuint index, GLint size, GLenum type,
GLboolean normalized, GLsizei stride,
const GLvoid *pointer) {
glEnableVertexAttribArray(index);
glVertexAttribPointer(index, size, GL_FLOAT, normalized, stride, pointer);
2016-09-15 15:23:02 +00:00
}
2016-09-27 15:57:41 +00:00
endofthejedi::Shader::Shader() {
m_program = glCreateProgram();
2016-09-15 15:23:02 +00:00
}
2016-09-27 15:57:41 +00:00
endofthejedi::Shader::~Shader() {}
2016-09-15 15:23:02 +00:00
2016-09-27 15:57:41 +00:00
void endofthejedi::Shader::bind() {
glUseProgram(m_program);
2016-09-25 20:24:04 +00:00
}
2016-09-27 15:57:41 +00:00
void endofthejedi::Shader::unbind() {
glUseProgram(0);
2016-09-25 20:24:04 +00:00
}
2016-09-15 15:23:02 +00:00
2016-09-27 15:57:41 +00:00
void endofthejedi::Shader::load(std::string path, GLenum shadertype) {
GLuint cheddar = glCreateShader(shadertype);
const char* cheddardata = path.c_str();
glShaderSource(cheddar, 1, &cheddardata, NULL);
glCompileShader(cheddar);
glAttachShader(m_program, cheddar);
glLinkProgram(m_program);
glDeleteShader(cheddar);
2016-09-25 20:24:04 +00:00
}