diff --git a/src/AbstractShaderProgram.h b/src/AbstractShaderProgram.h index ed189e87b..f219609fa 100644 --- a/src/AbstractShaderProgram.h +++ b/src/AbstractShaderProgram.h @@ -77,7 +77,7 @@ Basic workflow with AbstractShaderProgram subclasses is: instancing the class (once at the beginning), then in every frame calling use(), setting uniforms and calling Mesh::draw() (see its documentation for more). */ -class AbstractShaderProgram { +class MAGNUM_EXPORT AbstractShaderProgram { AbstractShaderProgram(const AbstractShaderProgram& other) = delete; AbstractShaderProgram(AbstractShaderProgram&& other) = delete; AbstractShaderProgram& operator=(const AbstractShaderProgram& other) = delete; diff --git a/src/AbstractTexture.h b/src/AbstractTexture.h index 17c08030e..574212b6f 100644 --- a/src/AbstractTexture.h +++ b/src/AbstractTexture.h @@ -29,7 +29,7 @@ namespace Magnum { See Texture documentation for more information. */ -class AbstractTexture { +class MAGNUM_EXPORT AbstractTexture { AbstractTexture(const AbstractTexture& other) = delete; AbstractTexture(AbstractTexture&& other) = delete; AbstractTexture& operator=(const AbstractTexture& other) = delete; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 08df23674..bbc755409 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,6 +24,11 @@ set(Magnum_SRCS ) add_library(Magnum SHARED ${Magnum_SRCS}) + +if(WIN32) + set_target_properties(Magnum PROPERTIES COMPILE_FLAGS -DMAGNUM_EXPORTING) +endif() + target_link_libraries(Magnum CorradePluginManager CorradeUtility ${OPENGL_gl_LIBRARY} ${GLEW_LIBRARY}) install(TARGETS Magnum DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) diff --git a/src/Camera.h b/src/Camera.h index 087ccfe22..83e5ed80f 100644 --- a/src/Camera.h +++ b/src/Camera.h @@ -28,7 +28,7 @@ namespace Magnum { * * @todo Subclasses - perspective, FBO postprocessing etc. */ -class Camera: public Object { +class MAGNUM_EXPORT Camera: public Object { public: /** @brief Aspect ratio policy */ enum AspectRatioPolicy { diff --git a/src/IndexedMesh.h b/src/IndexedMesh.h index 518a76336..4741aa73b 100644 --- a/src/IndexedMesh.h +++ b/src/IndexedMesh.h @@ -27,7 +27,7 @@ namespace Magnum { /** * @brief Indexed mesh */ -class IndexedMesh: public Mesh { +class MAGNUM_EXPORT IndexedMesh: public Mesh { public: /** * @brief Implicit constructor diff --git a/src/Math/Math.h b/src/Math/Math.h index e4ffdc5a8..130ff04f8 100644 --- a/src/Math/Math.h +++ b/src/Math/Math.h @@ -17,6 +17,8 @@ #include +#include "utilities.h" + /** @file * @brief Math constants and utilities */ @@ -51,7 +53,7 @@ template<> inline constexpr size_t pow<0>(size_t base) { return 1; } * * Returns integral logarithm of given number with given base. */ -size_t log(size_t base, size_t number); +size_t MAGNUM_EXPORT log(size_t base, size_t number); /** * @brief Angle in degrees diff --git a/src/Mesh.h b/src/Mesh.h index f1e14a808..47e8dbde1 100644 --- a/src/Mesh.h +++ b/src/Mesh.h @@ -36,7 +36,7 @@ class Buffer; * @todo Support for normalized values (e.g. for color as char[4] passed to * shader as floating-point vec4) */ -class Mesh { +class MAGNUM_EXPORT Mesh { Mesh(const Mesh& other) = delete; Mesh(Mesh&& other) = delete; Mesh& operator=(const Mesh& other) = delete; diff --git a/src/MeshTools/AbstractTool.h b/src/MeshTools/AbstractTool.h index a773df1d4..c5eb25e8e 100644 --- a/src/MeshTools/AbstractTool.h +++ b/src/MeshTools/AbstractTool.h @@ -56,7 +56,7 @@ template class AbstractTool { * Provides access only to index array and vertex count. See also * AbstractTool. */ -class AbstractIndexTool { +class MAGNUM_EXPORT AbstractIndexTool { public: /** * @brief Constructor diff --git a/src/MeshTools/CMakeLists.txt b/src/MeshTools/CMakeLists.txt index 0aeff3d3c..f59b8ee59 100644 --- a/src/MeshTools/CMakeLists.txt +++ b/src/MeshTools/CMakeLists.txt @@ -3,6 +3,11 @@ set(MagnumMeshTools_SRCS ) add_library(MagnumMeshTools SHARED ${MagnumMeshTools_SRCS}) + +if(WIN32) + set_target_properties(MagnumMeshTools PROPERTIES COMPILE_FLAGS -DMESHTOOLS_EXPORTING) +endif() + target_link_libraries(MagnumMeshTools ${MAGNUM_LIBRARY}) install(TARGETS MagnumMeshTools DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) diff --git a/src/MeshTools/Tipsify.h b/src/MeshTools/Tipsify.h index 9789bd0b5..38162a66d 100644 --- a/src/MeshTools/Tipsify.h +++ b/src/MeshTools/Tipsify.h @@ -28,7 +28,7 @@ namespace Magnum { namespace MeshTools { See tipsify() for full documentation. */ -class Tipsify: public AbstractIndexTool { +class MESHTOOLS_EXPORT Tipsify: public AbstractIndexTool { public: /** @copydoc AbstractIndexTool::AbstractIndexTool(MeshBuilder&) */ template inline Tipsify(MeshBuilder& builder): AbstractIndexTool(builder) {} diff --git a/src/Object.h b/src/Object.h index 97b21b393..e9ed3439d 100644 --- a/src/Object.h +++ b/src/Object.h @@ -33,7 +33,7 @@ class Scene; * @todo Transform transformation when changing parent, so the object stays in * place. */ -class Object { +class MAGNUM_EXPORT Object { Object(const Object& other) = delete; Object(Object&& other) = delete; Object& operator=(const Object& other) = delete; diff --git a/src/Scene.h b/src/Scene.h index f4705d731..aefd6680e 100644 --- a/src/Scene.h +++ b/src/Scene.h @@ -24,7 +24,7 @@ namespace Magnum { /** @brief %Scene */ -class Scene: public Object { +class MAGNUM_EXPORT Scene: public Object { private: void setParent(Object* parent) = delete; void setTransformation(const Matrix4& transformation) = delete; diff --git a/src/Shader.h b/src/Shader.h index 683a555dd..8b16808ef 100644 --- a/src/Shader.h +++ b/src/Shader.h @@ -33,7 +33,7 @@ namespace Magnum { * string. Compiled shaders are then passed to AbstractShaderProgram subclasses * for linking and usage. */ -class Shader { +class MAGNUM_EXPORT Shader { Shader(const Shader& other) = delete; Shader(Shader&& other) = delete; Shader& operator=(const Shader& other) = delete; diff --git a/src/Texture.h b/src/Texture.h index c544535b2..888d407e2 100644 --- a/src/Texture.h +++ b/src/Texture.h @@ -48,7 +48,7 @@ don't support mipmapping and repeating wrapping modes, see @ref Texture::Filter "Filter", @ref Texture::Mipmap "Mipmap" and generateMipmap() documentation for more information. */ -template class Texture: public AbstractTexture { +template class MAGNUM_EXPORT Texture: public AbstractTexture { public: static const size_t Dimensions = dimensions; /**< @brief Texture dimension count */ diff --git a/src/Trade/AbstractImporter.h b/src/Trade/AbstractImporter.h index 5a268556c..280db32c9 100644 --- a/src/Trade/AbstractImporter.h +++ b/src/Trade/AbstractImporter.h @@ -73,7 +73,7 @@ having copies of shared pointers for them will lead to dangling pointers when 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 { +class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin { PLUGIN_INTERFACE("cz.mosra.magnum.Trade.AbstractImporter/0.1") public: @@ -280,7 +280,7 @@ class AbstractImporter: public Corrade::PluginManager::Plugin { Provides direct access to data of any mesh. See also AbstractImporter::meshData(). */ -class AbstractImporter::MeshData { +class MAGNUM_EXPORT AbstractImporter::MeshData { public: /** * @brief Indices diff --git a/src/utilities.h b/src/utilities.h new file mode 100644 index 000000000..ab79e63c2 --- /dev/null +++ b/src/utilities.h @@ -0,0 +1,42 @@ +#ifndef Magnum_utilities_h +#define Magnum_utilities_h +/* + Copyright © 2010, 2011, 2012 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. +*/ + +/** @file + * @brief Various utilities and macros + */ + +namespace Magnum { + +#ifdef _WIN32 +#ifdef MAGNUM_EXPORTING + #define MAGNUM_EXPORT __declspec(dllexport) +#else + #define MAGNUM_EXPORT __declspec(dllimport) +#endif +#ifdef MESHTOOLS_EXPORTING + #define MESHTOOLS_EXPORT __declspec(dllexport) +#else + #define MESHTOOLS_EXPORT __declspec(dllimport) +#endif +#else + #define MAGNUM_EXPORT + #define MESHTOOLS_EXPORT +#endif + +} + +#endif