From dacd31fcc56a1dd00eda9e32ceabbd1ef2a2a4b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 27 Jan 2012 01:12:53 +0100 Subject: [PATCH] Moved AbstractImporter and Image to new Trade namespace. Start of AbstractImporter rework - Trade namespace will contain simple classes usable for exchanging data with other formats, importers will not depend on any OpenGL functionality, they will just provide access to plain data. --- src/CMakeLists.txt | 3 +- src/CubeMapTexture.h | 56 ++++++++++++++-------------- src/Texture.h | 6 +-- src/{ => Trade}/AbstractImporter.cpp | 4 +- src/{ => Trade}/AbstractImporter.h | 21 ++++++++--- src/{ => Trade}/AbstractMaterial.h | 10 ++--- src/{ => Trade}/Image.h | 12 +++--- 7 files changed, 60 insertions(+), 52 deletions(-) rename src/{ => Trade}/AbstractImporter.cpp (95%) rename src/{ => Trade}/AbstractImporter.h (96%) rename src/{ => Trade}/AbstractMaterial.h (87%) rename src/{ => Trade}/Image.h (95%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 368d66a5c..08df23674 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,7 +7,6 @@ add_subdirectory(MeshTools) add_subdirectory(Primitives) set(Magnum_SRCS - AbstractImporter.cpp Object.cpp AbstractTexture.cpp AbstractShaderProgram.cpp @@ -19,6 +18,8 @@ set(Magnum_SRCS SizeTraits.cpp Texture.cpp + Trade/AbstractImporter.cpp + Math/Math.cpp ) diff --git a/src/CubeMapTexture.h b/src/CubeMapTexture.h index 16759d242..a2ce45c90 100644 --- a/src/CubeMapTexture.h +++ b/src/CubeMapTexture.h @@ -57,14 +57,14 @@ class CubeMapTexture: public Texture2D { /** @brief Deleted. Use @ref setDataPositiveX(GLint, InternalFormat, const Math::Vector&, ColorFormat, const T*) "setDataPositiveX()" and others instead. */ template inline void setData(GLint mipLevel, InternalFormat internalFormat, const Math::Vector& _dimensions, ColorFormat colorFormat, const T* data) = delete; - /** @brief Deleted. Use @ref setDataPositiveX(GLint, InternalFormat, const Image*) "setDataPositiveX()" and others instead. */ - void setData(GLint mipLevel, InternalFormat internalFormat, const Image* image) = delete; + /** @brief Deleted. Use @ref setDataPositiveX(GLint, InternalFormat, const Trade::Image*) "setDataPositiveX()" and others instead. */ + void setData(GLint mipLevel, InternalFormat internalFormat, const Trade::Image* image) = delete; /** @brief Deleted. Use @ref setSubDataPositiveX(GLint, const Math::Vector&, const Math::Vector&, ColorFormat, const T*) "setSubDataPositiveX()" and others instead. */ template inline void setSubData(GLint mipLevel, const Math::Vector& offset, const Math::Vector& _dimensions, ColorFormat colorFormat, const T* data) = delete; - /** @brief Deleted. Use @ref setSubDataPositiveX(GLint, const Math::Vector&, const Image*) "setSubDataPositiveX()" and others instead. */ - void setSubData(GLint mipLevel, const Math::Vector& offset, const Image* image) = delete; + /** @brief Deleted. Use @ref setSubDataPositiveX(GLint, const Math::Vector&, const Trade::Image*) "setSubDataPositiveX()" and others instead. */ + void setSubData(GLint mipLevel, const Math::Vector& offset, const Trade::Image* image) = delete; /** * @brief Set texture data for positive X @@ -78,9 +78,9 @@ class CubeMapTexture: public Texture2D { /** * @brief Set texture data for positive X * - * @copydetails Texture::setData(GLint, InternalFormat, const Image*) + * @copydetails Texture::setData(GLint, InternalFormat, const Trade::Image*) */ - inline void setDataPositiveX(GLint mipLevel, InternalFormat internalFormat, const Image* image) { + inline void setDataPositiveX(GLint mipLevel, InternalFormat internalFormat, const Trade::Image* image) { setData(GL_TEXTURE_CUBE_MAP_POSITIVE_X, mipLevel, internalFormat, image->dimensions(), image->colorFormat(), image->type(), image->data()); } @@ -96,9 +96,9 @@ class CubeMapTexture: public Texture2D { /** * @brief Set texture subdata for positive X * - * @copydetails Texture::setSubData(GLint, const Math::Vector&, const Image*) + * @copydetails Texture::setSubData(GLint, const Math::Vector&, const Trade::Image*) */ - inline void setSubDataPositiveX(GLint mipLevel, const Math::Vector& offset, const Image* image) { + inline void setSubDataPositiveX(GLint mipLevel, const Math::Vector& offset, const Trade::Image* image) { setSubData(GL_TEXTURE_CUBE_MAP_POSITIVE_X, mipLevel, offset, image->dimensions(), image->colorFormat(), image->type(), image->data()); } @@ -114,9 +114,9 @@ class CubeMapTexture: public Texture2D { /** * @brief Set texture data for negative X * - * @copydetails Texture::setData(GLint, InternalFormat, const Image*) + * @copydetails Texture::setData(GLint, InternalFormat, const Trade::Image*) */ - inline void setDataNegativeX(GLint mipLevel, InternalFormat internalFormat, const Image* image) { + inline void setDataNegativeX(GLint mipLevel, InternalFormat internalFormat, const Trade::Image* image) { setData(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, mipLevel, internalFormat, image->dimensions(), image->colorFormat(), image->type(), image->data()); } @@ -132,9 +132,9 @@ class CubeMapTexture: public Texture2D { /** * @brief Set texture subdata for negative X * - * @copydetails Texture::setSubData(GLint, const Math::Vector&, const Image*) + * @copydetails Texture::setSubData(GLint, const Math::Vector&, const Trade::Image*) */ - inline void setSubDataNegativeX(GLint mipLevel, const Math::Vector& offset, const Image* image) { + inline void setSubDataNegativeX(GLint mipLevel, const Math::Vector& offset, const Trade::Image* image) { setSubData(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, mipLevel, offset, image->dimensions(), image->colorFormat(), image->type(), image->data()); } @@ -150,9 +150,9 @@ class CubeMapTexture: public Texture2D { /** * @brief Set texture data for positive Y * - * @copydetails Texture::setData(GLint, InternalFormat, const Image*) + * @copydetails Texture::setData(GLint, InternalFormat, const Trade::Image*) */ - inline void setDataPositiveY(GLint mipLevel, InternalFormat internalFormat, const Image* image) { + inline void setDataPositiveY(GLint mipLevel, InternalFormat internalFormat, const Trade::Image* image) { setData(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, mipLevel, internalFormat, image->dimensions(), image->colorFormat(), image->type(), image->data()); } @@ -168,9 +168,9 @@ class CubeMapTexture: public Texture2D { /** * @brief Set texture subdata for positive Y * - * @copydetails Texture::setSubData(GLint, const Math::Vector&, const Image*) + * @copydetails Texture::setSubData(GLint, const Math::Vector&, const Trade::Image*) */ - inline void setSubDataPositiveY(GLint mipLevel, const Math::Vector& offset, const Image* image) { + inline void setSubDataPositiveY(GLint mipLevel, const Math::Vector& offset, const Trade::Image* image) { setSubData(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, mipLevel, offset, image->dimensions(), image->colorFormat(), image->type(), image->data()); } @@ -186,9 +186,9 @@ class CubeMapTexture: public Texture2D { /** * @brief Set texture data for negative Y * - * @copydetails Texture::setData(GLint, InternalFormat, const Image*) + * @copydetails Texture::setData(GLint, InternalFormat, const Trade::Image*) */ - inline void setDataNegativeY(GLint mipLevel, InternalFormat internalFormat, const Image* image) { + inline void setDataNegativeY(GLint mipLevel, InternalFormat internalFormat, const Trade::Image* image) { setData(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, mipLevel, internalFormat, image->dimensions(), image->colorFormat(), image->type(), image->data()); } @@ -204,9 +204,9 @@ class CubeMapTexture: public Texture2D { /** * @brief Set texture subdata for negative Y * - * @copydetails Texture::setSubData(GLint, const Math::Vector&, const Image*) + * @copydetails Texture::setSubData(GLint, const Math::Vector&, const Trade::Image*) */ - inline void setSubDataNegativeY(GLint mipLevel, const Math::Vector& offset, const Image* image) { + inline void setSubDataNegativeY(GLint mipLevel, const Math::Vector& offset, const Trade::Image* image) { setSubData(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, mipLevel, offset, image->dimensions(), image->colorFormat(), image->type(), image->data()); } @@ -222,9 +222,9 @@ class CubeMapTexture: public Texture2D { /** * @brief Set texture data for positive Z * - * @copydetails Texture::setData(GLint, InternalFormat, const Image*) + * @copydetails Texture::setData(GLint, InternalFormat, const Trade::Image*) */ - inline void setDataPositiveZ(GLint mipLevel, InternalFormat internalFormat, const Image* image) { + inline void setDataPositiveZ(GLint mipLevel, InternalFormat internalFormat, const Trade::Image* image) { setData(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, mipLevel, internalFormat, image->dimensions(), image->colorFormat(), image->type(), image->data()); } @@ -240,9 +240,9 @@ class CubeMapTexture: public Texture2D { /** * @brief Set texture subdata for positive Z * - * @copydetails Texture::setSubData(GLint, const Math::Vector&, const Image*) + * @copydetails Texture::setSubData(GLint, const Math::Vector&, const Trade::Image*) */ - inline void setSubDataPositiveZ(GLint mipLevel, const Math::Vector& offset, const Image* image) { + inline void setSubDataPositiveZ(GLint mipLevel, const Math::Vector& offset, const Trade::Image* image) { setSubData(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, mipLevel, offset, image->dimensions(), image->colorFormat(), image->type(), image->data()); } @@ -258,9 +258,9 @@ class CubeMapTexture: public Texture2D { /** * @brief Set texture data for negative Z * - * @copydetails Texture::setData(GLint, InternalFormat, const Image*) + * @copydetails Texture::setData(GLint, InternalFormat, const Trade::Image*) */ - inline void setDataNegativeZ(GLint mipLevel, InternalFormat internalFormat, const Image* image) { + inline void setDataNegativeZ(GLint mipLevel, InternalFormat internalFormat, const Trade::Image* image) { setData(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, mipLevel, internalFormat, image->dimensions(), image->colorFormat(), image->type(), image->data()); } @@ -276,9 +276,9 @@ class CubeMapTexture: public Texture2D { /** * @brief Set texture subdata for negative Z * - * @copydetails Texture::setSubData(GLint, const Math::Vector&, const Image*) + * @copydetails Texture::setSubData(GLint, const Math::Vector&, const Trade::Image*) */ - inline void setSubDataNegativeZ(GLint mipLevel, const Math::Vector& offset, const Image* image) { + inline void setSubDataNegativeZ(GLint mipLevel, const Math::Vector& offset, const Trade::Image* image) { setSubData(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, mipLevel, offset, image->dimensions(), image->colorFormat(), image->type(), image->data()); } diff --git a/src/Texture.h b/src/Texture.h index 53de3a0aa..c544535b2 100644 --- a/src/Texture.h +++ b/src/Texture.h @@ -19,7 +19,7 @@ * @brief Class Magnum::Texture */ -#include "Image.h" +#include "Trade/Image.h" namespace Magnum { @@ -100,7 +100,7 @@ template class Texture: public AbstractTexture { * Sets texture data from given image. The image is not deleted * afterwards. */ - inline void setData(GLint mipLevel, InternalFormat internalFormat, const Image* image) { + inline void setData(GLint mipLevel, InternalFormat internalFormat, const Trade::Image* image) { bind(); DataHelper::set(target, mipLevel, internalFormat, image->dimensions(), image->colorFormat(), image->type(), image->data()); unbind(); @@ -133,7 +133,7 @@ template class Texture: public AbstractTexture { * Sets texture subdata from given image. The image is not deleted * afterwards. */ - inline void setSubData(GLint mipLevel, const Math::Vector& offset, const Image* image) { + inline void setSubData(GLint mipLevel, const Math::Vector& offset, const Trade::Image* image) { bind(); DataHelper::setSub(target, mipLevel, offset, image->dimensions(), image->colorFormat(), image->type(), image->data()); unbind(); diff --git a/src/AbstractImporter.cpp b/src/Trade/AbstractImporter.cpp similarity index 95% rename from src/AbstractImporter.cpp rename to src/Trade/AbstractImporter.cpp index c932f32a5..5ab008726 100644 --- a/src/AbstractImporter.cpp +++ b/src/Trade/AbstractImporter.cpp @@ -18,7 +18,7 @@ using namespace std; using namespace Corrade::Utility; -namespace Magnum { +namespace Magnum { namespace Trade { bool AbstractImporter::open(const std::string& filename) { Error() << plugin() << "doesn't support opening files"; @@ -30,4 +30,4 @@ bool AbstractImporter::open(std::istream& in) { return false; } -} +}} diff --git a/src/AbstractImporter.h b/src/Trade/AbstractImporter.h similarity index 96% rename from src/AbstractImporter.h rename to src/Trade/AbstractImporter.h index b6cc3994f..e38a932a0 100644 --- a/src/AbstractImporter.h +++ b/src/Trade/AbstractImporter.h @@ -1,5 +1,5 @@ -#ifndef Magnum_AbstractImporter_h -#define Magnum_AbstractImporter_h +#ifndef Magnum_Trade_AbstractImporter_h +#define Magnum_Trade_AbstractImporter_h /* Copyright © 2010, 2011, 2012 Vladimír Vondruš @@ -16,7 +16,7 @@ */ /** @file - * @brief Class Magnum::AbstractImporter + * @brief Class Magnum::Trade::AbstractImporter */ #include @@ -28,13 +28,22 @@ namespace Magnum { class AbstractShaderProgram; class AbstractTexture; -class AbstractMaterial; class Camera; class Light; class Mesh; class Object; class Scene; +/** +@brief Data format exchange + +Contains plugin interfaces for importing data of various formats and classes +for direct access to the data. +*/ +namespace Trade { + +class AbstractMaterial; + /** @brief Base class for importer plugins @@ -65,7 +74,7 @@ any object deletes its child objects. Thus the class should store only one shared pointer to root of each object tree.

*/ class AbstractImporter: public Corrade::PluginManager::Plugin { - PLUGIN_INTERFACE("cz.mosra.magnum.AbstractImporter/0.1") + PLUGIN_INTERFACE("cz.mosra.magnum.Trade.AbstractImporter/0.1") public: struct MeshData; @@ -304,6 +313,6 @@ class AbstractImporter::MeshData { virtual std::vector* const textureCoords2D(size_t id) { return nullptr; } }; -} +}} #endif diff --git a/src/AbstractMaterial.h b/src/Trade/AbstractMaterial.h similarity index 87% rename from src/AbstractMaterial.h rename to src/Trade/AbstractMaterial.h index 28412eb19..79c68a27b 100644 --- a/src/AbstractMaterial.h +++ b/src/Trade/AbstractMaterial.h @@ -1,5 +1,5 @@ -#ifndef Magnum_AbstractMaterial_h -#define Magnum_AbstractMaterial_h +#ifndef Magnum_Trade_AbstractMaterial_h +#define Magnum_Trade_AbstractMaterial_h /* Copyright © 2010, 2011, 2012 Vladimír Vondruš @@ -16,12 +16,12 @@ */ /** @file - * @brief Class Magnum::AbstractMaterial + * @brief Class Magnum::Trade::AbstractMaterial */ #include "Magnum.h" -namespace Magnum { +namespace Magnum { namespace Trade { /** @brief Base class for materials */ class AbstractMaterial { @@ -41,6 +41,6 @@ class AbstractMaterial { virtual bool use(const Matrix4& transformationMatrix, const Matrix4& projectionMatrix) = 0; }; -} +}} #endif diff --git a/src/Image.h b/src/Trade/Image.h similarity index 95% rename from src/Image.h rename to src/Trade/Image.h index e1e2abffa..e93cb3deb 100644 --- a/src/Image.h +++ b/src/Trade/Image.h @@ -1,5 +1,5 @@ -#ifndef Magnum_Image_h -#define Magnum_Image_h +#ifndef Magnum_Trade_Image_h +#define Magnum_Trade_Image_h /* Copyright © 2010, 2011, 2012 Vladimír Vondruš @@ -16,14 +16,12 @@ */ /** @file - * @brief Class Magnum::Image + * @brief Class Magnum::Trade::Image */ -#include "Magnum.h" -#include "TypeTraits.h" #include "AbstractTexture.h" -namespace Magnum { +namespace Magnum { namespace Trade { /** @brief %Image @@ -84,6 +82,6 @@ typedef Image<2> Image2D; /** @brief Three-dimensional image */ typedef Image<3> Image3D; -} +}} #endif