From 23dd34e0f445fbb2ba8e47d76f1c14284c918f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 9 Jul 2014 22:52:24 +0200 Subject: [PATCH 01/32] TgaImporter: use better-defined type. Commit mosra/corrade@9485ef7effd6c8241e03982c53e8fabfe260b525 broke this, apparently the compiler can't decide which overload to select when a type has implicit conversion to another type which is then supported by both Debug and std::ostream operator<<. Working around this for now as it is the only case, hopefully we won't run into something similar later. --- src/MagnumPlugins/TgaImporter/TgaImporter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MagnumPlugins/TgaImporter/TgaImporter.cpp b/src/MagnumPlugins/TgaImporter/TgaImporter.cpp index 9c4fd161c..28d6d311d 100644 --- a/src/MagnumPlugins/TgaImporter/TgaImporter.cpp +++ b/src/MagnumPlugins/TgaImporter/TgaImporter.cpp @@ -79,9 +79,9 @@ UnsignedInt TgaImporter::doImage2DCount() const { return 1; } std::optional TgaImporter::doImage2D(UnsignedInt) { /* Check if the file is long enough */ in->seekg(0, std::istream::end); - std::streampos filesize = in->tellg(); + std::streamoff filesize = in->tellg(); in->seekg(0, std::istream::beg); - if(filesize < std::streampos(sizeof(TgaHeader))) { + if(filesize < std::streamoff(sizeof(TgaHeader))) { Error() << "Trade::TgaImporter::image2D(): the file is too short:" << filesize << "bytes"; return std::nullopt; } From dfb697dd0c676394ddd4fd98f6e2bc315046fd4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 10 Jul 2014 00:58:33 +0200 Subject: [PATCH 02/32] CMake 3.0 compatibility: use AppleClang for Clang on OS X. Different name because of different version numbers. Also we need to stay compatible with <3.0, which defines it as "Clang" only. --- src/MagnumExternal/OpenGL/GL/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MagnumExternal/OpenGL/GL/CMakeLists.txt b/src/MagnumExternal/OpenGL/GL/CMakeLists.txt index 2e5a98c50..450b9cca6 100644 --- a/src/MagnumExternal/OpenGL/GL/CMakeLists.txt +++ b/src/MagnumExternal/OpenGL/GL/CMakeLists.txt @@ -25,7 +25,7 @@ add_library(MagnumGLLoadGenObjects OBJECT gl_magnum.c) -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang") set_target_properties(MagnumGLLoadGenObjects PROPERTIES COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} -fvisibility=hidden -DGLLoadGen_EXPORTS") else() set_target_properties(MagnumGLLoadGenObjects PROPERTIES COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} -DGLLoadGen_EXPORTS") From f74e68ec4e3623fe611bc826f45a4aaad3ea9c85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 21 Jul 2014 20:58:38 +0200 Subject: [PATCH 03/32] modules: bail out with proper message if Magnum is not found. Currently it failed on "error when trying to open configure.h", which is NOT a helpful message at all. Now we check for existence of the include dir before trying to open the file, thus failing with proper "Could NOT find Magnum" message. --- modules/FindMagnum.cmake | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index 55addc7aa..2c3552184 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -181,6 +181,15 @@ endif() find_path(MAGNUM_INCLUDE_DIR NAMES Magnum/Magnum.h) +# We need to open configure.h file from MAGNUM_INCLUDE_DIR before we check for +# the components. Bail out with proper error message if it wasn't found. The +# complete check with all components is further below. +if(NOT MAGNUM_INCLUDE_DIR) + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(Magnum + REQUIRED_VARS MAGNUM_LIBRARY MAGNUM_INCLUDE_DIR) +endif() + # Configuration file(READ ${MAGNUM_INCLUDE_DIR}/Magnum/configure.h _magnumConfigure) @@ -471,7 +480,7 @@ foreach(component ${Magnum_FIND_COMPONENTS}) endif() endforeach() -include(FindPackageHandleStandardArgs) +# Complete the check with also all components find_package_handle_standard_args(Magnum REQUIRED_VARS MAGNUM_LIBRARY MAGNUM_INCLUDE_DIR HANDLE_COMPONENTS) From a8817674bab9f35fe9c290396585aef7b908ac3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 21 Jul 2014 21:40:13 +0200 Subject: [PATCH 04/32] modules: no backticks in CMake documentation. That is only for Doxygen. Also improved the wording a bit. --- doc/cmake.dox | 2 +- modules/FindMagnum.cmake | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/cmake.dox b/doc/cmake.dox index da9e2b171..b586ae336 100644 --- a/doc/cmake.dox +++ b/doc/cmake.dox @@ -173,7 +173,7 @@ are also available as preprocessor variables if including If `MAGNUM_BUILD_DEPRECATED` is defined, the `MAGNUM_INCLUDE_DIR` variable also contains path directly to Magnum directory (i.e. for includes without `Magnum/` prefix) and `MAGNUM_PLUGINS_INCLUDE_DIR` contains include dir for plugins (i.e. -instead of `MagnumPlugins/` prefix). +for includes without `MagnumPlugins/` prefix). %Corrade library provides also its own set of CMake macros and variables, see @ref corrade-cmake "its documentation" for more information. diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index 2c3552184..b6b9f9e10 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -94,10 +94,10 @@ # emulation on desktop OpenGL # MAGNUM_TARGET_WEBGL - Defined if compiled for WebGL # -# If `MAGNUM_BUILD_DEPRECATED` is defined, the `MAGNUM_INCLUDE_DIR` variable -# also contains path directly to Magnum directory (i.e. for includes without -# `Magnum/` prefix) and `MAGNUM_PLUGINS_INCLUDE_DIR` contains include dir for -# plugins (i.e. instead of `MagnumPlugins/` prefix). +# If MAGNUM_BUILD_DEPRECATED is defined, the MAGNUM_INCLUDE_DIR variable also +# contains path directly to Magnum directory (i.e. for includes without +# Magnum/ prefix) and MAGNUM_PLUGINS_INCLUDE_DIR contains include dir for +# plugins (i.e. for includes without MagnumPlugins/ prefix). # # Additionally these variables are defined for internal usage: # MAGNUM_INCLUDE_DIR - Root include dir (w/o dependencies) From fb515177090b191062bd8a88236a3b065a67f35a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 21 Jul 2014 23:00:13 +0200 Subject: [PATCH 05/32] Audio: fix compilation on OSX. Broken since c7b23a884fabea1298ac4e68d7fa4e8da6ab31a6 (missing include). Thanks to @chris-chambers for the hint. --- src/Magnum/Audio/Audio.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Magnum/Audio/Audio.cpp b/src/Magnum/Audio/Audio.cpp index 90e4ea522..940d215c0 100644 --- a/src/Magnum/Audio/Audio.cpp +++ b/src/Magnum/Audio/Audio.cpp @@ -26,6 +26,7 @@ #include #include +#include "Corrade/configure.h" #include "Magnum/Types.h" namespace Magnum { namespace Audio { From bc81eb92d8b06abc7289246102aec3c5b8be6055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 22 Jul 2014 22:13:12 +0200 Subject: [PATCH 06/32] Added AbstractShaderProgram::attachShaders(). Convenience overload to attachShader(), allowing the user to specify more than one shader at once. Just a complement to initializer-list versions of compile() and link(), but without any performance difference. --- src/Magnum/AbstractShaderProgram.cpp | 4 ++++ src/Magnum/AbstractShaderProgram.h | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/src/Magnum/AbstractShaderProgram.cpp b/src/Magnum/AbstractShaderProgram.cpp index 2daf03574..dabc8b881 100644 --- a/src/Magnum/AbstractShaderProgram.cpp +++ b/src/Magnum/AbstractShaderProgram.cpp @@ -262,6 +262,10 @@ void AbstractShaderProgram::attachShader(Shader& shader) { glAttachShader(_id, shader.id()); } +void AbstractShaderProgram::attachShaders(std::initializer_list> shaders) { + for(Shader& s: shaders) attachShader(s); +} + void AbstractShaderProgram::bindAttributeLocation(UnsignedInt location, const std::string& name) { glBindAttribLocation(_id, location, name.data()); } diff --git a/src/Magnum/AbstractShaderProgram.h b/src/Magnum/AbstractShaderProgram.h index 0957857e1..9da0dc74f 100644 --- a/src/Magnum/AbstractShaderProgram.h +++ b/src/Magnum/AbstractShaderProgram.h @@ -614,6 +614,15 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject { */ void attachShader(Shader& shader); + /** + * @brief Attach shaders + * + * Convenience overload to the above, allowing the user to specify more + * than one shader at once. Other than that there is no other + * (performance) difference when using this function. + */ + void attachShaders(std::initializer_list> shaders); + /** * @brief Bind attribute to given location * @param location Location From 3be4422ded24cec3e5d027ba6de3b7c8f8d79225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 22 Jul 2014 22:17:58 +0200 Subject: [PATCH 07/32] Shaders: using attachShaders() everywhere. --- src/Magnum/Shaders/DistanceFieldVector.cpp | 3 +-- src/Magnum/Shaders/Flat.cpp | 3 +-- src/Magnum/Shaders/MeshVisualizer.cpp | 3 +-- src/Magnum/Shaders/Phong.cpp | 3 +-- src/Magnum/Shaders/Vector.cpp | 3 +-- src/Magnum/Shaders/VertexColor.cpp | 3 +-- 6 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/Magnum/Shaders/DistanceFieldVector.cpp b/src/Magnum/Shaders/DistanceFieldVector.cpp index 6479807ae..6faef96f9 100644 --- a/src/Magnum/Shaders/DistanceFieldVector.cpp +++ b/src/Magnum/Shaders/DistanceFieldVector.cpp @@ -59,8 +59,7 @@ template DistanceFieldVector::DistanceFieldV CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({frag, vert})); - AbstractShaderProgram::attachShader(frag); - AbstractShaderProgram::attachShader(vert); + AbstractShaderProgram::attachShaders({frag, vert}); #ifndef MAGNUM_TARGET_GLES if(!Context::current()->isExtensionSupported(version)) diff --git a/src/Magnum/Shaders/Flat.cpp b/src/Magnum/Shaders/Flat.cpp index 387e2c1f6..b75bf4d53 100644 --- a/src/Magnum/Shaders/Flat.cpp +++ b/src/Magnum/Shaders/Flat.cpp @@ -64,8 +64,7 @@ template Flat::Flat(const Flags flags): tran CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, frag})); - attachShader(vert); - attachShader(frag); + attachShaders({vert, frag}); #ifndef MAGNUM_TARGET_GLES if(!Context::current()->isExtensionSupported(version)) diff --git a/src/Magnum/Shaders/MeshVisualizer.cpp b/src/Magnum/Shaders/MeshVisualizer.cpp index 25155fc73..d5c78e570 100644 --- a/src/Magnum/Shaders/MeshVisualizer.cpp +++ b/src/Magnum/Shaders/MeshVisualizer.cpp @@ -87,8 +87,7 @@ MeshVisualizer::MeshVisualizer(const Flags flags): flags(flags), transformationP #endif Shader::compile({vert, frag}); - attachShader(vert); - attachShader(frag); + attachShaders({vert, frag}); #ifndef MAGNUM_TARGET_GLES if(geom) attachShader(*geom); #endif diff --git a/src/Magnum/Shaders/Phong.cpp b/src/Magnum/Shaders/Phong.cpp index 21f346d16..5ae33d71c 100644 --- a/src/Magnum/Shaders/Phong.cpp +++ b/src/Magnum/Shaders/Phong.cpp @@ -66,8 +66,7 @@ Phong::Phong(const Flags flags): transformationMatrixUniform(0), projectionMatri CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, frag})); - attachShader(vert); - attachShader(frag); + attachShaders({vert, frag}); #ifndef MAGNUM_TARGET_GLES if(!Context::current()->isExtensionSupported(version)) diff --git a/src/Magnum/Shaders/Vector.cpp b/src/Magnum/Shaders/Vector.cpp index c02411e5e..c3e855487 100644 --- a/src/Magnum/Shaders/Vector.cpp +++ b/src/Magnum/Shaders/Vector.cpp @@ -59,8 +59,7 @@ template Vector::Vector(): transformationPro CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, frag})); - AbstractShaderProgram::attachShader(vert); - AbstractShaderProgram::attachShader(frag); + AbstractShaderProgram::attachShaders({vert, frag}); #ifndef MAGNUM_TARGET_GLES if(!Context::current()->isExtensionSupported(version)) diff --git a/src/Magnum/Shaders/VertexColor.cpp b/src/Magnum/Shaders/VertexColor.cpp index fe4688f6f..f72450d4d 100644 --- a/src/Magnum/Shaders/VertexColor.cpp +++ b/src/Magnum/Shaders/VertexColor.cpp @@ -59,8 +59,7 @@ template VertexColor::VertexColor(): transfo CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, frag})); - attachShader(vert); - attachShader(frag); + attachShaders({vert, frag}); #ifndef MAGNUM_TARGET_GLES if(!Context::current()->isExtensionSupported(version)) From 824fc4974a7de938104a7f63a27e5848afddc9b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 22 Jul 2014 22:18:50 +0200 Subject: [PATCH 08/32] TextureTools: use threaded shader compilation also here. --- src/Magnum/TextureTools/DistanceField.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Magnum/TextureTools/DistanceField.cpp b/src/Magnum/TextureTools/DistanceField.cpp index 1145732bd..2542977f7 100644 --- a/src/Magnum/TextureTools/DistanceField.cpp +++ b/src/Magnum/TextureTools/DistanceField.cpp @@ -85,17 +85,17 @@ DistanceFieldShader::DistanceFieldShader(): radiusUniform(0), scalingUniform(1) #endif Shader vert(v, Shader::Type::Vertex); + Shader frag(v, Shader::Type::Fragment); + vert.addSource(rs.get("compatibility.glsl")) .addSource(rs.get("FullScreenTriangle.glsl")) .addSource(rs.get("DistanceFieldShader.vert")); - CORRADE_INTERNAL_ASSERT_OUTPUT(vert.compile()); - attachShader(vert); - - Shader frag(v, Shader::Type::Fragment); frag.addSource(rs.get("compatibility.glsl")) .addSource(rs.get("DistanceFieldShader.frag")); - CORRADE_INTERNAL_ASSERT_OUTPUT(frag.compile()); - attachShader(frag); + + CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, frag})); + + attachShaders({vert, frag}); /* Older GLSL doesn't have gl_VertexID, vertices must be supplied explicitly */ #ifndef MAGNUM_TARGET_GLES From 73404fc6e531f60f4146ebb902ba52589dd16f09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 22 Jul 2014 22:30:44 +0200 Subject: [PATCH 09/32] Added Renderer::enable()/disable(). Should be preferred to Renderer::setFeature() to avoid unnecessary branching. Also a bit shorter to write. --- src/Magnum/DebugMessage.h | 4 ++-- src/Magnum/Renderer.cpp | 10 +++++++++- src/Magnum/Renderer.h | 25 ++++++++++++++++++++++--- src/Magnum/SceneGraph/Drawable.h | 4 ++-- src/Magnum/Test/AbstractOpenGLTester.h | 4 ++-- src/Magnum/Test/DebugGLTest.cpp | 6 +++--- src/Magnum/Test/TimeQueryGLTest.cpp | 4 ++-- 7 files changed, 42 insertions(+), 15 deletions(-) diff --git a/src/Magnum/DebugMessage.h b/src/Magnum/DebugMessage.h index 217ebbc68..a213a1fb9 100644 --- a/src/Magnum/DebugMessage.h +++ b/src/Magnum/DebugMessage.h @@ -56,8 +56,8 @@ using @ref setCallback() or use the default one provided in @ref setDefaultCallback(): @code -Renderer::setFeature(Renderer::Feature::DebugOutput, true); -Renderer::setFeature(Renderer::Feature::DebugOutputSynchronous, true); +Renderer::enable(Renderer::Feature::DebugOutput); +Renderer::enable(Renderer::Feature::DebugOutputSynchronous); DebugMessage::setDefaultCallback(); DebugMessage::insert(DebugMessage::Source::Application, DebugMessage::Type::Marker, diff --git a/src/Magnum/Renderer.cpp b/src/Magnum/Renderer.cpp index e35a83c7f..9d68aab86 100644 --- a/src/Magnum/Renderer.cpp +++ b/src/Magnum/Renderer.cpp @@ -35,8 +35,16 @@ namespace Magnum { +void Renderer::enable(const Feature feature) { + glEnable(GLenum(feature)); +} + +void Renderer::disable(const Feature feature) { + glDisable(GLenum(feature)); +} + void Renderer::setFeature(const Feature feature, const bool enabled) { - enabled ? glEnable(GLenum(feature)) : glDisable(GLenum(feature)); + enabled ? enable(feature) : disable(feature); } void Renderer::setHint(const Hint target, const HintMode mode) { diff --git a/src/Magnum/Renderer.h b/src/Magnum/Renderer.h index bb90767ed..6df8f9513 100644 --- a/src/Magnum/Renderer.h +++ b/src/Magnum/Renderer.h @@ -74,7 +74,7 @@ class MAGNUM_EXPORT Renderer { * @brief Features * * All features are disabled by default unless specified otherwise. - * @see @ref setFeature() + * @see @ref enable(), @ref disable(), @ref setFeature() */ enum class Feature: GLenum { /** @@ -219,9 +219,28 @@ class MAGNUM_EXPORT Renderer { }; /** - * @brief Set feature + * @brief Enable feature * - * @see @fn_gl{Enable}/@fn_gl{Disable} + * @see @ref disable(), @ref setFeature(), @fn_gl{Enable} + */ + static void enable(Feature feature); + + /** + * @brief Disable feature + * + * @see @ref enable(), @ref setFeature(), @fn_gl{Disable} + */ + static void disable(Feature feature); + + /** + * @brief Enable or disable feature + * + * Convenience equivalent to the following: + * @code + * enabled ? Renderer::enable(feature) : Renderer::disable(feature) + * @endcode + * Prefer to use @ref enable() and @ref disable() directly to avoid + * unnecessary branching. */ static void setFeature(Feature feature, bool enabled); diff --git a/src/Magnum/SceneGraph/Drawable.h b/src/Magnum/SceneGraph/Drawable.h index 8763ddf07..e37ac3792 100644 --- a/src/Magnum/SceneGraph/Drawable.h +++ b/src/Magnum/SceneGraph/Drawable.h @@ -109,9 +109,9 @@ void MyApplication::drawEvent() { .setAmbientColor(ambientColor); camera.draw(phongObjects); - Renderer::setFeature(Renderer::Feature::Blending, true); + Renderer::enable(Renderer::Feature::Blending); camera.draw(transparentObjects); - Renderer::setFeature(Renderer::Feature::Blending, false); + Renderer::disable(Renderer::Feature::Blending); // ... } diff --git a/src/Magnum/Test/AbstractOpenGLTester.h b/src/Magnum/Test/AbstractOpenGLTester.h index 47bf4d684..bf576f8c7 100644 --- a/src/Magnum/Test/AbstractOpenGLTester.h +++ b/src/Magnum/Test/AbstractOpenGLTester.h @@ -53,8 +53,8 @@ class AbstractOpenGLTester: public TestSuite::Tester, public Platform::Windowles AbstractOpenGLTester::AbstractOpenGLTester(): Platform::WindowlessApplication({zero, nullptr}) { if(Context::current()->isExtensionSupported()) { - Renderer::setFeature(Renderer::Feature::DebugOutput, true); - Renderer::setFeature(Renderer::Feature::DebugOutputSynchronous, true); + Renderer::enable(Renderer::Feature::DebugOutput); + Renderer::enable(Renderer::Feature::DebugOutputSynchronous); DebugMessage::setDefaultCallback(); } } diff --git a/src/Magnum/Test/DebugGLTest.cpp b/src/Magnum/Test/DebugGLTest.cpp index 38a5e95e9..459c6b57a 100644 --- a/src/Magnum/Test/DebugGLTest.cpp +++ b/src/Magnum/Test/DebugGLTest.cpp @@ -77,16 +77,16 @@ void DebugGLTest::insertMessage() { if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::KHR::debug::string() + std::string(" is not supported")); - Renderer::setFeature(Renderer::Feature::DebugOutput, true); + Renderer::enable(Renderer::Feature::DebugOutput); - Renderer::setFeature(Renderer::Feature::DebugOutputSynchronous, true); + Renderer::enable(Renderer::Feature::DebugOutputSynchronous); std::ostringstream out; Debug::setOutput(&out); DebugMessage::setDefaultCallback(); DebugMessage::insert(DebugMessage::Source::Application, DebugMessage::Type::Marker, 1337, DebugMessage::Severity::Notification, "Hello from OpenGL command stream!"); - Renderer::setFeature(Renderer::Feature::DebugOutput, false); + Renderer::enable(Renderer::Feature::DebugOutput); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(out.str(), diff --git a/src/Magnum/Test/TimeQueryGLTest.cpp b/src/Magnum/Test/TimeQueryGLTest.cpp index 60552c30b..233a98b8a 100644 --- a/src/Magnum/Test/TimeQueryGLTest.cpp +++ b/src/Magnum/Test/TimeQueryGLTest.cpp @@ -60,7 +60,7 @@ void TimeQueryGLTest::queryTime() { TimeQuery q2; q2.begin(TimeQuery::Target::TimeElapsed); - Renderer::setFeature(Renderer::Feature::Blending, true); + Renderer::enable(Renderer::Feature::Blending); Renderer::finish(); q2.end(); const auto result2 = q2.result(); @@ -80,7 +80,7 @@ void TimeQueryGLTest::queryTimestamp() { q1.timestamp(); q.begin(TimeQuery::Target::TimeElapsed); - Renderer::setFeature(Renderer::Feature::Blending, true); + Renderer::enable(Renderer::Feature::Blending); Renderer::finish(); q.end(); From 9687b622f978972fa5582aca2f7e32778e209ad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 22 Jul 2014 22:37:28 +0200 Subject: [PATCH 10/32] Use threaded shader compilation etc. also in tests. --- .../Test/AbstractShaderProgramGLTest.cpp | 29 +++++++------------ src/Magnum/Test/MeshGLTest.cpp | 16 +++++----- src/Magnum/Test/PrimitiveQueryGLTest.cpp | 13 +++++---- src/Magnum/Test/SampleQueryGLTest.cpp | 18 +++++------- 4 files changed, 34 insertions(+), 42 deletions(-) diff --git a/src/Magnum/Test/AbstractShaderProgramGLTest.cpp b/src/Magnum/Test/AbstractShaderProgramGLTest.cpp index d087ebd87..8e7aa2fbb 100644 --- a/src/Magnum/Test/AbstractShaderProgramGLTest.cpp +++ b/src/Magnum/Test/AbstractShaderProgramGLTest.cpp @@ -138,7 +138,7 @@ void AbstractShaderProgramGLTest::label() { namespace { struct MyPublicShader: AbstractShaderProgram { - using AbstractShaderProgram::attachShader; + using AbstractShaderProgram::attachShaders; using AbstractShaderProgram::bindAttributeLocation; #ifndef MAGNUM_TARGET_GLES using AbstractShaderProgram::bindFragmentDataLocationIndexed; @@ -173,8 +173,7 @@ void AbstractShaderProgramGLTest::create() { CORRADE_VERIFY(fragCompiled); MyPublicShader program; - program.attachShader(vert); - program.attachShader(frag); + program.attachShaders({vert, frag}); MAGNUM_VERIFY_NO_ERROR(); @@ -215,8 +214,7 @@ void AbstractShaderProgramGLTest::createMultipleOutputs() { CORRADE_VERIFY(fragCompiled); MyPublicShader program; - program.attachShader(vert); - program.attachShader(frag); + program.attachShaders({vert, frag}); MAGNUM_VERIFY_NO_ERROR(); @@ -253,8 +251,7 @@ void AbstractShaderProgramGLTest::createMultipleOutputsIndexed() { CORRADE_VERIFY(fragCompiled); MyPublicShader program; - program.attachShader(vert); - program.attachShader(frag); + program.attachShaders({vert, frag}); MAGNUM_VERIFY_NO_ERROR(); @@ -289,21 +286,17 @@ MyShader::MyShader() { #ifndef MAGNUM_TARGET_GLES Shader vert(Version::GL210, Shader::Type::Vertex); - #else - Shader vert(Version::GLES200, Shader::Type::Vertex); - #endif - vert.addSource(rs.get("MyShader.vert")) - .compile(); - attachShader(vert); - - #ifndef MAGNUM_TARGET_GLES Shader frag(Version::GL210, Shader::Type::Fragment); #else + Shader vert(Version::GLES200, Shader::Type::Vertex); Shader frag(Version::GLES200, Shader::Type::Fragment); #endif - frag.addSource(rs.get("MyShader.frag")) - .compile(); - attachShader(frag); + vert.addSource(rs.get("MyShader.vert")); + frag.addSource(rs.get("MyShader.frag")); + + Shader::compile({vert, frag}); + + attachShaders({vert, frag}); bindAttributeLocation(0, "position"); link(); diff --git a/src/Magnum/Test/MeshGLTest.cpp b/src/Magnum/Test/MeshGLTest.cpp index 0de49d3a9..48faa22a7 100644 --- a/src/Magnum/Test/MeshGLTest.cpp +++ b/src/Magnum/Test/MeshGLTest.cpp @@ -369,8 +369,8 @@ FloatShader::FloatShader(const std::string& type, const std::string& conversion) #endif CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, frag})); - attachShader(vert); - attachShader(frag); + + attachShaders({vert, frag}); bindAttributeLocation(0, "value"); @@ -398,8 +398,8 @@ IntegerShader::IntegerShader(const std::string& type) { "void main() { result = valueInterpolated; }\n"); CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, frag})); - attachShader(vert); - attachShader(frag); + + attachShaders({vert, frag}); bindAttributeLocation(0, "value"); @@ -423,8 +423,8 @@ DoubleShader::DoubleShader(const std::string& type, const std::string& outputTyp "void main() { result = valueInterpolated; }\n"); CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, frag})); - attachShader(vert); - attachShader(frag); + + attachShaders({vert, frag}); bindAttributeLocation(0, "value"); @@ -1095,8 +1095,8 @@ MultipleShader::MultipleShader() { "void main() { gl_FragColor = valueInterpolated; }\n"); CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, frag})); - attachShader(vert); - attachShader(frag); + + attachShaders({vert, frag}); bindAttributeLocation(Position::Location, "position"); bindAttributeLocation(Normal::Location, "normal"); diff --git a/src/Magnum/Test/PrimitiveQueryGLTest.cpp b/src/Magnum/Test/PrimitiveQueryGLTest.cpp index 7099cd0ae..c85a70f05 100644 --- a/src/Magnum/Test/PrimitiveQueryGLTest.cpp +++ b/src/Magnum/Test/PrimitiveQueryGLTest.cpp @@ -62,15 +62,16 @@ void PrimitiveQueryGLTest::query() { explicit MyShader() { Utility::Resource rs("QueryGLTest"); - Shader vert(Version::GL210, Shader::Type::Vertex); - vert.addSource(rs.get("MyShader.vert")); - CORRADE_INTERNAL_ASSERT_OUTPUT(vert.compile()); - attachShader(vert); + Shader vert(Version::GL210, Shader::Type::Vertex); Shader frag(Version::GL210, Shader::Type::Fragment); + + vert.addSource(rs.get("MyShader.vert")); frag.addSource(rs.get("MyShader.frag")); - CORRADE_INTERNAL_ASSERT_OUTPUT(frag.compile()); - attachShader(frag); + + CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, frag})); + + attachShaders({vert, frag}); CORRADE_INTERNAL_ASSERT_OUTPUT(link()); } diff --git a/src/Magnum/Test/SampleQueryGLTest.cpp b/src/Magnum/Test/SampleQueryGLTest.cpp index 1d5acb6fd..e3f305f2b 100644 --- a/src/Magnum/Test/SampleQueryGLTest.cpp +++ b/src/Magnum/Test/SampleQueryGLTest.cpp @@ -68,23 +68,21 @@ namespace { #ifndef DOXYGEN_GENERATING_OUTPUT MyShader::MyShader() { Utility::Resource rs("QueryGLTest"); - #ifndef MAGNUM_TARGET_GLES - Shader vert(Version::GL210, Shader::Type::Vertex); - #else - Shader vert(Version::GLES200, Shader::Type::Vertex); - #endif - vert.addSource(rs.get("MyShader.vert")); - CORRADE_INTERNAL_ASSERT_OUTPUT(vert.compile()); - attachShader(vert); #ifndef MAGNUM_TARGET_GLES + Shader vert(Version::GL210, Shader::Type::Vertex); Shader frag(Version::GL210, Shader::Type::Fragment); #else + Shader vert(Version::GLES200, Shader::Type::Vertex); Shader frag(Version::GLES200, Shader::Type::Fragment); #endif + + vert.addSource(rs.get("MyShader.vert")); frag.addSource(rs.get("MyShader.frag")); - CORRADE_INTERNAL_ASSERT_OUTPUT(frag.compile()); - attachShader(frag); + + CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, frag})); + + attachShaders({vert, frag}); CORRADE_INTERNAL_ASSERT_OUTPUT(link()); } From dcec0bc95f26672bd365ad6e500355201f651b7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 24 Jul 2014 21:00:11 +0200 Subject: [PATCH 11/32] Remove old NVidia workaround from AbstractObject::getLabel(). This bug is fixed, but other issues appeared. --- src/Magnum/AbstractObject.cpp | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/src/Magnum/AbstractObject.cpp b/src/Magnum/AbstractObject.cpp index f295e3de1..df921a0cf 100644 --- a/src/Magnum/AbstractObject.cpp +++ b/src/Magnum/AbstractObject.cpp @@ -154,46 +154,31 @@ void AbstractObject::labelImplementationExt(const GLenum identifier, const GLuin std::string AbstractObject::getLabelImplementationNoOp(GLenum, GLuint) { return {}; } std::string AbstractObject::getLabelImplementationKhr(const GLenum identifier, const GLuint name) { - /** - * @todo Get rid of this workaround when NVidia returns proper size for - * length=0 & label=nullptr (even crashes on length>0 & label=nullptr) - */ - #if 0 /* Get label size (w/o null terminator) */ GLsizei size; + /** @todo Re-enable when extension loader is available for ES */ #ifndef MAGNUM_TARGET_GLES - glGetObjectLabel(type, name, 0, &size, nullptr); + glGetObjectLabel(identifier, name, 0, &size, nullptr); #else - glGetObjectLabelKHR(type, name, 0, &size, nullptr); + static_cast(identifier); + static_cast(name); + CORRADE_INTERNAL_ASSERT(false); + //glGetObjectLabelKHR(identifier, name, 0, &size, nullptr); #endif /* Make place also for the null terminator */ std::string label; label.resize(size+1); + /** @todo Re-enable when extension loader is available for ES */ #ifndef MAGNUM_TARGET_GLES glGetObjectLabel(identifier, name, size+1, nullptr, &label[0]); #else - glGetObjectLabelKHR(identifier, name, size+1, nullptr, &label[0]); + //glGetObjectLabelKHR(identifier, name, size+1, nullptr, &label[0]); #endif /* Pop null terminator and return the string */ label.resize(size); return label; - #else - GLsizei size; - std::string label; - label.resize(maxLabelLength()); - /** @todo Re-enable when extension loader is available for ES */ - #ifndef MAGNUM_TARGET_GLES - glGetObjectLabel(identifier, name, label.size(), &size, &label[0]); - #else - static_cast(identifier); - static_cast(name); - CORRADE_INTERNAL_ASSERT(false); - //glGetObjectLabelKHR(identifier, name, label.size(), &size, &label[0]); - #endif - return label.substr(0, size); - #endif } std::string AbstractObject::getLabelImplementationExt(const GLenum identifier, const GLuint name) { From 0dfbc6f8334b5c9e49e98a32f0df023dceb0917b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 24 Jul 2014 21:02:34 +0200 Subject: [PATCH 12/32] Use object at least once before testing its label. Otherwise my NVidia emits GL_INVALID_VALUE with message "that is not valid object", which isn't in the specs. I hate this "deferred everything" approach in GL. Is this even legal optimization? --- src/Magnum/Test/AbstractQueryGLTest.cpp | 8 ++++++++ src/Magnum/Test/AbstractTextureGLTest.cpp | 7 +++++++ src/Magnum/Test/BufferGLTest.cpp | 7 +++++++ src/Magnum/Test/FramebufferGLTest.cpp | 12 ++++++++++++ src/Magnum/Test/MeshGLTest.cpp | 8 ++++++++ src/Magnum/Test/RenderbufferGLTest.cpp | 11 +++++++++++ 6 files changed, 53 insertions(+) diff --git a/src/Magnum/Test/AbstractQueryGLTest.cpp b/src/Magnum/Test/AbstractQueryGLTest.cpp index 48b095604..0706be23c 100644 --- a/src/Magnum/Test/AbstractQueryGLTest.cpp +++ b/src/Magnum/Test/AbstractQueryGLTest.cpp @@ -106,7 +106,15 @@ void AbstractQueryGLTest::label() { !Context::current()->isExtensionSupported()) CORRADE_SKIP("Required extension is not available"); + { + /** @todo Is this even legal optimization? */ + CORRADE_EXPECT_FAIL("The object must be used at least once before setting/querying label."); + CORRADE_VERIFY(false); + } SampleQuery query; + query.begin(SampleQuery::Target::AnySamplesPassed); + query.end(); + CORRADE_COMPARE(query.label(), ""); query.setLabel("MyQuery"); diff --git a/src/Magnum/Test/AbstractTextureGLTest.cpp b/src/Magnum/Test/AbstractTextureGLTest.cpp index 57e5af65b..e5e6f39fe 100644 --- a/src/Magnum/Test/AbstractTextureGLTest.cpp +++ b/src/Magnum/Test/AbstractTextureGLTest.cpp @@ -93,7 +93,14 @@ void AbstractTextureGLTest::label() { !Context::current()->isExtensionSupported()) CORRADE_SKIP("Required extension is not available"); + { + /** @todo Is this even legal optimization? */ + CORRADE_EXPECT_FAIL("The object must be used at least once before setting/querying label."); + CORRADE_VERIFY(false); + } Texture2D texture; + texture.setMinificationFilter(Sampler::Filter::Linear); + CORRADE_COMPARE(texture.label(), ""); texture.setLabel("MyTexture"); diff --git a/src/Magnum/Test/BufferGLTest.cpp b/src/Magnum/Test/BufferGLTest.cpp index 58776d116..4358835bd 100644 --- a/src/Magnum/Test/BufferGLTest.cpp +++ b/src/Magnum/Test/BufferGLTest.cpp @@ -118,7 +118,14 @@ void BufferGLTest::label() { !Context::current()->isExtensionSupported()) CORRADE_SKIP("Required extension is not available"); + { + /** @todo Is this even legal optimization? */ + CORRADE_EXPECT_FAIL("The object must be used at least once before setting/querying label."); + CORRADE_VERIFY(false); + } Buffer buffer; + buffer.setData({nullptr, 3}, BufferUsage::StaticDraw); + CORRADE_COMPARE(buffer.label(), ""); buffer.setLabel("MyBuffer"); diff --git a/src/Magnum/Test/FramebufferGLTest.cpp b/src/Magnum/Test/FramebufferGLTest.cpp index 74537139c..2df5a8bd7 100644 --- a/src/Magnum/Test/FramebufferGLTest.cpp +++ b/src/Magnum/Test/FramebufferGLTest.cpp @@ -199,7 +199,19 @@ void FramebufferGLTest::label() { !Context::current()->isExtensionSupported()) CORRADE_SKIP("Required extension is not available"); + { + /** @todo Is this even legal optimization? */ + CORRADE_EXPECT_FAIL("The object must be used at least once before setting/querying label."); + CORRADE_VERIFY(false); + } + Renderbuffer renderbuffer; + #ifndef MAGNUM_TARGET_GLES2 + renderbuffer.setStorage(RenderbufferFormat::RGBA8, {128, 128}); + #else + renderbuffer.setStorage(RenderbufferFormat::RGBA4, {128, 128}); + #endif Framebuffer framebuffer({{}, Vector2i(32)}); + framebuffer.attachRenderbuffer(Framebuffer::BufferAttachment(Framebuffer::BufferAttachment::Depth), renderbuffer); CORRADE_COMPARE(framebuffer.label(), ""); MAGNUM_VERIFY_NO_ERROR(); diff --git a/src/Magnum/Test/MeshGLTest.cpp b/src/Magnum/Test/MeshGLTest.cpp index 48faa22a7..cb768dd4a 100644 --- a/src/Magnum/Test/MeshGLTest.cpp +++ b/src/Magnum/Test/MeshGLTest.cpp @@ -295,7 +295,15 @@ void MeshGLTest::label() { !Context::current()->isExtensionSupported()) CORRADE_SKIP("Required extension is not available"); + { + /** @todo Is this even legal optimization? */ + CORRADE_EXPECT_FAIL("The object must be used at least once before setting/querying label."); + CORRADE_VERIFY(false); + } + Buffer buffer{Buffer::Target::ElementArray}; Mesh mesh; + mesh.setIndexBuffer(buffer, 0, Mesh::IndexType::UnsignedShort); + CORRADE_COMPARE(mesh.label(), ""); mesh.setLabel("MyMesh"); diff --git a/src/Magnum/Test/RenderbufferGLTest.cpp b/src/Magnum/Test/RenderbufferGLTest.cpp index 89b54e0bb..a19a0a23f 100644 --- a/src/Magnum/Test/RenderbufferGLTest.cpp +++ b/src/Magnum/Test/RenderbufferGLTest.cpp @@ -116,7 +116,18 @@ void RenderbufferGLTest::label() { !Context::current()->isExtensionSupported()) CORRADE_SKIP("Required extension is not available"); + { + /** @todo Is this even legal optimization? */ + CORRADE_EXPECT_FAIL("The object must be used at least once before setting/querying label."); + CORRADE_VERIFY(false); + } Renderbuffer renderbuffer; + #ifndef MAGNUM_TARGET_GLES2 + renderbuffer.setStorage(RenderbufferFormat::RGBA8, {128, 128}); + #else + renderbuffer.setStorage(RenderbufferFormat::RGBA4, {128, 128}); + #endif + CORRADE_COMPARE(renderbuffer.label(), ""); renderbuffer.setLabel("MyRenderbuffer"); From ca84e60d6623cce80823aca1f100b5bffd906e98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 24 Jul 2014 21:06:16 +0200 Subject: [PATCH 13/32] Fix CubeMapTexture test. This time thank you, hardened NVidia drivers. --- src/Magnum/Test/CubeMapTextureGLTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Magnum/Test/CubeMapTextureGLTest.cpp b/src/Magnum/Test/CubeMapTextureGLTest.cpp index 7428b0e10..0f77f2bc4 100644 --- a/src/Magnum/Test/CubeMapTextureGLTest.cpp +++ b/src/Magnum/Test/CubeMapTextureGLTest.cpp @@ -467,7 +467,7 @@ void CubeMapTextureGLTest::invalidateImage() { void CubeMapTextureGLTest::invalidateSubImage() { CubeMapTexture texture; texture.setStorage(2, TextureFormat::RGBA8, Vector2i(32)); - texture.invalidateSubImage(1, Vector3i(2), Vector3i(8)); + texture.invalidateSubImage(1, Vector3i(2), Vector3i(Vector2i(8), 4)); MAGNUM_VERIFY_NO_ERROR(); } From 1b45a71ff57a90ea913c6985121a64ba8e7d02c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 24 Jul 2014 21:08:41 +0200 Subject: [PATCH 14/32] Allocation-free overloads for *::setLabel(). In most cases the label is set directly from code, e.g.: texture.setLabel("diffuse-duck"); Avoiding conversion to std::string and passing char(&)[size] directly will avoid one allocation and deallocation. Better solution would be to use std::string_view everywhere, but we're not in C++17 yet. --- src/Magnum/AbstractObject.cpp | 13 +++++++------ src/Magnum/AbstractObject.h | 9 +++++---- src/Magnum/AbstractShaderProgram.cpp | 2 +- src/Magnum/AbstractShaderProgram.h | 12 +++++++++++- src/Magnum/AbstractTexture.cpp | 2 +- src/Magnum/AbstractTexture.h | 13 ++++++++++++- src/Magnum/Buffer.cpp | 2 +- src/Magnum/Buffer.h | 11 ++++++++++- src/Magnum/BufferTexture.h | 4 ++++ src/Magnum/CubeMapTexture.h | 4 ++++ src/Magnum/CubeMapTextureArray.h | 4 ++++ src/Magnum/Framebuffer.cpp | 2 +- src/Magnum/Framebuffer.h | 11 ++++++++++- src/Magnum/Implementation/DebugState.h | 2 +- src/Magnum/Mesh.cpp | 2 +- src/Magnum/Mesh.h | 11 ++++++++++- src/Magnum/MultisampleTexture.h | 4 ++++ src/Magnum/Query.cpp | 2 +- src/Magnum/Query.h | 24 +++++++++++++++++++++++- src/Magnum/RectangleTexture.h | 4 ++++ src/Magnum/Renderbuffer.cpp | 2 +- src/Magnum/Renderbuffer.h | 13 ++++++++++++- src/Magnum/Shader.cpp | 2 +- src/Magnum/Shader.h | 12 +++++++++++- src/Magnum/Texture.h | 4 ++++ src/Magnum/TextureArray.h | 4 ++++ 26 files changed, 148 insertions(+), 27 deletions(-) diff --git a/src/Magnum/AbstractObject.cpp b/src/Magnum/AbstractObject.cpp index df921a0cf..0b07d3c8f 100644 --- a/src/Magnum/AbstractObject.cpp +++ b/src/Magnum/AbstractObject.cpp @@ -26,6 +26,7 @@ #include "AbstractObject.h" #include +#include #include "Magnum/Context.h" #include "Magnum/Extensions.h" @@ -123,26 +124,26 @@ Int AbstractObject::maxLabelLength() { return value; } -void AbstractObject::labelImplementationNoOp(GLenum, GLuint, const std::string&) {} +void AbstractObject::labelImplementationNoOp(GLenum, GLuint, Containers::ArrayReference) {} -void AbstractObject::labelImplementationKhr(const GLenum identifier, const GLuint name, const std::string& label) { +void AbstractObject::labelImplementationKhr(const GLenum identifier, const GLuint name, const Containers::ArrayReference label) { /** @todo Re-enable when extension loader is available for ES */ #ifndef MAGNUM_TARGET_GLES - glObjectLabel(identifier, name, label.size(), label.data()); + glObjectLabel(identifier, name, label.size(), label); #else static_cast(identifier); static_cast(name); static_cast(label); CORRADE_INTERNAL_ASSERT(false); - //glObjectLabelKHR(identifier, name, label.size(), label.data()); + //glObjectLabelKHR(identifier, name, label.size(), label); #endif } -void AbstractObject::labelImplementationExt(const GLenum identifier, const GLuint name, const std::string& label) { +void AbstractObject::labelImplementationExt(const GLenum identifier, const GLuint name, const Containers::ArrayReference label) { const GLenum type = extTypeFromKhrIdentifier(identifier); /** @todo Re-enable when extension loader is available for ES */ #ifndef MAGNUM_TARGET_GLES - glLabelObjectEXT(type, name, label.size(), label.data()); + glLabelObjectEXT(type, name, label.size(), label); #else static_cast(type); static_cast(name); diff --git a/src/Magnum/AbstractObject.h b/src/Magnum/AbstractObject.h index 54a220673..10cc5b821 100644 --- a/src/Magnum/AbstractObject.h +++ b/src/Magnum/AbstractObject.h @@ -30,9 +30,10 @@ */ #include +#include +#include "Magnum/Magnum.h" #include "Magnum/OpenGL.h" -#include "Magnum/Types.h" #include "Magnum/visibility.h" namespace Magnum { @@ -66,9 +67,9 @@ class MAGNUM_EXPORT AbstractObject { MAGNUM_LOCAL ~AbstractObject() = default; private: - static MAGNUM_LOCAL void labelImplementationNoOp(GLenum, GLuint, const std::string&); - static MAGNUM_LOCAL void labelImplementationExt(GLenum identifier, GLuint name, const std::string& label); - static MAGNUM_LOCAL void labelImplementationKhr(GLenum identifier, GLuint name, const std::string& label); + static MAGNUM_LOCAL void labelImplementationNoOp(GLenum, GLuint, Containers::ArrayReference label); + static MAGNUM_LOCAL void labelImplementationExt(GLenum identifier, GLuint name, Containers::ArrayReference label); + static MAGNUM_LOCAL void labelImplementationKhr(GLenum identifier, GLuint name, Containers::ArrayReference label); static MAGNUM_LOCAL std::string getLabelImplementationNoOp(GLenum, GLuint); static MAGNUM_LOCAL std::string getLabelImplementationExt(GLenum identifier, GLuint name); static MAGNUM_LOCAL std::string getLabelImplementationKhr(GLenum identifier, GLuint name); diff --git a/src/Magnum/AbstractShaderProgram.cpp b/src/Magnum/AbstractShaderProgram.cpp index dabc8b881..4b836eacf 100644 --- a/src/Magnum/AbstractShaderProgram.cpp +++ b/src/Magnum/AbstractShaderProgram.cpp @@ -225,7 +225,7 @@ std::string AbstractShaderProgram::label() const { #endif } -AbstractShaderProgram& AbstractShaderProgram::setLabel(const std::string& label) { +AbstractShaderProgram& AbstractShaderProgram::setLabelInternal(const Containers::ArrayReference label) { #ifndef MAGNUM_TARGET_GLES Context::current()->state().debug->labelImplementation(GL_PROGRAM, _id, label); #else diff --git a/src/Magnum/AbstractShaderProgram.h b/src/Magnum/AbstractShaderProgram.h index 9da0dc74f..eb1888de3 100644 --- a/src/Magnum/AbstractShaderProgram.h +++ b/src/Magnum/AbstractShaderProgram.h @@ -31,6 +31,7 @@ #include #include +#include #include #include "Magnum/AbstractObject.h" @@ -540,7 +541,14 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject { * @def_gl{PROGRAM} or @fn_gl_extension2{LabelObject,EXT,debug_label} * with @def_gl{PROGRAM_OBJECT_EXT} */ - AbstractShaderProgram& setLabel(const std::string& label); + AbstractShaderProgram& setLabel(const std::string& label) { + return setLabelInternal({label.data(), label.size()}); + } + + /** @overload */ + template AbstractShaderProgram& setLabel(const char (&label)[size]) { + return setLabelInternal(label); + } /** * @brief Validate program @@ -817,6 +825,8 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject { #endif private: + AbstractShaderProgram& setLabelInternal(Containers::ArrayReference label); + #ifndef MAGNUM_BUILD_DEPRECATED void use(); #endif diff --git a/src/Magnum/AbstractTexture.cpp b/src/Magnum/AbstractTexture.cpp index 61e3c870f..756940c2b 100644 --- a/src/Magnum/AbstractTexture.cpp +++ b/src/Magnum/AbstractTexture.cpp @@ -189,7 +189,7 @@ std::string AbstractTexture::label() const { return Context::current()->state().debug->getLabelImplementation(GL_TEXTURE, _id); } -AbstractTexture& AbstractTexture::setLabel(const std::string& label) { +AbstractTexture& AbstractTexture::setLabelInternal(const Containers::ArrayReference label) { Context::current()->state().debug->labelImplementation(GL_TEXTURE, _id, label); return *this; } diff --git a/src/Magnum/AbstractTexture.h b/src/Magnum/AbstractTexture.h index 56c8164c5..6d713509a 100644 --- a/src/Magnum/AbstractTexture.h +++ b/src/Magnum/AbstractTexture.h @@ -29,6 +29,8 @@ * @brief Class @ref Magnum::AbstractTexture */ +#include + #include "Magnum/Sampler.h" #include "Magnum/AbstractObject.h" @@ -258,7 +260,14 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { * @fn_gl_extension2{LabelObject,EXT,debug_label} with * @def_gl{TEXTURE} */ - AbstractTexture& setLabel(const std::string& label); + AbstractTexture& setLabel(const std::string& label) { + return setLabelInternal({label.data(), label.size()}); + } + + /** @overload */ + template AbstractTexture& setLabel(const char(&label)[size]) { + return setLabelInternal(label); + } /** @brief OpenGL texture ID */ GLuint id() const { return _id; } @@ -288,6 +297,8 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject { explicit AbstractTexture(GLenum target); + AbstractTexture& setLabelInternal(Containers::ArrayReference label); + /* Unlike bind() this also sets the texture binding unit as active */ void MAGNUM_LOCAL bindInternal(); diff --git a/src/Magnum/Buffer.cpp b/src/Magnum/Buffer.cpp index 37d96f8fc..75411ae09 100644 --- a/src/Magnum/Buffer.cpp +++ b/src/Magnum/Buffer.cpp @@ -138,7 +138,7 @@ std::string Buffer::label() const { #endif } -Buffer& Buffer::setLabel(const std::string& label) { +Buffer& Buffer::setLabelInternal(const Containers::ArrayReference label) { #ifndef MAGNUM_TARGET_GLES Context::current()->state().debug->labelImplementation(GL_BUFFER, _id, label); #else diff --git a/src/Magnum/Buffer.h b/src/Magnum/Buffer.h index cc9d24d13..e53d24fd5 100644 --- a/src/Magnum/Buffer.h +++ b/src/Magnum/Buffer.h @@ -582,7 +582,14 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { * or @fn_gl_extension2{LabelObject,EXT,debug_label} with * @def_gl{BUFFER_OBJECT_EXT} */ - Buffer& setLabel(const std::string& label); + Buffer& setLabel(const std::string& label) { + return setLabelInternal({label.data(), label.size()}); + } + + /** @overload */ + template Buffer& setLabel(const char(&label)[size]) { + return setLabelInternal(label); + } /** @brief Target hint */ Target targetHint() const { return _targetHint; } @@ -854,6 +861,8 @@ class MAGNUM_EXPORT Buffer: public AbstractObject { #endif private: + Buffer& setLabelInternal(Containers::ArrayReference label); + static void bind(Target hint, GLuint id); Target MAGNUM_LOCAL bindInternal(Target hint); diff --git a/src/Magnum/BufferTexture.h b/src/Magnum/BufferTexture.h index 980aae547..cf8fabf80 100644 --- a/src/Magnum/BufferTexture.h +++ b/src/Magnum/BufferTexture.h @@ -269,6 +269,10 @@ class MAGNUM_EXPORT BufferTexture: public AbstractTexture { AbstractTexture::setLabel(label); return *this; } + template BufferTexture& setLabel(const char(&label)[size]) { + AbstractTexture::setLabel(label); + return *this; + } #endif private: diff --git a/src/Magnum/CubeMapTexture.h b/src/Magnum/CubeMapTexture.h index 087c3e1ae..67319620b 100644 --- a/src/Magnum/CubeMapTexture.h +++ b/src/Magnum/CubeMapTexture.h @@ -382,6 +382,10 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture { AbstractTexture::setLabel(label); return *this; } + template CubeMapTexture& setLabel(const char(&label)[size]) { + AbstractTexture::setLabel(label); + return *this; + } #endif }; diff --git a/src/Magnum/CubeMapTextureArray.h b/src/Magnum/CubeMapTextureArray.h index 22230f084..e067c98b9 100644 --- a/src/Magnum/CubeMapTextureArray.h +++ b/src/Magnum/CubeMapTextureArray.h @@ -405,6 +405,10 @@ class CubeMapTextureArray: public AbstractTexture { AbstractTexture::setLabel(label); return *this; } + template CubeMapTextureArray& setLabel(const char(&label)[size]) { + AbstractTexture::setLabel(label); + return *this; + } #endif }; diff --git a/src/Magnum/Framebuffer.cpp b/src/Magnum/Framebuffer.cpp index cf028c4de..9aafd0cce 100644 --- a/src/Magnum/Framebuffer.cpp +++ b/src/Magnum/Framebuffer.cpp @@ -112,7 +112,7 @@ std::string Framebuffer::label() const { return Context::current()->state().debug->getLabelImplementation(GL_FRAMEBUFFER, _id); } -Framebuffer& Framebuffer::setLabel(const std::string& label) { +Framebuffer& Framebuffer::setLabelInternal(const Containers::ArrayReference label) { Context::current()->state().debug->labelImplementation(GL_FRAMEBUFFER, _id, label); return *this; } diff --git a/src/Magnum/Framebuffer.h b/src/Magnum/Framebuffer.h index 79d75d125..2368e938c 100644 --- a/src/Magnum/Framebuffer.h +++ b/src/Magnum/Framebuffer.h @@ -354,7 +354,14 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractObje * @fn_gl_extension2{LabelObject,EXT,debug_label} with * @def_gl{FRAMEBUFFER} */ - Framebuffer& setLabel(const std::string& label); + Framebuffer& setLabel(const std::string& label) { + return setLabelInternal({label.data(), label.size()}); + } + + /** @overload */ + template Framebuffer& setLabel(const char(&label)[size]) { + return setLabelInternal(label); + } /** * @brief Check framebuffer status @@ -627,6 +634,8 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractObje #endif private: + Framebuffer& setLabelInternal(Containers::ArrayReference label); + void MAGNUM_LOCAL renderbufferImplementationDefault(BufferAttachment attachment, Renderbuffer& renderbuffer); #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL renderbufferImplementationDSA(BufferAttachment attachment, Renderbuffer& renderbuffer); diff --git a/src/Magnum/Implementation/DebugState.h b/src/Magnum/Implementation/DebugState.h index a435e1b20..dd90ec181 100644 --- a/src/Magnum/Implementation/DebugState.h +++ b/src/Magnum/Implementation/DebugState.h @@ -36,7 +36,7 @@ struct DebugState { explicit DebugState(Context& context, std::vector& extensions); std::string(*getLabelImplementation)(GLenum, GLuint); - void(*labelImplementation)(GLenum, GLuint, const std::string&); + void(*labelImplementation)(GLenum, GLuint, Containers::ArrayReference); void(*messageInsertImplementation)(DebugMessage::Source, DebugMessage::Type, UnsignedInt, DebugMessage::Severity, const std::string&); void(*messageCallbackImplementation)(DebugMessage::Callback, const void*); diff --git a/src/Magnum/Mesh.cpp b/src/Magnum/Mesh.cpp index c91a8059f..54ab76406 100644 --- a/src/Magnum/Mesh.cpp +++ b/src/Magnum/Mesh.cpp @@ -148,7 +148,7 @@ std::string Mesh::label() const { #endif } -Mesh& Mesh::setLabel(const std::string& label) { +Mesh& Mesh::setLabelInternal(const Containers::ArrayReference label) { #ifndef MAGNUM_TARGET_GLES Context::current()->state().debug->labelImplementation(GL_VERTEX_ARRAY, _id, label); #else diff --git a/src/Magnum/Mesh.h b/src/Magnum/Mesh.h index c2d40b3fb..4e3cdf063 100644 --- a/src/Magnum/Mesh.h +++ b/src/Magnum/Mesh.h @@ -467,7 +467,14 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { * @def_gl{VERTEX_ARRAY} or @fn_gl_extension2{LabelObject,EXT,debug_label} * with @def_gl{VERTEX_ARRAY_OBJECT_EXT} */ - Mesh& setLabel(const std::string& label); + Mesh& setLabel(const std::string& label) { + return setLabelInternal({label.data(), label.size()}); + } + + /** @overload */ + template Mesh& setLabelInternal(const char(&label)[size]) { + return setLabelInternal(label); + } /** * @brief Whether the mesh is indexed @@ -836,6 +843,8 @@ class MAGNUM_EXPORT Mesh: public AbstractObject { #endif #endif + Mesh& setLabelInternal(Containers::ArrayReference label); + /* Computing stride of interleaved vertex attributes */ template static GLsizei strideOfInterleaved(const AbstractShaderProgram::Attribute& attribute, const U&... attributes) { return attribute.vectorSize()*AbstractShaderProgram::Attribute::VectorCount + strideOfInterleaved(attributes...); diff --git a/src/Magnum/MultisampleTexture.h b/src/Magnum/MultisampleTexture.h index 54c4e1038..6bc3848e4 100644 --- a/src/Magnum/MultisampleTexture.h +++ b/src/Magnum/MultisampleTexture.h @@ -180,6 +180,10 @@ template class MultisampleTexture: public AbstractTextur AbstractTexture::setLabel(label); return *this; } + template MultisampleTexture& setLabel(const char(&label)[size]) { + AbstractTexture::setLabel(label); + return *this; + } #endif }; diff --git a/src/Magnum/Query.cpp b/src/Magnum/Query.cpp index d6bee60f2..8fd4e7a15 100644 --- a/src/Magnum/Query.cpp +++ b/src/Magnum/Query.cpp @@ -66,7 +66,7 @@ std::string AbstractQuery::label() const { #endif } -AbstractQuery& AbstractQuery::setLabel(const std::string& label) { +AbstractQuery& AbstractQuery::setLabelInternal(const Containers::ArrayReference label) { #ifndef MAGNUM_TARGET_GLES Context::current()->state().debug->labelImplementation(GL_QUERY, _id, label); #else diff --git a/src/Magnum/Query.h b/src/Magnum/Query.h index 99c62c641..a0b152c4f 100644 --- a/src/Magnum/Query.h +++ b/src/Magnum/Query.h @@ -29,6 +29,7 @@ * @brief Class @ref Magnum::AbstractQuery, @ref Magnum::PrimitiveQuery, @ref Magnum::SampleQuery, @ref Magnum::TimeQuery */ +#include #include #include "Magnum/AbstractObject.h" @@ -84,7 +85,14 @@ class MAGNUM_EXPORT AbstractQuery: public AbstractObject { * @def_gl{QUERY} or @fn_gl_extension2{LabelObject,EXT,debug_label} * with @def_gl{QUERY_OBJECT_EXT} */ - AbstractQuery& setLabel(const std::string& label); + AbstractQuery& setLabel(const std::string& label) { + return setLabelInternal({label.data(), label.size()}); + } + + /** @overload */ + template AbstractQuery& setLabel(const char(&label)[size]) { + return setLabelInternal(label); + } /** * @brief Whether the result is available @@ -140,6 +148,8 @@ class MAGNUM_EXPORT AbstractQuery: public AbstractObject { void begin(GLenum target); private: + AbstractQuery& setLabelInternal(Containers::ArrayReference label); + GLuint _id; GLenum target; }; @@ -217,6 +227,10 @@ class PrimitiveQuery: public AbstractQuery { AbstractQuery::setLabel(label); return *this; } + template PrimitiveQuery& setLabel(const char(&label)[size]) { + AbstractQuery::setLabel(label); + return *this; + } #endif }; #endif @@ -367,6 +381,10 @@ class SampleQuery: public AbstractQuery { AbstractQuery::setLabel(label); return *this; } + template SampleQuery& setLabel(const char(&label)[size]) { + AbstractQuery::setLabel(label); + return *this; + } #endif }; @@ -446,6 +464,10 @@ class TimeQuery: public AbstractQuery { AbstractQuery::setLabel(label); return *this; } + template TimeQuery& setLabel(const char(&label)[size]) { + AbstractQuery::setLabel(label); + return *this; + } #endif }; diff --git a/src/Magnum/RectangleTexture.h b/src/Magnum/RectangleTexture.h index 3bea9918d..cf98b51e9 100644 --- a/src/Magnum/RectangleTexture.h +++ b/src/Magnum/RectangleTexture.h @@ -404,6 +404,10 @@ class MAGNUM_EXPORT RectangleTexture: public AbstractTexture { AbstractTexture::setLabel(label); return *this; } + template RectangleTexture& setLabel(const char(&label)[size]) { + AbstractTexture::setLabel(label); + return *this; + } #endif }; diff --git a/src/Magnum/Renderbuffer.cpp b/src/Magnum/Renderbuffer.cpp index 47a99b4bb..d2a0e8b4e 100644 --- a/src/Magnum/Renderbuffer.cpp +++ b/src/Magnum/Renderbuffer.cpp @@ -81,7 +81,7 @@ std::string Renderbuffer::label() const { return Context::current()->state().debug->getLabelImplementation(GL_RENDERBUFFER, _id); } -Renderbuffer& Renderbuffer::setLabel(const std::string& label) { +Renderbuffer& Renderbuffer::setLabelInternal(const Containers::ArrayReference label) { Context::current()->state().debug->labelImplementation(GL_RENDERBUFFER, _id, label); return *this; } diff --git a/src/Magnum/Renderbuffer.h b/src/Magnum/Renderbuffer.h index 33b82bf11..c5bfe4b4f 100644 --- a/src/Magnum/Renderbuffer.h +++ b/src/Magnum/Renderbuffer.h @@ -29,6 +29,8 @@ * @brief Class @ref Magnum::Renderbuffer */ +#include + #include "Magnum/AbstractObject.h" #include "Magnum/Magnum.h" @@ -135,7 +137,14 @@ class MAGNUM_EXPORT Renderbuffer: public AbstractObject { * @fn_gl_extension2{LabelObject,EXT,debug_label} with * @def_gl{RENDERBUFFER} */ - Renderbuffer& setLabel(const std::string& label); + Renderbuffer& setLabel(const std::string& label) { + return setLabelInternal({label.data(), label.size()}); + } + + /** @overload */ + template Renderbuffer& setLabel(const char(&label)[size]) { + return setLabelInternal(label); + } /** * @brief Set renderbuffer storage @@ -169,6 +178,8 @@ class MAGNUM_EXPORT Renderbuffer: public AbstractObject { void setStorageMultisample(Int samples, RenderbufferFormat internalFormat, const Vector2i& size); private: + Renderbuffer& setLabelInternal(Containers::ArrayReference label); + void MAGNUM_LOCAL storageImplementationDefault(RenderbufferFormat internalFormat, const Vector2i& size); #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL storageImplementationDSA(RenderbufferFormat internalFormat, const Vector2i& size); diff --git a/src/Magnum/Shader.cpp b/src/Magnum/Shader.cpp index 86d4b8722..1d3f3d31b 100644 --- a/src/Magnum/Shader.cpp +++ b/src/Magnum/Shader.cpp @@ -580,7 +580,7 @@ std::string Shader::label() const { #endif } -Shader& Shader::setLabel(const std::string& label) { +Shader& Shader::setLabelInternal(const Containers::ArrayReference label) { #ifndef MAGNUM_TARGET_GLES Context::current()->state().debug->labelImplementation(GL_SHADER, _id, label); #else diff --git a/src/Magnum/Shader.h b/src/Magnum/Shader.h index 1afd37c31..adab40a4b 100644 --- a/src/Magnum/Shader.h +++ b/src/Magnum/Shader.h @@ -32,6 +32,7 @@ #include #include #include +#include #include "Magnum/AbstractObject.h" #include "Magnum/Magnum.h" @@ -504,7 +505,14 @@ class MAGNUM_EXPORT Shader: public AbstractObject { * @def_gl{SHADER} or @fn_gl_extension2{LabelObject,EXT,debug_label} * with @def_gl{SHADER_OBJECT_EXT} */ - Shader& setLabel(const std::string& label); + Shader& setLabel(const std::string& label) { + return setLabelInternal({label.data(), label.size()}); + } + + /** @overload */ + template Shader& setLabel(const char(&label)[size]) { + return setLabelInternal(label); + } /** @brief %Shader type */ Type type() const { return _type; } @@ -545,6 +553,8 @@ class MAGNUM_EXPORT Shader: public AbstractObject { bool compile() { return compile({*this}); } private: + Shader& setLabelInternal(Containers::ArrayReference label); + Type _type; GLuint _id; diff --git a/src/Magnum/Texture.h b/src/Magnum/Texture.h index 6aa1bdbe8..25a142b99 100644 --- a/src/Magnum/Texture.h +++ b/src/Magnum/Texture.h @@ -759,6 +759,10 @@ template class Texture: public AbstractTexture { AbstractTexture::setLabel(label); return *this; } + template Texture& setLabel(const char(&label)[size]) { + AbstractTexture::setLabel(label); + return *this; + } #endif }; diff --git a/src/Magnum/TextureArray.h b/src/Magnum/TextureArray.h index 37916c8d7..78630806d 100644 --- a/src/Magnum/TextureArray.h +++ b/src/Magnum/TextureArray.h @@ -389,6 +389,10 @@ template class TextureArray: public AbstractTexture { AbstractTexture::setLabel(label); return *this; } + template TextureArray& setLabel(const char(&label)[size]) { + AbstractTexture::setLabel(label); + return *this; + } #endif }; From e71be176a973b56a579feafaa536da47635ea871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 24 Jul 2014 21:11:32 +0200 Subject: [PATCH 15/32] Allocation-free overloads for AbstractShaderProgram string functions. In nearly every case the attributes are bound and uniform locations queried with constant char arrays: bindAttributeLocation("position", Position::Location); colorUniform = uniformLocation("color"); Avoiding conversion to std::string and passing const char(&)[size] directly will avoid needless allocation (and later deallocation) for every call. --- src/Magnum/AbstractShaderProgram.cpp | 18 ++++++------ src/Magnum/AbstractShaderProgram.h | 41 +++++++++++++++++++++++++--- 2 files changed, 46 insertions(+), 13 deletions(-) diff --git a/src/Magnum/AbstractShaderProgram.cpp b/src/Magnum/AbstractShaderProgram.cpp index 4b836eacf..954dfbdd4 100644 --- a/src/Magnum/AbstractShaderProgram.cpp +++ b/src/Magnum/AbstractShaderProgram.cpp @@ -266,16 +266,16 @@ void AbstractShaderProgram::attachShaders(std::initializer_list name) { + glBindAttribLocation(_id, location, name); } #ifndef MAGNUM_TARGET_GLES -void AbstractShaderProgram::bindFragmentDataLocation(UnsignedInt location, const std::string& name) { - glBindFragDataLocation(_id, location, name.data()); +void AbstractShaderProgram::bindFragmentDataLocationInternal(const UnsignedInt location, const Containers::ArrayReference name) { + glBindFragDataLocation(_id, location, name); } -void AbstractShaderProgram::bindFragmentDataLocationIndexed(UnsignedInt location, UnsignedInt index, const std::string& name) { - glBindFragDataLocationIndexed(_id, location, index, name.data()); +void AbstractShaderProgram::bindFragmentDataLocationIndexedInternal(const UnsignedInt location, UnsignedInt index, const Containers::ArrayReference name) { + glBindFragDataLocationIndexed(_id, location, index, name); } #endif @@ -346,10 +346,10 @@ bool AbstractShaderProgram::link(std::initializer_list name) { + GLint location = glGetUniformLocation(_id, name); if(location == -1) - Warning() << "AbstractShaderProgram: location of uniform \'" + name + "\' cannot be retrieved!"; + Warning() << "AbstractShaderProgram: location of uniform \'" + std::string{name, name.size()} + "\' cannot be retrieved!"; return location; } diff --git a/src/Magnum/AbstractShaderProgram.h b/src/Magnum/AbstractShaderProgram.h index eb1888de3..e89e85523 100644 --- a/src/Magnum/AbstractShaderProgram.h +++ b/src/Magnum/AbstractShaderProgram.h @@ -644,7 +644,14 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject { * @ref AbstractShaderProgram-attribute-location "class documentation" * for more information. */ - void bindAttributeLocation(UnsignedInt location, const std::string& name); + void bindAttributeLocation(UnsignedInt location, const std::string& name) { + bindAttributeLocationInternal(location, {name.data(), name.size()}); + } + + /** @overload */ + template void bindAttributeLocation(UnsignedInt location, const char(&name)[size]) { + bindAttributeLocationInternal(location, name); + } #ifndef MAGNUM_TARGET_GLES /** @@ -665,7 +672,14 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject { * @requires_gl Multiple blend function inputs are not available in * OpenGL ES. */ - void bindFragmentDataLocationIndexed(UnsignedInt location, UnsignedInt index, const std::string& name); + void bindFragmentDataLocationIndexed(UnsignedInt location, UnsignedInt index, const std::string& name) { + bindFragmentDataLocationIndexedInternal(location, index, {name.data(), name.size()}); + } + + /** @overload */ + template void bindFragmentDataLocationIndexed(UnsignedInt location, UnsignedInt index, const char(&name)[size]) { + bindFragmentDataLocationIndexedInternal(location, index, name); + } /** * @brief Bind fragment data to given location and first color input index @@ -680,7 +694,15 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject { * and `gl_FragData[n]` provided by @es_extension2{NV,draw_buffers,GL_NV_draw_buffers} * in OpenGL ES 2.0. */ - void bindFragmentDataLocation(UnsignedInt location, const std::string& name); + void bindFragmentDataLocation(UnsignedInt location, const std::string& name) { + bindFragmentDataLocationInternal(location, {name.data(), name.size()}); + } + + /** @overload */ + template void bindFragmentDataLocation(UnsignedInt location, const char(&name)[size]) { + /* Not using const char* parameter, because this way it avoids most accidents with non-zero-terminated strings */ + bindFragmentDataLocationInternal(location, name); + } #endif /** @@ -703,7 +725,14 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject { * @ref AbstractShaderProgram-uniform-location "class documentation" * for more information. */ - Int uniformLocation(const std::string& name); + Int uniformLocation(const std::string& name) { + return uniformLocationInternal({name.data(), name.size()}); + } + + /** @overload */ + template Int uniformLocation(const char(&name)[size]) { + return uniformLocationInternal(name); + } /** * @brief Set uniform value @@ -826,6 +855,10 @@ class MAGNUM_EXPORT AbstractShaderProgram: public AbstractObject { private: AbstractShaderProgram& setLabelInternal(Containers::ArrayReference label); + void bindAttributeLocationInternal(UnsignedInt location, Containers::ArrayReference name); + void bindFragmentDataLocationIndexedInternal(UnsignedInt location, UnsignedInt index, Containers::ArrayReference name); + void bindFragmentDataLocationInternal(UnsignedInt location, Containers::ArrayReference name); + Int uniformLocationInternal(Containers::ArrayReference name); #ifndef MAGNUM_BUILD_DEPRECATED void use(); From ea28b3e8f4aa65c68bb8694d76cb800987bca69c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 24 Jul 2014 23:27:57 +0200 Subject: [PATCH 16/32] TgaImporter: remove old nonsense from plugin configuration file. --- src/MagnumPlugins/TgaImporter/TgaImporter.conf | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/MagnumPlugins/TgaImporter/TgaImporter.conf b/src/MagnumPlugins/TgaImporter/TgaImporter.conf index 02be1f4ce..e69de29bb 100644 --- a/src/MagnumPlugins/TgaImporter/TgaImporter.conf +++ b/src/MagnumPlugins/TgaImporter/TgaImporter.conf @@ -1,4 +0,0 @@ -author=Vladimír Vondruš - -[metadata] -name=TGA image importer From a201f32aab872c68285019cd228e5b826d245a2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 24 Jul 2014 23:28:23 +0200 Subject: [PATCH 17/32] Trade: allow instantiating importer plugins with access to manager. --- src/Magnum/Trade/AbstractImporter.cpp | 5 ++++- src/Magnum/Trade/AbstractImporter.h | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Magnum/Trade/AbstractImporter.cpp b/src/Magnum/Trade/AbstractImporter.cpp index 741988f97..10a4cfe23 100644 --- a/src/Magnum/Trade/AbstractImporter.cpp +++ b/src/Magnum/Trade/AbstractImporter.cpp @@ -25,6 +25,7 @@ #include "AbstractImporter.h" +#include #include #include #include @@ -44,7 +45,9 @@ namespace Magnum { namespace Trade { AbstractImporter::AbstractImporter() = default; -AbstractImporter::AbstractImporter(PluginManager::AbstractManager& manager, std::string plugin): AbstractPlugin(manager, std::move(plugin)) {} +AbstractImporter::AbstractImporter(PluginManager::Manager& manager): AbstractManagingPlugin{manager} {} + +AbstractImporter::AbstractImporter(PluginManager::AbstractManager& manager, std::string plugin): AbstractManagingPlugin(manager, std::move(plugin)) {} bool AbstractImporter::openData(Containers::ArrayReference data) { CORRADE_ASSERT(features() & Feature::OpenData, diff --git a/src/Magnum/Trade/AbstractImporter.h b/src/Magnum/Trade/AbstractImporter.h index 90b3b73f4..b4c99bb4a 100644 --- a/src/Magnum/Trade/AbstractImporter.h +++ b/src/Magnum/Trade/AbstractImporter.h @@ -31,7 +31,7 @@ #include #include -#include +#include #include "Magnum/Magnum.h" #include "Magnum/visibility.h" @@ -74,7 +74,7 @@ checked by the implementation: @todo How to handle casting from std::unique_ptr<> in more convenient way? */ -class MAGNUM_EXPORT AbstractImporter: public PluginManager::AbstractPlugin { +class MAGNUM_EXPORT AbstractImporter: public PluginManager::AbstractManagingPlugin { CORRADE_PLUGIN_INTERFACE("cz.mosra.magnum.Trade.AbstractImporter/0.3") public: @@ -94,6 +94,9 @@ class MAGNUM_EXPORT AbstractImporter: public PluginManager::AbstractPlugin { /** @brief Default constructor */ explicit AbstractImporter(); + /** @brief Default constructor with access to plugin manaer */ + explicit AbstractImporter(PluginManager::Manager& manager); + /** @brief Plugin manager constructor */ explicit AbstractImporter(PluginManager::AbstractManager& manager, std::string plugin); From 539da0daf17274618a8ab08b2a0aa3d6379de0d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 26 Jul 2014 18:46:16 +0200 Subject: [PATCH 18/32] Trade: minor cleanup. --- src/Magnum/Trade/AbstractImporter.cpp | 2 +- src/Magnum/Trade/AbstractImporter.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Magnum/Trade/AbstractImporter.cpp b/src/Magnum/Trade/AbstractImporter.cpp index 10a4cfe23..5825b3c88 100644 --- a/src/Magnum/Trade/AbstractImporter.cpp +++ b/src/Magnum/Trade/AbstractImporter.cpp @@ -25,8 +25,8 @@ #include "AbstractImporter.h" -#include #include +#include #include #include diff --git a/src/Magnum/Trade/AbstractImporter.h b/src/Magnum/Trade/AbstractImporter.h index b4c99bb4a..10023b4b9 100644 --- a/src/Magnum/Trade/AbstractImporter.h +++ b/src/Magnum/Trade/AbstractImporter.h @@ -94,7 +94,7 @@ class MAGNUM_EXPORT AbstractImporter: public PluginManager::AbstractManagingPlug /** @brief Default constructor */ explicit AbstractImporter(); - /** @brief Default constructor with access to plugin manaer */ + /** @brief Default constructor with access to plugin manager */ explicit AbstractImporter(PluginManager::Manager& manager); /** @brief Plugin manager constructor */ From b60c2dcb513261a5e1a350efafc0ec4f2d4e98c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 26 Jul 2014 18:47:51 +0200 Subject: [PATCH 19/32] Math: better algorithm for comparing floating-point values. Still not ideal (for values around zero), but can't do much better for such general case. --- .../Math/Algorithms/Test/GramSchmidtTest.cpp | 6 +- src/Magnum/Math/Test/Matrix4Test.cpp | 14 +-- src/Magnum/Math/Test/QuaternionTest.cpp | 2 +- src/Magnum/Math/Test/TypeTraitsTest.cpp | 85 +++++++++++++++---- src/Magnum/Math/Test/UnitTest.cpp | 4 +- src/Magnum/Math/TypeTraits.h | 38 ++++++--- 6 files changed, 105 insertions(+), 44 deletions(-) diff --git a/src/Magnum/Math/Algorithms/Test/GramSchmidtTest.cpp b/src/Magnum/Math/Algorithms/Test/GramSchmidtTest.cpp index dac903407..f363b0a30 100644 --- a/src/Magnum/Math/Algorithms/Test/GramSchmidtTest.cpp +++ b/src/Magnum/Math/Algorithms/Test/GramSchmidtTest.cpp @@ -90,9 +90,9 @@ void GramSchmidtTest::orthonormalize() { CORRADE_COMPARE(Vector3::dot(orthonormalized[1], orthonormalized[2]), 0.0f); /* Just to be sure */ - Matrix3x3 expected(Vector3( 0.303046f, 0.505076f, 0.808122f), - Vector3( 0.928316f, -0.348119f, -0.130544f), - Vector3(-0.215388f, -0.789754f, 0.574367f)); + Matrix3x3 expected(Vector3( 0.3030458f, 0.5050763f, 0.8081220f), + Vector3( 0.9283164f, -0.3481189f, -0.1305445f), + Vector3(-0.2153877f, -0.7897540f, 0.5743665f)); CORRADE_COMPARE(orthonormalized, expected); } diff --git a/src/Magnum/Math/Test/Matrix4Test.cpp b/src/Magnum/Math/Test/Matrix4Test.cpp index a22c00f62..0ab83290a 100644 --- a/src/Magnum/Math/Test/Matrix4Test.cpp +++ b/src/Magnum/Math/Test/Matrix4Test.cpp @@ -263,10 +263,10 @@ void Matrix4Test::rotation() { CORRADE_COMPARE(Matrix4::rotation(Deg(-74.0f), {-1.0f, 2.0f, 2.0f}), Matrix4()); CORRADE_COMPARE(o.str(), "Math::Matrix4::rotation(): axis must be normalized\n"); - Matrix4 matrix({ 0.35612214f, -0.80181062f, 0.47987163f, 0.0f}, - { 0.47987163f, 0.59757638f, 0.6423595f, 0.0f}, - {-0.80181062f, 0.0015183985f, 0.59757638f, 0.0f}, - { 0.0f, 0.0f, 0.0f, 1.0f}); + Matrix4 matrix({ 0.35612202f, -0.80181062f, 0.47987163f, 0.0f}, + { 0.47987163f, 0.59757626f, 0.6423596f, 0.0f}, + {-0.80181062f, 0.00151846f, 0.59757626f, 0.0f}, + { 0.0f, 0.0f, 0.0f, 1.0f}); CORRADE_COMPARE(Matrix4::rotation(Deg(-74.0f), Vector3(-1.0f, 2.0f, 2.0f).normalized()), matrix); } @@ -388,9 +388,9 @@ void Matrix4Test::rotationNormalizedPart() { void Matrix4Test::rotationPart() { Matrix4 rotation = Matrix4::rotation(Deg(-74.0f), Vector3(-1.0f, 2.0f, 2.0f).normalized()); - Matrix3x3 expectedRotationPart(Vector3( 0.35612214f, -0.80181062f, 0.47987163f), - Vector3( 0.47987163f, 0.59757638f, 0.6423595f), - Vector3(-0.80181062f, 0.0015183985f, 0.59757638f)); + Matrix3x3 expectedRotationPart(Vector3( 0.35612206f, -0.80181074f, 0.47987169f), + Vector3( 0.47987163f, 0.59757626f, 0.64235962f), + Vector3(-0.80181062f, 0.00151846f, 0.59757626f)); /* For rotation and translation this is the same as rotationScaling() */ Matrix4 rotationTranslation = rotation*Matrix4::translation({2.0f, 5.0f, -3.0f}); diff --git a/src/Magnum/Math/Test/QuaternionTest.cpp b/src/Magnum/Math/Test/QuaternionTest.cpp index ef77adcca..6ea6ba624 100644 --- a/src/Magnum/Math/Test/QuaternionTest.cpp +++ b/src/Magnum/Math/Test/QuaternionTest.cpp @@ -347,7 +347,7 @@ void QuaternionTest::slerp() { CORRADE_COMPARE(o.str(), "Math::Quaternion::slerp(): quaternions must be normalized\n"); Quaternion slerp = Quaternion::slerp(a, b, 0.35f); - CORRADE_COMPARE(slerp, Quaternion({0.119165f, 0.0491109f, 0.0491109f}, 0.990442f)); + CORRADE_COMPARE(slerp, Quaternion({0.1191653f, 0.0491109f, 0.0491109f}, 0.9904423f)); } void QuaternionTest::transformVector() { diff --git a/src/Magnum/Math/Test/TypeTraitsTest.cpp b/src/Magnum/Math/Test/TypeTraitsTest.cpp index 225ada51d..bd0bcde71 100644 --- a/src/Magnum/Math/Test/TypeTraitsTest.cpp +++ b/src/Magnum/Math/Test/TypeTraitsTest.cpp @@ -34,17 +34,29 @@ class TypeTraitsTest: public Corrade::TestSuite::Tester { public: TypeTraitsTest(); - void equalsFloatingPoint(); void equalsIntegral(); + void equalsFloatingPoint0(); + void equalsFloatingPoint1(); + void equalsFloatingPointLarge(); + void equalsFloatingPointInfinity(); + void equalsFloatingPointNaN(); private: - template void _equalsFloatingPoint(); - template void _equalsIntegral(); + template void _equalsIntegral(); + template void _equalsFloatingPoint0(); + template void _equalsFloatingPoint1(); + template void _equalsFloatingPointLarge(); + template void _equalsFloatingPointInfinity(); + template void _equalsFloatingPointNaN(); }; TypeTraitsTest::TypeTraitsTest() { addTests({&TypeTraitsTest::equalsIntegral, - &TypeTraitsTest::equalsFloatingPoint}); + &TypeTraitsTest::equalsFloatingPoint0, + &TypeTraitsTest::equalsFloatingPoint1, + &TypeTraitsTest::equalsFloatingPointLarge, + &TypeTraitsTest::equalsFloatingPointInfinity, + &TypeTraitsTest::equalsFloatingPointNaN}); } void TypeTraitsTest::equalsIntegral() { @@ -58,29 +70,68 @@ void TypeTraitsTest::equalsIntegral() { _equalsIntegral(); } -void TypeTraitsTest::equalsFloatingPoint() { - _equalsFloatingPoint(); +template void TypeTraitsTest::_equalsIntegral() { + CORRADE_VERIFY(!TypeTraits::equals(1, 1+TypeTraits::epsilon())); +} + +void TypeTraitsTest::equalsFloatingPoint0() { + _equalsFloatingPoint0(); #ifndef MAGNUM_TARGET_GLES - _equalsFloatingPoint(); + _equalsFloatingPoint0(); #endif } -template void TypeTraitsTest::_equalsIntegral() { - CORRADE_VERIFY(!TypeTraits::equals(1, 1+TypeTraits::epsilon())); +template void TypeTraitsTest::_equalsFloatingPoint0() { + CORRADE_VERIFY(TypeTraits::equals(T(0)+TypeTraits::epsilon()/T(2), T(0))); + CORRADE_VERIFY(!TypeTraits::equals(T(0)+TypeTraits::epsilon()*T(2), T(0))); } -template void TypeTraitsTest::_equalsFloatingPoint() { +void TypeTraitsTest::equalsFloatingPoint1() { + _equalsFloatingPoint1(); + #ifndef MAGNUM_TARGET_GLES + _equalsFloatingPoint1(); + #endif +} + +template void TypeTraitsTest::_equalsFloatingPoint1() { CORRADE_VERIFY(TypeTraits::equals(T(1)+TypeTraits::epsilon()/T(2), T(1))); - CORRADE_VERIFY(!TypeTraits::equals(T(1)+TypeTraits::epsilon()*T(2), T(1))); + CORRADE_VERIFY(!TypeTraits::equals(T(1)+TypeTraits::epsilon()*T(3), T(1))); +} + +void TypeTraitsTest::equalsFloatingPointLarge() { + _equalsFloatingPointLarge(); + #ifndef MAGNUM_TARGET_GLES + _equalsFloatingPointLarge(); + #endif +} + +template void TypeTraitsTest::_equalsFloatingPointLarge() { + CORRADE_VERIFY(TypeTraits::equals(T(25)+TypeTraits::epsilon()*T(2), T(25))); + CORRADE_VERIFY(!TypeTraits::equals(T(25)+TypeTraits::epsilon()*T(75), T(25))); +} - { - CORRADE_EXPECT_FAIL("Comparing to infinity is broken"); - CORRADE_VERIFY(TypeTraits::equals(std::numeric_limits::infinity(), - std::numeric_limits::infinity())); - } +void TypeTraitsTest::equalsFloatingPointInfinity() { + _equalsFloatingPointInfinity(); + #ifndef MAGNUM_TARGET_GLES + _equalsFloatingPointInfinity(); + #endif +} + +template void TypeTraitsTest::_equalsFloatingPointInfinity() { + CORRADE_VERIFY(TypeTraits::equals(std::numeric_limits::infinity(), + std::numeric_limits::infinity())); +} + +void TypeTraitsTest::equalsFloatingPointNaN() { + _equalsFloatingPointNaN(); + #ifndef MAGNUM_TARGET_GLES + _equalsFloatingPointNaN(); + #endif +} +template void TypeTraitsTest::_equalsFloatingPointNaN() { CORRADE_VERIFY(!TypeTraits::equals(std::numeric_limits::quiet_NaN(), - std::numeric_limits::quiet_NaN())); + std::numeric_limits::quiet_NaN())); } }}} diff --git a/src/Magnum/Math/Test/UnitTest.cpp b/src/Magnum/Math/Test/UnitTest.cpp index 587ded6e9..c80157e68 100644 --- a/src/Magnum/Math/Test/UnitTest.cpp +++ b/src/Magnum/Math/Test/UnitTest.cpp @@ -86,8 +86,8 @@ void UnitTest::constructConversion() { } void UnitTest::compare() { - CORRADE_VERIFY(Sec(25.0f + TypeTraits::epsilon()/2) == Sec(25.0f)); - CORRADE_VERIFY(Sec(25.0f + TypeTraits::epsilon()*2) != Sec(25.0f)); + CORRADE_VERIFY(Sec(25.0f + TypeTraits::epsilon()/2.0f) == Sec(25.0f)); + CORRADE_VERIFY(Sec(25.0f + TypeTraits::epsilon()*75.0f) != Sec(25.0f)); constexpr bool c = Sec(3.0f) < Sec(3.0f); constexpr bool d = Sec(3.0f) <= Sec(3.0f); diff --git a/src/Magnum/Math/TypeTraits.h b/src/Magnum/Math/TypeTraits.h index 10c3fbbff..109137c48 100644 --- a/src/Magnum/Math/TypeTraits.h +++ b/src/Magnum/Math/TypeTraits.h @@ -106,14 +106,6 @@ template struct TypeTraits: Implementation::TypeTraitsDefault { #endif }; -/** @bug Infinity comparison! */ - -/** - * @todo Implement better fuzzy comparison algorithm, like at - * http://floating-point-gui.de/errors/comparison/ or - * http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm - */ - /* Integral scalar types */ namespace Implementation { template struct TypeTraitsIntegral: TypeTraitsDefault { @@ -159,13 +151,31 @@ template<> struct TypeTraits: Implementation::TypeTraitsIntegral { /* Floating-point scalar types */ namespace Implementation { - template struct TypeTraitsFloatingPoint { - TypeTraitsFloatingPoint() = delete; - static bool equals(T a, T b) { - return std::abs(a - b) < TypeTraits::epsilon(); - } - }; +template struct TypeTraitsFloatingPoint { + TypeTraitsFloatingPoint() = delete; + + static bool equals(T a, T b); +}; + +/* Adapted from http://floating-point-gui.de/errors/comparison/ */ +template bool TypeTraitsFloatingPoint::equals(const T a, const T b) { + /* Shortcut for binary equality (also infinites) */ + if (a == b) return true; + + const T absA = std::abs(a); + const T absB = std::abs(b); + const T difference = std::abs(a - b); + + /* One of the numbers is zero or both are extremely close to it, relative + error is meaningless */ + if (a == T{} || b == T{} || difference < TypeTraits::epsilon()) + return difference < TypeTraits::epsilon(); + + /* Relative error */ + return difference/(absA + absB) < TypeTraits::epsilon(); +} + } template<> struct TypeTraits: Implementation::TypeTraitsFloatingPoint { From 5e88bb0da2524866d46912042fe4c802ce6349bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 26 Jul 2014 18:48:42 +0200 Subject: [PATCH 20/32] Math: less strict precision for comparing floats. Now the viewer example is usable again. --- src/Magnum/Math/TypeTraits.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Magnum/Math/TypeTraits.h b/src/Magnum/Math/TypeTraits.h index 109137c48..7a5fb6914 100644 --- a/src/Magnum/Math/TypeTraits.h +++ b/src/Magnum/Math/TypeTraits.h @@ -35,7 +35,7 @@ /** @brief Precision when testing floats for equality */ #ifndef FLOAT_EQUALITY_PRECISION -#define FLOAT_EQUALITY_PRECISION 1.0e-6f +#define FLOAT_EQUALITY_PRECISION 1.0e-5f #endif /** @brief Precision when testing doubles for equality */ From dfec071575d76d007d4551bf3cb67ed3b6cb5e6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 30 Jul 2014 19:37:43 +0200 Subject: [PATCH 21/32] Less strict version string comparison in Context. Not all drivers return "2.1 Vendor", there is also "2.1.2 NVIDIA" (and probably more). --- src/Magnum/Context.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Magnum/Context.cpp b/src/Magnum/Context.cpp index a9661133a..e3aeb3fd4 100644 --- a/src/Magnum/Context.cpp +++ b/src/Magnum/Context.cpp @@ -332,7 +332,7 @@ Context::Context() { /* Allow ES2 context on driver that reports ES3 as supported */ const std::string version = versionString(); #ifndef MAGNUM_TARGET_GLES - if(version.compare(0, 4, "2.1 ") == 0) + if(version.compare(0, 3, "2.1") == 0) #elif defined(MAGNUM_TARGET_WEBGL) if(version.find("WebGL 1") != std::string::npos) #else From 0d9c21b4913d1746a90309f2550ca52edd98b6cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 27 Jul 2014 12:09:36 +0200 Subject: [PATCH 22/32] doc: mention plugin interface string in plugin interface docs. --- src/Magnum/Audio/AbstractImporter.h | 2 ++ src/Magnum/Text/AbstractFont.h | 2 ++ src/Magnum/Text/AbstractFontConverter.h | 2 ++ src/Magnum/Trade/AbstractImageConverter.h | 2 ++ src/Magnum/Trade/AbstractImporter.h | 4 +++- 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Magnum/Audio/AbstractImporter.h b/src/Magnum/Audio/AbstractImporter.h index 429253d11..86d60d918 100644 --- a/src/Magnum/Audio/AbstractImporter.h +++ b/src/Magnum/Audio/AbstractImporter.h @@ -59,6 +59,8 @@ checked by the implementation: supported. - All `do*()` implementations working on opened file are called only if there is any file opened. + +Plugin interface string is `"cz.mosra.magnum.Audio.AbstractImporter/0.1"`. */ class MAGNUM_AUDIO_EXPORT AbstractImporter: public PluginManager::AbstractPlugin { CORRADE_PLUGIN_INTERFACE("cz.mosra.magnum.Audio.AbstractImporter/0.1") diff --git a/src/Magnum/Text/AbstractFont.h b/src/Magnum/Text/AbstractFont.h index e903cef6f..54d088377 100644 --- a/src/Magnum/Text/AbstractFont.h +++ b/src/Magnum/Text/AbstractFont.h @@ -71,6 +71,8 @@ checked by the implementation: @ref Feature::OpenData is supported. - All `do*()` implementations working on opened file are called only if there is any file opened. + +Plugin interface string is `"cz.mosra.magnum.Text.AbstractFont/0.2.3"`. */ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin { CORRADE_PLUGIN_INTERFACE("cz.mosra.magnum.Text.AbstractFont/0.2.3") diff --git a/src/Magnum/Text/AbstractFontConverter.h b/src/Magnum/Text/AbstractFontConverter.h index 015ce5038..c2af1025a 100644 --- a/src/Magnum/Text/AbstractFontConverter.h +++ b/src/Magnum/Text/AbstractFontConverter.h @@ -67,6 +67,8 @@ checked by the implementation: if @ref Feature::ConvertData is supported. - Function `doImport*FromData()` is called only if there is at least one data array passed. + +Plugin interface string is `"cz.mosra.magnum.Text.AbstractFontConverter/0.1.1"`. */ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPlugin { CORRADE_PLUGIN_INTERFACE("cz.mosra.magnum.Text.AbstractFontConverter/0.1.1") diff --git a/src/Magnum/Trade/AbstractImageConverter.h b/src/Magnum/Trade/AbstractImageConverter.h index 4c39a6144..c2994d39b 100644 --- a/src/Magnum/Trade/AbstractImageConverter.h +++ b/src/Magnum/Trade/AbstractImageConverter.h @@ -55,6 +55,8 @@ checked by the implementation: - Functions @ref doExportToImage() or @ref doExportToData() are called only if @ref Feature::ConvertImage or @ref Feature::ConvertData is supported. + +Plugin interface string is `"cz.mosra.magnum.Trade.AbstractImageConverter/0.2.1"`. */ class MAGNUM_EXPORT AbstractImageConverter: public PluginManager::AbstractPlugin { CORRADE_PLUGIN_INTERFACE("cz.mosra.magnum.Trade.AbstractImageConverter/0.2.1") diff --git a/src/Magnum/Trade/AbstractImporter.h b/src/Magnum/Trade/AbstractImporter.h index 10023b4b9..00dfff541 100644 --- a/src/Magnum/Trade/AbstractImporter.h +++ b/src/Magnum/Trade/AbstractImporter.h @@ -72,6 +72,8 @@ checked by the implementation: - All `do*()` implementations taking data ID as parameter are called only if the ID is from valid range. +Plugin interface string is `"cz.mosra.magnum.Trade.AbstractImporter/0.3"`. + @todo How to handle casting from std::unique_ptr<> in more convenient way? */ class MAGNUM_EXPORT AbstractImporter: public PluginManager::AbstractManagingPlugin { @@ -94,7 +96,7 @@ class MAGNUM_EXPORT AbstractImporter: public PluginManager::AbstractManagingPlug /** @brief Default constructor */ explicit AbstractImporter(); - /** @brief Default constructor with access to plugin manager */ + /** @brief Constructor with access to plugin manager */ explicit AbstractImporter(PluginManager::Manager& manager); /** @brief Plugin manager constructor */ From 25bbc57d4c6106e06bb53041d44ae7748a3fb397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 27 Jul 2014 22:16:04 +0200 Subject: [PATCH 23/32] modules: minor cleanup. --- modules/FindMagnum.cmake | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index b6b9f9e10..cef0cfc98 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -357,20 +357,18 @@ foreach(component ${Magnum_FIND_COMPONENTS}) else() unset(MAGNUM_${_COMPONENT}_LIBRARY) endif() - endif() # GLUT application dependencies - if(${component} STREQUAL GlutApplication) + elseif(${component} STREQUAL GlutApplication) find_package(GLUT) if(GLUT_FOUND) set(_MAGNUM_${_COMPONENT}_LIBRARIES ${GLUT_glut_LIBRARY}) else() unset(MAGNUM_${_COMPONENT}_LIBRARY) endif() - endif() # SDL2 application dependencies - if(${component} STREQUAL Sdl2Application) + elseif(${component} STREQUAL Sdl2Application) find_package(SDL2) if(SDL2_FOUND) set(_MAGNUM_${_COMPONENT}_LIBRARIES ${SDL2_LIBRARY}) @@ -378,25 +376,25 @@ foreach(component ${Magnum_FIND_COMPONENTS}) else() unset(MAGNUM_${_COMPONENT}_LIBRARY) endif() - endif() # (Windowless) NaCl application dependencies - if(${component} STREQUAL NaClApplication OR ${component} STREQUAL WindowlessNaClApplication) + elseif(${component} STREQUAL NaClApplication OR ${component} STREQUAL WindowlessNaClApplication) set(_MAGNUM_${_COMPONENT}_LIBRARIES ppapi_cpp ppapi) - endif() - # GLX application dependencies - if(${component} STREQUAL GlxApplication OR ${component} STREQUAL WindowlessGlxApplication) + # (Windowless) GLX application dependencies + elseif(${component} STREQUAL GlxApplication OR ${component} STREQUAL WindowlessGlxApplication) find_package(X11) if(X11_FOUND) set(_MAGNUM_${_COMPONENT}_LIBRARIES ${X11_LIBRARIES}) else() unset(MAGNUM_${_COMPONENT}_LIBRARY) endif() - endif() + + # Windowless CGL application has no additional dependencies + # Windowless WGL application has no additional dependencies # X/EGL application dependencies - if(${component} STREQUAL XEglApplication) + elseif(${component} STREQUAL XEglApplication) find_package(EGL) find_package(X11) if(EGL_FOUND AND X11_FOUND) @@ -407,7 +405,9 @@ foreach(component ${Magnum_FIND_COMPONENTS}) endif() # Common application dependencies - set(_MAGNUM_${_COMPONENT}_LIBRARIES ${_MAGNUM_${_COMPONENT}_LIBRARIES} ${_WINDOWCONTEXT_MAGNUM_LIBRARIES_DEPENDENCY}) + set(_MAGNUM_${_COMPONENT}_LIBRARIES + ${_MAGNUM_${_COMPONENT}_LIBRARIES} + ${_WINDOWCONTEXT_MAGNUM_LIBRARIES_DEPENDENCY}) # Audio library elseif(${component} STREQUAL Audio) From 746b4eb692ce4d07ece059c456d220f0d491f719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 28 Jul 2014 23:01:49 +0200 Subject: [PATCH 24/32] Platform: specify dependencies for Application libs on single place. --- CMakeLists.txt | 3 +-- src/Magnum/Platform/CMakeLists.txt | 8 ++++++-- src/Magnum/Text/CMakeLists.txt | 6 +++--- src/Magnum/TextureTools/CMakeLists.txt | 6 +++--- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 34e71f6b3..cf29c4e72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -168,8 +168,7 @@ endif() if(BUILD_GL_TESTS) if(UNIX AND (NOT MAGNUM_TARGET_GLES OR MAGNUM_TARGET_DESKTOP_GLES)) set(WITH_WINDOWLESSGLXAPPLICATION ON) - find_package(X11 REQUIRED) - set(GL_TEST_LIBRARIES Magnum MagnumWindowlessGlxApplication ${X11_LIBRARIES}) + set(GL_TEST_LIBRARIES Magnum MagnumWindowlessGlxApplication) else() message(FATAL_ERROR "Cannot run tests for OpenGL code on this platform. Set BUILD_GL_TESTS to OFF to skip building them.") endif() diff --git a/src/Magnum/Platform/CMakeLists.txt b/src/Magnum/Platform/CMakeLists.txt index 09087aca0..30fa74ab2 100644 --- a/src/Magnum/Platform/CMakeLists.txt +++ b/src/Magnum/Platform/CMakeLists.txt @@ -108,6 +108,7 @@ if(WITH_WINDOWLESSNACLAPPLICATION) add_library(MagnumWindowlessNaClApplication STATIC WindowlessNaClApplication.cpp) set_target_properties(MagnumWindowlessNaClApplication PROPERTIES DEBUG_POSTFIX "-d") + target_link_libraries(MagnumWindowlessNaClApplication Magnum ppapi_cpp ppapi) install(FILES WindowlessNaClApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) install(TARGETS MagnumWindowlessNaClApplication RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} @@ -171,6 +172,7 @@ if(WITH_WINDOWLESSGLXAPPLICATION) set_target_properties(MagnumWindowlessGlxApplication PROPERTIES COMPILE_FLAGS "-Wno-old-style-cast" DEBUG_POSTFIX "-d") + target_link_libraries(MagnumWindowlessGlxApplication Magnum ${X11_LIBRARIES}) install(FILES WindowlessGlxApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) install(TARGETS MagnumWindowlessGlxApplication RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} @@ -184,6 +186,7 @@ if(WITH_WINDOWLESSWGLAPPLICATION) set_target_properties(MagnumWindowlessWglApplication PROPERTIES COMPILE_FLAGS "-DUNICODE" DEBUG_POSTFIX "-d") + target_link_libraries(MagnumWindowlessWglApplication Magnum) install(FILES WindowlessWglApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) install(TARGETS MagnumWindowlessWglApplication RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} @@ -194,6 +197,7 @@ endif() # Windowless CGL application if(WITH_WINDOWLESSCGLAPPLICATION) add_library(MagnumWindowlessCglApplication STATIC WindowlessCglApplication.cpp) + target_link_libraries(MagnumWindowlessCglApplication Magnum) install(FILES WindowlessCglApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) install(TARGETS MagnumWindowlessCglApplication RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} @@ -235,9 +239,9 @@ if(WITH_MAGNUMINFO) if(CORRADE_TARGET_APPLE) target_link_libraries(magnum-info MagnumWindowlessCglApplication) elseif(CORRADE_TARGET_NACL) - target_link_libraries(magnum-info MagnumWindowlessNaClApplication ppapi_cpp ppapi) + target_link_libraries(magnum-info MagnumWindowlessNaClApplication) elseif(CORRADE_TARGET_UNIX) - target_link_libraries(magnum-info MagnumWindowlessGlxApplication ${X11_LIBRARIES}) + target_link_libraries(magnum-info MagnumWindowlessGlxApplication) elseif(CORRADE_TARGET_WINDOWS) target_link_libraries(magnum-info MagnumWindowlessWglApplication) else() diff --git a/src/Magnum/Text/CMakeLists.txt b/src/Magnum/Text/CMakeLists.txt index 5513a8d5d..6b179a817 100644 --- a/src/Magnum/Text/CMakeLists.txt +++ b/src/Magnum/Text/CMakeLists.txt @@ -68,11 +68,11 @@ if(WITH_FONTCONVERTER) add_executable(magnum-fontconverter fontconverter.cpp) if(CORRADE_TARGET_APPLE) - target_link_libraries(magnum-fontconverter MagnumText Magnum MagnumWindowlessCglApplication) + target_link_libraries(magnum-fontconverter MagnumText MagnumWindowlessCglApplication) elseif(CORRADE_TARGET_UNIX AND NOT TARGET_GLES) - target_link_libraries(magnum-fontconverter MagnumText Magnum MagnumWindowlessGlxApplication ${X11_LIBRARIES}) + target_link_libraries(magnum-fontconverter MagnumText MagnumWindowlessGlxApplication) elseif(CORRADE_TARGET_WINDOWS) - target_link_libraries(magnum-fontconverter MagnumText Magnum MagnumWindowlessWglApplication) + target_link_libraries(magnum-fontconverter MagnumText MagnumWindowlessWglApplication) else() message(FATAL_ERROR "magnum-fontconverter is not available on this platform. Set WITH_FONTCONVERTER to OFF to suppress this warning.") endif() diff --git a/src/Magnum/TextureTools/CMakeLists.txt b/src/Magnum/TextureTools/CMakeLists.txt index d5ad0a28d..a6ce5b75e 100644 --- a/src/Magnum/TextureTools/CMakeLists.txt +++ b/src/Magnum/TextureTools/CMakeLists.txt @@ -57,11 +57,11 @@ if(WITH_DISTANCEFIELDCONVERTER) add_executable(magnum-distancefieldconverter distancefieldconverter.cpp) if(CORRADE_TARGET_APPLE) - target_link_libraries(magnum-distancefieldconverter MagnumTextureTools MagnumWindowlessCglApplication Magnum) + target_link_libraries(magnum-distancefieldconverter MagnumTextureTools MagnumWindowlessCglApplication) elseif(CORRADE_TARGET_UNIX AND NOT TARGET_GLES) - target_link_libraries(magnum-distancefieldconverter MagnumTextureTools Magnum MagnumWindowlessGlxApplication ${X11_LIBRARIES}) + target_link_libraries(magnum-distancefieldconverter MagnumTextureTools Magnum MagnumWindowlessGlxApplication) elseif(CORRADE_TARGET_WINDOWS) - target_link_libraries(magnum-distancefieldconverter MagnumTextureTools MagnumWindowlessWglApplication Magnum) + target_link_libraries(magnum-distancefieldconverter MagnumTextureTools MagnumWindowlessWglApplication) else() message(FATAL_ERROR "magnum-distancefieldconverter is not available on this platform. Set WITH_DISTANCEFIELDCONVERTER to OFF to suppress this warning.") endif() From 53039793157ceb1ae91461de85f970c233860340 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 28 Jul 2014 23:03:08 +0200 Subject: [PATCH 25/32] Shaders: make the helper function inline. Will be used outside of the library and I don't want to create another inter-library dependency. --- src/Magnum/Shaders/CMakeLists.txt | 2 - .../CreateCompatibilityShader.cpp | 58 ------------------- .../CreateCompatibilityShader.h | 27 ++++++++- 3 files changed, 26 insertions(+), 61 deletions(-) delete mode 100644 src/Magnum/Shaders/Implementation/CreateCompatibilityShader.cpp diff --git a/src/Magnum/Shaders/CMakeLists.txt b/src/Magnum/Shaders/CMakeLists.txt index 6ffa51558..4099261d8 100644 --- a/src/Magnum/Shaders/CMakeLists.txt +++ b/src/Magnum/Shaders/CMakeLists.txt @@ -34,8 +34,6 @@ set(MagnumShaders_SRCS Vector.cpp VertexColor.cpp - Implementation/CreateCompatibilityShader.cpp - ${MagnumShaders_RCS}) set(MagnumShaders_HEADERS diff --git a/src/Magnum/Shaders/Implementation/CreateCompatibilityShader.cpp b/src/Magnum/Shaders/Implementation/CreateCompatibilityShader.cpp deleted file mode 100644 index 04accbfa1..000000000 --- a/src/Magnum/Shaders/Implementation/CreateCompatibilityShader.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - This file is part of Magnum. - - Copyright © 2010, 2011, 2012, 2013, 2014 - Vladimír Vondruš - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the "Software"), - to deal in the Software without restriction, including without limitation - the rights to use, copy, modify, merge, publish, distribute, sublicense, - and/or sell copies of the Software, and to permit persons to whom the - Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. -*/ - -#include "CreateCompatibilityShader.h" - -#include - -#include "Magnum/Context.h" -#include "Magnum/Extensions.h" - -namespace Magnum { namespace Shaders { namespace Implementation { - -Shader createCompatibilityShader(const Version version, const Shader::Type type) { - Shader shader(version, type); - - #ifndef MAGNUM_TARGET_GLES - if(Context::current()->isExtensionDisabled(version)) - shader.addSource("#define DISABLE_GL_ARB_explicit_attrib_location\n"); - if(Context::current()->isExtensionDisabled(version)) - shader.addSource("#define DISABLE_GL_ARB_shading_language_420pack\n"); - if(Context::current()->isExtensionDisabled(version)) - shader.addSource("#define DISABLE_GL_ARB_explicit_uniform_location\n"); - #endif - - /* My Android emulator (running on NVidia) doesn't define GL_ES - preprocessor macro, thus *all* the stock shaders fail to compile */ - /** @todo remove this when Android emulator is sane */ - #ifdef CORRADE_TARGET_ANDROID - shader.addSource("#ifndef GL_ES\n#define GL_ES 1\n#endif\n"); - #endif - - shader.addSource(Utility::Resource("MagnumShaders").get("compatibility.glsl")); - return shader; -} - -}}} diff --git a/src/Magnum/Shaders/Implementation/CreateCompatibilityShader.h b/src/Magnum/Shaders/Implementation/CreateCompatibilityShader.h index bb8790629..b3cd0322f 100644 --- a/src/Magnum/Shaders/Implementation/CreateCompatibilityShader.h +++ b/src/Magnum/Shaders/Implementation/CreateCompatibilityShader.h @@ -25,11 +25,36 @@ DEALINGS IN THE SOFTWARE. */ +#include + +#include "Magnum/Context.h" +#include "Magnum/Extensions.h" #include "Magnum/Shader.h" namespace Magnum { namespace Shaders { namespace Implementation { -Shader createCompatibilityShader(Version version, Shader::Type type); +inline Shader createCompatibilityShader(Version version, Shader::Type type) { + Shader shader(version, type); + + #ifndef MAGNUM_TARGET_GLES + if(Context::current()->isExtensionDisabled(version)) + shader.addSource("#define DISABLE_GL_ARB_explicit_attrib_location\n"); + if(Context::current()->isExtensionDisabled(version)) + shader.addSource("#define DISABLE_GL_ARB_shading_language_420pack\n"); + if(Context::current()->isExtensionDisabled(version)) + shader.addSource("#define DISABLE_GL_ARB_explicit_uniform_location\n"); + #endif + + /* My Android emulator (running on NVidia) doesn't define GL_ES + preprocessor macro, thus *all* the stock shaders fail to compile */ + /** @todo remove this when Android emulator is sane */ + #ifdef CORRADE_TARGET_ANDROID + shader.addSource("#ifndef GL_ES\n#define GL_ES 1\n#endif\n"); + #endif + + shader.addSource(Utility::Resource("MagnumShaders").get("compatibility.glsl")); + return shader; +} }}} From df699b75b5cfd0598bdc0135307e5ceab84e6283 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 28 Jul 2014 23:04:12 +0200 Subject: [PATCH 26/32] TextureTools: properly create compatibility shader. --- src/Magnum/TextureTools/DistanceField.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Magnum/TextureTools/DistanceField.cpp b/src/Magnum/TextureTools/DistanceField.cpp index 2542977f7..42aadc390 100644 --- a/src/Magnum/TextureTools/DistanceField.cpp +++ b/src/Magnum/TextureTools/DistanceField.cpp @@ -36,6 +36,7 @@ #include "Magnum/Mesh.h" #include "Magnum/Shader.h" #include "Magnum/Texture.h" +#include "Magnum/Shaders/Implementation/CreateCompatibilityShader.h" namespace Magnum { namespace TextureTools { @@ -84,14 +85,12 @@ DistanceFieldShader::DistanceFieldShader(): radiusUniform(0), scalingUniform(1) const Version v = Context::current()->supportedVersion({Version::GLES300, Version::GLES200}); #endif - Shader vert(v, Shader::Type::Vertex); - Shader frag(v, Shader::Type::Fragment); + Shader vert = Shaders::Implementation::createCompatibilityShader(v, Shader::Type::Vertex); + Shader frag = Shaders::Implementation::createCompatibilityShader(v, Shader::Type::Fragment); - vert.addSource(rs.get("compatibility.glsl")) - .addSource(rs.get("FullScreenTriangle.glsl")) + vert.addSource(rs.get("FullScreenTriangle.glsl")) .addSource(rs.get("DistanceFieldShader.vert")); - frag.addSource(rs.get("compatibility.glsl")) - .addSource(rs.get("DistanceFieldShader.frag")); + frag.addSource(rs.get("DistanceFieldShader.frag")); CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, frag})); From 6fa9d36005c0d27470678b5c6edd4e61e44813d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 28 Jul 2014 23:04:52 +0200 Subject: [PATCH 27/32] TextureTools: const is available since GLSL 4.20. --- src/Magnum/TextureTools/DistanceFieldShader.frag | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Magnum/TextureTools/DistanceFieldShader.frag b/src/Magnum/TextureTools/DistanceFieldShader.frag index b82c6d94b..1224b7f72 100644 --- a/src/Magnum/TextureTools/DistanceFieldShader.frag +++ b/src/Magnum/TextureTools/DistanceFieldShader.frag @@ -26,10 +26,13 @@ #ifndef NEW_GLSL #define in varying #define value gl_FragColor.x -#define const #define texture texture2D #endif +#ifndef RUNTIME_CONST +#define const +#endif + #if (defined(GL_ES) && __VERSION__ >= 300) || (!defined(GL_ES) && __VERSION__ >= 150) #define TEXELFETCH_USABLE #endif From eb32fb1c400edbb6b564ff09e64f406ae2d9c37a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 30 Jul 2014 20:03:23 +0200 Subject: [PATCH 28/32] Proper no-op fallback for *Framebuffer::invalidate*(). The documentation of ARB_invalidate_subdata mentions that all the functions are really just a hint for the implementation to make some performance optimizations and they are not affecting behavior at all. So it's perfectly fine to do nothing if the extension is not supported. I didn't do this originally as I mistakenly thought that invalidating depth buffer would somehow behave the same as clearing it, but that's not the case. --- src/Magnum/AbstractFramebuffer.cpp | 8 +++-- src/Magnum/AbstractFramebuffer.h | 9 ++++-- src/Magnum/DefaultFramebuffer.cpp | 4 +-- src/Magnum/DefaultFramebuffer.h | 28 +++++++---------- src/Magnum/Framebuffer.cpp | 4 +-- src/Magnum/Framebuffer.h | 27 ++++++++--------- .../Implementation/FramebufferState.cpp | 30 +++++++++++++++++++ src/Magnum/Implementation/FramebufferState.h | 2 ++ src/Magnum/Test/FramebufferGLTest.cpp | 10 ------- 9 files changed, 71 insertions(+), 51 deletions(-) diff --git a/src/Magnum/AbstractFramebuffer.cpp b/src/Magnum/AbstractFramebuffer.cpp index c0c5f2f7e..99cefef14 100644 --- a/src/Magnum/AbstractFramebuffer.cpp +++ b/src/Magnum/AbstractFramebuffer.cpp @@ -211,7 +211,9 @@ void AbstractFramebuffer::read(const Vector2i& offset, const Vector2i& size, Buf } #endif -void AbstractFramebuffer::invalidateImplementation(GLsizei count, GLenum* attachments) { +void AbstractFramebuffer::invalidateImplementationNoOp(GLsizei, const GLenum* const) {} + +void AbstractFramebuffer::invalidateImplementationDefault(const GLsizei count, const GLenum* const attachments) { /** @todo Re-enable when extension loader is available for ES */ #ifndef MAGNUM_TARGET_GLES2 glInvalidateFramebuffer(GLenum(bindInternal()), count, attachments); @@ -223,7 +225,9 @@ void AbstractFramebuffer::invalidateImplementation(GLsizei count, GLenum* attach #endif } -void AbstractFramebuffer::invalidateImplementation(GLsizei count, GLenum* attachments, const Range2Di& rectangle) { +void AbstractFramebuffer::invalidateImplementationNoOp(GLsizei, const GLenum*, const Range2Di&) {} + +void AbstractFramebuffer::invalidateImplementationDefault(const GLsizei count, const GLenum* const attachments, const Range2Di& rectangle) { /** @todo Re-enable when extension loader is available for ES */ #ifndef MAGNUM_TARGET_GLES2 glInvalidateSubFramebuffer(GLenum(bindInternal()), count, attachments, rectangle.left(), rectangle.bottom(), rectangle.sizeX(), rectangle.sizeY()); diff --git a/src/Magnum/AbstractFramebuffer.h b/src/Magnum/AbstractFramebuffer.h index 7ab04f1d2..296447830 100644 --- a/src/Magnum/AbstractFramebuffer.h +++ b/src/Magnum/AbstractFramebuffer.h @@ -333,9 +333,6 @@ class MAGNUM_EXPORT AbstractFramebuffer { FramebufferTarget MAGNUM_LOCAL bindInternal(); void MAGNUM_LOCAL setViewportInternal(); - void MAGNUM_LOCAL invalidateImplementation(GLsizei count, GLenum* attachments); - void MAGNUM_LOCAL invalidateImplementation(GLsizei count, GLenum* attachments, const Range2Di& rectangle); - GLuint _id; Range2Di _viewport; @@ -362,6 +359,12 @@ class MAGNUM_EXPORT AbstractFramebuffer { static void MAGNUM_LOCAL readImplementationDefault(const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data); static void MAGNUM_LOCAL readImplementationRobustness(const Vector2i& offset, const Vector2i& size, ColorFormat format, ColorType type, std::size_t dataSize, GLvoid* data); + + void MAGNUM_LOCAL invalidateImplementationNoOp(GLsizei, const GLenum*); + void MAGNUM_LOCAL invalidateImplementationDefault(GLsizei count, const GLenum* attachments); + + void MAGNUM_LOCAL invalidateImplementationNoOp(GLsizei, const GLenum*, const Range2Di&); + void MAGNUM_LOCAL invalidateImplementationDefault(GLsizei count, const GLenum* attachments, const Range2Di& rectangle); }; CORRADE_ENUMSET_OPERATORS(FramebufferClearMask) diff --git a/src/Magnum/DefaultFramebuffer.cpp b/src/Magnum/DefaultFramebuffer.cpp index f2990e3f5..6ccfeb13e 100644 --- a/src/Magnum/DefaultFramebuffer.cpp +++ b/src/Magnum/DefaultFramebuffer.cpp @@ -77,7 +77,7 @@ void DefaultFramebuffer::invalidate(std::initializer_list*Context::current()->state().framebuffer->invalidateImplementation)(attachments.size(), _attachments); } void DefaultFramebuffer::invalidate(std::initializer_list attachments, const Range2Di& rectangle) { @@ -86,7 +86,7 @@ void DefaultFramebuffer::invalidate(std::initializer_list*Context::current()->state().framebuffer->invalidateSubImplementation)(attachments.size(), _attachments, rectangle); } void DefaultFramebuffer::initializeContextBasedFunctionality(Context& context) { diff --git a/src/Magnum/DefaultFramebuffer.h b/src/Magnum/DefaultFramebuffer.h index db2b87b76..b859ce9e8 100644 --- a/src/Magnum/DefaultFramebuffer.h +++ b/src/Magnum/DefaultFramebuffer.h @@ -388,17 +388,13 @@ class MAGNUM_EXPORT DefaultFramebuffer: public AbstractFramebuffer { * @brief Invalidate framebuffer * @param attachments Attachments to invalidate * - * The framebuffer is bound to some target before the operation, if - * not already. + * If extension @extension{ARB,invalidate_subdata} (part of OpenGL + * 4.3), extension @es_extension{EXT,discard_framebuffer} in OpenGL ES + * 2.0 or OpenGL ES 3.0 is not available, this function does nothing. + * The framebuffer is bound to some target before the operation, if not + * already. * @see @fn_gl{InvalidateFramebuffer} or @fn_gles_extension{DiscardFramebuffer,EXT,discard_framebuffer} * on OpenGL ES 2.0 - * @requires_gl43 %Extension @extension{ARB,invalidate_subdata}. Use - * @ref Magnum::DefaultFramebuffer::clear() "clear()" instead - * where the extension is not supported. - * @requires_gles30 %Extension @es_extension{EXT,discard_framebuffer} - * in OpenGL ES 2.0. Use - * @ref Magnum::DefaultFramebuffer::clear() "clear()" instead - * where the extension is not supported. */ void invalidate(std::initializer_list attachments); @@ -407,17 +403,13 @@ class MAGNUM_EXPORT DefaultFramebuffer: public AbstractFramebuffer { * @param attachments Attachments to invalidate * @param rectangle %Rectangle to invalidate * - * The framebuffer is bound to some target before the operation, if - * not already. + * If extension @extension{ARB,invalidate_subdata} (part of OpenGL + * 4.3), extension @es_extension{EXT,discard_framebuffer} in OpenGL ES + * 2.0 or OpenGL ES 3.0 is not available, this function does nothing. + * The framebuffer is bound to some target before the operation, if not + * already. * @see @fn_gl{InvalidateSubFramebuffer} or @fn_gles_extension{DiscardSubFramebuffer,EXT,discard_framebuffer} * on OpenGL ES 2.0 - * @requires_gl43 %Extension @extension{ARB,invalidate_subdata}. Use - * @ref Magnum::DefaultFramebuffer::clear() "clear()" instead - * where the extension is not supported. - * @requires_gles30 %Extension @es_extension{EXT,discard_framebuffer} - * in OpenGL ES 2.0. Use - * @ref Magnum::DefaultFramebuffer::clear() "clear()" instead - * where the extension is not supported. */ void invalidate(std::initializer_list attachments, const Range2Di& rectangle); diff --git a/src/Magnum/Framebuffer.cpp b/src/Magnum/Framebuffer.cpp index 9aafd0cce..d43bf891d 100644 --- a/src/Magnum/Framebuffer.cpp +++ b/src/Magnum/Framebuffer.cpp @@ -154,7 +154,7 @@ void Framebuffer::invalidate(std::initializer_list attac for(std::size_t i = 0; i != attachments.size(); ++i) _attachments[i] = GLenum(*(attachments.begin()+i)); - invalidateImplementation(attachments.size(), _attachments); + (this->*Context::current()->state().framebuffer->invalidateImplementation)(attachments.size(), _attachments); } void Framebuffer::invalidate(std::initializer_list attachments, const Range2Di& rectangle) { @@ -163,7 +163,7 @@ void Framebuffer::invalidate(std::initializer_list attac for(std::size_t i = 0; i != attachments.size(); ++i) _attachments[i] = GLenum(*(attachments.begin()+i)); - invalidateImplementation(attachments.size(), _attachments, rectangle); + (this->*Context::current()->state().framebuffer->invalidateSubImplementation)(attachments.size(), _attachments, rectangle); } Framebuffer& Framebuffer::attachRenderbuffer(const BufferAttachment attachment, Renderbuffer& renderbuffer) { diff --git a/src/Magnum/Framebuffer.h b/src/Magnum/Framebuffer.h index 2368e938c..b2d951c08 100644 --- a/src/Magnum/Framebuffer.h +++ b/src/Magnum/Framebuffer.h @@ -457,16 +457,13 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractObje * @param attachments Attachments to invalidate * @param rectangle %Rectangle to invalidate * - * The framebuffer is bound to some target before the operation, if - * not already. - * @see @fn_gl{InvalidateSubFramebuffer} or @fn_gles_extension{DiscardSubFramebuffer,EXT,discard_framebuffer} + * If extension @extension{ARB,invalidate_subdata} (part of OpenGL + * 4.3), extension @es_extension{EXT,discard_framebuffer} in OpenGL ES + * 2.0 or OpenGL ES 3.0 is not available, this function does nothing. + * The framebuffer is bound to some target before the operation, if not + * already. + * @see @fn_gl{InvalidateFramebuffer} or @fn_gles_extension{DiscardFramebuffer,EXT,discard_framebuffer} * on OpenGL ES 2.0 - * @requires_gl43 %Extension @extension{ARB,invalidate_subdata}. Use - * @ref Magnum::Framebuffer::clear() "clear()" instead where the - * extension is not supported. - * @requires_gles30 %Extension @es_extension{EXT,discard_framebuffer} - * in OpenGL ES 2.0. Use @ref Magnum::Framebuffer::clear() "clear()" - * instead where the extension is not supported. */ void invalidate(std::initializer_list attachments, const Range2Di& rectangle); @@ -476,11 +473,13 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractObje * @param renderbuffer %Renderbuffer * @return Reference to self (for method chaining) * - * If @extension{EXT,direct_state_access} is not available and the - * framebufferbuffer is not currently bound, it is bound before the - * operation. - * @see @fn_gl{BindFramebuffer}, @fn_gl{FramebufferRenderbuffer} or - * @fn_gl_extension{NamedFramebufferRenderbuffer,EXT,direct_state_access} + * If extension @extension{ARB,invalidate_subdata} (part of OpenGL + * 4.3), extension @es_extension{EXT,discard_framebuffer} in OpenGL ES + * 2.0 or OpenGL ES 3.0 is not available, this function does nothing. + * The framebuffer is bound to some target before the operation, if not + * already. + * @see @fn_gl{InvalidateSubFramebuffer} or @fn_gles_extension{DiscardSubFramebuffer,EXT,discard_framebuffer} + * on OpenGL ES 2.0 */ Framebuffer& attachRenderbuffer(BufferAttachment attachment, Renderbuffer& renderbuffer); diff --git a/src/Magnum/Implementation/FramebufferState.cpp b/src/Magnum/Implementation/FramebufferState.cpp index 0f6f3c121..010d23307 100644 --- a/src/Magnum/Implementation/FramebufferState.cpp +++ b/src/Magnum/Implementation/FramebufferState.cpp @@ -138,6 +138,36 @@ FramebufferState::FramebufferState(Context& context, std::vector& e renderbufferStorageMultisampleImplementation = &Renderbuffer::storageMultisampleImplementationDefault; #endif } + + /* Framebuffer invalidation implementation on desktop GL */ + #ifndef MAGNUM_TARGET_GLES + if(context.isExtensionSupported()) { + extensions.push_back(Extensions::GL::ARB::invalidate_subdata::string()); + + invalidateImplementation = &AbstractFramebuffer::invalidateImplementationDefault; + invalidateSubImplementation = &AbstractFramebuffer::invalidateImplementationDefault; + } else { + invalidateImplementation = &AbstractFramebuffer::invalidateImplementationNoOp; + invalidateSubImplementation = &AbstractFramebuffer::invalidateImplementationNoOp; + } + + /* Framebuffer invalidation implementation on ES2 */ + #elif defined(MAGNUM_TARGET_GLES2) + if(context.isExtensionSupported()) { + extensions.push_back(Extensions::GL::EXT::discard_framebuffer::string()); + + invalidateImplementation = &AbstractFramebuffer::invalidateImplementationDefault; + invalidateSubImplementation = &AbstractFramebuffer::invalidateImplementationDefault; + } else { + invalidateImplementation = &AbstractFramebuffer::invalidateImplementationNoOp; + invalidateSubImplementation = &AbstractFramebuffer::invalidateImplementationNoOp; + } + + /* Always available on ES3 */ + #else + invalidateImplementation = &AbstractFramebuffer::invalidateImplementationDefault; + invalidateSubImplementation = &AbstractFramebuffer::invalidateImplementationDefault; + #endif } void FramebufferState::reset() { diff --git a/src/Magnum/Implementation/FramebufferState.h b/src/Magnum/Implementation/FramebufferState.h index 25c55fe29..c2c7322e9 100644 --- a/src/Magnum/Implementation/FramebufferState.h +++ b/src/Magnum/Implementation/FramebufferState.h @@ -41,6 +41,8 @@ struct FramebufferState { void(AbstractFramebuffer::*drawBuffersImplementation)(GLsizei, const GLenum*); void(AbstractFramebuffer::*drawBufferImplementation)(GLenum); void(AbstractFramebuffer::*readBufferImplementation)(GLenum); + void(AbstractFramebuffer::*invalidateImplementation)(GLsizei, const GLenum*); + void(AbstractFramebuffer::*invalidateSubImplementation)(GLsizei, const GLenum*, const Range2Di&); void(Framebuffer::*renderbufferImplementation)(Framebuffer::BufferAttachment, Renderbuffer&); #ifndef MAGNUM_TARGET_GLES diff --git a/src/Magnum/Test/FramebufferGLTest.cpp b/src/Magnum/Test/FramebufferGLTest.cpp index 2df5a8bd7..93fc2f4aa 100644 --- a/src/Magnum/Test/FramebufferGLTest.cpp +++ b/src/Magnum/Test/FramebufferGLTest.cpp @@ -643,11 +643,6 @@ void FramebufferGLTest::invalidate() { #ifndef MAGNUM_TARGET_GLES if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); - if(!Context::current()->isExtensionSupported()) - CORRADE_SKIP(Extensions::GL::ARB::invalidate_subdata::string() + std::string(" is not available.")); - #elif defined(MAGNUM_TARGET_GLES2) - if(!Context::current()->isExtensionSupported()) - CORRADE_SKIP(Extensions::GL::EXT::discard_framebuffer::string() + std::string(" is not available.")); #endif Renderbuffer color; @@ -675,11 +670,6 @@ void FramebufferGLTest::invalidateSub() { #ifndef MAGNUM_TARGET_GLES if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); - if(!Context::current()->isExtensionSupported()) - CORRADE_SKIP(Extensions::GL::ARB::invalidate_subdata::string() + std::string(" is not available.")); - #elif defined(MAGNUM_TARGET_GLES2) - if(!Context::current()->isExtensionSupported()) - CORRADE_SKIP(Extensions::GL::EXT::discard_framebuffer::string() + std::string(" is not available.")); #endif Renderbuffer color; From f5db09b667660d57ea8498ffbc4e7dbfc593fea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 2 Aug 2014 12:57:39 +0200 Subject: [PATCH 29/32] Audio: minor cleanup. --- src/Magnum/Audio/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Magnum/Audio/CMakeLists.txt b/src/Magnum/Audio/CMakeLists.txt index f5b35054d..baba53b79 100644 --- a/src/Magnum/Audio/CMakeLists.txt +++ b/src/Magnum/Audio/CMakeLists.txt @@ -27,7 +27,7 @@ find_package(OpenAL REQUIRED) include_directories(${OPENAL_INCLUDE_DIR}) -set(MagnumAudio_SOURCES +set(MagnumAudio_SRCS AbstractImporter.cpp Audio.cpp Buffer.cpp @@ -45,7 +45,7 @@ set(MagnumAudio_HEADERS visibility.h) -add_library(MagnumAudio ${SHARED_OR_STATIC} ${MagnumAudio_SOURCES}) +add_library(MagnumAudio ${SHARED_OR_STATIC} ${MagnumAudio_SRCS}) set_target_properties(MagnumAudio PROPERTIES DEBUG_POSTFIX "-d") target_link_libraries(MagnumAudio ${CORRADE_PLUGINMANAGER_LIBRARIES} ${OPENAL_LIBRARY}) From 36c85988a81e6aff146e955fa823fedad71319ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 2 Aug 2014 13:01:15 +0200 Subject: [PATCH 30/32] Platform: minor cleanup. --- src/Magnum/Platform/CMakeLists.txt | 42 +++++++++++++++--------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Magnum/Platform/CMakeLists.txt b/src/Magnum/Platform/CMakeLists.txt index 30fa74ab2..33ece0423 100644 --- a/src/Magnum/Platform/CMakeLists.txt +++ b/src/Magnum/Platform/CMakeLists.txt @@ -24,13 +24,13 @@ # # Headers -set(Platform_HEADERS +set(MagnumPlatform_HEADERS Platform.h Screen.h ScreenedApplication.h ScreenedApplication.hpp) -install(FILES ${Platform_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) +install(FILES ${MagnumPlatform_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) # Android application if(WITH_ANDROIDAPPLICATION) @@ -55,34 +55,34 @@ endif() # GLUT application if(WITH_GLUTAPPLICATION) find_package(GLUT) - if(GLUT_FOUND) - add_library(MagnumGlutApplication STATIC GlutApplication.cpp) - set_target_properties(MagnumGlutApplication PROPERTIES DEBUG_POSTFIX "-d") - install(FILES GlutApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) - install(TARGETS MagnumGlutApplication - RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} - LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} - ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) - else() + if(NOT GLUT_FOUND) message(FATAL_ERROR "GLUT library, required by GlutApplication, was not found. Set WITH_GLUTAPPLICATION to OFF to skip building it.") endif() + + add_library(MagnumGlutApplication STATIC GlutApplication.cpp) + set_target_properties(MagnumGlutApplication PROPERTIES DEBUG_POSTFIX "-d") + install(FILES MagnumGlutApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) + install(TARGETS MagnumGlutApplication + RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} + LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} + ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) endif() # SDL2 application if(WITH_SDL2APPLICATION) find_package(SDL2) - if(SDL2_FOUND) - include_directories(${SDL2_INCLUDE_DIR}) - add_library(MagnumSdl2Application STATIC Sdl2Application.cpp) - set_target_properties(MagnumSdl2Application PROPERTIES DEBUG_POSTFIX "-d") - install(FILES Sdl2Application.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) - install(TARGETS MagnumSdl2Application - RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} - LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} - ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) - else() + if(NOT SDL2_FOUND) message(FATAL_ERROR "SDL2 library, required by Sdl2Application, was not found. Set WITH_SDL2APPLICATION to OFF to skip building it.") endif() + + include_directories(${SDL2_INCLUDE_DIR}) + add_library(MagnumSdl2Application STATIC Sdl2Application.cpp) + set_target_properties(MagnumSdl2Application PROPERTIES DEBUG_POSTFIX "-d") + install(FILES Sdl2Application.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) + install(TARGETS MagnumSdl2Application + RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} + LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} + ARCHIVE DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) endif() # NaCl application From b79c3d9305ca26fadf138f654435b27bb105eb90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 2 Aug 2014 13:15:55 +0200 Subject: [PATCH 31/32] Platform: properly set debug postfix also for WindowlessCglApplication. --- src/Magnum/Platform/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Magnum/Platform/CMakeLists.txt b/src/Magnum/Platform/CMakeLists.txt index 33ece0423..11e8d6949 100644 --- a/src/Magnum/Platform/CMakeLists.txt +++ b/src/Magnum/Platform/CMakeLists.txt @@ -197,6 +197,7 @@ endif() # Windowless CGL application if(WITH_WINDOWLESSCGLAPPLICATION) add_library(MagnumWindowlessCglApplication STATIC WindowlessCglApplication.cpp) + set_target_properties(MagnumWindowlessCglApplication PROPERTIES DEBUG_POSTFIX "-d") target_link_libraries(MagnumWindowlessCglApplication Magnum) install(FILES WindowlessCglApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) install(TARGETS MagnumWindowlessCglApplication From 217b53ceb27b25774cb7a1501a6d128e63d094c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 2 Aug 2014 13:47:27 +0200 Subject: [PATCH 32/32] Display all headers in project view of IDEs. Finally makes development with QtCreator usable. --- src/Magnum/Audio/CMakeLists.txt | 4 +- src/Magnum/CMakeLists.txt | 15 +++ src/Magnum/DebugTools/CMakeLists.txt | 21 ++- src/Magnum/Math/Algorithms/CMakeLists.txt | 3 + src/Magnum/Math/CMakeLists.txt | 3 + src/Magnum/Math/Geometry/CMakeLists.txt | 3 + src/Magnum/MeshTools/CMakeLists.txt | 4 +- src/Magnum/Platform/CMakeLists.txt | 148 ++++++++++++++++++---- src/Magnum/Primitives/CMakeLists.txt | 10 +- src/Magnum/SceneGraph/CMakeLists.txt | 4 +- src/Magnum/Shaders/CMakeLists.txt | 8 +- src/Magnum/Shapes/CMakeLists.txt | 8 +- src/Magnum/Text/CMakeLists.txt | 4 +- src/Magnum/TextureTools/CMakeLists.txt | 4 +- src/Magnum/Trade/CMakeLists.txt | 3 + 15 files changed, 206 insertions(+), 36 deletions(-) diff --git a/src/Magnum/Audio/CMakeLists.txt b/src/Magnum/Audio/CMakeLists.txt index baba53b79..2dc837505 100644 --- a/src/Magnum/Audio/CMakeLists.txt +++ b/src/Magnum/Audio/CMakeLists.txt @@ -45,7 +45,9 @@ set(MagnumAudio_HEADERS visibility.h) -add_library(MagnumAudio ${SHARED_OR_STATIC} ${MagnumAudio_SRCS}) +add_library(MagnumAudio ${SHARED_OR_STATIC} + ${MagnumAudio_SRCS} + ${MagnumAudio_HEADERS}) set_target_properties(MagnumAudio PROPERTIES DEBUG_POSTFIX "-d") target_link_libraries(MagnumAudio ${CORRADE_PLUGINMANAGER_LIBRARIES} ${OPENAL_LIBRARY}) diff --git a/src/Magnum/CMakeLists.txt b/src/Magnum/CMakeLists.txt index dd7499091..9cbe04011 100644 --- a/src/Magnum/CMakeLists.txt +++ b/src/Magnum/CMakeLists.txt @@ -119,6 +119,19 @@ set(Magnum_HEADERS visibility.h) +# Header files to display in project view of IDEs only +set(Magnum_PRIVATE_HEADERS + Implementation/BufferState.h + Implementation/DebugState.h + Implementation/FramebufferState.h + Implementation/maxTextureSize.h + Implementation/MeshState.h + Implementation/RendererState.h + Implementation/ShaderProgramState.h + Implementation/ShaderState.h + Implementation/State.h + Implementation/TextureState.h) + # Deprecated headers if(BUILD_DEPRECATED) set(Magnum_HEADERS ${Magnum_HEADERS} @@ -159,6 +172,8 @@ set(MagnumMath_SRCS add_library(MagnumMathObjects OBJECT ${MagnumMath_SRCS}) add_library(Magnum ${SHARED_OR_STATIC} ${Magnum_SRCS} + ${Magnum_HEADERS} + ${Magnum_PRIVATE_HEADERS} $) set_target_properties(Magnum PROPERTIES DEBUG_POSTFIX "-d") diff --git a/src/Magnum/DebugTools/CMakeLists.txt b/src/Magnum/DebugTools/CMakeLists.txt index 4455b248e..d7dd783b3 100644 --- a/src/Magnum/DebugTools/CMakeLists.txt +++ b/src/Magnum/DebugTools/CMakeLists.txt @@ -50,7 +50,26 @@ set(MagnumDebugTools_HEADERS visibility.h) -add_library(MagnumDebugTools ${SHARED_OR_STATIC} ${MagnumDebugTools_SRCS}) +# Header files to display in project view of IDEs only +set(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/ForceRendererTransformation.h + Implementation/LineSegmentRenderer.h + Implementation/LineSegmentRendererTransformation.h + Implementation/PointRenderer.h + Implementation/SphereRenderer.h) + +add_library(MagnumDebugTools ${SHARED_OR_STATIC} + ${MagnumDebugTools_SRCS} + ${MagnumDebugTools_HEADERS} + ${MagnumDebugTools_PRIVATE_HEADERS}) set_target_properties(MagnumDebugTools PROPERTIES DEBUG_POSTFIX "-d") if(BUILD_STATIC_PIC) # TODO: CMake 2.8.9 has this as POSITION_INDEPENDENT_CODE property diff --git a/src/Magnum/Math/Algorithms/CMakeLists.txt b/src/Magnum/Math/Algorithms/CMakeLists.txt index 93f6d48b6..deeec09df 100644 --- a/src/Magnum/Math/Algorithms/CMakeLists.txt +++ b/src/Magnum/Math/Algorithms/CMakeLists.txt @@ -28,6 +28,9 @@ set(MagnumMathAlgorithms_HEADERS GramSchmidt.h Svd.h) +# Force IDEs to display all header files in project view +add_custom_target(MagnumMathAlgorithms SOURCES ${MagnumMathAlgorithms_HEADERS}) + install(FILES ${MagnumMathAlgorithms_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Math/Algorithms) if(BUILD_TESTS) diff --git a/src/Magnum/Math/CMakeLists.txt b/src/Magnum/Math/CMakeLists.txt index cff0d8ee6..bcffdce8b 100644 --- a/src/Magnum/Math/CMakeLists.txt +++ b/src/Magnum/Math/CMakeLists.txt @@ -47,6 +47,9 @@ set(MagnumMath_HEADERS Vector3.h Vector4.h) +# Force IDEs to display all header files in project view +add_custom_target(MagnumMath SOURCES ${MagnumMath_HEADERS}) + install(FILES ${MagnumMath_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Math) add_subdirectory(Algorithms) diff --git a/src/Magnum/Math/Geometry/CMakeLists.txt b/src/Magnum/Math/Geometry/CMakeLists.txt index 1e35f14f7..ac7fb7ff8 100644 --- a/src/Magnum/Math/Geometry/CMakeLists.txt +++ b/src/Magnum/Math/Geometry/CMakeLists.txt @@ -33,6 +33,9 @@ if(BUILD_DEPRECATED) Rectangle.h) endif() +# Force IDEs to display all header files in project view +add_custom_target(MagnumMathGeometry SOURCES ${MagnumMathGeometry_HEADERS}) + install(FILES ${MagnumMathGeometry_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Math/Geometry) if(BUILD_TESTS) diff --git a/src/Magnum/MeshTools/CMakeLists.txt b/src/Magnum/MeshTools/CMakeLists.txt index e700d6f0f..39be0a151 100644 --- a/src/Magnum/MeshTools/CMakeLists.txt +++ b/src/Magnum/MeshTools/CMakeLists.txt @@ -54,7 +54,9 @@ set(MagnumMeshTools_HEADERS # Set shared library flags for the objects, as they will be part of shared lib # TODO: fix when CMake sets target_EXPORTS for OBJECT targets as well -add_library(MagnumMeshToolsObjects OBJECT ${MagnumMeshTools_SRCS}) +add_library(MagnumMeshToolsObjects OBJECT + ${MagnumMeshTools_SRCS} + ${MagnumMeshTools_HEADERS}) if(NOT BUILD_SHARED OR BUILD_STATIC_PIC) # TODO: CMake 2.8.9 has this as POSITION_INDEPENDENT_CODE property set_target_properties(MagnumMeshToolsObjects PROPERTIES COMPILE_FLAGS "-DMagnumMeshToolsObjects_EXPORTS ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}") diff --git a/src/Magnum/Platform/CMakeLists.txt b/src/Magnum/Platform/CMakeLists.txt index 11e8d6949..7001bd717 100644 --- a/src/Magnum/Platform/CMakeLists.txt +++ b/src/Magnum/Platform/CMakeLists.txt @@ -30,6 +30,9 @@ set(MagnumPlatform_HEADERS ScreenedApplication.h ScreenedApplication.hpp) +# Files to display in project view of IDEs only (filled in below) +set(MagnumPlatform_FILES ) + install(FILES ${MagnumPlatform_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) # Android application @@ -40,12 +43,21 @@ if(WITH_ANDROIDAPPLICATION) include_directories(${ANDROID_NATIVE_APP_GLUE_INCLUDE_DIR}) - add_library(MagnumAndroidApplication STATIC + set(MagnumAndroidApplication_SRCS AndroidApplication.cpp - Implementation/Egl.cpp + Implementation/Egl.cpp) + set(MagnumAndroidApplication_HEADERS + AndroidApplication.h) + set(MagnumAndroidApplication_PRIVATE_HEADERS + Implementation/Egl.h) + + add_library(MagnumAndroidApplication STATIC + ${MagnumAndroidApplication_SRCS} + ${MagnumAndroidApplication_HEADERS} + ${MagnumAndroidApplication_PRIVATE_HEADERS} ${ANDROID_NATIVE_APP_GLUE_SRC}) set_target_properties(MagnumAndroidApplication PROPERTIES DEBUG_POSTFIX "-d") - install(FILES AndroidApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) + install(FILES ${MagnumAndroidApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) install(TARGETS MagnumAndroidApplication RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} @@ -59,9 +71,14 @@ if(WITH_GLUTAPPLICATION) message(FATAL_ERROR "GLUT library, required by GlutApplication, was not found. Set WITH_GLUTAPPLICATION to OFF to skip building it.") endif() - add_library(MagnumGlutApplication STATIC GlutApplication.cpp) + set(MagnumGlutApplication_SRCS GlutApplication.cpp) + set(MagnumGlutApplication_HEADERS GlutApplication.h) + + add_library(MagnumGlutApplication STATIC + ${MagnumGlutApplication_SRCS} + ${MagnumGlutApplication_HEADERS}) set_target_properties(MagnumGlutApplication PROPERTIES DEBUG_POSTFIX "-d") - install(FILES MagnumGlutApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) + install(FILES ${MagnumGlutApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) install(TARGETS MagnumGlutApplication RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} @@ -76,9 +93,15 @@ if(WITH_SDL2APPLICATION) endif() include_directories(${SDL2_INCLUDE_DIR}) - add_library(MagnumSdl2Application STATIC Sdl2Application.cpp) + + set(MagnumSdl2Application_SRCS Sdl2Application.cpp) + set(MagnumSdl2Application_HEADERS Sdl2Application.h) + + add_library(MagnumSdl2Application STATIC + ${MagnumSdl2Application_SRCS} + ${MagnumSdl2Application_HEADERS}) set_target_properties(MagnumSdl2Application PROPERTIES DEBUG_POSTFIX "-d") - install(FILES Sdl2Application.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) + install(FILES ${MagnumSdl2Application_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) install(TARGETS MagnumSdl2Application RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} @@ -91,9 +114,14 @@ if(WITH_NACLAPPLICATION) message(FATAL_ERROR "NaClApplication is available only when targeting Google Chrome Native Client. Set WITH_NACLAPPLICATION to OFF to skip building it.") endif() - add_library(MagnumNaClApplication STATIC NaClApplication.cpp) + set(MagnumNaClApplication_SRCS NaClApplication.cpp) + set(MagnumNaClApplication_HEADERS NaClApplication.h) + + add_library(MagnumNaClApplication STATIC + ${MagnumNaClApplication_SRCS} + ${MagnumNaClApplication_HEADERS}) set_target_properties(MagnumNaClApplication PROPERTIES DEBUG_POSTFIX "-d") - install(FILES NaClApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) + install(FILES ${MagnumNaClApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) install(TARGETS MagnumNaClApplication RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} @@ -106,10 +134,15 @@ if(WITH_WINDOWLESSNACLAPPLICATION) message(FATAL_ERROR "WindowlessNaClApplication is available only when targeting Google Chrome Native Client. Set WITH_WINDOWLESSNACLAPPLICATION to OFF to skip building it.") endif() - add_library(MagnumWindowlessNaClApplication STATIC WindowlessNaClApplication.cpp) + set(MagnumWindowlessNaClApplication_SRCS WindowlessNaClApplication.cpp) + set(MagnumWindowlessNaClApplication_HEADERS WindowlessNaClApplication.h) + + add_library(MagnumWindowlessNaClApplication STATIC + ${MagnumWindowlessNaClApplication_SRCS} + ${MagnumWindowlessNaClApplication_HEADERS}) set_target_properties(MagnumWindowlessNaClApplication PROPERTIES DEBUG_POSTFIX "-d") target_link_libraries(MagnumWindowlessNaClApplication Magnum ppapi_cpp ppapi) - install(FILES WindowlessNaClApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) + install(FILES ${MagnumWindowlessNaClApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) install(TARGETS MagnumWindowlessNaClApplication RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} @@ -118,24 +151,38 @@ endif() # JavaScript and CSS stuff for NaCl if(WITH_NACLAPPLICATION OR WITH_WINDOWLESSNACLAPPLICATION) - install(FILES NaClApplication.js WebApplication.css DESTINATION ${MAGNUM_DATA_INSTALL_DIR}) + set(MagnumNaClApplication_FILES + NaClApplication.js + WebApplication.css) + list(APPEND MagnumPlatform_FILES ${MagnumNaClApplication_FILES}) + install(FILES ${MagnumNaClApplication_FILES} DESTINATION ${MAGNUM_DATA_INSTALL_DIR}) endif() # JavaScript and CSS stuff for Emscripten if(WITH_SDL2APPLICATION AND CORRADE_TARGET_EMSCRIPTEN) - install(FILES EmscriptenApplication.js WebApplication.css DESTINATION ${MAGNUM_DATA_INSTALL_DIR}) + set(MagnumSdl2Application_FILES + EmscriptenApplication.js + WebApplication.css) + list(APPEND MagnumPlatform_FILES ${MagnumSdl2Application_FILES}) + install(FILES ${MagnumSdl2Application_FILES} DESTINATION ${MAGNUM_DATA_INSTALL_DIR}) endif() # GLX application if(WITH_GLXAPPLICATION) set(NEED_ABSTRACTXAPPLICATION 1) set(NEED_GLXCONTEXT 1) - add_library(MagnumGlxApplication STATIC + + set(MagnumGlxApplication_SRCS $ $ GlxApplication.cpp) + set(MagnumGlxApplication_HEADERS GlxApplication.h) + + add_library(MagnumGlxApplication STATIC + ${MagnumGlxApplication_SRCS} + ${MagnumGlxApplication_HEADERS}) set_target_properties(MagnumGlxApplication PROPERTIES DEBUG_POSTFIX "-d") - install(FILES GlxApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) + install(FILES ${MagnumGlxApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) install(TARGETS MagnumGlxApplication RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} @@ -146,12 +193,18 @@ endif() if(WITH_XEGLAPPLICATION) set(NEED_ABSTRACTXAPPLICATION 1) set(NEED_EGLCONTEXT 1) - add_library(MagnumXEglApplication STATIC + + set(MagnumXEglApplication_SRCS $ $ XEglApplication.cpp) + set(MagnumXEglApplication_HEADERS XEglApplication.h) + + add_library(MagnumXEglApplication STATIC + ${MagnumXEglApplication_SRCS} + ${MagnumXEglApplication_HEADERS}) set_target_properties(MagnumXEglApplication PROPERTIES DEBUG_POSTFIX "-d") - install(FILES XEglApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) + install(FILES ${MagnumXEglApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) install(TARGETS MagnumXEglApplication RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} @@ -167,13 +220,18 @@ endif() # Windowless GLX application if(WITH_WINDOWLESSGLXAPPLICATION) - add_library(MagnumWindowlessGlxApplication STATIC WindowlessGlxApplication.cpp) + set(MagnumWindowlessGlxApplication_SRCS WindowlessGlxApplication.cpp) + set(MagnumWindowlessGlxApplication_HEADERS WindowlessGlxApplication.h) + + add_library(MagnumWindowlessGlxApplication STATIC + ${MagnumWindowlessGlxApplication_SRCS} + ${MagnumWindowlessGlxApplication_HEADERS}) # X11 macros are a mess, disable warnings for C-style casts set_target_properties(MagnumWindowlessGlxApplication PROPERTIES COMPILE_FLAGS "-Wno-old-style-cast" DEBUG_POSTFIX "-d") target_link_libraries(MagnumWindowlessGlxApplication Magnum ${X11_LIBRARIES}) - install(FILES WindowlessGlxApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) + install(FILES ${MagnumWindowlessGlxApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) install(TARGETS MagnumWindowlessGlxApplication RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} @@ -182,12 +240,17 @@ endif() # Windowless WGL application if(WITH_WINDOWLESSWGLAPPLICATION) - add_library(MagnumWindowlessWglApplication STATIC WindowlessWglApplication.cpp) + set(MagnumWindowlessWglApplication_SRCS WindowlessWglApplication.cpp) + set(MagnumWindowlessWglApplication_HEADERS WindowlessWglApplication.h) + + add_library(MagnumWindowlessWglApplication STATIC + ${MagnumWindowlessWglApplication_SRCS} + ${MagnumWindowlessWglApplication_HEADERS}) set_target_properties(MagnumWindowlessWglApplication PROPERTIES COMPILE_FLAGS "-DUNICODE" DEBUG_POSTFIX "-d") target_link_libraries(MagnumWindowlessWglApplication Magnum) - install(FILES WindowlessWglApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) + install(FILES ${MagnumWindowlessWglApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) install(TARGETS MagnumWindowlessWglApplication RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} @@ -196,10 +259,15 @@ endif() # Windowless CGL application if(WITH_WINDOWLESSCGLAPPLICATION) - add_library(MagnumWindowlessCglApplication STATIC WindowlessCglApplication.cpp) + set(MagnumWindowlessCglApplication_SRCS WindowlessCglApplication.cpp) + set(MagnumWindowlessCglApplication_HEADERS WindowlessCglApplication.h) + + add_library(MagnumWindowlessCglApplication STATIC + ${MagnumWindowlessCglApplication_SRCS} + ${MagnumWindowlessCglApplication_HEADERS}) set_target_properties(MagnumWindowlessCglApplication PROPERTIES DEBUG_POSTFIX "-d") target_link_libraries(MagnumWindowlessCglApplication Magnum) - install(FILES WindowlessCglApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) + install(FILES ${MagnumWindowlessGlxApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) install(TARGETS MagnumWindowlessCglApplication RUNTIME DESTINATION ${MAGNUM_BINARY_INSTALL_DIR} LIBRARY DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR} @@ -208,15 +276,28 @@ endif() # Abstract X application if(NEED_ABSTRACTXAPPLICATION) - add_library(MagnumAbstractXApplication OBJECT AbstractXApplication.cpp) + set(MagnumAbstractXApplication_SRCS AbstractXApplication.cpp) + set(MagnumAbstractXApplication_HEADERS AbstractXApplication.h) + + add_library(MagnumAbstractXApplication OBJECT + ${MagnumAbstractXApplication_SRCS} + ${MagnumAbstractXApplication_HEADERS}) # X11 macros are a mess, disable warnings for C-style casts set_target_properties(MagnumAbstractXApplication PROPERTIES COMPILE_FLAGS "-Wno-old-style-cast") - install(FILES AbstractXApplication.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) + install(FILES ${MagnumAbstractXApplication_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) endif() # GLX context if(NEED_GLXCONTEXT) - add_library(MagnumGlxContextHandler OBJECT Implementation/GlxContextHandler.cpp) + set(MagnumGlxContextHandler_SRCS + Implementation/GlxContextHandler.cpp) + set(MagnumGlxContextHandler_PRIVATE_HEADERS + Implementation/AbstractContextHandler.h + Implementation/GlxContextHandler.h) + + add_library(MagnumGlxContextHandler OBJECT + ${MagnumGlxContextHandler_SRCS} + ${MagnumGlxContextHandler_PRIVATE_HEADERS}) # X11 macros are a mess, disable warnings for C-style casts set_target_properties(MagnumGlxContextHandler PROPERTIES COMPILE_FLAGS "-Wno-old-style-cast") endif() @@ -227,9 +308,18 @@ if(NEED_EGLCONTEXT) if(NOT EGL_FOUND) message(FATAL_ERROR "EGL library, required by some window contexts, was not found. Set WITH_*EGL*APPLICATION to OFF to skip building them.") endif() - add_library(MagnumEglContextHandler OBJECT + + set(MagnumEglContextHandler_SRCS Implementation/EglContextHandler.cpp Implementation/Egl.cpp) + set(MagnumEglContextHandler_PRIVATE_HEADERS + Implementation/AbstractContextHandler.h + Implementation/EglContextHandler.h + Implementation/Egl.h) + + add_library(MagnumEglContextHandler OBJECT + ${MagnumEglContextHandler_SRCS} + ${MagnumEglContextHandler_PRIVATE_HEADERS}) # X11 macros are a mess, disable warnings for C-style casts set_target_properties(MagnumEglContextHandler PROPERTIES COMPILE_FLAGS "-Wno-old-style-cast") endif() @@ -254,5 +344,9 @@ if(WITH_MAGNUMINFO) if(CORRADE_TARGET_NACL) install(FILES magnum-info-nacl.html DESTINATION ${MAGNUM_DATA_INSTALL_DIR} RENAME magnum-info.html) install(FILES magnum-info-nacl.nmf DESTINATION ${MAGNUM_DATA_INSTALL_DIR} RENAME magnum-info.nmf) + list(APPEND MagnumPlatform_FILES magnum-info-nacl.html magnum-info-nacl.nmf) endif() endif() + +# Force IDEs display also all header files and additional files in project view +add_custom_target(MagnumPlatform SOURCES ${MagnumPlatform_HEADERS} ${MagnumPlatform_FILES}) diff --git a/src/Magnum/Primitives/CMakeLists.txt b/src/Magnum/Primitives/CMakeLists.txt index 6f2119939..04c2976cf 100644 --- a/src/Magnum/Primitives/CMakeLists.txt +++ b/src/Magnum/Primitives/CMakeLists.txt @@ -52,7 +52,15 @@ set(MagnumPrimitives_HEADERS visibility.h) -add_library(MagnumPrimitives ${SHARED_OR_STATIC} ${MagnumPrimitives_SRCS}) +# Header files to display in project view of IDEs only +set(MagnumPrimitives_PRIVATE_HEADERS + Implementation/Spheroid.h + Implementation/WireframeSpheroid.h) + +add_library(MagnumPrimitives ${SHARED_OR_STATIC} + ${MagnumPrimitives_SRCS} + ${MagnumPrimitives_HEADERS} + ${MagnumPrimitives_PRIVATE_HEADERS}) set_target_properties(MagnumPrimitives PROPERTIES DEBUG_POSTFIX "-d") if(BUILD_STATIC_PIC) # TODO: CMake 2.8.9 has this as POSITION_INDEPENDENT_CODE property diff --git a/src/Magnum/SceneGraph/CMakeLists.txt b/src/Magnum/SceneGraph/CMakeLists.txt index f9166bec9..3ec9ca2e2 100644 --- a/src/Magnum/SceneGraph/CMakeLists.txt +++ b/src/Magnum/SceneGraph/CMakeLists.txt @@ -71,7 +71,9 @@ set(MagnumSceneGraph_HEADERS # Set shared library flags for the objects, as they will be part of shared lib # TODO: fix when CMake sets target_EXPORTS for OBJECT targets as well -add_library(MagnumSceneGraphObjects OBJECT ${MagnumSceneGraph_SRCS}) +add_library(MagnumSceneGraphObjects OBJECT + ${MagnumSceneGraph_SRCS} + ${MagnumSceneGraph_HEADERS}) if(NOT BUILD_STATIC OR BUILD_STATIC_PIC) # TODO: CMake 2.8.9 has this as POSITION_INDEPENDENT_CODE property set_target_properties(MagnumSceneGraphObjects PROPERTIES COMPILE_FLAGS "-DMagnumSceneGraphObjects_EXPORTS ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}") diff --git a/src/Magnum/Shaders/CMakeLists.txt b/src/Magnum/Shaders/CMakeLists.txt index 4099261d8..04a0a0db9 100644 --- a/src/Magnum/Shaders/CMakeLists.txt +++ b/src/Magnum/Shaders/CMakeLists.txt @@ -49,6 +49,9 @@ set(MagnumShaders_HEADERS visibility.h) +# Header files to display in project view of IDEs only +set(MagnumShaders_PRIVATE_HEADERS Implementation/CreateCompatibilityShader.h) + if(BUILD_STATIC) set(MagnumShaders_HEADERS ${MagnumShaders_HEADERS} resourceImport.hpp) @@ -57,7 +60,10 @@ if(BUILD_STATIC) endif() endif() -add_library(MagnumShaders ${SHARED_OR_STATIC} ${MagnumShaders_SRCS}) +add_library(MagnumShaders ${SHARED_OR_STATIC} + ${MagnumShaders_SRCS} + ${MagnumShaders_HEADERS} + ${MagnumShaders_PRIVATE_HEADERS}) set_target_properties(MagnumShaders PROPERTIES DEBUG_POSTFIX "-d") if(BUILD_STATIC_PIC) # TODO: CMake 2.8.9 has this as POSITION_INDEPENDENT_CODE property diff --git a/src/Magnum/Shapes/CMakeLists.txt b/src/Magnum/Shapes/CMakeLists.txt index 4c8669773..42f90ba38 100644 --- a/src/Magnum/Shapes/CMakeLists.txt +++ b/src/Magnum/Shapes/CMakeLists.txt @@ -61,7 +61,13 @@ set(MagnumShapes_HEADERS shapeImplementation.h visibility.h) -add_library(MagnumShapes ${SHARED_OR_STATIC} ${MagnumShapes_SRCS}) +# Header files to display in project view of IDEs only +set(MagnumShapes_PRIVATE_HEADERS Implementation/CollisionDispatch.h) + +add_library(MagnumShapes ${SHARED_OR_STATIC} + ${MagnumShapes_SRCS} + ${MagnumShapes_HEADERS} + ${MagnumShapes_PRIVATE_HEADERS}) set_target_properties(MagnumShapes PROPERTIES DEBUG_POSTFIX "-d") if(BUILD_STATIC_PIC) # TODO: CMake 2.8.9 has this as POSITION_INDEPENDENT_CODE property diff --git a/src/Magnum/Text/CMakeLists.txt b/src/Magnum/Text/CMakeLists.txt index 6b179a817..4127a15b6 100644 --- a/src/Magnum/Text/CMakeLists.txt +++ b/src/Magnum/Text/CMakeLists.txt @@ -45,7 +45,9 @@ if(MAGNUM_BUILD_DEPRECATED) TextRenderer.h) endif() -add_library(MagnumText ${SHARED_OR_STATIC} ${MagnumText_SRCS}) +add_library(MagnumText ${SHARED_OR_STATIC} + ${MagnumText_SRCS} + ${MagnumText_HEADERS}) set_target_properties(MagnumText PROPERTIES DEBUG_POSTFIX "-d") if(BUILD_STATIC_PIC) # TODO: CMake 2.8.9 has this as POSITION_INDEPENDENT_CODE property diff --git a/src/Magnum/TextureTools/CMakeLists.txt b/src/Magnum/TextureTools/CMakeLists.txt index a6ce5b75e..8621c2a63 100644 --- a/src/Magnum/TextureTools/CMakeLists.txt +++ b/src/Magnum/TextureTools/CMakeLists.txt @@ -40,7 +40,9 @@ if(BUILD_STATIC) set(MagnumTextureTools_HEADERS ${MagnumTextureTools_HEADERS} magnumTextureToolsResourceImport.hpp) endif() -add_library(MagnumTextureTools ${SHARED_OR_STATIC} ${MagnumTextureTools_SRCS}) +add_library(MagnumTextureTools ${SHARED_OR_STATIC} + ${MagnumTextureTools_SRCS} + ${MagnumTextureTools_HEADERS}) set_target_properties(MagnumTextureTools PROPERTIES DEBUG_POSTFIX "-d") if(BUILD_STATIC_PIC) # TODO: CMake 2.8.9 has this as POSITION_INDEPENDENT_CODE property diff --git a/src/Magnum/Trade/CMakeLists.txt b/src/Magnum/Trade/CMakeLists.txt index 6dcbc34f2..229492815 100644 --- a/src/Magnum/Trade/CMakeLists.txt +++ b/src/Magnum/Trade/CMakeLists.txt @@ -41,6 +41,9 @@ set(MagnumTrade_HEADERS TextureData.h Trade.h) +# Force IDEs to display all header files in project view +add_custom_target(MagnumTrade SOURCES ${MagnumTrade_HEADERS}) + install(FILES ${MagnumTrade_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Trade) if(BUILD_TESTS)