From d02e6ebf8f711ba32f48b248606f84c080a0bf2e Mon Sep 17 00:00:00 2001 From: Meoweg Date: Fri, 13 Nov 2015 11:23:22 +0000 Subject: [PATCH] Don't link program at creation --- src/main.cpp | 3 ++- src/program.cpp | 7 +++++-- src/program.hpp | 3 +++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 8cd6bfd..0f6cb81 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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"); diff --git a/src/program.cpp b/src/program.cpp index f8cbd81..e9d932e 100644 --- a/src/program.cpp +++ b/src/program.cpp @@ -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); diff --git a/src/program.hpp b/src/program.hpp index cfd8a41..f74b158 100644 --- a/src/program.hpp +++ b/src/program.hpp @@ -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: