From 5c652f2cc06de44ad6855638f7f4146227d42b85 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Thu, 11 Jun 2015 21:13:56 -0400 Subject: [PATCH] allow binding attributes as part of the Program.create() call --- include/glcxx/Program.hpp | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/include/glcxx/Program.hpp b/include/glcxx/Program.hpp index 7b86f02..990542b 100644 --- a/include/glcxx/Program.hpp +++ b/include/glcxx/Program.hpp @@ -42,18 +42,6 @@ namespace glcxx glAttachShader(m_id, shader->id()); } - void bind_attribute(const char * name, GLuint index) const - { - glBindAttribLocation(m_id, index, name); - } - - template - void bind_attributes(const char * name, GLuint index, Args... args) const - { - bind_attribute(name, index); - bind_attributes(args...); - } - GLint get_uniform_location(const char * uniform_name) { return glGetUniformLocation(m_id, uniform_name); @@ -64,13 +52,34 @@ namespace glcxx void _create() const; - template - void _create(T shader, Shaders... args) const + template + void _create(const Shader & shader, Shaders... args) const { attach_shader(shader); _create(args...); } + template + void _create(std::unique_ptr shader, Shaders... args) const + { + attach_shader(shader); + _create(args...); + } + + template + void _create(std::shared_ptr shader, Shaders... args) const + { + attach_shader(shader); + _create(args...); + } + + template + void _create(const char * attribute_name, GLuint index, Shaders... args) const + { + glBindAttribLocation(m_id, index, attribute_name); + _create(args...); + } + GLuint m_id; }; };