From ac8d9df962e8e98a9102cb946b5b2179db0e9564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 26 Jun 2014 20:50:22 +0200 Subject: [PATCH 1/6] doc: mention all windowless applications in platform documentation. --- doc/platform.dox | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/doc/platform.dox b/doc/platform.dox index 633f38057..ef1cd319f 100644 --- a/doc/platform.dox +++ b/doc/platform.dox @@ -125,15 +125,19 @@ void MyApplication::viewportEvent(const Vector2i& size) { Windowless applications provide just a context for ofscreen rendering or performing tasks on GPU. There is not yet any platform-independent toolkit which could handle this in portable way, thus you have to use platform-specific -ones. As example we use @ref Platform::WindowlessGlxApplication, you need to -implement just @ref WindowlessGlxApplication::exec() "exec()" function. The -class can be then used directly in `main()`, but again, for convenience and -portability it's better to use @ref MAGNUM_WINDOWLESSGLXAPPLICATION_MAIN() -macro. +ones. %Magnum provides windowless applications for X11-based Unix, OS X and +Windows. To make things simple, as an example we will use only +@ref Platform::WindowlessGlxApplication, see link for bootstrap application +below for fully portable example. + +You need to implement just @ref WindowlessGlxApplication::exec() "exec()" +function. The class can be then used directly in `main()`, but again, for +convenience and portability it's better to use +@ref MAGNUM_WINDOWLESSGLXAPPLICATION_MAIN() macro. Similarly as with windowed applications, to simplify the porting, the library provides `Platform::WindowlessApplication` typedef and `MAGNUM_WINDOWLESSAPPLICATION_MAIN()` -macro, but only if only one windowless application header is included. Changing +macro, but only if just one windowless application header is included. Changing the code to use different toolkit is then matter of replacing only the #`include` statement. Aliases for windowless applications are separated from aliases for windowed applications, because projects commonly @@ -143,8 +147,10 @@ etc.). Barebone application which will just print out current OpenGL version and renderer string and exits is in the following code listing. -@note Fully contained windowless application along with CMake setup is - available in `windowless` branch of [Magnum Bootstrap](https://github.com/mosra/magnum-bootstrap) +@note Fully contained windowless application using @ref Platform::WindowlessCglApplication + on OS X, @ref Platform::WindowlessGlxApplication on Unix and + @ref Platform::WindowlessWglApplication on Windows along with CMake setup + is available in `windowless` branch of [Magnum Bootstrap](https://github.com/mosra/magnum-bootstrap) repository. @code From 3037e2c88962c1a7e2724963c4452cab269b30d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 26 Jun 2014 21:13:28 +0200 Subject: [PATCH 2/6] doc: mention the need to use compatibility version of FindCorrade.cmake. --- doc/getting-started.dox | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/getting-started.dox b/doc/getting-started.dox index 35b90f9ad..e8d0ff721 100644 --- a/doc/getting-started.dox +++ b/doc/getting-started.dox @@ -61,6 +61,10 @@ The code will be slightly different from what is presented below, but the changes are only minor (two modified lines and one additional file) and the main principles are the same. +If you are using `compatibility` branch of Magnum and Corrade, replace +`modules/FindCorrade.cmake` with [the one from `compatibility` branch](https://github.com/mosra/corrade/blob/compatibility/modules/FindCorrade.cmake) +so the compatibility mode gets properly detected and used. + @section getting-started-review Review project structure The base project consists of just six files in two subfolders. %Magnum uses From d5f58b025fd8e9a1cda882da551a76a95aa9f52c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 26 Jun 2014 21:23:45 +0200 Subject: [PATCH 3/6] Code reorganization. --- src/Magnum/Context.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Magnum/Context.h b/src/Magnum/Context.h index 0b9d69078..e68221939 100644 --- a/src/Magnum/Context.h +++ b/src/Magnum/Context.h @@ -130,6 +130,13 @@ class MAGNUM_EXPORT Context { #endif }; + /** + * @brief %Context flags + * + * @see @ref flags() + */ + typedef Containers::EnumSet Flags; + /** * @brief State to reset * @@ -162,13 +169,6 @@ class MAGNUM_EXPORT Context { */ typedef Containers::EnumSet States; - /** - * @brief %Context flags - * - * @see @ref flags() - */ - typedef Containers::EnumSet Flags; - /** * @brief Constructor * From 795da389c8b6de3afd38b4f113f87c46f2ca08f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 28 Jun 2014 16:44:49 +0200 Subject: [PATCH 4/6] Doc++ --- doc/cmake.dox | 6 +++--- src/Magnum/Context.h | 2 ++ src/Magnum/Magnum.h | 17 ++++++++++------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/doc/cmake.dox b/doc/cmake.dox index b6ab4f3a9..b80791ca6 100644 --- a/doc/cmake.dox +++ b/doc/cmake.dox @@ -156,12 +156,12 @@ variable along with `MAGNUM_PLUGINS_*_DEBUG_DIR` / `MAGNUM_PLUGINS_*_RELEASE_DIR variables to decide in preprocessing step. Features of found %Magnum library are exposed in these CMake variables, they -are also available as preprocessor variables if including Magnum.h: +are also available as preprocessor variables if including @ref Magnum/Magnum.h: - `MAGNUM_BUILD_DEPRECATED` -- Defined if compiled with deprecated APIs included -- `MAGNUM_BUILD_STATIC` -- Defined if built as static libraries. Default are - shared libraries. +- `MAGNUM_BUILD_STATIC` -- Defined if compiled as static libraries. Default + are shared libraries. - `MAGNUM_TARGET_GLES` -- Defined if compiled for OpenGL ES - `MAGNUM_TARGET_GLES2` -- Defined if compiled for OpenGL ES 2.0 - `MAGNUM_TARGET_GLES3` -- Defined if compiled for OpenGL ES 3.0 diff --git a/src/Magnum/Context.h b/src/Magnum/Context.h index e68221939..93eee5bef 100644 --- a/src/Magnum/Context.h +++ b/src/Magnum/Context.h @@ -381,6 +381,7 @@ class MAGNUM_EXPORT Context { * as it does most operations in compile time. * @see @ref supportedExtensions(), @ref Extension::extensions(), * @ref MAGNUM_ASSERT_EXTENSION_SUPPORTED() + * @todoc Explicit reference when Doxygen can handle const */ bool isExtensionSupported(const Extension& extension) const { return isVersionSupported(_extensionRequiredVersion[extension._index]) && extensionStatus[extension._index]; @@ -414,6 +415,7 @@ class MAGNUM_EXPORT Context { * Can be used e.g. for listing extensions available on current * hardware, but for general usage prefer isExtensionDisabled() const, * as it does most operations in compile time. + * @todoc Explicit reference when Doxygen can handle const */ bool isExtensionDisabled(const Extension& extension) const { return isVersionSupported(extension._requiredVersion) && extensionStatus[extension._index] && !isVersionSupported(_extensionRequiredVersion[extension._index]); diff --git a/src/Magnum/Magnum.h b/src/Magnum/Magnum.h index 77a551697..93e0915d0 100644 --- a/src/Magnum/Magnum.h +++ b/src/Magnum/Magnum.h @@ -73,7 +73,7 @@ using Corrade::Utility::Error; Defined if the library contains deprecated API (which will be removed in the future). To preserve backward compatibility, %Magnum is by default built with deprecated API included. -@see @ref building +@see @ref building, @ref cmake */ #define MAGNUM_BUILD_DEPRECATED /* (enabled by default) */ @@ -82,7 +82,7 @@ deprecated API included. @brief Static library build Defined if built as static libraries. Default are shared libraries. -@see @ref building +@see @ref building, @ref cmake */ #define MAGNUM_BUILD_STATIC #undef MAGNUM_BUILD_STATIC @@ -92,7 +92,7 @@ Defined if built as static libraries. Default are shared libraries. Defined if the engine is built for OpenGL ES 3.0 or OpenGL ES 2.0. @see @ref MAGNUM_TARGET_GLES2, @ref MAGNUM_TARGET_GLES3, - @ref MAGNUM_TARGET_DESKTOP_GLES, @ref building + @ref MAGNUM_TARGET_DESKTOP_GLES, @ref building, @ref cmake */ #define MAGNUM_TARGET_GLES #undef MAGNUM_TARGET_GLES @@ -102,7 +102,8 @@ Defined if the engine is built for OpenGL ES 3.0 or OpenGL ES 2.0. Defined if the engine is built for OpenGL ES 2.0. Implies also @ref MAGNUM_TARGET_GLES. -@see @ref MAGNUM_TARGET_GLES3, @ref MAGNUM_TARGET_DESKTOP_GLES, @ref building +@see @ref MAGNUM_TARGET_GLES3, @ref MAGNUM_TARGET_DESKTOP_GLES, @ref building, + @ref cmake */ #define MAGNUM_TARGET_GLES2 #undef MAGNUM_TARGET_GLES2 @@ -112,7 +113,8 @@ Defined if the engine is built for OpenGL ES 2.0. Implies also Defined if the engine is built for OpenGL ES 3.0. Implies also @ref MAGNUM_TARGET_GLES. -@see @ref MAGNUM_TARGET_GLES2, @ref MAGNUM_TARGET_DESKTOP_GLES, @ref building +@see @ref MAGNUM_TARGET_GLES2, @ref MAGNUM_TARGET_DESKTOP_GLES, @ref building, + @ref cmake */ #define MAGNUM_TARGET_GLES3 #undef MAGNUM_TARGET_GLES3 @@ -122,7 +124,8 @@ Defined if the engine is built for OpenGL ES 3.0. Implies also Defined if the engine is built for OpenGL ES 3.0 or OpenGL ES 2.0 emulated within standard desktop OpenGL. Implies also @ref MAGNUM_TARGET_GLES. -@see @ref MAGNUM_TARGET_GLES2, @ref MAGNUM_TARGET_GLES3, @ref building +@see @ref MAGNUM_TARGET_GLES2, @ref MAGNUM_TARGET_GLES3, @ref building, + @ref cmake */ #define MAGNUM_TARGET_DESKTOP_GLES #undef MAGNUM_TARGET_DESKTOP_GLES @@ -136,7 +139,7 @@ differently, but there are some [specific restrictions and features](http://www.khronos.org/registry/webgl/specs/latest/1.0/#6) which you might want to be aware of. Implies also @ref MAGNUM_TARGET_GLES and @ref MAGNUM_TARGET_GLES2. -@see @ref CORRADE_TARGET_EMSCRIPTEN, @ref building +@see @ref CORRADE_TARGET_EMSCRIPTEN, @ref building, @ref cmake */ #define MAGNUM_TARGET_WEBGL #undef MAGNUM_TARGET_WEBGL From 68016dbee316a7d46fb3da1ee9dd8e4ec3d139a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 28 Jun 2014 16:45:01 +0200 Subject: [PATCH 5/6] Provide MAGNUM_TARGET_WEBGL also in CMake. --- doc/cmake.dox | 1 + modules/FindMagnum.cmake | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/doc/cmake.dox b/doc/cmake.dox index b80791ca6..73732b990 100644 --- a/doc/cmake.dox +++ b/doc/cmake.dox @@ -167,6 +167,7 @@ are also available as preprocessor variables if including @ref Magnum/Magnum.h: - `MAGNUM_TARGET_GLES3` -- Defined if compiled for OpenGL ES 3.0 - `MAGNUM_TARGET_DESKTOP_GLES` -- Defined if compiled with OpenGL ES 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/` diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index 22b5d029e..55addc7aa 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -92,6 +92,7 @@ # MAGNUM_TARGET_GLES3 - Defined if compiled for OpenGL ES 3.0 # MAGNUM_TARGET_DESKTOP_GLES - Defined if compiled with OpenGL ES # 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 @@ -207,6 +208,10 @@ string(FIND "${_magnumConfigure}" "#define MAGNUM_TARGET_DESKTOP_GLES" _TARGET_D if(NOT _TARGET_DESKTOP_GLES EQUAL -1) set(MAGNUM_TARGET_DESKTOP_GLES 1) endif() +string(FIND "${_magnumConfigure}" "#define MAGNUM_TARGET_WEBGL" _TARGET_WEBGL) +if(NOT _TARGET_WEBGL EQUAL -1) + set(MAGNUM_TARGET_WEBGL 1) +endif() # Dependent libraries and includes set(MAGNUM_INCLUDE_DIRS ${MAGNUM_INCLUDE_DIR} From 2848d1d37c16810c3d894854e340410db5a219c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 28 Jun 2014 18:58:07 +0200 Subject: [PATCH 6/6] DebugTools: defaulted destructor implementation in source files. To avoid errors about deleting incomplete when destructing Resource instances. Spotted by Clang. --- src/Magnum/DebugTools/ForceRenderer.cpp | 3 +++ src/Magnum/DebugTools/ForceRenderer.h | 2 ++ src/Magnum/DebugTools/ObjectRenderer.cpp | 3 +++ src/Magnum/DebugTools/ObjectRenderer.h | 2 ++ 4 files changed, 10 insertions(+) diff --git a/src/Magnum/DebugTools/ForceRenderer.cpp b/src/Magnum/DebugTools/ForceRenderer.cpp index a713fdc70..e46a301ea 100644 --- a/src/Magnum/DebugTools/ForceRenderer.cpp +++ b/src/Magnum/DebugTools/ForceRenderer.cpp @@ -86,6 +86,9 @@ template ForceRenderer::ForceRenderer(SceneG ResourceManager::instance().set(this->mesh.key(), mesh, ResourceDataState::Final, ResourcePolicy::Manual); } +/* To avoid deleting pointers to incomplete type on destruction of Resource members */ +template ForceRenderer::~ForceRenderer() = default; + template void ForceRenderer::draw(const MatrixTypeFor& transformationMatrix, SceneGraph::AbstractCamera& camera) { shader->setTransformationProjectionMatrix(camera.projectionMatrix()*Implementation::forceRendererTransformation(transformationMatrix.transformPoint(forcePosition), force)*MatrixTypeFor::scaling(VectorTypeFor{options->scale()})) .setColor(options->color()); diff --git a/src/Magnum/DebugTools/ForceRenderer.h b/src/Magnum/DebugTools/ForceRenderer.h index e6db5d56f..3282f575b 100644 --- a/src/Magnum/DebugTools/ForceRenderer.h +++ b/src/Magnum/DebugTools/ForceRenderer.h @@ -125,6 +125,8 @@ template class MAGNUM_DEBUGTOOLS_EXPORT ForceRenderer: p */ ForceRenderer(SceneGraph::AbstractObject&, const VectorTypeFor&, VectorTypeFor&&, ResourceKey = ResourceKey(), SceneGraph::DrawableGroup* = nullptr) = delete; + ~ForceRenderer(); + private: void draw(const MatrixTypeFor& transformationMatrix, SceneGraph::AbstractCamera& camera) override; diff --git a/src/Magnum/DebugTools/ObjectRenderer.cpp b/src/Magnum/DebugTools/ObjectRenderer.cpp index 02e9257f4..d7be15cf6 100644 --- a/src/Magnum/DebugTools/ObjectRenderer.cpp +++ b/src/Magnum/DebugTools/ObjectRenderer.cpp @@ -175,6 +175,9 @@ template ObjectRenderer::ObjectRenderer(Scen ResourceManager::instance().set(this->mesh.key(), mesh, ResourceDataState::Final, ResourcePolicy::Manual); } +/* To avoid deleting pointers to incomplete type on destruction of Resource members */ +template ObjectRenderer::~ObjectRenderer() = default; + template void ObjectRenderer::draw(const MatrixTypeFor& transformationMatrix, SceneGraph::AbstractCamera& camera) { shader->setTransformationProjectionMatrix(camera.projectionMatrix()*transformationMatrix*MatrixTypeFor::scaling(VectorTypeFor{options->size()})); mesh->draw(*shader); diff --git a/src/Magnum/DebugTools/ObjectRenderer.h b/src/Magnum/DebugTools/ObjectRenderer.h index e9d22c906..eaeed85f1 100644 --- a/src/Magnum/DebugTools/ObjectRenderer.h +++ b/src/Magnum/DebugTools/ObjectRenderer.h @@ -97,6 +97,8 @@ template class MAGNUM_DEBUGTOOLS_EXPORT ObjectRenderer: */ explicit ObjectRenderer(SceneGraph::AbstractObject& object, ResourceKey options = ResourceKey(), SceneGraph::DrawableGroup* drawables = nullptr); + ~ObjectRenderer(); + private: void draw(const MatrixTypeFor& transformationMatrix, SceneGraph::AbstractCamera& camera) override;