]> git.tdb.fi Git - libs/gl.git/commitdiff
Add an overload of bind_attribute that takes a VertexComponent
authorMikko Rasa <tdb@tdb.fi>
Thu, 19 Dec 2013 20:40:52 +0000 (22:40 +0200)
committerMikko Rasa <tdb@tdb.fi>
Thu, 19 Dec 2013 20:40:52 +0000 (22:40 +0200)
source/program.cpp
source/program.h
source/programbuilder.cpp

index 9c95ee1730d522665fd78e63ed1124a8ab618556..50ebed22899d57fae6d21518fdce048084b7062b 100644 (file)
@@ -89,6 +89,11 @@ void Program::bind_attribute(unsigned index, const string &name)
        glBindAttribLocation(id, index, name.c_str());
 }
 
+void Program::bind_attribute(VertexComponent comp, const string &name)
+{
+       bind_attribute(get_component_type(comp), name);
+}
+
 void Program::bind_fragment_data(unsigned index, const string &name)
 {
        static Require _req(EXT_gpu_shader4);
index 642bcf5e7755652734069e33d9df182a0e2fad96..b41f9ac225e9edc724b18d375b278e4793b6b15b 100644 (file)
@@ -7,6 +7,7 @@
 #include "bindable.h"
 #include "gl.h"
 #include "programbuilder.h"
+#include "vertexformat.h"
 
 namespace Msp {
 namespace GL {
@@ -81,6 +82,7 @@ public:
        const ShaderList &get_shaders() const { return shaders; }
 
        void bind_attribute(unsigned, const std::string &);
+       void bind_attribute(VertexComponent, const std::string &);
        void bind_fragment_data(unsigned, const std::string &);
 
        void link();
index d231f349ac3593ee73e8ac32797f3719192a8cb3..44b7798e9857dfeef01fe525365364e8e8693370 100644 (file)
@@ -220,13 +220,13 @@ void ProgramBuilder::add_shaders(Program &prog) const
        if(!features.legacy)
        {
                prog.bind_fragment_data(0, "frag_color");
-               prog.bind_attribute(get_component_type(VERTEX4), "vertex");
+               prog.bind_attribute(VERTEX4, "vertex");
                if(features.lighting)
-                       prog.bind_attribute(get_component_type(NORMAL3), "normal");
+                       prog.bind_attribute(NORMAL3, "normal");
                else if(features.material)
-                       prog.bind_attribute(get_component_type(COLOR4_FLOAT), "color");
+                       prog.bind_attribute(COLOR4_FLOAT, "color");
                if(features.texture || features.normalmap)
-                       prog.bind_attribute(get_component_type(TEXCOORD4), "texcoord");
+                       prog.bind_attribute(TEXCOORD4, "texcoord");
        }
        if(features.normalmap)
        {