1
0
Fork 0

Don't link program at creation

This commit is contained in:
Meoweg 2015-11-13 11:23:22 +00:00
parent 0e108e00f3
commit d02e6ebf8f
3 changed files with 10 additions and 3 deletions

View file

@ -72,7 +72,8 @@ int main()
glfwSetKeyCallback(on_key); glfwSetKeyCallback(on_key);
emscripten_set_mousemove_callback(nullptr, nullptr, false, on_em_mousemove); emscripten_set_mousemove_callback(nullptr, nullptr, false, on_em_mousemove);
const Program *program = new Program("textured"); Program *program = new Program("textured");
program->link();
program->use(); program->use();
mvp_uniform = program->get_uniform_location("mvp"); mvp_uniform = program->get_uniform_location("mvp");

View file

@ -29,8 +29,6 @@ Program::Program(const std::string &name)
while (std::getline(file, line)) while (std::getline(file, line))
glBindAttribLocation(_id, index++, line.c_str()); glBindAttribLocation(_id, index++, line.c_str());
glLinkProgram(_id);
for (int i = 0; i < index; ++i) for (int i = 0; i < index; ++i)
glEnableVertexAttribArray(i); glEnableVertexAttribArray(i);
} }
@ -40,6 +38,11 @@ void Program::use() const
glUseProgram(_id); glUseProgram(_id);
} }
void Program::link()
{
glLinkProgram(_id);
}
GLuint Program::get_uniform_location(const GLchar *name) const GLuint Program::get_uniform_location(const GLchar *name) const
{ {
return glGetUniformLocation(_id, name); return glGetUniformLocation(_id, name);

View file

@ -10,6 +10,9 @@ struct Program
Program(const std::string &name); Program(const std::string &name);
void use() const; void use() const;
void link();
GLuint get_uniform_location(const GLchar *name) const; GLuint get_uniform_location(const GLchar *name) const;
private: private: