diff --git a/CMakeLists.txt b/CMakeLists.txt index 3217e371e..3908b08b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,15 +106,15 @@ cmake_dependent_option(WITH_TGAIMPORTER "Build TgaImporter plugin" OFF "NOT WITH # Parts of the library cmake_dependent_option(WITH_AUDIO "Build Audio library" OFF "NOT WITH_AL_INFO;NOT WITH_ANYAUDIOIMPORTER;NOT WITH_WAVAUDIOIMPORTER" ON) option(WITH_DEBUGTOOLS "Build DebugTools library" ON) -cmake_dependent_option(WITH_MESHTOOLS "Build MeshTools library" ON "( NOT WITH_DEBUGTOOLS OR ( NOT WITH_SHAPES AND NOT WITH_SCENEGRAPH ) ) AND NOT WITH_OBJIMPORTER" ON) -cmake_dependent_option(WITH_PRIMITIVES "Builf Primitives library" ON "NOT WITH_DEBUGTOOLS OR NOT WITH_SHAPES" ON) +cmake_dependent_option(WITH_MESHTOOLS "Build MeshTools library" ON "NOT WITH_OBJIMPORTER" ON) option(WITH_SHAPES "Build Shapes library" ON) cmake_dependent_option(WITH_SCENEGRAPH "Build SceneGraph library" ON "NOT WITH_SHAPES" ON) -cmake_dependent_option(WITH_SHADERS "Build Shaders library" ON "NOT WITH_DEBUGTOOLS OR ( NOT WITH_SHAPES AND NOT WITH_SCENEGRAPH )" ON) +option(WITH_SHADERS "Build Shaders library" ON) cmake_dependent_option(WITH_TEXT "Build Text library" ON "NOT WITH_FONTCONVERTER;NOT WITH_MAGNUMFONT;NOT WITH_MAGNUMFONTCONVERTER" ON) cmake_dependent_option(WITH_TEXTURETOOLS "Build TextureTools library" ON "NOT WITH_TEXT;NOT WITH_DISTANCEFIELDCONVERTER" ON) cmake_dependent_option(WITH_TRADE "Build Trade library" ON "NOT WITH_MESHTOOLS;NOT WITH_PRIMITIVES;NOT WITH_IMAGECONVERTER;NOT WITH_ANYIMAGEIMPORTER;NOT WITH_ANYIMAGECONVERTER;NOT WITH_ANYSCENEIMPORTER;NOT WITH_OBJIMPORTER;NOT WITH_TGAIMAGECONVERTER;NOT WITH_TGAIMPORTER" ON) -cmake_dependent_option(WITH_GL "Build GL library" ON "NOT WITH_DEBUGTOOLS;NOT WITH_MESHTOOLS;NOT WITH_PRIMITIVES;NOT WITH_SHADERS;NOT WITH_TEXT;NOT WITH_TEXTURETOOLS;NOT WITH_TRADE;NOT WITH_GL_INFO;NOT WITH_ANDROIDAPPLICATION;NOT WITH_WINDOWLESSIOSAPPLICATION;NOT WITH_CGLCONTEXT;NOT WITH_GLXAPPLICATION;NOT WITH_GLXCONTEXT;NOT WITH_XEGLAPPLICATION;NOT WITH_WINDOWLESSWGLAPPLICATION;NOT WITH_GLXCONTEXT;NOT WITH_XEGLAPPLICATION;NOT WITH_WINDOWLESSWGLAPPLICATION;NOT WITH_WGLCONTEXT;NOT WITH_WINDOWLESSWINDOWSEGLAPPLICATION;NOT WITH_GLFWAPPLICATION;NOT WITH_GLUTAPPLICATION;NOT WITH_SDL2APPLICATION;NOT WITH_DISTANCEFIELDCONVERTER;NOT WITH_FONTCONVERTER;NOT WITH_IMAGECONVERTER" ON) +cmake_dependent_option(WITH_GL "Build GL library" ON "NOT WITH_SHADERS;NOT WITH_TEXT;NOT WITH_GL_INFO;NOT WITH_ANDROIDAPPLICATION;NOT WITH_WINDOWLESSIOSAPPLICATION;NOT WITH_CGLCONTEXT;NOT WITH_GLXAPPLICATION;NOT WITH_GLXCONTEXT;NOT WITH_XEGLAPPLICATION;NOT WITH_WINDOWLESSWGLAPPLICATION;NOT WITH_GLXCONTEXT;NOT WITH_XEGLAPPLICATION;NOT WITH_WINDOWLESSWGLAPPLICATION;NOT WITH_WGLCONTEXT;NOT WITH_WINDOWLESSWINDOWSEGLAPPLICATION;NOT WITH_GLFWAPPLICATION;NOT WITH_GLUTAPPLICATION;NOT WITH_SDL2APPLICATION;NOT WITH_DISTANCEFIELDCONVERTER;NOT WITH_FONTCONVERTER;NOT WITH_IMAGECONVERTER" ON) +option(WITH_PRIMITIVES "Builf Primitives library" ON) cmake_dependent_option(TARGET_GL "Build libraries with OpenGL interoperability" ON "WITH_GL" OFF) diff --git a/doc/building.dox b/doc/building.dox index b1d4cab1a..28c14e6a3 100644 --- a/doc/building.dox +++ b/doc/building.dox @@ -385,8 +385,8 @@ available for desktop OpenGL only, see @ref requires-gl. - `TARGET_GL` --- Build libraries with OpenGL interoperability enabled. Enabled by default when `WITH_GL` is enabled. Disabling this will cause - libraries to not depend on the @ref GL library, but doesn't affect the - @ref GL library itself. + other libraries to not depend on the @ref GL library, but doesn't affect + the @ref GL library itself. - `TARGET_GLES` --- Target OpenGL ES. Available only when `WITH_GL` is enabled. - `TARGET_GLES2` --- Target OpenGL ES 2.0 instead of 3.0 and later. Available @@ -419,27 +419,24 @@ be built and which not: - `WITH_AUDIO` --- Build the @ref Audio library. Depends on [OpenAL](https://www.openal.org/), not built by default. -- `WITH_DEBUGTOOLS` --- Build the @ref DebugTools library. Enables also - building of the GL library. -- `WITH_GL` --- Build the @ref GL library +- `WITH_DEBUGTOOLS` --- Build the @ref DebugTools library. +- `WITH_GL` --- Build the @ref GL library. Enabled automatically if + `WITH_SHADERS` or `WITH_TEXT` is enabled. - `WITH_MESHTOOLS` --- Build the @ref MeshTools library. Enables also - building of the Trade and GL libraries. + building of the Trade library. - `WITH_PRIMITIVES` --- Build the @ref Primitives library. Enables also - building of the Trade and GL libraries. + building of the Trade library. - `WITH_SCENEGRAPH` --- Build the @ref SceneGraph library. Enabled automatically if `WITH_SHAPES` is enabled. - `WITH_SHADERS` --- Build the @ref Shaders library. Enables also building of the GL library. - `WITH_SHAPES` --- Build the @ref Shapes library. Enables also building of - the SceneGraph library. Enabled automatically if `WITH_DEBUGTOOLS` is - enabled. + the SceneGraph library. - `WITH_TEXT` --- Build the @ref Text library. Enables also building of the TextureTools and GL libraries. -- `WITH_TEXTURETOOLS` --- Build the @ref TextureTools library. Enables also - building of the GL library. Enabled automatically if `WITH_TEXT` or - `WITH_DISTANCEFIELDCONVERTER` is enabled. -- `WITH_TRADE` --- Build the @ref Trade library. Enables also building of the - GL library. +- `WITH_TEXTURETOOLS` --- Build the @ref TextureTools library. Enabled + automatically if `WITH_TEXT` or `WITH_DISTANCEFIELDCONVERTER` is enabled. +- `WITH_TRADE` --- Build the @ref Trade library. There are more involved component dependencies that are not described here (for example the @ref DebugTools has some functionality that gets built only when diff --git a/doc/changelog.dox b/doc/changelog.dox index 6b091d109..1ae8c9039 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -131,6 +131,11 @@ See also: @subsection changelog-latest-buildsystem Build system +- The core @ref Magnum library is not depending on OpenGL anymore, all + GL-related APIs are now part of a new @ref GL library +- @ref Primitives and @ref Trade libraries do not depend on OpenGL anymore +- @ref DebugTools, @ref MeshTools and @ref TextureTools have only an optional + dependency on the @ref GL library, controlled with `TARGET_GL` CMake option - All plugin interfaces now implement @ref Corrade::PluginManager::AbstractPlugin::pluginSearchPaths() "pluginSearchPaths()" for plugin directory autodetection --- you no longer need to specify the diff --git a/doc/namespaces.dox b/doc/namespaces.dox index e3199d33e..5e211d7df 100644 --- a/doc/namespaces.dox +++ b/doc/namespaces.dox @@ -280,6 +280,10 @@ find_package(Magnum REQUIRED MeshTools) target_link_libraries(your-app Magnum::MeshTools) @endcode +Note that functionality depending on @ref GL APIs is available only if Magnum +is built with both `WITH_GL` and `TARGET_GL` enabled (which is done by +default). + See @ref building and @ref cmake for more information. */ @@ -417,6 +421,10 @@ find_package(Magnum REQUIRED TextureTools) target_link_libraries(your-app Magnum::TextureTools) @endcode +Note that functionality depending on @ref GL APIs is available only if Magnum +is built with both `WITH_GL` and `TARGET_GL` enabled (which is done by +default). + See @ref building and @ref cmake for more information. */ diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index 12efa879d..119d264f4 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -336,9 +336,16 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) if(_component STREQUAL Audio) # no inter-component dependencies elseif(_component STREQUAL DebugTools) - set(_MAGNUM_${_COMPONENT}_DEPENDENCIES MeshTools Primitives SceneGraph Shaders Shapes Trade GL) + if(MAGNUM_TARGET_GL) + # MeshTools, Primitives, SceneGraph, Shaders and Shapes are used + # only for GL renderers + set(_MAGNUM_${_COMPONENT}_DEPENDENCIES MeshTools Primitives SceneGraph Shaders Shapes Trade GL) + endif() elseif(_component STREQUAL MeshTools) - set(_MAGNUM_${_COMPONENT}_DEPENDENCIES Trade GL) + if(MAGNUM_TARGET_GL) + # Trade is used only in compile(), which needs GL as well + set(_MAGNUM_${_COMPONENT}_DEPENDENCIES Trade GL) + endif() elseif(_component STREQUAL OpenGLTester) if(MAGNUM_TARGET_HEADLESS OR CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_ANDROID) set(_MAGNUM_${_COMPONENT}_DEPENDENCIES WindowlessEglApplication GL) @@ -360,7 +367,7 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) endif() endif() elseif(_component STREQUAL Primitives) - set(_MAGNUM_${_COMPONENT}_DEPENDENCIES Trade GL) + set(_MAGNUM_${_COMPONENT}_DEPENDENCIES Trade) elseif(_component STREQUAL SceneGraph) # no dependencies except for the main lib elseif(_component STREQUAL Shaders) @@ -370,9 +377,11 @@ foreach(_component ${Magnum_FIND_COMPONENTS}) elseif(_component STREQUAL Text) set(_MAGNUM_${_COMPONENT}_DEPENDENCIES TextureTools GL) elseif(_component STREQUAL TextureTools) - set(_MAGNUM_${_COMPONENT}_DEPENDENCIES GL) + if(MAGNUM_TARGET_GL) + set(_MAGNUM_${_COMPONENT}_DEPENDENCIES GL) + endif() elseif(_component STREQUAL Trade) - set(_MAGNUM_${_COMPONENT}_DEPENDENCIES GL) + # no dependencies except for the main lib elseif(_component STREQUAL AndroidApplication) set(_MAGNUM_${_COMPONENT}_DEPENDENCIES GL) elseif(_component STREQUAL GlfwApplication) diff --git a/src/Magnum/DebugTools/BufferData.h b/src/Magnum/DebugTools/BufferData.h index e4b402a17..f4783444e 100644 --- a/src/Magnum/DebugTools/BufferData.h +++ b/src/Magnum/DebugTools/BufferData.h @@ -25,7 +25,7 @@ DEALINGS IN THE SOFTWARE. */ -#ifndef MAGNUM_TARGET_WEBGL +#if defined(MAGNUM_TARGET_GL) && !defined(MAGNUM_TARGET_WEBGL) /** @file * @brief Function @ref Magnum::DebugTools::bufferData(), @ref Magnum::DebugTools::bufferSubData() */ @@ -36,7 +36,7 @@ #include "Magnum/GL/Buffer.h" #include "Magnum/DebugTools/visibility.h" -#ifndef MAGNUM_TARGET_WEBGL +#if defined(MAGNUM_TARGET_GL) && !defined(MAGNUM_TARGET_WEBGL) namespace Magnum { namespace DebugTools { namespace Implementation { @@ -48,6 +48,11 @@ namespace Implementation { Emulates @ref GL::Buffer::subData() call on platforms that don't support it (such as OpenGL ES) by using @ref GL::Buffer::map(). + +@note This function is available only if Magnum is compiled with + @ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features + for more information. + @requires_gles30 Extension @extension{EXT,map_buffer_range} in OpenGL ES 2.0. @requires_gles Buffer mapping is not available in WebGL. @@ -63,6 +68,11 @@ template Containers::Array inline bufferSubData(GL::Buffer& buffer, Emulates @ref GL::Buffer::data() call on platforms that don't support it (such as OpenGL ES) by using @ref GL::Buffer::map(). + +@note This function is available only if Magnum is compiled with + @ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features + for more information. + @requires_gles30 Extension @extension{EXT,map_buffer_range} in OpenGL ES 2.0. @requires_gles Buffer mapping is not available in WebGL. @@ -75,7 +85,7 @@ template Containers::Array inline bufferData(GL::Buffer& buff }} #else -#error this header is not available in WebGL build +#error this header is available only in the OpenGL (ES) build and not available in the WebGL build #endif #endif diff --git a/src/Magnum/DebugTools/CMakeLists.txt b/src/Magnum/DebugTools/CMakeLists.txt index 29b03a9e9..50587589b 100644 --- a/src/Magnum/DebugTools/CMakeLists.txt +++ b/src/Magnum/DebugTools/CMakeLists.txt @@ -24,23 +24,82 @@ # set(MagnumDebugTools_SRCS - Profiler.cpp - ResourceManager.cpp - TextureImage.cpp) + Profiler.cpp) set(MagnumDebugTools_HEADERS DebugTools.h - Profiler.h - ResourceManager.h - TextureImage.h - visibility.h) + Profiler.h) # Header files to display in project view of IDEs only set(MagnumDebugTools_PRIVATE_HEADERS ) -if(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_GLES2) - corrade_add_resource(MagnumDebugTools_RESOURCES resources.conf) - list(APPEND MagnumDebugTools_SRCS ${MagnumDebugTools_RESOURCES}) +if(TARGET_GL) + list(APPEND MagnumDebugTools_SRCS + ResourceManager.cpp + TextureImage.cpp) + + list(APPEND MagnumDebugTools_HEADERS + ResourceManager.h + TextureImage.h + visibility.h) + + if(MAGNUM_TARGET_GLES AND NOT MAGNUM_TARGET_GLES2) + corrade_add_resource(MagnumDebugTools_RESOURCES resources.conf) + list(APPEND MagnumDebugTools_SRCS ${MagnumDebugTools_RESOURCES}) + endif() + + if(NOT MAGNUM_TARGET_WEBGL) + list(APPEND MagnumDebugTools_SRCS + BufferData.cpp) + + list(APPEND MagnumDebugTools_HEADERS + BufferData.h) + endif() + + if(WITH_SCENEGRAPH) + list(APPEND MagnumDebugTools_SRCS + ForceRenderer.cpp + ObjectRenderer.cpp) + + list(APPEND MagnumDebugTools_HEADERS + ForceRenderer.h + ObjectRenderer.h) + + list(APPEND MagnumDebugTools_PRIVATE_HEADERS + Implementation/ForceRendererTransformation.h) + endif() + + if(WITH_SHAPES) + list(APPEND MagnumDebugTools_SRCS + ShapeRenderer.cpp + + Implementation/AbstractBoxRenderer.cpp + Implementation/AbstractShapeRenderer.cpp + Implementation/AxisAlignedBoxRenderer.cpp + Implementation/BoxRenderer.cpp + Implementation/CapsuleRenderer.cpp + Implementation/CylinderRenderer.cpp + Implementation/LineSegmentRenderer.cpp + Implementation/PointRenderer.cpp + Implementation/SphereRenderer.cpp) + + list(APPEND MagnumDebugTools_HEADERS + ShapeRenderer.h) + + list(APPEND MagnumDebugTools_PRIVATE_HEADERS + Implementation/AbstractBoxRenderer.h + Implementation/AbstractShapeRenderer.h + Implementation/AxisAlignedBoxRenderer.h + Implementation/BoxRenderer.h + Implementation/CapsuleRenderer.h + Implementation/CapsuleRendererTransformation.h + Implementation/CylinderRenderer.h + Implementation/CylinderRendererTransformation.h + Implementation/LineSegmentRenderer.h + Implementation/LineSegmentRendererTransformation.h + Implementation/PointRenderer.h + Implementation/SphereRenderer.h) + endif() endif() # Build the TestSuite-related functionality only if it is present @@ -53,59 +112,6 @@ if(Corrade_TestSuite_FOUND) CompareImage.h) endif() -if(NOT MAGNUM_TARGET_WEBGL) - list(APPEND MagnumDebugTools_SRCS - BufferData.cpp) - - list(APPEND MagnumDebugTools_HEADERS - BufferData.h) -endif() - -if(WITH_SCENEGRAPH) - list(APPEND MagnumDebugTools_SRCS - ForceRenderer.cpp - ObjectRenderer.cpp) - - list(APPEND MagnumDebugTools_HEADERS - ForceRenderer.h - ObjectRenderer.h) - - list(APPEND MagnumDebugTools_PRIVATE_HEADERS - Implementation/ForceRendererTransformation.h) -endif() - -if(WITH_SHAPES) - list(APPEND MagnumDebugTools_SRCS - ShapeRenderer.cpp - - Implementation/AbstractBoxRenderer.cpp - Implementation/AbstractShapeRenderer.cpp - Implementation/AxisAlignedBoxRenderer.cpp - Implementation/BoxRenderer.cpp - Implementation/CapsuleRenderer.cpp - Implementation/CylinderRenderer.cpp - Implementation/LineSegmentRenderer.cpp - Implementation/PointRenderer.cpp - Implementation/SphereRenderer.cpp) - - list(APPEND MagnumDebugTools_HEADERS - ShapeRenderer.h) - - list(APPEND MagnumDebugTools_PRIVATE_HEADERS - Implementation/AbstractBoxRenderer.h - Implementation/AbstractShapeRenderer.h - Implementation/AxisAlignedBoxRenderer.h - Implementation/BoxRenderer.h - Implementation/CapsuleRenderer.h - Implementation/CapsuleRendererTransformation.h - Implementation/CylinderRenderer.h - Implementation/CylinderRendererTransformation.h - Implementation/LineSegmentRenderer.h - Implementation/LineSegmentRendererTransformation.h - Implementation/PointRenderer.h - Implementation/SphereRenderer.h) -endif() - # DebugTools library add_library(MagnumDebugTools ${SHARED_OR_STATIC} ${MagnumDebugTools_SRCS} @@ -119,22 +125,23 @@ if(NOT BUILD_STATIC) elseif(BUILD_STATIC_PIC) set_target_properties(MagnumDebugTools PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() -target_link_libraries(MagnumDebugTools PUBLIC - Magnum - MagnumGL) +target_link_libraries(MagnumDebugTools PUBLIC Magnum) if(Corrade_TestSuite_FOUND) target_link_libraries(MagnumDebugTools PUBLIC Corrade::TestSuite) endif() -if(WITH_SCENEGRAPH) - target_link_libraries(MagnumDebugTools PUBLIC MagnumSceneGraph) -endif() -if(WITH_SHAPES) - target_link_libraries(MagnumDebugTools PUBLIC MagnumShapes MagnumPrimitives) -endif() -if(WITH_SCENEGRAPH OR WITH_SHAPES) - target_link_libraries(MagnumDebugTools PUBLIC - MagnumMeshTools - MagnumShaders) +if(TARGET_GL) + target_link_libraries(MagnumDebugTools PUBLIC MagnumGL) + if(WITH_SCENEGRAPH) + target_link_libraries(MagnumDebugTools PUBLIC MagnumSceneGraph) + endif() + if(WITH_SHAPES) + target_link_libraries(MagnumDebugTools PUBLIC MagnumShapes MagnumPrimitives) + endif() + if(WITH_SCENEGRAPH OR WITH_SHAPES) + target_link_libraries(MagnumDebugTools PUBLIC + MagnumMeshTools + MagnumShaders) + endif() endif() install(TARGETS MagnumDebugTools diff --git a/src/Magnum/DebugTools/DebugTools.h b/src/Magnum/DebugTools/DebugTools.h index 956cc1724..cbc2c0f26 100644 --- a/src/Magnum/DebugTools/DebugTools.h +++ b/src/Magnum/DebugTools/DebugTools.h @@ -34,6 +34,9 @@ namespace Magnum { namespace DebugTools { #ifndef DOXYGEN_GENERATING_OUTPUT +class Profiler; + +#ifdef MAGNUM_TARGET_GL template class ForceRenderer; typedef ForceRenderer<2> ForceRenderer2D; typedef ForceRenderer<3> ForceRenderer3D; @@ -44,7 +47,6 @@ typedef ObjectRenderer<2> ObjectRenderer2D; typedef ObjectRenderer<3> ObjectRenderer3D; class ObjectRendererOptions; -class Profiler; class ResourceManager; template class ShapeRenderer; @@ -52,6 +54,7 @@ typedef ShapeRenderer<2> ShapeRenderer2D; typedef ShapeRenderer<3> ShapeRenderer3D; class ShapeRendererOptions; #endif +#endif }} diff --git a/src/Magnum/DebugTools/ForceRenderer.h b/src/Magnum/DebugTools/ForceRenderer.h index 92018ce99..e6519ba91 100644 --- a/src/Magnum/DebugTools/ForceRenderer.h +++ b/src/Magnum/DebugTools/ForceRenderer.h @@ -25,9 +25,11 @@ DEALINGS IN THE SOFTWARE. */ +#ifdef MAGNUM_TARGET_GL /** @file * @brief Class @ref Magnum::DebugTools::ForceRenderer, @ref Magnum::DebugTools::ForceRendererOptions, typedef @ref Magnum::DebugTools::ForceRenderer2D, @ref Magnum::DebugTools::ForceRenderer3D */ +#endif #include "Magnum/Resource.h" #include "Magnum/GL/GL.h" @@ -36,12 +38,17 @@ #include "Magnum/Shaders/Shaders.h" #include "Magnum/DebugTools/visibility.h" +#ifdef MAGNUM_TARGET_GL namespace Magnum { namespace DebugTools { /** @brief Force renderer options See @ref ForceRenderer documentation for more information. + +@note This class is available only if Magnum is compiled with + @ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features + for more information. */ class ForceRendererOptions { public: @@ -101,6 +108,10 @@ Vector3 force; new DebugTools::ForceRenderer2D(object, {0.3f, 1.5f, -0.7f}, &force, "my", debugDrawables); @endcode +@note This class is available only if Magnum is compiled with + @ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features + for more information. + @see @ref ForceRenderer2D, @ref ForceRenderer3D, @ref ForceRendererOptions */ template class MAGNUM_DEBUGTOOLS_EXPORT ForceRenderer: public SceneGraph::Drawable { @@ -148,5 +159,8 @@ typedef ForceRenderer<2> ForceRenderer2D; typedef ForceRenderer<3> ForceRenderer3D; }} +#else +#error this header is available only in the OpenGL build +#endif #endif diff --git a/src/Magnum/DebugTools/ObjectRenderer.h b/src/Magnum/DebugTools/ObjectRenderer.h index 275b88eb7..115dd4170 100644 --- a/src/Magnum/DebugTools/ObjectRenderer.h +++ b/src/Magnum/DebugTools/ObjectRenderer.h @@ -25,9 +25,11 @@ DEALINGS IN THE SOFTWARE. */ +#ifdef MAGNUM_TARGET_GL /** @file * @brief Class @ref Magnum::DebugTools::ObjectRenderer, @ref Magnum::DebugTools::ObjectRendererOptions, typedef @ref Magnum::DebugTools::ObjectRenderer2D, @ref Magnum::DebugTools::ObjectRenderer3D */ +#endif #include "Magnum/Resource.h" #include "Magnum/DebugTools/visibility.h" @@ -35,12 +37,17 @@ #include "Magnum/SceneGraph/Drawable.h" #include "Magnum/Shaders/Shaders.h" +#ifdef MAGNUM_TARGET_GL namespace Magnum { namespace DebugTools { /** @brief Object renderer options See @ref ObjectRenderer documentation for more information. + +@note This class is available only if Magnum is compiled with + @ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features + for more information. */ class ObjectRendererOptions { public: @@ -83,6 +90,10 @@ Object3D* object; new DebugTools::ObjectRenderer2D(object, "my", debugDrawables); @endcode +@note This class is available only if Magnum is compiled with + @ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features + for more information. + @see @ref ObjectRenderer2D, @ref ObjectRenderer3D, @ref ObjectRendererOptions */ template class MAGNUM_DEBUGTOOLS_EXPORT ObjectRenderer: public SceneGraph::Drawable { @@ -117,5 +128,8 @@ typedef ObjectRenderer<2> ObjectRenderer2D; typedef ObjectRenderer<3> ObjectRenderer3D; }} +#else +#error this header is available only in the OpenGL build +#endif #endif diff --git a/src/Magnum/DebugTools/ResourceManager.h b/src/Magnum/DebugTools/ResourceManager.h index 69333dbf8..a4d5458a6 100644 --- a/src/Magnum/DebugTools/ResourceManager.h +++ b/src/Magnum/DebugTools/ResourceManager.h @@ -25,9 +25,11 @@ DEALINGS IN THE SOFTWARE. */ +#ifdef MAGNUM_TARGET_GL /** @file * @brief Class @ref Magnum::DebugTools::ResourceManager */ +#endif #include "Magnum/ResourceManager.h" @@ -49,21 +51,27 @@ #include "Magnum/GL/MeshView.h" #endif -namespace Magnum { - -namespace DebugTools { +#ifdef MAGNUM_TARGET_GL +namespace Magnum { namespace DebugTools { /** @brief Resource manager for debug tools Stores various data used by debug renderers. See @ref debug-tools for more information. + +@note This class is available only if Magnum is compiled with + @ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features + for more information. */ class MAGNUM_DEBUGTOOLS_EXPORT ResourceManager: public Magnum::ResourceManager { public: explicit ResourceManager(); ~ResourceManager(); }; +#else +#error this header is available only in the OpenGL build +#endif }} diff --git a/src/Magnum/DebugTools/ShapeRenderer.h b/src/Magnum/DebugTools/ShapeRenderer.h index 60e39a12e..922a025ee 100644 --- a/src/Magnum/DebugTools/ShapeRenderer.h +++ b/src/Magnum/DebugTools/ShapeRenderer.h @@ -25,9 +25,11 @@ DEALINGS IN THE SOFTWARE. */ +#ifdef MAGNUM_TARGET_GL /** @file * @brief Class @ref Magnum::DebugTools::ShapeRenderer, @ref Magnum::DebugTools::ShapeRendererOptions, typedef @ref Magnum::DebugTools::ShapeRenderer2D, @ref Magnum::DebugTools::ShapeRenderer3D */ +#endif #include "Magnum/Resource.h" #include "Magnum/Math/Color.h" @@ -36,6 +38,7 @@ #include "Magnum/Shapes/shapeImplementation.h" #include "Magnum/DebugTools/visibility.h" +#ifdef MAGNUM_TARGET_GL namespace Magnum { namespace DebugTools { template class ShapeRenderer; @@ -50,6 +53,10 @@ namespace Implementation { @brief Shape renderer options See @ref ShapeRenderer documentation for more information. + +@note This class is available only if Magnum is compiled with + @ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features + for more information. */ class ShapeRendererOptions { public: @@ -134,6 +141,10 @@ Shapes::AbstractShape2D* shape; new DebugTools::ShapeRenderer2D(shape, "red", debugDrawables); @endcode +@note This class is available only if Magnum is compiled with + @ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features + for more information. + @see @ref ShapeRenderer2D, @ref ShapeRenderer3D, @ref ShapeRendererOptions @todo Different drawing style for inverted shapes? (marking the "inside" somehow) @@ -174,5 +185,8 @@ typedef ShapeRenderer<2> ShapeRenderer2D; typedef ShapeRenderer<3> ShapeRenderer3D; }} +#else +#error this header is available only in the OpenGL build +#endif #endif diff --git a/src/Magnum/DebugTools/Test/CMakeLists.txt b/src/Magnum/DebugTools/Test/CMakeLists.txt index f06c9b2c6..6299c862d 100644 --- a/src/Magnum/DebugTools/Test/CMakeLists.txt +++ b/src/Magnum/DebugTools/Test/CMakeLists.txt @@ -23,35 +23,37 @@ # DEALINGS IN THE SOFTWARE. # -if(WITH_SHAPES) - corrade_add_test(DebugToolsCapsuleRendererTest CapsuleRendererTest.cpp LIBRARIES MagnumMathTestLib) - corrade_add_test(DebugToolsCylinderRendererTest CylinderRendererTest.cpp LIBRARIES MagnumMathTestLib) - corrade_add_test(DebugToolsLineSegmentRendererTest LineSegmentRendererTest.cpp LIBRARIES MagnumMathTestLib) - - set_target_properties( - DebugToolsCapsuleRendererTest - DebugToolsCylinderRendererTest - DebugToolsLineSegmentRendererTest - PROPERTIES FOLDER "Magnum/DebugTools/Test") -endif() - -if(WITH_SCENEGRAPH) - corrade_add_test(DebugToolsForceRendererTest ForceRendererTest.cpp LIBRARIES MagnumMathTestLib) - set_target_properties(DebugToolsForceRendererTest PROPERTIES FOLDER "Magnum/DebugTools/Test") -endif() - if(Corrade_TestSuite_FOUND) corrade_add_test(DebugToolsCompareImageTest CompareImageTest.cpp LIBRARIES MagnumDebugTools) set_target_properties(DebugToolsCompareImageTest PROPERTIES FOLDER "Magnum/DebugTools/Test") endif() -if(BUILD_GL_TESTS) - corrade_add_test(DebugToolsTextureImageGLTest TextureImageGLTest.cpp LIBRARIES MagnumDebugTools MagnumOpenGLTester) - set_target_properties(DebugToolsTextureImageGLTest PROPERTIES FOLDER "Magnum/DebugTools/Test") +if(TARGET_GL) + if(WITH_SHAPES) + corrade_add_test(DebugToolsCapsuleRendererTest CapsuleRendererTest.cpp LIBRARIES MagnumMathTestLib) + corrade_add_test(DebugToolsCylinderRendererTest CylinderRendererTest.cpp LIBRARIES MagnumMathTestLib) + corrade_add_test(DebugToolsLineSegmentRendererTest LineSegmentRendererTest.cpp LIBRARIES MagnumMathTestLib) + + set_target_properties( + DebugToolsCapsuleRendererTest + DebugToolsCylinderRendererTest + DebugToolsLineSegmentRendererTest + PROPERTIES FOLDER "Magnum/DebugTools/Test") + endif() + + if(WITH_SCENEGRAPH) + corrade_add_test(DebugToolsForceRendererTest ForceRendererTest.cpp LIBRARIES MagnumMathTestLib) + set_target_properties(DebugToolsForceRendererTest PROPERTIES FOLDER "Magnum/DebugTools/Test") + endif() + + if(BUILD_GL_TESTS) + corrade_add_test(DebugToolsTextureImageGLTest TextureImageGLTest.cpp LIBRARIES MagnumDebugTools MagnumOpenGLTester) + set_target_properties(DebugToolsTextureImageGLTest PROPERTIES FOLDER "Magnum/DebugTools/Test") - if(NOT (MAGNUM_TARGET_GLES2 AND MAGNUM_TARGET_WEBGL)) - corrade_add_test(DebugToolsBufferDataGLTest BufferDataGLTest.cpp LIBRARIES MagnumDebugTools MagnumOpenGLTester) + if(NOT (MAGNUM_TARGET_GLES2 AND MAGNUM_TARGET_WEBGL)) + corrade_add_test(DebugToolsBufferDataGLTest BufferDataGLTest.cpp LIBRARIES MagnumDebugTools MagnumOpenGLTester) - set_target_properties(DebugToolsBufferDataGLTest PROPERTIES FOLDER "Magnum/DebugTools/Test") + set_target_properties(DebugToolsBufferDataGLTest PROPERTIES FOLDER "Magnum/DebugTools/Test") + endif() endif() endif() diff --git a/src/Magnum/MeshTools/CMakeLists.txt b/src/Magnum/MeshTools/CMakeLists.txt index ff1797fd5..462b33ef8 100644 --- a/src/Magnum/MeshTools/CMakeLists.txt +++ b/src/Magnum/MeshTools/CMakeLists.txt @@ -25,8 +25,6 @@ # Files shared between main library and unit test library set(MagnumMeshTools_SRCS - Compile.cpp - FullScreenTriangle.cpp Tipsify.cpp) # Files compiled with different flags for main library and unit test library @@ -38,11 +36,9 @@ set(MagnumMeshTools_GracefulAssert_SRCS set(MagnumMeshTools_HEADERS CombineIndexedArrays.h - Compile.h CompressIndices.h Duplicate.h FlipNormals.h - FullScreenTriangle.h GenerateFlatNormals.h Interleave.h RemoveDuplicates.h @@ -52,11 +48,21 @@ set(MagnumMeshTools_HEADERS visibility.h) +if(TARGET_GL) + list(APPEND MagnumMeshTools_SRCS + Compile.cpp + FullScreenTriangle.cpp) + + list(APPEND MagnumMeshTools_HEADERS + Compile.h + FullScreenTriangle.h) +endif() + # Objects shared between main and test library add_library(MagnumMeshToolsObjects OBJECT ${MagnumMeshTools_SRCS} ${MagnumMeshTools_HEADERS}) -target_include_directories(MagnumMeshToolsObjects PUBLIC $) +target_include_directories(MagnumMeshToolsObjects PUBLIC $) if(NOT BUILD_STATIC) target_compile_definitions(MagnumMeshToolsObjects PRIVATE "MagnumMeshToolsObjects_EXPORTS") endif() @@ -64,6 +70,9 @@ if(NOT BUILD_STATIC OR BUILD_STATIC_PIC) set_target_properties(MagnumMeshToolsObjects PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() set_target_properties(MagnumMeshToolsObjects PROPERTIES FOLDER "Magnum/MeshTools") +if(TARGET_GL) + target_include_directories(MagnumMeshToolsObjects PUBLIC $) +endif() # Main MeshTools library add_library(MagnumMeshTools ${SHARED_OR_STATIC} @@ -78,8 +87,10 @@ elseif(BUILD_STATIC_PIC) set_target_properties(MagnumMeshTools PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() target_link_libraries(MagnumMeshTools PUBLIC - Magnum - MagnumTrade) + Magnum) +if(TARGET_GL) + target_link_libraries(MagnumMeshTools PUBLIC MagnumGL MagnumTrade) +endif() install(TARGETS MagnumMeshTools RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} @@ -101,8 +112,10 @@ if(BUILD_TESTS) set_target_properties(MagnumMeshToolsTestLib PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() target_link_libraries(MagnumMeshToolsTestLib PUBLIC - Magnum - MagnumTrade) + Magnum) + if(TARGET_GL) + target_link_libraries(MagnumMeshToolsTestLib PUBLIC MagnumGL MagnumTrade) + endif() # On Windows we need to install first and then run the tests to avoid "DLL # not found" hell, thus we need to install this too diff --git a/src/Magnum/MeshTools/Compile.h b/src/Magnum/MeshTools/Compile.h index c53163e27..13145cc95 100644 --- a/src/Magnum/MeshTools/Compile.h +++ b/src/Magnum/MeshTools/Compile.h @@ -29,6 +29,9 @@ * @brief Function @ref Magnum::MeshTools::compile() */ +#include "Magnum/configure.h" + +#ifdef MAGNUM_TARGET_GL #include #include @@ -55,6 +58,10 @@ This is just a convenience function for creating generic meshes, you might want to use @ref interleave() and @ref compressIndices() functions instead for greater flexibility. +@note This function is available only if Magnum is compiled with + @ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features + for more information. + @see @ref shaders-generic */ MAGNUM_MESHTOOLS_EXPORT std::tuple, std::unique_ptr> compile(const Trade::MeshData2D& meshData, GL::BufferUsage usage); @@ -76,10 +83,17 @@ This is just a convenience function for creating generic meshes, you might want to use @ref interleave() and @ref compressIndices() functions instead for greater flexibility. +@note This function is available only if Magnum is compiled with + @ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features + for more information. + @see @ref shaders-generic */ MAGNUM_MESHTOOLS_EXPORT std::tuple, std::unique_ptr> compile(const Trade::MeshData3D& meshData, GL::BufferUsage usage); }} +#else +#error this header is available only in the OpenGL build +#endif #endif diff --git a/src/Magnum/MeshTools/CompressIndices.h b/src/Magnum/MeshTools/CompressIndices.h index e9015cb3f..2d8c79184 100644 --- a/src/Magnum/MeshTools/CompressIndices.h +++ b/src/Magnum/MeshTools/CompressIndices.h @@ -30,6 +30,7 @@ */ #include +#include #include "Magnum/Mesh.h" #include "Magnum/MeshTools/visibility.h" diff --git a/src/Magnum/MeshTools/FullScreenTriangle.h b/src/Magnum/MeshTools/FullScreenTriangle.h index eefe5986b..9a8a5c1c1 100644 --- a/src/Magnum/MeshTools/FullScreenTriangle.h +++ b/src/Magnum/MeshTools/FullScreenTriangle.h @@ -25,10 +25,15 @@ DEALINGS IN THE SOFTWARE. */ +#ifdef MAGNUM_TARGET_GL /** @file * @brief Function @ref Magnum::MeshTools::fullScreenTriangle() */ +#endif + +#include "Magnum/configure.h" +#ifdef MAGNUM_TARGET_GL #include #include @@ -79,15 +84,25 @@ void main() { #endif } @endcode + +@note This function is available only if Magnum is compiled with + @ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features + for more information. */ std::pair, GL::Mesh> MAGNUM_MESHTOOLS_EXPORT fullScreenTriangle(GL::Version version); -/** -@overload +/** @overload This function implicitly uses current context version. + +@note This function is available only if Magnum is compiled with + @ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features + for more information. */ std::pair, GL::Mesh> MAGNUM_MESHTOOLS_EXPORT fullScreenTriangle(); +#else +#error this header is available only in the OpenGL build +#endif }} diff --git a/src/Magnum/TextureTools/CMakeLists.txt b/src/Magnum/TextureTools/CMakeLists.txt index 1ef8c736b..550c3fa17 100644 --- a/src/Magnum/TextureTools/CMakeLists.txt +++ b/src/Magnum/TextureTools/CMakeLists.txt @@ -23,20 +23,25 @@ # DEALINGS IN THE SOFTWARE. # -corrade_add_resource(MagnumTextureTools_RCS resources.conf) -set_target_properties(MagnumTextureTools_RCS-dependencies PROPERTIES FOLDER "Magnum/TextureTools") - set(MagnumTextureTools_SRCS - Atlas.cpp - DistanceField.cpp - ${MagnumTextureTools_RCS}) + Atlas.cpp) set(MagnumTextureTools_HEADERS Atlas.h - DistanceField.h visibility.h) +if(TARGET_GL) + corrade_add_resource(MagnumTextureTools_RCS resources.conf) + set_target_properties(MagnumTextureTools_RCS-dependencies PROPERTIES FOLDER "Magnum/TextureTools") + + list(APPEND MagnumTextureTools_SRCS + DistanceField.cpp + ${MagnumTextureTools_RCS}) + + list(APPEND MagnumTextureTools_HEADERS DistanceField.h) +endif() + # TextureTools library add_library(MagnumTextureTools ${SHARED_OR_STATIC} ${MagnumTextureTools_SRCS} @@ -50,8 +55,10 @@ elseif(BUILD_STATIC_PIC) set_target_properties(MagnumTextureTools PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() target_link_libraries(MagnumTextureTools PUBLIC - Magnum - MagnumGL) + Magnum) +if(WITH_GL) + target_link_libraries(MagnumTextureTools PUBLIC MagnumGL) +endif() install(TARGETS MagnumTextureTools RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} diff --git a/src/Magnum/TextureTools/DistanceField.h b/src/Magnum/TextureTools/DistanceField.h index b7cf643ab..983620c8d 100644 --- a/src/Magnum/TextureTools/DistanceField.h +++ b/src/Magnum/TextureTools/DistanceField.h @@ -29,6 +29,9 @@ * @brief Function @ref Magnum::TextureTools::distanceField() */ +#include "Magnum/configure.h" + +#ifdef MAGNUM_TARGET_GL #include "Magnum/Magnum.h" #include "Magnum/GL/GL.h" #ifndef MAGNUM_TARGET_GLES @@ -92,6 +95,10 @@ http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_AlphaTestedMagnifica rendering to @ref GL::TextureFormat::Luminance is not supported in most cases. +@note This function is available only if Magnum is compiled with + @ref MAGNUM_TARGET_GL enabled (done by default). See @ref building-features + for more information. + @bug ES (and maybe GL < 3.20) implementation behaves slightly different (jaggies, visible e.g. when rendering outlined fonts) */ @@ -102,5 +109,8 @@ void MAGNUM_TEXTURETOOLS_EXPORT distanceField(GL::Texture2D& input, GL::Texture2 #endif }} +#else +#error this header is available only in the OpenGL build +#endif #endif diff --git a/src/Magnum/Trade/CMakeLists.txt b/src/Magnum/Trade/CMakeLists.txt index 6384715e0..e4dbc704e 100644 --- a/src/Magnum/Trade/CMakeLists.txt +++ b/src/Magnum/Trade/CMakeLists.txt @@ -74,7 +74,6 @@ add_library(MagnumTradeObjects OBJECT ${MagnumTrade_HEADERS}) target_include_directories(MagnumTradeObjects PUBLIC $ - $ $) if(NOT BUILD_STATIC) target_compile_definitions(MagnumTradeObjects PRIVATE "MagnumTradeObjects_EXPORTS") @@ -98,7 +97,6 @@ elseif(BUILD_STATIC_PIC) endif() target_link_libraries(MagnumTrade PUBLIC Magnum - MagnumGL Corrade::PluginManager) install(TARGETS MagnumTrade @@ -138,7 +136,6 @@ if(BUILD_TESTS) endif() target_link_libraries(MagnumTradeTestLib Magnum - MagnumGL Corrade::PluginManager) # On Windows we need to install first and then run the tests to avoid "DLL