1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
matabstrix/src/program.cpp

31 lines
683 B
C++
Raw Normal View History

2015-11-07 14:11:23 +00:00
#include "program.hpp"
2015-11-09 15:06:34 +00:00
#include "shader.hpp"
#include <fstream>
2015-11-11 17:28:11 +00:00
const std::string Program::filename(const std::string &name)
2015-11-07 14:11:23 +00:00
{
2015-11-11 17:28:11 +00:00
return "/data/shaders/" + name;
}
2015-11-13 13:37:53 +00:00
Program::Program(const std::string &name):
vertex_shader(GL_VERTEX_SHADER, filename(name) + "/vertex.glsl"),
fragment_shader(GL_FRAGMENT_SHADER, filename(name) + "/fragment.glsl")
{}
2015-11-07 14:11:23 +00:00
2015-11-13 13:37:53 +00:00
const Executable *Program::build(GLuint count, const GLchar *const names[])
2015-11-07 14:11:23 +00:00
{
2015-11-13 13:37:53 +00:00
Executable *exe = new Executable();
2015-11-13 13:10:49 +00:00
2015-11-13 13:37:53 +00:00
exe->attach_shader(vertex_shader);
exe->attach_shader(fragment_shader);
2015-11-13 13:10:49 +00:00
2015-11-13 13:37:53 +00:00
for (GLuint index = 0; index < count; ++index)
exe->bind_attrib_location(index, names[index]);
2015-11-13 11:23:22 +00:00
2015-11-13 13:37:53 +00:00
exe->link();
2015-11-13 11:29:42 +00:00
2015-11-13 13:37:53 +00:00
return exe;
2015-11-07 14:11:23 +00:00
}