rename OpenGL "programs" to "shaders"

This commit is contained in:
josh committed 2016-07-29 21:27:32 -04:00
1 parent b61513b97e
commit cef49e9e6e
4 files changed
+17 -17

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
#include "TextShader.h"
#include "Runtime.h"
TextShader::TextShader()
{
std::string v_path = Runtime::find(Runtime::SHADER, "text.v");
std::string f_path = Runtime::find(Runtime::SHADER, "text.f");
m_program = glcxx::Program::create(
glcxx::Shader::create_from_file(GL_VERTEX_SHADER, v_path.c_str()),
glcxx::Shader::create_from_file(GL_FRAGMENT_SHADER, f_path.c_str()),
"coords", 0);
m_uniforms.viewport_size = m_program->get_uniform_location("viewport_size");
m_uniforms.texture = m_program->get_uniform_location("texture");
m_uniforms.color = m_program->get_uniform_location("color");
m_uniforms.position = m_program->get_uniform_location("position");
}
+46
View File
@@ -0,0 +1,46 @@
#ifndef TEXTSHADER_H
#define TEXTSHADER_H
#include "glcxx.hpp"
#include <memory>
class TextShader
{
public:
TextShader();
void use() { m_program->use(); }
void set_viewport_size(int width, int height)
{
glUniform2i(m_uniforms.viewport_size, width, height);
}
void set_texture(int texture)
{
glUniform1i(m_uniforms.texture, texture);
}
void set_color(float r, float g, float b, float a)
{
glUniform4f(m_uniforms.color, r, g, b, a);
}
void set_position(int x, int y)
{
glUniform2i(m_uniforms.position, x, y);
}
protected:
std::shared_ptr<glcxx::Program> m_program;
struct
{
GLint viewport_size;
GLint texture;
GLint color;
GLint position;
} m_uniforms;
};
#endif