From 9e92bbf2657c7bc3302116c78925ebd155d8f0e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 1 Dec 2011 16:39:48 +0100 Subject: [PATCH] Using TypeTraits in Mesh::bindAttribute(), largely reducing code size. --- src/Mesh.h | 49 ++++--------------------------------------------- 1 file changed, 4 insertions(+), 45 deletions(-) diff --git a/src/Mesh.h b/src/Mesh.h index ffe47da53..c1e3b5770 100644 --- a/src/Mesh.h +++ b/src/Mesh.h @@ -24,6 +24,7 @@ #include #include "Magnum.h" +#include "TypeTraits.h" namespace Magnum { @@ -143,7 +144,9 @@ class Mesh { * initialized with addBuffer) or the mesh was already drawn, the * function does nothing. */ - template void bindAttribute(Buffer* buffer, GLuint attribute); + template inline void bindAttribute(Buffer* buffer, GLuint attribute) { + bindAttribute(buffer, attribute, TypeTraits::count(), TypeTraits::glType()); + } /** * @brief Draw the mesh @@ -207,50 +210,6 @@ class Mesh { GLsizei sizeOf(GLenum type); }; -template<> inline void Mesh::bindAttribute(Buffer* buffer, GLuint attribute) { - bindAttribute(buffer, attribute, 1, GL_BYTE); -} - -template<> inline void Mesh::bindAttribute(Buffer* buffer, GLuint attribute) { - bindAttribute(buffer, attribute, 1, GL_UNSIGNED_BYTE); -} - -template<> inline void Mesh::bindAttribute(Buffer* buffer, GLuint attribute) { - bindAttribute(buffer, attribute, 1, GL_SHORT); -} - -template<> inline void Mesh::bindAttribute(Buffer* buffer, GLuint attribute) { - bindAttribute(buffer, attribute, 1, GL_UNSIGNED_SHORT); -} - -template<> inline void Mesh::bindAttribute(Buffer* buffer, GLuint attribute) { - bindAttribute(buffer, attribute, 1, GL_INT); -} - -template<> inline void Mesh::bindAttribute(Buffer* buffer, GLuint attribute) { - bindAttribute(buffer, attribute, 1, GL_UNSIGNED_INT); -} - -template<> inline void Mesh::bindAttribute(Buffer* buffer, GLuint attribute) { - bindAttribute(buffer, attribute, 1, GL_FLOAT); -} - -template<> inline void Mesh::bindAttribute(Buffer* buffer, GLuint attribute) { - bindAttribute(buffer, attribute, 1, GL_DOUBLE); -} - -template<> inline void Mesh::bindAttribute(Buffer* buffer, GLuint attribute) { - bindAttribute(buffer, attribute, 2, GL_FLOAT); -} - -template<> inline void Mesh::bindAttribute(Buffer* buffer, GLuint attribute) { - bindAttribute(buffer, attribute, 3, GL_FLOAT); -} - -template<> inline void Mesh::bindAttribute(Buffer* buffer, GLuint attribute) { - bindAttribute(buffer, attribute, 4, GL_FLOAT); -} - } #endif