Don't link program at creation
This commit is contained in:
parent
0e108e00f3
commit
d02e6ebf8f
3 changed files with 10 additions and 3 deletions
|
@ -72,7 +72,8 @@ int main()
|
|||
glfwSetKeyCallback(on_key);
|
||||
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();
|
||||
|
||||
mvp_uniform = program->get_uniform_location("mvp");
|
||||
|
|
|
@ -29,8 +29,6 @@ Program::Program(const std::string &name)
|
|||
while (std::getline(file, line))
|
||||
glBindAttribLocation(_id, index++, line.c_str());
|
||||
|
||||
glLinkProgram(_id);
|
||||
|
||||
for (int i = 0; i < index; ++i)
|
||||
glEnableVertexAttribArray(i);
|
||||
}
|
||||
|
@ -40,6 +38,11 @@ void Program::use() const
|
|||
glUseProgram(_id);
|
||||
}
|
||||
|
||||
void Program::link()
|
||||
{
|
||||
glLinkProgram(_id);
|
||||
}
|
||||
|
||||
GLuint Program::get_uniform_location(const GLchar *name) const
|
||||
{
|
||||
return glGetUniformLocation(_id, name);
|
||||
|
|
|
@ -10,6 +10,9 @@ struct Program
|
|||
Program(const std::string &name);
|
||||
|
||||
void use() const;
|
||||
|
||||
void link();
|
||||
|
||||
GLuint get_uniform_location(const GLchar *name) const;
|
||||
|
||||
private:
|
||||
|
|
Reference in a new issue