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

35 lines
812 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-16 13:05:04 +00:00
return "/programs/" + name;
2015-11-11 17:28:11 +00:00
}
2015-11-16 13:05:04 +00:00
Program::Program(const Adapter &adapter, const std::string &name):
vertex_shader(adapter.load<Shader>(name + ".vert")),
fragment_shader(adapter.load<Shader>(name + ".frag"))
2015-11-13 13:37:53 +00:00
{}
2015-11-07 14:11:23 +00:00
2015-11-13 13:52:01 +00:00
const Executable *Program::build(
GLuint attrib_count, const GLchar *const attribs[],
2015-11-13 15:02:01 +00:00
unsigned uniform_count, const GLchar *const uniforms[]) const
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 14:52:35 +00:00
exe->attach_shader(*vertex_shader);
exe->attach_shader(*fragment_shader);
2015-11-13 13:10:49 +00:00
2015-11-13 13:52:01 +00:00
for (GLuint attrib = 0; attrib < attrib_count; ++attrib)
exe->bind_attrib_location(attrib, attribs[attrib]);
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:52:01 +00:00
exe->get_uniforms(uniform_count, uniforms);
2015-11-13 13:37:53 +00:00
return exe;
2015-11-07 14:11:23 +00:00
}