From 6ae92d5056915c28ddf3eb76a7bb473b97896a40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 8 Jul 2012 00:50:03 +0200 Subject: [PATCH 01/31] Matrix4 code cleanup * Don't assume the values are float, use T(0) instead of 0.0f. * Explicitly specify templated type. --- src/Math/Matrix4.h | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Math/Matrix4.h b/src/Math/Matrix4.h index 87e585f92..af1f7486f 100644 --- a/src/Math/Matrix4.h +++ b/src/Math/Matrix4.h @@ -37,11 +37,11 @@ template class Matrix4: public Matrix<4, T> { * @param vec Translation vector */ inline constexpr static Matrix4 translation(const Vector3& vec) { - return Matrix4( /* Column-major! */ - 1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - vec.x(), vec.y(), vec.z(), 1.0f + return Matrix4( /* Column-major! */ + T(1), T(0), T(0), T(0), + T(0), T(1), T(0), T(0), + T(0), T(0), T(1), T(0), + vec.x(), vec.y(), vec.z(), T(1) ); } @@ -49,12 +49,12 @@ template class Matrix4: public Matrix<4, T> { * @brief Scaling matrix * @param vec Scaling vector */ - inline constexpr static Matrix4 scaling(const Vector3& vec) { - return Matrix4( /* Column-major! */ - vec.x(), 0.0f, 0.0f, 0.0f, - 0.0f, vec.y(), 0.0f, 0.0f, - 0.0f, 0.0f, vec.z(), 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f + inline constexpr static Matrix4 scaling(const Vector3& vec) { + return Matrix4( /* Column-major! */ + vec.x(), T(0), T(0), T(0), + T(0), vec.y(), T(0), T(0), + T(0), T(0), vec.z(), T(0), + T(0), T(0), T(0), T(1) ); } @@ -63,7 +63,7 @@ template class Matrix4: public Matrix<4, T> { * @param angle Rotation angle (counterclockwise, in radians) * @param vec Rotation vector */ - static Matrix4 rotation(T angle, const Vector3& vec) { + static Matrix4 rotation(T angle, const Vector3& vec) { Vector3 vn = vec.normalized(); T sine = sin(angle); @@ -77,7 +77,7 @@ template class Matrix4: public Matrix<4, T> { T yz = vn.y()*vn.z(); T zz = vn.z()*vn.z(); - return Matrix4( /* Column-major! */ + return Matrix4( /* Column-major! */ cosine + xx*oneMinusCosine, xy*oneMinusCosine + vn.z()*sine, xz*oneMinusCosine - vn.y()*sine, @@ -99,10 +99,10 @@ template class Matrix4: public Matrix<4, T> { /** @copydoc Matrix::Matrix(IdentityType, T) */ inline constexpr explicit Matrix4(typename Matrix<4, T>::IdentityType = (Matrix<4, T>::Identity), T value = T(1)): Matrix<4, T>( - value, 0.0f, 0.0f, 0.0f, - 0.0f, value, 0.0f, 0.0f, - 0.0f, 0.0f, value, 0.0f, - 0.0f, 0.0f, 0.0f, value + value, T(0), T(0), T(0), + T(0), value, T(0), T(0), + T(0), T(0), value, T(0), + T(0), T(0), T(0), value ) {} /** @copydoc Matrix::Matrix(T, U...) */ From 4b352e43f09670903e7b2ea3ea13802255df7223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 8 Jul 2012 00:51:29 +0200 Subject: [PATCH 02/31] Doc: @todo++ --- src/Math/Matrix4.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Math/Matrix4.h b/src/Math/Matrix4.h index af1f7486f..d9ce27269 100644 --- a/src/Math/Matrix4.h +++ b/src/Math/Matrix4.h @@ -62,6 +62,8 @@ template class Matrix4: public Matrix<4, T> { * @brief Rotation matrix * @param angle Rotation angle (counterclockwise, in radians) * @param vec Rotation vector + * + * @todo optimize - Assume the vectors are normalized? */ static Matrix4 rotation(T angle, const Vector3& vec) { Vector3 vn = vec.normalized(); From d56270835e49865b4c60d7e9c978808d91c2e88f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 17 Jul 2012 16:37:07 +0200 Subject: [PATCH 03/31] Matrix3 code cleanup. Don't assume the values are float, use T(0) instead of 0.0f. --- src/Math/Matrix3.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Math/Matrix3.h b/src/Math/Matrix3.h index a1799dfe3..31eefcf6d 100644 --- a/src/Math/Matrix3.h +++ b/src/Math/Matrix3.h @@ -32,9 +32,9 @@ template class Matrix3: public Matrix<3, T> { /** @copydoc Matrix::Matrix(IdentityType, T) */ inline constexpr explicit Matrix3(typename Matrix<3, T>::IdentityType = (Matrix<3, T>::Identity), T value = T(1)): Matrix<3, T>( - value, 0.0f, 0.0f, - 0.0f, value, 0.0f, - 0.0f, 0.0f, value + value, T(0), T(0), + T(0), value, T(0), + T(0), T(0), value ) {} /** @copydoc Matrix::Matrix(T, U...) */ From 59ca55abe01a86a3b323cf686880d470667738fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 17 Jul 2012 16:38:20 +0200 Subject: [PATCH 04/31] Undefine None from Xlib.h to avoid conflicts (e.g. in Framebuffer). --- src/Contexts/EglContext.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Contexts/EglContext.h b/src/Contexts/EglContext.h index a063a591a..fe2e48cb2 100644 --- a/src/Contexts/EglContext.h +++ b/src/Contexts/EglContext.h @@ -22,6 +22,9 @@ #include "Magnum.h" #include +#ifdef None // undef Xlib nonsense to avoid conflicts +#undef None +#endif #ifndef SUPPORT_X11 #define SUPPORT_X11 // OpenGL ES on BeagleBoard needs this (?) From 6add425bb350254e494e1c8c21475c140e549865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 17 Jul 2012 17:34:30 +0200 Subject: [PATCH 05/31] Cleaned up CMakeLists.txt. --- src/CMakeLists.txt | 27 ++++++++++++--------------- src/MeshTools/CMakeLists.txt | 12 ++++-------- src/Physics/CMakeLists.txt | 3 +-- src/Primitives/CMakeLists.txt | 3 +-- src/Shaders/CMakeLists.txt | 9 ++++----- 5 files changed, 22 insertions(+), 32 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c88df8331..ee656275f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,9 +1,9 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -std=c++0x -fvisibility=hidden") +# If targeting GLES, save it into configuration header if(TARGET_GLES) set(MAGNUM_TARGET_GLES 1) endif() - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/magnumConfigure.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/magnumConfigure.h) @@ -27,37 +27,34 @@ set(Magnum_SRCS TypeTraits.cpp Trade/AbstractImporter.cpp - Trade/MeshData.cpp -) + Trade/MeshData.cpp) add_library(MagnumObjects OBJECT ${Magnum_SRCS}) # Files shared between main library and math unit test library set(MagnumMath_SRCS - Math/Math.cpp -) + Math/Math.cpp) add_library(MagnumMathObjects OBJECT ${MagnumMath_SRCS}) +# Files compiled with different flags for main library and unit test library +set(Magnum_GracefulAssert_SRCS + Object.cpp) + # 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 set_target_properties(MagnumObjects MagnumMathObjects PROPERTIES COMPILE_FLAGS "-DMagnumObjects_EXPORTS ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}") -# Files compiled with different flags for main library and unit test library -set(Magnum_GracefulAssert_SRCS - Object.cpp -) - # Main library add_library(Magnum SHARED $ $ - ${Magnum_GracefulAssert_SRCS} -) + ${Magnum_GracefulAssert_SRCS}) target_link_libraries(Magnum ${CORRADE_UTILITY_LIBRARY} ${CORRADE_PLUGINMANAGER_LIBRARY}) if(NOT TARGET_GLES) target_link_libraries(Magnum ${OPENGL_gl_LIBRARY} ${GLEW_LIBRARY}) else() target_link_libraries(Magnum ${OPENGLES2_LIBRARY}) endif() + install(TARGETS Magnum DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) # Install also configure file @@ -73,11 +70,12 @@ add_subdirectory(Shaders) if(BUILD_TESTS) enable_testing() + include_directories(${QT_INCLUDE_DIR}) + # Library with graceful assert for testing add_library(MagnumTestLib SHARED $ - ${Magnum_GracefulAssert_SRCS} - ) + ${Magnum_GracefulAssert_SRCS}) set_target_properties(MagnumTestLib PROPERTIES COMPILE_FLAGS -DCORRADE_GRACEFUL_ASSERT) target_link_libraries(MagnumTestLib ${CORRADE_UTILITY_LIBRARY} ${CORRADE_PLUGINMANAGER_LIBRARY}) if(NOT TARGET_GLES) @@ -86,6 +84,5 @@ if(BUILD_TESTS) target_link_libraries(MagnumTestLib ${OPENGLES2_LIBRARY}) endif() - include_directories(${QT_INCLUDE_DIR}) add_subdirectory(Test) endif() diff --git a/src/MeshTools/CMakeLists.txt b/src/MeshTools/CMakeLists.txt index 2d33389d8..bc2605a7d 100644 --- a/src/MeshTools/CMakeLists.txt +++ b/src/MeshTools/CMakeLists.txt @@ -1,7 +1,6 @@ # Files shared between main library and unit test library set(MagnumMeshTools_SRCS - Tipsify.cpp -) + Tipsify.cpp) add_library(MagnumMeshToolsObjects OBJECT ${MagnumMeshTools_SRCS}) # Set shared library flags for the objects, as they will be part of shared lib @@ -11,14 +10,12 @@ set_target_properties(MagnumMeshToolsObjects PROPERTIES COMPILE_FLAGS "-DMagnumM # Files compiled with different flags for main library and unit test library set(MagnumMeshTools_GracefulAssert_SRCS FlipNormals.cpp - GenerateFlatNormals.cpp -) + GenerateFlatNormals.cpp) # Main library add_library(MagnumMeshTools SHARED $ - ${MagnumMeshTools_GracefulAssert_SRCS} -) + ${MagnumMeshTools_GracefulAssert_SRCS}) target_link_libraries(MagnumMeshTools Magnum) install(TARGETS MagnumMeshTools DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) @@ -29,8 +26,7 @@ if(BUILD_TESTS) # Library with graceful assert for testing add_library(MagnumMeshToolsTestLib SHARED $ - ${MagnumMeshTools_GracefulAssert_SRCS} - ) + ${MagnumMeshTools_GracefulAssert_SRCS}) set_target_properties(MagnumMeshToolsTestLib PROPERTIES COMPILE_FLAGS -DCORRADE_GRACEFUL_ASSERT) target_link_libraries(MagnumMeshToolsTestLib Magnum) diff --git a/src/Physics/CMakeLists.txt b/src/Physics/CMakeLists.txt index 0f3833d7a..f1338baf2 100644 --- a/src/Physics/CMakeLists.txt +++ b/src/Physics/CMakeLists.txt @@ -5,8 +5,7 @@ set(MagnumPhysics_SRCS Line.cpp Plane.cpp ShapeGroup.cpp - Sphere.cpp -) + Sphere.cpp) add_library(MagnumPhysics SHARED ${MagnumPhysics_SRCS}) diff --git a/src/Primitives/CMakeLists.txt b/src/Primitives/CMakeLists.txt index 17a80f388..8a75a54ac 100644 --- a/src/Primitives/CMakeLists.txt +++ b/src/Primitives/CMakeLists.txt @@ -3,8 +3,7 @@ set(MagnumPrimitives_SRCS Cube.cpp Icosphere.cpp Plane.cpp - UVSphere.cpp -) + UVSphere.cpp) add_library(MagnumPrimitives STATIC ${MagnumPrimitives_SRCS}) target_link_libraries(MagnumPrimitives Magnum) diff --git a/src/Shaders/CMakeLists.txt b/src/Shaders/CMakeLists.txt index 8ee7c2b6e..17287f68a 100644 --- a/src/Shaders/CMakeLists.txt +++ b/src/Shaders/CMakeLists.txt @@ -1,10 +1,9 @@ -corrade_add_resource(Shaders MagnumShaders PhongShader.frag PhongShader.vert) -set(Shaders_SRCS +corrade_add_resource(MagnumShaders_RCS MagnumShaders PhongShader.frag PhongShader.vert) +set(MagnumShaders_SRCS PhongShader.cpp - ${Shaders} -) + ${MagnumShaders_RCS}) -add_library(MagnumShaders SHARED ${Shaders_SRCS}) +add_library(MagnumShaders SHARED ${MagnumShaders_SRCS}) target_link_libraries(MagnumShaders Magnum) From 75a6030205a57c9d80aa484713140a4a6771dad4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 17 Jul 2012 17:41:53 +0200 Subject: [PATCH 06/31] (Incomplete) coding style for CMake code. --- doc/coding-style.dox | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/doc/coding-style.dox b/doc/coding-style.dox index f3e940062..41da98db2 100644 --- a/doc/coding-style.dox +++ b/doc/coding-style.dox @@ -9,6 +9,25 @@ Please note that if you have a good excuse to either break the rules or modify them, feel free to do it (and update this guide accordingly, if appropriate). Nothing is worse than rule that hurts productivity instead of improving it. +@section cmake CMake code + +All cmake functions and macros (e.g. `add_executable()`, `set()`) are +lowercase, keywords (e.g. `FILES`, `DESTINATION`) are uppercase. Variables are +mostly uppercase with underscores between words, except for variables with +direct relation to any named target - then they have the target name as prefix +with no case change, followed with underscore, the rest of variable name is +uppercase, e.g. variable holding all sources for target `MagnuMeshTools` will +be named `MagnumMeshTools_SRCS`. + +Multi-line calls (i.e. `set()`) have trailing parenthesis on the same line as +last parameter, *not* on separate line: +@code +set(Magnum_SRCS + Object.cpp + Camera.cpp + Light.cpp) +@endcode + @section cpp C++ code @subsection cpp-files File naming and directory structure From 92aab9753d1bb525ef35f1f11095abda04083737 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 17 Jul 2012 18:09:15 +0200 Subject: [PATCH 07/31] Fixed compilation of EglContext. Introduced in 59ca55abe01a86a3b323cf686880d470667738fb, we need 'None' after all. --- src/Contexts/EglContext.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Contexts/EglContext.cpp b/src/Contexts/EglContext.cpp index fcf7de69f..4f28ca148 100644 --- a/src/Contexts/EglContext.cpp +++ b/src/Contexts/EglContext.cpp @@ -15,6 +15,8 @@ #include "EglContext.h" +#define None 0L // redef Xlib nonsense + using namespace std; namespace Magnum { namespace Contexts { From 5c70b482e7e7698ef23fc90db851925109d4a991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 17 Jul 2012 21:22:45 +0200 Subject: [PATCH 08/31] Fail when Qt4 is not found and BUILD_TESTS is set to true. It's up to user to disable building of tests if Qt4 is not found, instead of failing silently without user noticing it. --- CMakeLists.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 014b64876..1af8506cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,11 +10,10 @@ if(BUILD_TESTS) find_package(Qt4) if(NOT QT4_FOUND) - message(WARNING "Qt4 is required for building unit tests. No tests will be build.") - set(BUILD_TESTS OFF) - else() - enable_testing() + message(FATAL_ERROR "Qt4, required for building unit tests, was not found. Set BUILD_TESTS to OFF to skip building them.") endif() + + enable_testing() endif() set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${Magnum_SOURCE_DIR}/modules/") From 6bd43a9f959b0d9ad5e00b4aba448a6c47965f24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 19 Jul 2012 15:54:31 +0200 Subject: [PATCH 09/31] Modularization of building and installation process. By default everything except contexts is built, features can be enabled/disables using WITH_* CMake options. --- CMakeLists.txt | 25 ++++++++++++---- README.md | 14 +++++---- doc/building.dox | 44 ++++++++++++++++++++++----- src/CMakeLists.txt | 51 ++++++++++++++++++++++++++++---- src/Contexts/CMakeLists.txt | 42 ++++++++++++++------------ src/Math/CMakeLists.txt | 12 ++++++++ src/Math/Geometry/CMakeLists.txt | 5 ++++ src/MeshTools/CMakeLists.txt | 12 ++++++++ src/Physics/CMakeLists.txt | 14 +++++++++ src/Primitives/CMakeLists.txt | 7 +++++ src/Shaders/CMakeLists.txt | 3 ++ src/Trade/CMakeLists.txt | 13 ++++++++ 12 files changed, 200 insertions(+), 42 deletions(-) create mode 100644 src/Trade/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 1af8506cf..c14721889 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,10 +2,30 @@ cmake_minimum_required(VERSION 2.8.8) project(Magnum) +include(CMakeDependentOption) + option(TARGET_GLES "Build for OpenGL ES 2 instead of desktop OpenGL" OFF) +# Parts of the library +option(WITH_EVERYTHING "Build everything (doesn't include contexts)" ON) +option(WITH_MESHTOOLS "Build MeshTools library" OFF) +option(WITH_PHYSICS "Build Physics library" OFF) +option(WITH_PRIMITIVES "Builf Primitives library" OFF) +option(WITH_SHADERS "Build Shaders library" OFF) + +cmake_dependent_option(WITH_EGLCONTEXT "Build EglContext library" OFF "TARGET_GLES" OFF) +cmake_dependent_option(WITH_GLUTCONTEXT "Build GlutContext library" OFF "NOT TARGET_GLES" OFF) +option(WITH_SDL2CONTEXT "Build Sdl2Context library" OFF) + option(BUILD_TESTS "Build unit tests (requires Qt4)." OFF) +if(WITH_EVERYTHING) + set(WITH_MESHTOOLS ON) + set(WITH_PHYSICS ON) + set(WITH_PRIMITIVES ON) + set(WITH_SHADERS ON) +endif() + if(BUILD_TESTS) find_package(Qt4) @@ -25,8 +45,3 @@ include(FindMagnum) add_subdirectory(modules) add_subdirectory(src) - -install(DIRECTORY src/ DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR} - FILES_MATCHING PATTERN "*.h" - PATTERN "*/Test" EXCLUDE - PATTERN "src/Contexts" EXCLUDE) diff --git a/README.md b/README.md index 462dbb789..7785fd91d 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,8 @@ Minimal dependencies which are tested to support everything needed: **GCC** >= 4.6 and **Clang** >= 3.1. * **CMake** >= 2.8.8 (needed for `OBJECT` library target) - * **OpenGL headers**, on Linux most probably shipped with Mesa + * **OpenGL** headers, on Linux most probably shipped with Mesa or + **OpenGL ES 2** headers, if targeting OpenGL ES. * **GLEW** - OpenGL extension wrangler * **Corrade** - Plugin management and utility library. You can get it at http://mosra.cz/blog/corrade.php @@ -41,11 +42,14 @@ Minimal dependencies Compilation, installation ------------------------- -The library can be built and installed using these four commands: +The library (for example with GLUT context) can be built and installed using +these four commands: - mkdir -p build - cd build - cmake -DCMAKE_INSTALL_PREFIX=/usr .. && make + mkdir -p build && cd build + cmake .. \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DWITH_GLUTCONTEXT=ON + make make install Building and running unit tests diff --git a/doc/building.dox b/doc/building.dox index a619c3384..4a6d6901a 100644 --- a/doc/building.dox +++ b/doc/building.dox @@ -1,3 +1,4 @@ +namespace Magnum { /** @page building Downloading and building @brief Guide how to download and build %Magnum on different platforms. @@ -15,7 +16,7 @@ Minimal set of tools and libraries required for building is: >= 3.1. - **CMake** >= 2.8.8 (needed for `OBJECT` library target) - **OpenGL** headers, on Linux most probably shipped with Mesa or - **OpenGL ES 2** headers, if targetting OpenGL ES 2. + **OpenGL ES 2** headers, if targeting OpenGL ES (see below). - **GLEW** - OpenGL extension wrangler - **Corrade** - Plugin management and utility library. You can get it at http://github.com/mosra/corrade or at http://mosra.cz/blog/corrade.php. @@ -36,19 +37,45 @@ subdirectory: git submodule update @section building-compilation Compilation, installation -The library can be built and installed using these four commands: +The library (for example with GLUT context) can be built and installed using +these four commands. See below for more information about optional features. - mkdir -p build - cd build - cmake -DCMAKE_INSTALL_PREFIX=/usr .. && make + mkdir -p build && cd build + cmake .. \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DWITH_GLUTCONTEXT=ON + make make install -By default the engine is built for desktop OpenGL. If you want to target -OpenGL ES 2, pass `-DTARGET_GLES=True` to CMake. - If you want to build with another compiler (e.g. Clang), pass `-DCMAKE_CXX_COMPILER=clang++` to CMake. +@subsection building-optional Enabling or disabling features +By default the engine is built for desktop OpenGL. If you want to target +OpenGL ES, set `TARGET_GLES` to `ON` or pass `-DTARGET_GLES=ON` to CMake. Note +that some features are available for desktop OpenGL only, see @ref requires-gl. + +By default the engine is built with everything except +@ref Contexts "context libraries". Using `WITH_*` CMake parameters you can +specify which parts will be built and which not: + + - `WITH_EVERYTHING` - Defaults to `ON`, builds everything except contexts. If + set to `OFF`, only the main library is built and you can select additional + libraries with the following: + - `WITH_MESHTOOLS` - MeshTools library. + - `WITH_PHYSICS` - Physics library. + - `WITH_PRIMITIVES` - Primitives library. + - `WITH_SHADERS` - Shaders library. + +None of the context libraries is built by default, regardless to +`WITH_EVERYTHING` is enabled or not: + + - `WITH_EGLCONTEXT` - X/EGL context, available only if targeting OpenGL ES + (see above). Requires **X11** and **EGL** libraries. + - `WITH_GLUTCONTEXT` - GLUT context, available only if targeting desktop + OpenGL. Requires **GLUT** library. + - `WITH_SDL2CONTEXT` - SDL2 context. Requires **SDL2** library. + @subsection building-tests Building and running unit tests If you want to build also unit tests (which are not built by default), pass `-DBUILD_TESTS=True` to CMake. Unit tests use QtTest framework (you need at @@ -114,3 +141,4 @@ You may need to modify the `basic-mingw32.cmake` file and `CMAKE_INSTALL_PREFIX` to suit your distribution filesystem hierarchy. If everything goes well, in `build-win/` subdirectories will be the DLLs. */ +} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ee656275f..ba893f944 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -28,6 +28,34 @@ set(Magnum_SRCS Trade/AbstractImporter.cpp Trade/MeshData.cpp) +set(Magnum_HEADERS + AbstractImage.h + AbstractShaderProgram.h + AbstractTexture.h + BufferedImage.h + BufferedTexture.h + Buffer.h + Camera.h + CubeMapTextureArray.h + CubeMapTexture.h + Framebuffer.h + Image.h + ImageWrapper.h + IndexedMesh.h + Light.h + Magnum.h + Mesh.h + Object.h + Query.h + Renderbuffer.h + Scene.h + Set.h + Shader.h + SizeTraits.h + Texture.h + TypeTraits.h + + magnumVisibility.h) add_library(MagnumObjects OBJECT ${Magnum_SRCS}) # Files shared between main library and math unit test library @@ -56,20 +84,33 @@ else() endif() install(TARGETS Magnum DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) +install(FILES ${Magnum_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}) # Install also configure file install(FILES ${CMAKE_CURRENT_BINARY_DIR}/magnumConfigure.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}) add_subdirectory(Contexts) add_subdirectory(Math) -add_subdirectory(MeshTools) -add_subdirectory(Physics) -add_subdirectory(Primitives) -add_subdirectory(Shaders) +add_subdirectory(Trade) + +if(WITH_MESHTOOLS) + add_subdirectory(MeshTools) +endif() + +if(WITH_PHYSICS) + add_subdirectory(Physics) +endif() + +if(WITH_PRIMITIVES) + add_subdirectory(Primitives) +endif() + +if(WITH_SHADERS) + add_subdirectory(Shaders) +endif() if(BUILD_TESTS) enable_testing() - include_directories(${QT_INCLUDE_DIR}) # Library with graceful assert for testing diff --git a/src/Contexts/CMakeLists.txt b/src/Contexts/CMakeLists.txt index 3550ae14d..c0e5eef45 100644 --- a/src/Contexts/CMakeLists.txt +++ b/src/Contexts/CMakeLists.txt @@ -1,36 +1,40 @@ install(FILES AbstractContext.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts) # GLUT context -if(NOT TARGET_GLES) +if(WITH_GLUTCONTEXT) find_package(GLUT) if(GLUT_FOUND) add_library(MagnumGlutContext STATIC GlutContext.cpp) install(FILES GlutContext.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts) install(TARGETS MagnumGlutContext DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) else() - message(WARNING "GLUT library was not found. GLUT context library will not be generated.") + message(FATAL_ERROR "GLUT library, required by GlutContext, was not found. Set WITH_GLUTCONTEXT to OFF to skip building it.") endif() endif() # SDL2 context -find_package(SDL2) -if(SDL2_FOUND) - include_directories(${SDL2_INCLUDE_DIR}) - add_library(MagnumSdl2Context STATIC Sdl2Context.cpp) - install(FILES Sdl2Context.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts) - install(TARGETS MagnumSdl2Context DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) -else() - message(WARNING "SDL2 library was not found. SDL2 context library will not be generated.") +if(WITH_SDL2CONTEXT) + find_package(SDL2) + if(SDL2_FOUND) + include_directories(${SDL2_INCLUDE_DIR}) + add_library(MagnumSdl2Context STATIC Sdl2Context.cpp) + install(FILES Sdl2Context.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts) + install(TARGETS MagnumSdl2Context DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) + else() + message(FATAL_ERROR "SDL2 library, required by Sdl2Context, was not found. Set WITH_SDL2CONTEXT to OFF to skip building it.") + endif() endif() # X/EGL context -find_package(OpenGLES2) -find_package(EGL) -find_package(X11) -if(OPENGLES2_FOUND AND EGL_FOUND AND X11_FOUND) - add_library(MagnumEglContext STATIC EglContext.cpp) - install(FILES EglContext.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts) - install(TARGETS MagnumEglContext DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) -else() - message(WARNING "OpenGL ES 2, EGL or X11 libraries were not found. EGL context library will not be generated.") +if(WITH_EGLCONTEXT) + find_package(OpenGLES2) + find_package(EGL) + find_package(X11) + if(OPENGLES2_FOUND AND EGL_FOUND AND X11_FOUND) + add_library(MagnumEglContext STATIC EglContext.cpp) + install(FILES EglContext.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts) + install(TARGETS MagnumEglContext DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) + else() + message(FATAL_ERROR "OpenGL ES 2, EGL or X11 libraries, required by EglContext, were not found. Set WITH_EGLCONTEXT to OFF to skip building it.") + endif() endif() diff --git a/src/Math/CMakeLists.txt b/src/Math/CMakeLists.txt index efb6838e2..a0cc17b69 100644 --- a/src/Math/CMakeLists.txt +++ b/src/Math/CMakeLists.txt @@ -1,5 +1,17 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +set(MagnumMath_HEADERS + Math.h + MathTypeTraits.h + Matrix.h + Matrix3.h + Matrix4.h + Vector.h + Vector2.h + Vector3.h + Vector4.h) +install(FILES ${MagnumMath_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Math) + add_subdirectory(Geometry) if(BUILD_TESTS) diff --git a/src/Math/Geometry/CMakeLists.txt b/src/Math/Geometry/CMakeLists.txt index 6879e1b55..35e4ba1e0 100644 --- a/src/Math/Geometry/CMakeLists.txt +++ b/src/Math/Geometry/CMakeLists.txt @@ -1,5 +1,10 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +set(MagnumMathGeometry_HEADERS + Distance.h + Intersection.h) +install(FILES ${MagnumMathGeometry_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Math/Geometry) + if(BUILD_TESTS) enable_testing() add_subdirectory(Test) diff --git a/src/MeshTools/CMakeLists.txt b/src/MeshTools/CMakeLists.txt index bc2605a7d..e2b347f4b 100644 --- a/src/MeshTools/CMakeLists.txt +++ b/src/MeshTools/CMakeLists.txt @@ -1,6 +1,17 @@ # Files shared between main library and unit test library set(MagnumMeshTools_SRCS Tipsify.cpp) +set(MagnumMeshTools_HEADERS + Clean.h + CombineIndexedArrays.h + CompressIndices.h + FlipNormals.h + GenerateFlatNormals.h + Interleave.h + Subdivide.h + Tipsify.h + + magnumMeshToolsVisibility.h) add_library(MagnumMeshToolsObjects OBJECT ${MagnumMeshTools_SRCS}) # Set shared library flags for the objects, as they will be part of shared lib @@ -19,6 +30,7 @@ add_library(MagnumMeshTools SHARED target_link_libraries(MagnumMeshTools Magnum) install(TARGETS MagnumMeshTools DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) +install(FILES ${MagnumMeshTools_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/MeshTools) if(BUILD_TESTS) enable_testing() diff --git a/src/Physics/CMakeLists.txt b/src/Physics/CMakeLists.txt index f1338baf2..8201d490b 100644 --- a/src/Physics/CMakeLists.txt +++ b/src/Physics/CMakeLists.txt @@ -6,12 +6,26 @@ set(MagnumPhysics_SRCS Plane.cpp ShapeGroup.cpp Sphere.cpp) +set(MagnumPhysics_HEADERS + AbstractShape.h + AxisAlignedBox.h + Box.h + Capsule.h + Line.h + LineSegment.h + Plane.h + Point.h + ShapeGroup.h + Sphere.h + + magnumPhysicsVisibility.h) add_library(MagnumPhysics SHARED ${MagnumPhysics_SRCS}) target_link_libraries(MagnumPhysics Magnum) install(TARGETS MagnumPhysics DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) +install(FILES ${MagnumPhysics_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Physics) if(BUILD_TESTS) enable_testing() diff --git a/src/Primitives/CMakeLists.txt b/src/Primitives/CMakeLists.txt index 8a75a54ac..28d2aa07d 100644 --- a/src/Primitives/CMakeLists.txt +++ b/src/Primitives/CMakeLists.txt @@ -4,11 +4,18 @@ set(MagnumPrimitives_SRCS Icosphere.cpp Plane.cpp UVSphere.cpp) +set(MagnumPrimitives_HEADERS + Capsule.h + Cube.h + Icosphere.h + Plane.h + UVSphere.h) add_library(MagnumPrimitives STATIC ${MagnumPrimitives_SRCS}) target_link_libraries(MagnumPrimitives Magnum) install(TARGETS MagnumPrimitives DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) +install(FILES ${MagnumPrimitives_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Primitives) if(BUILD_TESTS) enable_testing() diff --git a/src/Shaders/CMakeLists.txt b/src/Shaders/CMakeLists.txt index 17287f68a..59cadb3e7 100644 --- a/src/Shaders/CMakeLists.txt +++ b/src/Shaders/CMakeLists.txt @@ -2,9 +2,12 @@ corrade_add_resource(MagnumShaders_RCS MagnumShaders PhongShader.frag PhongShade set(MagnumShaders_SRCS PhongShader.cpp ${MagnumShaders_RCS}) +set(MagnumShaders_HEADERS + PhongShader.h) add_library(MagnumShaders SHARED ${MagnumShaders_SRCS}) target_link_libraries(MagnumShaders Magnum) install(TARGETS MagnumShaders DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) +install(FILES ${MagnumShaders_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Shaders) diff --git a/src/Trade/CMakeLists.txt b/src/Trade/CMakeLists.txt new file mode 100644 index 000000000..9ef1442be --- /dev/null +++ b/src/Trade/CMakeLists.txt @@ -0,0 +1,13 @@ +set(MagnumTrade_HEADERS + AbstractImporter.h + AbstractMaterialData.h + CameraData.h + ImageData.h + LightData.h + MeshData.h + MeshObjectData.h + ObjectData.h + PhongMaterialData.h + SceneData.h + TextureData.h) +install(FILES ${MagnumTrade_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Trade) From 3c1c3d4668587f609bd376a3e0d094fba19df54b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 19 Jul 2012 15:56:09 +0200 Subject: [PATCH 10/31] Document Doxygen's inability to create full path, if it doesn't exist. --- README.md | 3 ++- doc/building.dox | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7785fd91d..086fcef4a 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,8 @@ documentation can be build by running: doxygen in root directory (i.e. where `Doxyfile` is). Resulting HTML documentation -will be in `build/doc/` directory. +will be in `build/doc/` directory. You might need to create `build/` directory +if it doesn't exist yet. PLUGINS AND EXAMPLES ==================== diff --git a/doc/building.dox b/doc/building.dox index 4a6d6901a..cc17e340f 100644 --- a/doc/building.dox +++ b/doc/building.dox @@ -94,7 +94,8 @@ for math formulas. The documentation can be build by running doxygen in root directory (i.e. where `Doxyfile` is). Resulting HTML documentation -will be in `build/doc/` directory. +will be in `build/doc/` directory. You might need to create `build/` directory +if it doesn't exist yet. @section building-arch Building ArchLinux packages In `package/archlinux` directory is currently one PKGBUILD for Git development From 7e62a19401d0e30efb0ee849936447b3219529a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 19 Jul 2012 15:57:13 +0200 Subject: [PATCH 11/31] Don't try to find OpenGL ES more times than necessary. --- modules/FindMagnum.cmake | 1 - src/Contexts/CMakeLists.txt | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index f4cddbe73..772ca9043 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -92,7 +92,6 @@ foreach(component ${Magnum_FIND_COMPONENTS}) # X/EGL context dependencies if(${component} STREQUAL EglContext) - find_package(OpenGLES2) find_package(EGL) find_package(X11) if(NOT OPENGLES2_FOUND OR NOT EGL_FOUND OR NOT X11_FOUND) diff --git a/src/Contexts/CMakeLists.txt b/src/Contexts/CMakeLists.txt index c0e5eef45..2ac978d58 100644 --- a/src/Contexts/CMakeLists.txt +++ b/src/Contexts/CMakeLists.txt @@ -27,14 +27,13 @@ endif() # X/EGL context if(WITH_EGLCONTEXT) - find_package(OpenGLES2) find_package(EGL) find_package(X11) - if(OPENGLES2_FOUND AND EGL_FOUND AND X11_FOUND) + if(EGL_FOUND AND X11_FOUND) add_library(MagnumEglContext STATIC EglContext.cpp) install(FILES EglContext.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Contexts) install(TARGETS MagnumEglContext DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR}) else() - message(FATAL_ERROR "OpenGL ES 2, EGL or X11 libraries, required by EglContext, were not found. Set WITH_EGLCONTEXT to OFF to skip building it.") + message(FATAL_ERROR "EGL or X11 libraries, required by EglContext, were not found. Set WITH_EGLCONTEXT to OFF to skip building it.") endif() endif() From 3a4041ce6918cd6b2d49766f3ed44ccb26d81c87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 19 Jul 2012 19:58:10 +0200 Subject: [PATCH 12/31] Updated FindMagnum.cmake documentation. --- modules/FindMagnum.cmake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index 772ca9043..22b776da2 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -16,12 +16,15 @@ # Additional dependencies are specified by the components. The optional # components are: # -# GlutContext - GLUT context (depends on GLUT package) # MeshTools - MeshTools library # Physics - Physics library # Primitives - Library with stock geometric primitives (static) # Shaders - Library with stock shaders # +# EglContext - EGL context (depends on EGL and X11 libraries) +# GlutContext - GLUT context (depends on GLUT library) +# Sdl2Context - SDL2 context (depends on SDL2 library) +# # Example usage with specifying additional components is: # # find_package(Magnum [REQUIRED|COMPONENTS] MeshTools Primitives GlutContext) From 1b989aa0cde0be31f7896a55af1c831f7d38bae6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 19 Jul 2012 20:03:56 +0200 Subject: [PATCH 13/31] Don't use FindMagnum.cmake for populating *_INSTALL_DIR variables. It's overly complicated to hack around all find_* algorithms just to find some dependencies and set three variables. --- CMakeLists.txt | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c14721889..617f3c1c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,10 +38,19 @@ endif() set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${Magnum_SOURCE_DIR}/modules/") -# Populate MAGNUM_*_INSTALL_DIR variables, check for dependencies -set(MAGNUM_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src") -set(MAGNUM_LIBRARY Magnum) -include(FindMagnum) +# Check dependencies +find_package(Corrade REQUIRED) +if(NOT TARGET_GLES) + find_package(OpenGL REQUIRED) + find_package(GLEW REQUIRED) +else() + find_package(OpenGLES2 REQUIRED) +endif() + +# Installation paths +set(MAGNUM_LIBRARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}) +set(MAGNUM_CMAKE_MODULE_INSTALL_DIR ${CMAKE_ROOT}/Modules) +set(MAGNUM_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/Magnum) add_subdirectory(modules) add_subdirectory(src) From 9f592882530336f594f0ca0aae680fd011401e95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 19 Jul 2012 22:05:53 +0200 Subject: [PATCH 14/31] Checking whether Magnum was build for OpenGL ES in FindMagnum.cmake. --- modules/FindMagnum.cmake | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index 22b776da2..f60e0cb6c 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -7,6 +7,9 @@ # This command tries to find Magnum library and then defines: # # MAGNUM_FOUND - Whether the library was found +# MAGNUM_TARGET_GLES - Defined if Magnum was built for OpenGL ES, +# slightly reducing feature count. The same variable is also #defined in +# Magnum headers. # MAGNUM_LIBRARY - Magnum library # MAGNUM_INCLUDE_DIR - Root include dir # MAGNUM_PLUGINS_IMPORTER_DIR - Directory with importer plugins @@ -47,13 +50,6 @@ # Dependencies find_package(Corrade REQUIRED) -if(NOT TARGET_GLES) - find_package(OpenGL REQUIRED) - find_package(GLEW REQUIRED) -else() - find_package(OpenGLES2 REQUIRED) -endif() - # Magnum library find_library(MAGNUM_LIBRARY Magnum) @@ -63,6 +59,22 @@ find_path(MAGNUM_INCLUDE_DIR PATH_SUFFIXES Magnum ) +# Configuration +file(READ ${MAGNUM_INCLUDE_DIR}/magnumConfigure.h _magnumConfigure) + +# Built for OpenGL ES? +string(FIND "${_magnumConfigure}" "#define MAGNUM_TARGET_GLES" _TARGET_GLES) +if(NOT _TARGET_GLES EQUAL -1) + set(MAGNUM_TARGET_GLES 1) +endif() + +if(NOT MAGNUM_TARGET_GLES) + find_package(OpenGL REQUIRED) + find_package(GLEW REQUIRED) +else() + find_package(OpenGLES2 REQUIRED) +endif() + # Additional components foreach(component ${Magnum_FIND_COMPONENTS}) string(TOUPPER ${component} _COMPONENT) From 3d750c5e7dd74487f0fb0392e16c3bfd95dc79df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 19 Jul 2012 22:39:07 +0200 Subject: [PATCH 15/31] Don't check if OpenGL ES 2 was found when looking for EglContext. Missed in 7e62a19401d0e30efb0ee849936447b3219529a2. --- modules/FindMagnum.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index f60e0cb6c..e11bb6021 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -109,7 +109,7 @@ foreach(component ${Magnum_FIND_COMPONENTS}) if(${component} STREQUAL EglContext) find_package(EGL) find_package(X11) - if(NOT OPENGLES2_FOUND OR NOT EGL_FOUND OR NOT X11_FOUND) + if(NOT EGL_FOUND OR NOT X11_FOUND) unset(MAGNUM_${_COMPONENT}_LIBRARY) endif() endif() From bf649d3bb89ccbdb729812c8c75aa88d5973c844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 19 Jul 2012 22:40:32 +0200 Subject: [PATCH 16/31] Follow CMake coding guidelines in FindMagnum.cmake. --- modules/FindMagnum.cmake | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index e11bb6021..0aee97166 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -56,8 +56,7 @@ find_library(MAGNUM_LIBRARY Magnum) # Root include dir find_path(MAGNUM_INCLUDE_DIR NAMES Magnum.h - PATH_SUFFIXES Magnum -) + PATH_SUFFIXES Magnum) # Configuration file(READ ${MAGNUM_INCLUDE_DIR}/magnumConfigure.h _magnumConfigure) @@ -139,8 +138,7 @@ foreach(component ${Magnum_FIND_COMPONENTS}) if(_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES) find_path(_MAGNUM_${_COMPONENT}_INCLUDE_DIR NAMES ${_MAGNUM_${_COMPONENT}_INCLUDE_PATH_NAMES} - PATHS ${MAGNUM_INCLUDE_DIR}/${_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX} - ) + PATHS ${MAGNUM_INCLUDE_DIR}/${_MAGNUM_${_COMPONENT}_INCLUDE_PATH_SUFFIX}) endif() # Decide if the library was found @@ -154,8 +152,7 @@ endforeach() include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Magnum REQUIRED_VARS MAGNUM_INCLUDE_DIR MAGNUM_LIBRARY - HANDLE_COMPONENTS -) + HANDLE_COMPONENTS) # Installation dirs set(MAGNUM_LIBRARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}) @@ -170,8 +167,7 @@ mark_as_advanced(FORCE MAGNUM_PLUGINS_IMPORTER_INSTALL_DIR MAGNUM_CMAKE_MODULE_INSTALL_DIR MAGNUM_INCLUDE_INSTALL_DIR - MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR -) + MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR) # Importer plugins dir if(NOT WIN32) From 000ac5158373cebc38171010050aa8f0e4f3c6c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 19 Jul 2012 23:31:52 +0200 Subject: [PATCH 17/31] Forgot to install visibility header for Shaders. Hope this is the last bug caused by recent modularization. --- src/Shaders/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Shaders/CMakeLists.txt b/src/Shaders/CMakeLists.txt index 59cadb3e7..020acb2b7 100644 --- a/src/Shaders/CMakeLists.txt +++ b/src/Shaders/CMakeLists.txt @@ -3,7 +3,9 @@ set(MagnumShaders_SRCS PhongShader.cpp ${MagnumShaders_RCS}) set(MagnumShaders_HEADERS - PhongShader.h) + PhongShader.h + + magnumShadersVisibility.h) add_library(MagnumShaders SHARED ${MagnumShaders_SRCS}) From fd0b01510ce8cd5f75c58ea60d5b81a477329d2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 19 Jul 2012 23:32:46 +0200 Subject: [PATCH 18/31] Removed superfluous operators from Set class. Moreover returning base type from & operator is bad, really bad: if it results in 0, how it will map to original enum? --- src/Set.h | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/Set.h b/src/Set.h index 439e9a56c..5a9c04c67 100644 --- a/src/Set.h +++ b/src/Set.h @@ -54,33 +54,17 @@ template class Set { /** @brief Create set from one value */ inline constexpr Set(T value): value(static_cast(value)) {} - /** @brief Add value to the set */ - inline constexpr Set operator|(T other) const { - return Set(value | static_cast(other)); - } - /** @brief Union of two sets */ inline constexpr Set operator|(Set other) const { return Set(value | other.value); } - /** @brief Add value to the set and assign */ - inline Set& operator|=(T other) { - value |= static_cast(other); - return *this; - } - /** @brief Union two sets and assign */ inline Set& operator|=(Set other) { value |= other.value; return *this; } - /** @brief Check if given value is in the set */ - inline constexpr T operator&(T other) const { - return static_cast(value & static_cast(other)); - } - /** @brief Intersection of two sets */ inline constexpr Set operator&(Set other) const { return Set(value & other.value); From daaf89a1a154e32a5394580224cdc7761e428ee9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 19 Jul 2012 23:34:30 +0200 Subject: [PATCH 19/31] Added (explicit) operator bool to Set. So things like if(!(set & Enum::Value)) are possible. --- src/Set.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Set.h b/src/Set.h index 5a9c04c67..c693c8a33 100644 --- a/src/Set.h +++ b/src/Set.h @@ -81,6 +81,11 @@ template class Set { return Set(~value); } + /** @brief Value as boolean */ + inline constexpr explicit operator bool() const { + return value == 0; + } + /** @brief Value in underlying type */ inline constexpr explicit operator UnderlyingType() const { return value; From fd78db3f47ab1444dc5cf27148af498fa022632e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 19 Jul 2012 23:36:42 +0200 Subject: [PATCH 20/31] Plural versions of *_INCLUDE_DIR and *_LIBRARY FindMagnum variables. It took me years to fully accept this CMake policy. Now it's enough to specify ${MAGNUM_LIBRARIES} instead of all those Corrade, OpenGL / OpenGL ES, GLEW etc. dependencies (heh). --- modules/FindMagnum.cmake | 41 ++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index 0aee97166..988cf4167 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -10,8 +10,9 @@ # MAGNUM_TARGET_GLES - Defined if Magnum was built for OpenGL ES, # slightly reducing feature count. The same variable is also #defined in # Magnum headers. -# MAGNUM_LIBRARY - Magnum library -# MAGNUM_INCLUDE_DIR - Root include dir +# MAGNUM_LIBRARIES - Magnum library and dependent libraries +# MAGNUM_INCLUDE_DIRS - Root include dir and include dirs of +# dependencies # MAGNUM_PLUGINS_IMPORTER_DIR - Directory with importer plugins # # This command will try to find only the base library, not the optional @@ -35,10 +36,14 @@ # For each component is then defined: # # MAGNUM_*_FOUND - Whether the component was found -# MAGNUM_*_LIBRARY - Component library +# MAGNUM_*_LIBRARIES - Component library and dependent libraries # # Additionally these variables are defined for internal usage: # +# MAGNUM_INCLUDE_DIR - Root include dir (w/o dependencies) +# MAGNUM_LIBRARY - Magnum library (w/o dependencies) +# MAGNUM_*_LIBRARY - Component libraries (w/o dependencies) +# # MAGNUM_LIBRARY_INSTALL_DIR - Library installation directory # MAGNUM_PLUGINS_INSTALL_DIR - Plugin installation directory # MAGNUM_PLUGINS_IMPORTER_INSTALL_DIR - Importer plugin installation directory @@ -91,7 +96,9 @@ foreach(component ${Magnum_FIND_COMPONENTS}) # GLUT context dependencies if(${component} STREQUAL GlutContext) find_package(GLUT) - if(NOT GLUT_FOUND) + if(GLUT_FOUND) + set(_MAGNUM_${_COMPONENT}_LIBRARIES ${GLUT_LIBRARIES}) + else() unset(MAGNUM_${_COMPONENT}_LIBRARY) endif() endif() @@ -99,7 +106,9 @@ foreach(component ${Magnum_FIND_COMPONENTS}) # SDL2 context dependencies if(${component} STREQUAL Sdl2Context) find_package(SDL2) - if(NOT SDL2_FOUND) + if(SDL2_FOUND) + set(_MAGNUM_${_COMPONENT}_LIBRARIES ${SDL2_LIBRARY}) + else() unset(MAGNUM_${_COMPONENT}_LIBRARY) endif() endif() @@ -108,7 +117,9 @@ foreach(component ${Magnum_FIND_COMPONENTS}) if(${component} STREQUAL EglContext) find_package(EGL) find_package(X11) - if(NOT EGL_FOUND OR NOT X11_FOUND) + if(EGL_FOUND AND X11_FOUND) + set(_MAGNUM_${_COMPONENT}_LIBRARIES ${EGL_LIBRARY} ${X11_LIBRARIES}) + else() unset(MAGNUM_${_COMPONENT}_LIBRARY) endif() endif() @@ -143,6 +154,7 @@ foreach(component ${Magnum_FIND_COMPONENTS}) # Decide if the library was found if(MAGNUM_${_COMPONENT}_LIBRARY AND _MAGNUM_${_COMPONENT}_INCLUDE_DIR) + set(MAGNUM_${_COMPONENT}_LIBRARIES ${MAGNUM_${_COMPONENT}_LIBRARY} ${_MAGNUM_${_COMPONENT}_LIBRARIES}) set(Magnum_${component}_FOUND TRUE) else() set(Magnum_${component}_FOUND FALSE) @@ -154,6 +166,21 @@ find_package_handle_standard_args(Magnum REQUIRED_VARS MAGNUM_INCLUDE_DIR MAGNUM_LIBRARY HANDLE_COMPONENTS) +# Dependent libraries and includes +set(MAGNUM_INCLUDE_DIRS ${MAGNUM_INCLUDE_DIR} + ${CORRADE_INCLUDE_DIR}) +set(MAGNUM_LIBRARIES ${MAGNUM_LIBRARY} + ${CORRADE_UTILITY_LIBRARY} + ${CORRADE_PLUGINMANAGER_LIBRARY}) +if(NOT MAGNUM_TARGET_GLES) + set(MAGNUM_LIBRARIES ${MAGNUM_LIBRARIES} + ${OPENGL_gl_LIBRARY} + ${GLEW_LIBRARY}) +else() + set(MAGNUM_LIBRARIES ${MAGNUM_LIBRARIES} + ${OPENGLES2_LIBRARY}) +endif() + # Installation dirs set(MAGNUM_LIBRARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}) set(MAGNUM_PLUGINS_INSTALL_DIR ${MAGNUM_LIBRARY_INSTALL_DIR}/magnum) @@ -162,6 +189,8 @@ set(MAGNUM_CMAKE_MODULE_INSTALL_DIR ${CMAKE_ROOT}/Modules) set(MAGNUM_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/Magnum) set(MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/Magnum/Plugins) mark_as_advanced(FORCE + MAGNUM_LIBRARY + MAGNUM_INCLUDE_DIR MAGNUM_LIBRARY_INSTALL_DIR MAGNUM_PLUGINS_INSTALL_DIR MAGNUM_PLUGINS_IMPORTER_INSTALL_DIR From e034b1171858def88fbf347de17cd11ece2233c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 20 Jul 2012 00:52:36 +0200 Subject: [PATCH 21/31] Excluding benchmarks from CTest run. They took too much time without doing anything useful with measured time (regression testing). --- PKGBUILD | 2 +- PKGBUILD-release | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index cc16f63ce..0953e7761 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -29,7 +29,7 @@ build() { check() { cd "$startdir/build" - ctest --output-on-failure + ctest --output-on-failure -E Benchmark } package() { diff --git a/PKGBUILD-release b/PKGBUILD-release index e91c675d8..3409b26e2 100644 --- a/PKGBUILD-release +++ b/PKGBUILD-release @@ -28,7 +28,7 @@ build() { check() { cd "$startdir/build" - ctest --output-on-failure + ctest --output-on-failure -E Benchmark } package() { From 8f008c53c5fdf000827dbd00a7ed60559f88a10a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 20 Jul 2012 00:54:05 +0200 Subject: [PATCH 22/31] Support for 2D transformations in addition to 3D in Matrix classes. --- src/Math/Matrix3.h | 49 ++++++++++++++++++++++++++++++++++- src/Math/Matrix4.h | 13 +++++++--- src/Math/Test/Matrix3Test.cpp | 31 ++++++++++++++++++++++ src/Math/Test/Matrix3Test.h | 3 +++ 4 files changed, 92 insertions(+), 4 deletions(-) diff --git a/src/Math/Matrix3.h b/src/Math/Matrix3.h index 31eefcf6d..1dec2c7f3 100644 --- a/src/Math/Matrix3.h +++ b/src/Math/Matrix3.h @@ -24,9 +24,56 @@ namespace Magnum { namespace Math { -/** @brief 3x3 matrix */ +/** +@brief 3x3 matrix + +Provides functions for transformations in 2D. See also Matrix4 for 3D +transformations. +*/ template class Matrix3: public Matrix<3, T> { public: + /** + * @brief 2D translation matrix + * @param vec Translation vector + * + * @see Matrix4::translation() + */ + inline constexpr static Matrix3 translation(const Vector2& vec) { + return Matrix3( /* Column-major! */ + T(1), T(0), T(0), + T(0), T(1), T(0), + vec.x(), vec.y(), T(1) + ); + } + + /** + * @brief 2D scaling matrix + * @param vec Scaling vector + * + * @see Matrix4::scaling() + */ + inline constexpr static Matrix3 scaling(const Vector2& vec) { + return Matrix3( /* Column-major! */ + vec.x(), T(0), T(0), + T(0), vec.y(), T(0), + T(0), T(0), T(1) + ); + } + + /** + * @brief 3D rotation matrix + * @param angle Rotation angle (counterclockwise, in radians) + * + * @see Matrix4::rotation() + */ + static Matrix3 rotation(T angle) { + return Matrix3( /* Column-major! */ + T(cos(angle)), T(sin(angle)), T(0), + -T(sin(angle)), T(cos(angle)), T(0), + T(0), T(0), T(1) + ); + } + /** @copydoc Matrix::Matrix(ZeroType) */ inline constexpr explicit Matrix3(typename Matrix<3, T>::ZeroType): Matrix<3, T>(Matrix<3, T>::Zero) {} diff --git a/src/Math/Matrix4.h b/src/Math/Matrix4.h index d9ce27269..9674d2159 100644 --- a/src/Math/Matrix4.h +++ b/src/Math/Matrix4.h @@ -27,14 +27,18 @@ namespace Magnum { namespace Math { /** @brief 4x4 matrix +Provides functions for transformations in 3D. See also Matrix3 for 2D +transformations. @todo Shearing @todo Reflection */ template class Matrix4: public Matrix<4, T> { public: /** - * @brief Translation matrix + * @brief 3D translation matrix * @param vec Translation vector + * + * @see Matrix3::translation() */ inline constexpr static Matrix4 translation(const Vector3& vec) { return Matrix4( /* Column-major! */ @@ -46,8 +50,10 @@ template class Matrix4: public Matrix<4, T> { } /** - * @brief Scaling matrix + * @brief 3D scaling matrix * @param vec Scaling vector + * + * @see Matrix3::scaling() */ inline constexpr static Matrix4 scaling(const Vector3& vec) { return Matrix4( /* Column-major! */ @@ -59,10 +65,11 @@ template class Matrix4: public Matrix<4, T> { } /** - * @brief Rotation matrix + * @brief 3D rotation matrix * @param angle Rotation angle (counterclockwise, in radians) * @param vec Rotation vector * + * @see Matrix3::rotation() * @todo optimize - Assume the vectors are normalized? */ static Matrix4 rotation(T angle, const Vector3& vec) { diff --git a/src/Math/Test/Matrix3Test.cpp b/src/Math/Test/Matrix3Test.cpp index ab550d6a8..32d445d72 100644 --- a/src/Math/Test/Matrix3Test.cpp +++ b/src/Math/Test/Matrix3Test.cpp @@ -19,6 +19,7 @@ #include #include "Matrix3.h" +#include "Math.h" QTEST_APPLESS_MAIN(Magnum::Math::Test::Matrix3Test) @@ -51,6 +52,36 @@ void Matrix3Test::constructIdentity() { QVERIFY(identity3 == identity3Expected); } +void Matrix3Test::translation() { + Matrix3 matrix( + 1.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, + 3.0f, 1.0f, 1.0f + ); + + QVERIFY(Matrix3::translation({3.0f, 1.0f}) == matrix); +} + +void Matrix3Test::scaling() { + Matrix3 matrix( + 3.0f, 0.0f, 0.0f, + 0.0f, 1.5f, 0.0f, + 0.0f, 0.0f, 1.0f + ); + + QVERIFY(Matrix3::scaling({3.0f, 1.5f}) == matrix); +} + +void Matrix3Test::rotation() { + Matrix3 matrix( + 0.965926f, 0.258819f, 0.0f, + -0.258819f, 0.965926f, 0.0f, + 0.0f, 0.0f, 1.0f + ); + + QVERIFY(Matrix3::rotation(deg(15.0f)) == matrix); +} + void Matrix3Test::debug() { Matrix3 m( 3.0f, 5.0f, 8.0f, diff --git a/src/Math/Test/Matrix3Test.h b/src/Math/Test/Matrix3Test.h index d482a6a0c..60aed65b4 100644 --- a/src/Math/Test/Matrix3Test.h +++ b/src/Math/Test/Matrix3Test.h @@ -25,6 +25,9 @@ class Matrix3Test: public QObject { private slots: void constructIdentity(); + void translation(); + void scaling(); + void rotation(); void debug(); }; From eb82cb462a2d853df142cccfa09a0f402efd8f82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 20 Jul 2012 14:50:20 +0200 Subject: [PATCH 23/31] Disabled RTTI and exceptions. They wouldn't probably be used at all (RTTI is too heavy for dynamic cast and has too few features to be used for reflection) and they break C++ rule "you don't pay for what you don't use". --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ba893f944..f2be2ee3c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -std=c++0x -fvisibility=hidden") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -std=c++0x -fvisibility=hidden -fno-rtti -fno-exceptions") # If targeting GLES, save it into configuration header if(TARGET_GLES) From 8a85e764ab8371f8a6e7af9f0f462cd7d1bce3ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 20 Jul 2012 14:53:26 +0200 Subject: [PATCH 24/31] Doc: updated Coding Style. * Links to LLVM and Qt guidelines * Forbidden features * Assertions * Keyword order --- doc/coding-style.dox | 54 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/doc/coding-style.dox b/doc/coding-style.dox index 41da98db2..5a06bdfbd 100644 --- a/doc/coding-style.dox +++ b/doc/coding-style.dox @@ -9,6 +9,12 @@ Please note that if you have a good excuse to either break the rules or modify them, feel free to do it (and update this guide accordingly, if appropriate). Nothing is worse than rule that hurts productivity instead of improving it. +You can also take inspiration from other thorougly written coding style +guidelines of large projects: + + - LLVM: http://llvm.org/docs/CodingStandards.html + - Qt: http://qt-project.org/wiki/Qt_Coding_Style + @section cmake CMake code All cmake functions and macros (e.g. `add_executable()`, `set()`) are @@ -225,9 +231,10 @@ switch(type) { } @endcode -@subsubsection cpp-virtual Virtual functions +@subsubsection cpp-keywords Class member and function keywords -Only base virtual functions should have `virtual` keyword, not the +Use keywords in this order: `template virtual inline constexpr static`. Only +base virtual functions should have `virtual` keyword, not the reimplementations. @subsubsection cpp-includes Includes @@ -250,6 +257,49 @@ it should be wrapped on multiple lines, each successive line indented and the line wrapping indicator `\` should be aligned around 80th column, preferably on some tab-stop. +@subsection cpp-constexpr Constant expressions and constants + +Use `constexpr` keyword as much as possible, mainly for getters and static +pure functions, e.g. Matrix4::translation(). If the function is not a single +return-statement, try hard to make it so. + +Traits class members and class constants which are not meant to be referenced +or pointed to should be defined as inline (constexpr) function, because +declaring them as static const variable will result in another (probably +unwanted) symbol. + +@subsection cpp-assert Assertions + +Use asserts as much as possible. %Corrade utility library has convenient +`CORRADE_ASSERT()` macro, which does everything needed - checks the statement, +prints given message to error output and exits immediately or returns default +value: + +@code +T operator[](size_t pos) const { + CORRADE_ASSERT(pos < size(), "Index out of range", T()) + return data[pos]; +} +@endcode + +@subsection cpp-forbidden Forbidden C/C++ features + +Don't use C-style casts, use C++-style `static_cast` and `reinterpret_cast` +instead. For numeric types (e.g. casting from int to float) you can use +"constructor cast": + +@code +int a = 22; +int b = 7; +float pi = ((float) a)/b; // bad! +float pi = static_cast(a)/b; // good +float pi = float(a)/b; // even better here +@endcode + +Don't use RTTI (`dynamic_cast` and `std::typeinfo`) and exceptions. They +violate C++ principle of "don't pay for what you don't use" and thus they are +disabled in the code (GCC/Clang option `-fno-rtti -fno-exceptions`). + @section comments Comments All comments should be in C-style (i.e. slash and asterisk, not two slashes). From 45d1cb1225e61ccd74bc5bf308289ebccd5c4bc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 20 Jul 2012 16:48:29 +0200 Subject: [PATCH 25/31] Anonymized unused function parameters. --- src/Contexts/GlutContext.h | 11 ++++-- src/Contexts/Sdl2Context.cpp | 2 +- src/Contexts/Sdl2Context.h | 17 +++++--- src/Math/Math.h | 2 +- src/Math/Matrix.h | 6 +-- src/Math/Vector.h | 4 +- src/MeshTools/Interleave.h | 2 +- src/MeshTools/Test/CleanTest.h | 4 +- src/MeshTools/Test/SubdivideTest.h | 4 +- src/Object.h | 11 ++++-- src/Scene.h | 2 +- src/Trade/AbstractImporter.cpp | 4 +- src/Trade/AbstractImporter.h | 62 ++++++++++++++++++++---------- 13 files changed, 84 insertions(+), 47 deletions(-) diff --git a/src/Contexts/GlutContext.h b/src/Contexts/GlutContext.h index 9b9c84595..454bd5b0a 100644 --- a/src/Contexts/GlutContext.h +++ b/src/Contexts/GlutContext.h @@ -127,7 +127,7 @@ class GlutContext: public AbstractContext { * * Called when an key is pressed. Default implementation does nothing. */ - virtual inline void keyEvent(Key key, const Math::Vector2& position) {} + virtual void keyEvent(Key key, const Math::Vector2& position); /*@}*/ @@ -182,7 +182,7 @@ class GlutContext: public AbstractContext { * Called when mouse button is pressed or released. Default * implementation does nothing. */ - virtual inline void mouseEvent(MouseButton button, MouseState state, const Math::Vector2& position) {} + virtual void mouseEvent(MouseButton button, MouseState state, const Math::Vector2& position); /** * @brief Mouse motion event @@ -192,7 +192,7 @@ class GlutContext: public AbstractContext { * * @see setMouseTracking() */ - virtual inline void mouseMotionEvent(const Math::Vector2& position) {} + virtual void mouseMotionEvent(const Math::Vector2& position); /*@}*/ @@ -223,6 +223,11 @@ class GlutContext: public AbstractContext { char** argv; }; +/* Implementations for inline functions with unused parameters */ +inline void GlutContext::keyEvent(GlutContext::Key, const Math::Vector2&) {} +inline void GlutContext::mouseEvent(GlutContext::MouseButton, GlutContext::MouseState, const Math::Vector2&) {} +inline void GlutContext::mouseMotionEvent(const Math::Vector2&) {} + }} #endif diff --git a/src/Contexts/Sdl2Context.cpp b/src/Contexts/Sdl2Context.cpp index 3959db0ee..472b9fc95 100644 --- a/src/Contexts/Sdl2Context.cpp +++ b/src/Contexts/Sdl2Context.cpp @@ -17,7 +17,7 @@ namespace Magnum { namespace Contexts { -Sdl2Context::Sdl2Context(int argc, char** argv, const std::string& name, const Math::Vector2& size): _redraw(true) { +Sdl2Context::Sdl2Context(int, char**, const std::string& name, const Math::Vector2& size): _redraw(true) { if(SDL_Init(SDL_INIT_VIDEO) < 0) { Error() << "Cannot initialize SDL."; exit(1); diff --git a/src/Contexts/Sdl2Context.h b/src/Contexts/Sdl2Context.h index b441f44da..906daf49a 100644 --- a/src/Contexts/Sdl2Context.h +++ b/src/Contexts/Sdl2Context.h @@ -96,13 +96,13 @@ class Sdl2Context: public AbstractContext { * @param key Key pressed * @param repeat Non-zero if this is a key repeat */ - inline virtual void keyPressEvent(Key key, Uint8 repeat) {} + virtual void keyPressEvent(Key key, Uint8 repeat); /** * @brief Key release event * @param key Key release */ - inline virtual void keyReleaseEvent(Key key) {} + virtual void keyReleaseEvent(Key key); /*@}*/ @@ -138,7 +138,7 @@ class Sdl2Context: public AbstractContext { * Called when mouse button is pressed or released. Default * implementation does nothing. */ - virtual inline void mouseEvent(MouseButton button, MouseState state, const Math::Vector2& position) {} + virtual void mouseEvent(MouseButton button, MouseState state, const Math::Vector2& position); /** * @brief Mouse wheel event @@ -148,7 +148,7 @@ class Sdl2Context: public AbstractContext { * Called when mouse wheel is rotated. Default implementation does * nothing. */ - virtual inline void mouseWheelEvent(const Math::Vector2& direction) {} + virtual void mouseWheelEvent(const Math::Vector2& direction); /** * @brief Mouse motion event @@ -157,7 +157,7 @@ class Sdl2Context: public AbstractContext { * * Called when mouse is moved. Default implementation does nothing. */ - virtual inline void mouseMotionEvent(const Math::Vector2& position, const Math::Vector2& delta) {} + virtual void mouseMotionEvent(const Math::Vector2& position, const Math::Vector2& delta); /*@}*/ @@ -168,6 +168,13 @@ class Sdl2Context: public AbstractContext { bool _redraw; }; +/* Implementations for inline functions with unused parameters */ +inline void Sdl2Context::keyPressEvent(Sdl2Context::Key, Uint8) {} +inline void Sdl2Context::keyReleaseEvent(Sdl2Context::Key) {} +inline void Sdl2Context::mouseEvent(Sdl2Context::MouseButton, Sdl2Context::MouseState, const Math::Vector2&) {} +inline void Sdl2Context::mouseWheelEvent(const Math::Vector2&) {} +inline void Sdl2Context::mouseMotionEvent(const Math::Vector2&, const Math::Vector2&) {} + }} #endif diff --git a/src/Math/Math.h b/src/Math/Math.h index e6e7e24b5..7b56d7f5a 100644 --- a/src/Math/Math.h +++ b/src/Math/Math.h @@ -64,7 +64,7 @@ namespace Implementation { } }; template<> struct Pow<0> { - template inline constexpr T operator()(T base) const { return 1; } + template inline constexpr T operator()(T) const { return 1; } }; } #endif diff --git a/src/Math/Matrix.h b/src/Math/Matrix.h index 24dee3c7d..47d6c41ee 100644 --- a/src/Math/Matrix.h +++ b/src/Math/Matrix.h @@ -117,10 +117,10 @@ template class Matrix { #endif /** @brief Copy constructor */ - inline constexpr Matrix(const Matrix& other) = default; + inline constexpr Matrix(const Matrix&) = default; /** @brief Assignment operator */ - inline Matrix& operator=(const Matrix& other) = default; + inline Matrix& operator=(const Matrix&) = default; /** * @brief Raw data @@ -244,7 +244,7 @@ template class Matrix { return from(s, next..., first[sequence]...); } - template inline constexpr static Matrix from(Implementation::Sequence s, T first, U... next) { + template inline constexpr static Matrix from(Implementation::Sequence, T first, U... next) { return Matrix(first, next...); } diff --git a/src/Math/Vector.h b/src/Math/Vector.h index d2321292c..3b1dc7057 100644 --- a/src/Math/Vector.h +++ b/src/Math/Vector.h @@ -109,10 +109,10 @@ template class Vector { } /** @brief Copy constructor */ - inline constexpr Vector(const Vector& other) = default; + inline constexpr Vector(const Vector&) = default; /** @brief Assignment operator */ - inline Vector& operator=(const Vector& other) = default; + inline Vector& operator=(const Vector&) = default; /** * @brief Raw data diff --git a/src/MeshTools/Interleave.h b/src/MeshTools/Interleave.h index faf0506cd..8376b1ae7 100644 --- a/src/MeshTools/Interleave.h +++ b/src/MeshTools/Interleave.h @@ -69,7 +69,7 @@ class Interleave { return first.size(); } - template inline static size_t stride(const T& first, const U&... next) { + template inline static size_t stride(const T&, const U&... next) { return sizeof(typename T::value_type) + stride(next...); } diff --git a/src/MeshTools/Test/CleanTest.h b/src/MeshTools/Test/CleanTest.h index fa28c6a11..98362d2e5 100644 --- a/src/MeshTools/Test/CleanTest.h +++ b/src/MeshTools/Test/CleanTest.h @@ -33,8 +33,8 @@ class CleanTest: public QObject { Vector1(): data(0) {} Vector1(int i): data(i) {} - int operator[](size_t i) const { return data; } - int& operator[](size_t i) { return data; } + int operator[](size_t) const { return data; } + int& operator[](size_t) { return data; } bool operator==(Vector1 i) const { return i.data == data; } Vector1 operator-(Vector1 i) const { return data-i.data; } diff --git a/src/MeshTools/Test/SubdivideTest.h b/src/MeshTools/Test/SubdivideTest.h index 2f5da2656..28ade77a0 100644 --- a/src/MeshTools/Test/SubdivideTest.h +++ b/src/MeshTools/Test/SubdivideTest.h @@ -34,8 +34,8 @@ class SubdivideTest: public QObject { Vector1(): data(0) {} Vector1(int i): data(i) {} - int operator[](size_t i) const { return data; } - int& operator[](size_t i) { return data; } + int operator[](size_t) const { return data; } + int& operator[](size_t) { return data; } bool operator==(Vector1 i) const { return i.data == data; } Vector1 operator-(Vector1 i) const { return data-i.data; } diff --git a/src/Object.h b/src/Object.h index 4c6494c0d..d4df67530 100644 --- a/src/Object.h +++ b/src/Object.h @@ -178,7 +178,7 @@ class MAGNUM_EXPORT Object { * * Default implementation does nothing. */ - virtual void draw(const Matrix4& transformationMatrix, Camera* camera) {} + virtual void draw(const Matrix4& transformationMatrix, Camera* camera); /** @{ @name Caching helpers * @@ -253,9 +253,7 @@ class MAGNUM_EXPORT Object { * } * @endcode */ - virtual inline void clean(const Matrix4& absoluteTransformation) { - dirty = false; - } + virtual void clean(const Matrix4& absoluteTransformation); /*@}*/ @@ -266,6 +264,11 @@ class MAGNUM_EXPORT Object { bool dirty; }; +/* Implementations for inline functions with unused parameters */ +inline void Object::draw(const Matrix4&, Camera*) {} +inline void Object::clean(const Matrix4&) { dirty = false; } + + } #endif diff --git a/src/Scene.h b/src/Scene.h index 744d81262..076e6f4ef 100644 --- a/src/Scene.h +++ b/src/Scene.h @@ -39,7 +39,7 @@ class MAGNUM_EXPORT Scene: public Object { void rotate(GLfloat angle, Vector3 vec, Transformation type = Transformation::Global) = delete; private: - inline virtual void draw(const Magnum::Matrix4& transformationMatrix, Camera* camera) {} + inline void draw(const Magnum::Matrix4&, Camera*) {} }; } diff --git a/src/Trade/AbstractImporter.cpp b/src/Trade/AbstractImporter.cpp index 271d5be44..cfd07c7a3 100644 --- a/src/Trade/AbstractImporter.cpp +++ b/src/Trade/AbstractImporter.cpp @@ -19,12 +19,12 @@ using namespace std; namespace Magnum { namespace Trade { -bool AbstractImporter::open(const std::string& filename) { +bool AbstractImporter::open(const std::string&) { Error() << plugin() << "doesn't support opening files"; return false; } -bool AbstractImporter::open(std::istream& in) { +bool AbstractImporter::open(std::istream&) { Error() << plugin() << "doesn't support opening input streams"; return false; } diff --git a/src/Trade/AbstractImporter.h b/src/Trade/AbstractImporter.h index c0bdba48f..5faa77607 100644 --- a/src/Trade/AbstractImporter.h +++ b/src/Trade/AbstractImporter.h @@ -121,7 +121,7 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin { * If no scene for given name exists, returns -1. * @see SceneData::name() */ - virtual inline int sceneForName(const std::string& name) { return -1; } + virtual int sceneForName(const std::string& name); /** * @brief %Scene @@ -129,7 +129,7 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin { * * Returns pointer to given scene or nullptr, if no such scene exists. */ - virtual inline SceneData* scene(unsigned int id) { return nullptr; } + virtual SceneData* scene(unsigned int id); /** @brief %Light count */ virtual inline unsigned int lightCount() const { return 0; } @@ -140,7 +140,7 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin { * If no light for given name exists, returns -1. * @see LightData::name() */ - virtual inline int lightForName(const std::string& name) { return -1; } + virtual int lightForName(const std::string& name); /** * @brief %Light @@ -148,7 +148,7 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin { * * Returns pointer to given light or nullptr, if no such light exists. */ - virtual inline LightData* light(unsigned int id) { return nullptr; } + virtual LightData* light(unsigned int id); /** @brief %Camera count */ virtual inline unsigned int cameraCount() const { return 0; } @@ -159,7 +159,7 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin { * If no camera for given name exists, returns -1. * @see CameraData::name() */ - virtual inline int cameraForName(const std::string& name) { return -1; } + virtual int cameraForName(const std::string& name); /** * @brief %Camera @@ -168,7 +168,7 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin { * Returns pointer to given camera or nullptr, if no such camera * exists. */ - virtual inline CameraData* camera(unsigned int id) { return nullptr; } + virtual CameraData* camera(unsigned int id); /** @brief %Object count */ virtual inline unsigned int objectCount() const { return 0; } @@ -179,7 +179,7 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin { * If no scene for given name exists, returns -1. * @see ObjectData::name() */ - virtual inline int objectForName(const std::string& name) { return -1; } + virtual int objectForName(const std::string& name); /** * @brief %Object @@ -188,7 +188,7 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin { * Returns pointer to given object or nullptr, if no such object * exists. */ - virtual inline ObjectData* object(unsigned int id) { return nullptr; } + virtual ObjectData* object(unsigned int id); /** @brief %Mesh count */ virtual inline unsigned int meshCount() const { return 0; } @@ -199,7 +199,7 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin { * If no mesh for given name exists, returns -1. * @see MeshData::name() */ - virtual inline int meshForName(const std::string& name) { return -1; } + virtual int meshForName(const std::string& name); /** * @brief %Mesh @@ -207,7 +207,7 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin { * * Returns pointer to given mesh or nullptr, if no such mesh exists. */ - virtual inline MeshData* mesh(unsigned int id) { return nullptr; } + virtual MeshData* mesh(unsigned int id); /** @brief Material count */ virtual inline unsigned int materialCount() const { return 0; } @@ -218,7 +218,7 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin { * If no material for given name exists, returns -1. * @see AbstractMaterialData::name() */ - virtual inline int materialForName(const std::string& name) { return -1; } + virtual int materialForName(const std::string& name); /** * @brief Material @@ -227,7 +227,7 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin { * Returns pointer to given material or nullptr, if no such material * exists. */ - virtual inline AbstractMaterialData* material(unsigned int id) { return nullptr; } + virtual AbstractMaterialData* material(unsigned int id); /** @brief %Texture count */ virtual inline unsigned int textureCount() const { return 0; } @@ -238,7 +238,7 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin { * If no texture for given name exists, returns -1. * @see TextureData::name() */ - virtual inline int textureForName(const std::string& name) { return -1; } + virtual int textureForName(const std::string& name); /** * @brief %Texture @@ -247,7 +247,7 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin { * Returns pointer to given texture or nullptr, if no such texture * exists. */ - virtual inline TextureData* texture(unsigned int id) { return nullptr; } + virtual TextureData* texture(unsigned int id); /** @brief One-dimensional image count */ virtual inline unsigned int image1DCount() const { return 0; } @@ -258,7 +258,7 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin { * If no image for given name exists, returns -1. * @see ImageData1D::name() */ - virtual inline int image1DForName(const std::string& name) { return -1; } + virtual int image1DForName(const std::string& name); /** * @brief One-dimensional image @@ -266,7 +266,7 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin { * * Returns pointer to given image or nullptr, if no such image exists. */ - virtual inline ImageData1D* image1D(unsigned int id) { return nullptr; } + virtual ImageData1D* image1D(unsigned int id); /** @brief Two-dimensional image count */ virtual inline unsigned int image2DCount() const { return 0; } @@ -277,7 +277,7 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin { * If no image for given name exists, returns -1. * @see ImageData2D::name() */ - virtual inline int image2DForName(const std::string& name) { return -1; } + virtual int image2DForName(const std::string& name); /** * @brief Two-dimensional image @@ -285,7 +285,7 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin { * * Returns pointer to given image or nullptr, if no such image exists. */ - virtual inline ImageData2D* image2D(unsigned int id) { return nullptr; } + virtual ImageData2D* image2D(unsigned int id); /** @brief Three-dimensional image count */ virtual inline unsigned int image3DCount() const { return 0; } @@ -296,7 +296,7 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin { * If no image for given name exists, returns -1. * @see ImageData3D::name() */ - virtual inline int image3DForName(const std::string& name) { return -1; } + virtual int image3DForName(const std::string& name); /** * @brief Three-dimensional image @@ -304,13 +304,35 @@ class MAGNUM_EXPORT AbstractImporter: public Corrade::PluginManager::Plugin { * * Returns pointer to given image or nullptr, if no such image exists. */ - virtual inline ImageData3D* image3D(unsigned int id) { return nullptr; } + virtual ImageData3D* image3D(unsigned int id); /*@}*/ }; SET_OPERATORS(AbstractImporter::Features) +/* Implementations for inline functions with unused parameters */ +inline int AbstractImporter::sceneForName(const std::string&) { return -1; } +inline SceneData* AbstractImporter::scene(unsigned int) { return nullptr; } +inline int AbstractImporter::lightForName(const std::string&) { return -1; } +inline LightData* AbstractImporter::light(unsigned int) { return nullptr; } +inline int AbstractImporter::cameraForName(const std::string&) { return -1; } +inline CameraData* AbstractImporter::camera(unsigned int) { return nullptr; } +inline int AbstractImporter::objectForName(const std::string&) { return -1; } +inline ObjectData* AbstractImporter::object(unsigned int) { return nullptr; } +inline int AbstractImporter::meshForName(const std::string&) { return -1; } +inline MeshData* AbstractImporter::mesh(unsigned int) { return nullptr; } +inline int AbstractImporter::materialForName(const std::string&) { return -1; } +inline AbstractMaterialData* AbstractImporter::material(unsigned int) { return nullptr; } +inline int AbstractImporter::textureForName(const std::string&) { return -1; } +inline TextureData* AbstractImporter::texture(unsigned int) { return nullptr; } +inline int AbstractImporter::image1DForName(const std::string&) { return -1; } +inline ImageData1D* AbstractImporter::image1D(unsigned int) { return nullptr; } +inline int AbstractImporter::image2DForName(const std::string&) { return -1; } +inline ImageData2D* AbstractImporter::image2D(unsigned int) { return nullptr; } +inline int AbstractImporter::image3DForName(const std::string&) { return -1; } +inline ImageData3D* AbstractImporter::image3D(unsigned int) { return nullptr; } + }} #endif From 27dad83dbc330bc38b405224ad229690ba745806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 20 Jul 2012 16:54:35 +0200 Subject: [PATCH 26/31] Don't pretend we are working with floats when they are doubles. --- src/Math/Test/MathTypeTraitsTest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Math/Test/MathTypeTraitsTest.cpp b/src/Math/Test/MathTypeTraitsTest.cpp index 126a36186..d2d787f9c 100644 --- a/src/Math/Test/MathTypeTraitsTest.cpp +++ b/src/Math/Test/MathTypeTraitsTest.cpp @@ -46,8 +46,8 @@ template void MathTypeTraitsTest::_equalsIntegral() { } template void MathTypeTraitsTest::_equalsFloatingPoint() { - QVERIFY(MathTypeTraits::equals(1.0f+MathTypeTraits::epsilon()/2, 1.0f)); - QVERIFY(!MathTypeTraits::equals(1.0f+MathTypeTraits::epsilon()*2, 1.0f)); + QVERIFY(MathTypeTraits::equals(T(1)+MathTypeTraits::epsilon()/T(2), T(1))); + QVERIFY(!MathTypeTraits::equals(T(1)+MathTypeTraits::epsilon()*T(2), T(1))); QEXPECT_FAIL(0, "Comparing to infinity is broken", Continue); QVERIFY(MathTypeTraits::equals(std::numeric_limits::infinity(), From 8b3e065d52153b208b44c2fd25b868f5cce4c5cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 20 Jul 2012 16:57:09 +0200 Subject: [PATCH 27/31] Don't use == when comparing floating point values. --- src/Math/Test/MatrixTest.cpp | 2 +- src/Math/Test/VectorTest.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Math/Test/MatrixTest.cpp b/src/Math/Test/MatrixTest.cpp index 7f2552089..a88245f86 100644 --- a/src/Math/Test/MatrixTest.cpp +++ b/src/Math/Test/MatrixTest.cpp @@ -110,7 +110,7 @@ void MatrixTest::data() { m[1][2] = 1.5f; - QVERIFY(m[2][1] == 1.0f); + QCOMPARE(m[2][1], 1.0f); QVERIFY(m[3] == vector); Matrix4 expected( diff --git a/src/Math/Test/VectorTest.cpp b/src/Math/Test/VectorTest.cpp index 23fecc55f..3bebbd863 100644 --- a/src/Math/Test/VectorTest.cpp +++ b/src/Math/Test/VectorTest.cpp @@ -69,7 +69,7 @@ void VectorTest::copy() { } void VectorTest::dot() { - QVERIFY(Vector4::dot({1.0f, 0.5f, 0.75f, 1.5f}, {2.0f, 4.0f, 1.0f, 7.0f}) == 15.25f); + QCOMPARE(Vector4::dot({1.0f, 0.5f, 0.75f, 1.5f}, {2.0f, 4.0f, 1.0f, 7.0f}), 15.25f); } void VectorTest::multiplyDivide() { From 8fec5075a107f2c9d78afe8e4e174c7d95413a3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 20 Jul 2012 16:58:02 +0200 Subject: [PATCH 28/31] Enable some more warnings. --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f2be2ee3c..880645104 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -std=c++0x -fvisibility=hidden -fno-rtti -fno-exceptions") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wold-style-cast -pedantic -std=c++0x -fvisibility=hidden -fno-rtti -fno-exceptions") # If targeting GLES, save it into configuration header if(TARGET_GLES) From 4594781d749552f4f28aba92ed8e7c3d74a6da52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 20 Jul 2012 17:07:41 +0200 Subject: [PATCH 29/31] Warn about float -> double promotion. --- src/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 880645104..fa67b9547 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,9 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wold-style-cast -pedantic -std=c++0x -fvisibility=hidden -fno-rtti -fno-exceptions") +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdouble-promotion") +endif() + # If targeting GLES, save it into configuration header if(TARGET_GLES) set(MAGNUM_TARGET_GLES 1) From 39b4f6873f40c83d20e59372cdad58751c0d51f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 20 Jul 2012 20:04:54 +0200 Subject: [PATCH 30/31] Fixed issue with depth buffer not cleared. Introduced in 51aa660f6c12de932b88bb8a58a4964932ebc07f, typo when refactoring the code. --- src/Framebuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Framebuffer.cpp b/src/Framebuffer.cpp index 864a70d80..d0f1d4cd2 100644 --- a/src/Framebuffer.cpp +++ b/src/Framebuffer.cpp @@ -25,7 +25,7 @@ void Framebuffer::setFeature(Feature feature, bool enabled) { /* Update clear mask, if needed */ ClearMask clearMaskChange; - if(feature == Feature::DepthTest) clearMaskChange = Clear::Color; + if(feature == Feature::DepthTest) clearMaskChange = Clear::Depth; else if(feature == Feature::StencilTest) clearMaskChange = Clear::Stencil; else return; From 7e0b8601f770667647e89709a5ab29f10aa87949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 20 Jul 2012 20:06:15 +0200 Subject: [PATCH 31/31] Added MAGNUM_*_INCLUDE_DIRS for all modules too. Some modules need it (Sdl2Context), some not. --- modules/FindMagnum.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index 988cf4167..a41a79287 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -37,6 +37,7 @@ # # MAGNUM_*_FOUND - Whether the component was found # MAGNUM_*_LIBRARIES - Component library and dependent libraries +# MAGNUM_*_INCLUDE_DIRS - Include dirs of module dependencies # # Additionally these variables are defined for internal usage: # @@ -108,6 +109,7 @@ foreach(component ${Magnum_FIND_COMPONENTS}) find_package(SDL2) if(SDL2_FOUND) set(_MAGNUM_${_COMPONENT}_LIBRARIES ${SDL2_LIBRARY}) + set(_MAGNUM_${_COMPONENT}_INCLUDE_DIRS ${SDL2_INCLUDE_DIR}) else() unset(MAGNUM_${_COMPONENT}_LIBRARY) endif() @@ -155,6 +157,7 @@ foreach(component ${Magnum_FIND_COMPONENTS}) # Decide if the library was found if(MAGNUM_${_COMPONENT}_LIBRARY AND _MAGNUM_${_COMPONENT}_INCLUDE_DIR) set(MAGNUM_${_COMPONENT}_LIBRARIES ${MAGNUM_${_COMPONENT}_LIBRARY} ${_MAGNUM_${_COMPONENT}_LIBRARIES}) + set(MAGNUM_${_COMPONENT}_INCLUDE_DIRS ${_MAGNUM_${_COMPONENT}_INCLUDE_DIRS}) set(Magnum_${component}_FOUND TRUE) else() set(Magnum_${component}_FOUND FALSE)