From 749e72344ba72c5654306178617f08cdb0ee03cd Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 19 Dec 2013 22:40:52 +0200 Subject: [PATCH] Add an overload of bind_attribute that takes a VertexComponent --- source/program.cpp | 5 +++++ source/program.h | 2 ++ source/programbuilder.cpp | 8 ++++---- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/source/program.cpp b/source/program.cpp index 9c95ee17..50ebed22 100644 --- a/source/program.cpp +++ b/source/program.cpp @@ -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); diff --git a/source/program.h b/source/program.h index 642bcf5e..b41f9ac2 100644 --- a/source/program.h +++ b/source/program.h @@ -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(); diff --git a/source/programbuilder.cpp b/source/programbuilder.cpp index d231f349..44b7798e 100644 --- a/source/programbuilder.cpp +++ b/source/programbuilder.cpp @@ -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) { -- 2.43.0