From 4a58fc9f0c5e8714d3804436fa8c35f70f6bb12b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 1 Dec 2011 18:31:16 +0100 Subject: [PATCH] Added Texture.cpp with explicit specialization for all texture dimensions. Non-inline functions which don't depend on another template moved to Texture.cpp, inlined the rest. --- src/CMakeLists.txt | 1 + src/Texture.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ src/Texture.h | 20 +++----------------- 3 files changed, 45 insertions(+), 17 deletions(-) create mode 100644 src/Texture.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7d37ed483..28898d050 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -15,6 +15,7 @@ set(Magnum_SRCS Mesh.cpp Scene.cpp Shader.cpp + Texture.cpp ) add_library(Magnum SHARED ${Magnum_SRCS}) diff --git a/src/Texture.cpp b/src/Texture.cpp new file mode 100644 index 000000000..81a7dd7f2 --- /dev/null +++ b/src/Texture.cpp @@ -0,0 +1,41 @@ +/* + Copyright © 2010, 2011 Vladimír Vondruš + + This file is part of Magnum. + + Magnum is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 3 + only, as published by the Free Software Foundation. + + Magnum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License version 3 for more details. +*/ + +#include "Texture.h" + +namespace Magnum { + +template void Texture::setWrapping(const Math::Vector& wrapping) { + bind(); + for(int i = 0; i != dimensions; ++i) switch(i) { + case 0: + glTexParameteri(target, GL_TEXTURE_WRAP_S, wrapping.at(i)); + break; + case 1: + glTexParameteri(target, GL_TEXTURE_WRAP_T, wrapping.at(i)); + break; + case 2: + glTexParameteri(target, GL_TEXTURE_WRAP_R, wrapping.at(i)); + break; + } + unbind(); +} + +/* Instantiate all textures */ +template class Texture<1>; +template class Texture<2>; +template class Texture<3>; + +} diff --git a/src/Texture.h b/src/Texture.h index f177d69a1..e15ed687d 100644 --- a/src/Texture.h +++ b/src/Texture.h @@ -188,28 +188,14 @@ template class Texture { * * Sets wrapping type for coordinates out of range (-1, 1). */ - void setWrapping(const Math::Vector& wrapping) { - bind(); - for(int i = 0; i != dimensions; ++i) switch(i) { - case 0: - glTexParameteri(target, GL_TEXTURE_WRAP_S, wrapping.at(i)); - break; - case 1: - glTexParameteri(target, GL_TEXTURE_WRAP_T, wrapping.at(i)); - break; - case 2: - glTexParameteri(target, GL_TEXTURE_WRAP_R, wrapping.at(i)); - break; - } - unbind(); - } + void setWrapping(const Math::Vector& wrapping); /** * @brief Set border color * * Border color when wrapping is set to ClampToBorder. */ - void setBorderColor(const Vector4& color) { + inline void setBorderColor(const Vector4& color) { bind(); glTexParameterfv(target, GL_TEXTURE_BORDER_COLOR, color.data()); unbind(); @@ -220,7 +206,7 @@ template class Texture { * * @see setMinificationFilter() */ - void generateMipmap() { + inline void generateMipmap() { bind(); glGenerateMipmap(target); unbind();