diff --git a/CMakeLists.txt b/CMakeLists.txt index d2ef795a6..49781f968 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -178,8 +178,24 @@ endif() include(CorradeLibSuffix) set(MAGNUM_BINARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin) set(MAGNUM_LIBRARY_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}) +set(MAGNUM_DATA_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/magnum) +set(MAGNUM_CMAKE_FIND_MODULE_INSTALL_DIR ${CMAKE_ROOT}/Modules) +set(MAGNUM_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/Magnum) +set(MAGNUM_EXTERNAL_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/MagnumExternal) +set(MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/MagnumPlugins) + +# Separate install dirs for debug and release plugins set(MAGNUM_PLUGINS_DEBUG_INSTALL_DIR ${MAGNUM_LIBRARY_INSTALL_DIR}/magnum-d) set(MAGNUM_PLUGINS_RELEASE_INSTALL_DIR ${MAGNUM_LIBRARY_INSTALL_DIR}/magnum) + +# Plugin installation dirs based on wheter we are in debug or release build, +# needed by some command-line tools +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + set(MAGNUM_PLUGINS_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_INSTALL_DIR}) +else() + set(MAGNUM_PLUGINS_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_INSTALL_DIR}) +endif() + set(MAGNUM_PLUGINS_FONT_DEBUG_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_INSTALL_DIR}/fonts) set(MAGNUM_PLUGINS_FONT_RELEASE_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_INSTALL_DIR}/fonts) set(MAGNUM_PLUGINS_FONTCONVERTER_DEBUG_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_INSTALL_DIR}/fontconverters) @@ -190,11 +206,6 @@ set(MAGNUM_PLUGINS_IMPORTER_DEBUG_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_INSTALL_DIR set(MAGNUM_PLUGINS_IMPORTER_RELEASE_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_INSTALL_DIR}/importers) set(MAGNUM_PLUGINS_AUDIOIMPORTER_DEBUG_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_INSTALL_DIR}/audioimporters) set(MAGNUM_PLUGINS_AUDIOIMPORTER_RELEASE_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_INSTALL_DIR}/audioimporters) -set(MAGNUM_DATA_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/magnum) -set(MAGNUM_CMAKE_FIND_MODULE_INSTALL_DIR ${CMAKE_ROOT}/Modules) -set(MAGNUM_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/Magnum) -set(MAGNUM_EXTERNAL_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/MagnumExternal) -set(MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/MagnumPlugins) add_subdirectory(modules) add_subdirectory(src) diff --git a/doc/building.dox b/doc/building.dox index daf4de874..747192216 100644 --- a/doc/building.dox +++ b/doc/building.dox @@ -167,26 +167,27 @@ CMake and C++ sources, see @ref cmake and @ref Magnum/Magnum.h for more information. See also @ref corrade-cmake and @ref Corrade/Corrade.h for additional information. -By default the engine is built with nearly everything except Audio library, -plugins and application libraries (see below). Using `WITH_*` CMake parameters -you can specify which parts will be built and which not: - -- `WITH_AUDIO` - Audio library. Depends on **OpenAL** library, not built by - default. -- `WITH_DEBUGTOOLS` - DebugTools library. Enables also building of MeshTools, - Primitives, SceneGraph, Shaders and Shapes libraries. -- `WITH_MESHTOOLS` - MeshTools library. Enabled automatically if +By default the engine is built with nearly everything except @ref Audio +library, plugins and application libraries (see below). Using `WITH_*` CMake +parameters you can specify which parts will be built and which not: + +- `WITH_AUDIO` - @ref Audio library. Depends on **OpenAL** library, not built + by default. +- `WITH_DEBUGTOOLS` - @ref DebugTools library. Enables also building of + %MeshTools, %Primitives, %SceneGraph, %Shaders and %Shapes libraries. +- `WITH_MESHTOOLS` - @ref MeshTools library. Enabled automatically if `WITH_DEBUGTOOLS` is enabled. -- `WITH_PRIMITIVES` - Primitives library. Enabled automatically if +- `WITH_PRIMITIVES` - @ref Primitives library. Enabled automatically if `WITH_DEBUGTOOLS` is enabled. -- `WITH_SCENEGRAPH` - SceneGraph library. Enabled automatically if +- `WITH_SCENEGRAPH` - @ref SceneGraph library. Enabled automatically if `WITH_DEBUGTOOLS` or `WITH_SHAPES` is enabled. -- `WITH_SHADERS` - Shaders library. Enabled automatically if `WITH_DEBUGTOOLS` - is enabled. -- `WITH_SHAPES` - Shapes library. Enables also building of SceneGraph +- `WITH_SHADERS` - @ref Shaders library. Enabled automatically if + `WITH_DEBUGTOOLS` is enabled. +- `WITH_SHAPES` - @ref Shapes library. Enables also building of %SceneGraph library. Enabled automatically if `WITH_DEBUGTOOLS` is enabled. -- `WITH_TEXT` - Text library. Enables also building of TextureTools library. -- `WITH_TEXTURETOOLS` - TextureTools library. Enabled automatically if +- `WITH_TEXT` - @ref Text library. Enables also building of %TextureTools + library. +- `WITH_TEXTURETOOLS` - @ref TextureTools library. Enabled automatically if `WITH_TEXT` or `WITH_DISTANCEFIELDCONVERTER` is enabled. None of the @ref Platform "application libraries" is built by default (and you @@ -207,15 +208,16 @@ platform best: There are also a few command-line utilities. They are currently available only on Linux, Mac OS X and Windows, also disabled by default: -- `WITH_MAGNUMINFO` - `magnum-info` executable, provides information about - the engine and OpenGL capabilities. -- `WITH_FONTCONVERTER` - `magnum-fontconverter` executable for converting - fonts to raster ones. Enables also building of Text library. -- `WITH_DISTANCEFIELDCONVERTER` - `magnum-distancefieldconverter` executable - for converting black&white images to distance field textures. Enables also - building of TextureTools library. +- `WITH_MAGNUMINFO` - @ref magnum-info "magnum-info" executable, provides + information about the engine and OpenGL capabilities. +- `WITH_DISTANCEFIELDCONVERTER` - @ref magnum-distancefieldconverter "magnum-distancefieldconverter" + executable for converting black&white images to distance field textures. + Enables also building of %TextureTools library. +- `WITH_FONTCONVERTER` - @ref magnum-fontconverter "magnum-fontconverter" + executable for converting fonts to raster ones. Enables also building of + %Text library. -Magnum also contains a set of dependency-less plugins for importing essential +%Magnum also contains a set of dependency-less plugins for importing essential file formats. Additional plugins are provided in separate plugin repository, see @ref building-plugins for more information. None of the plugins is built by default. diff --git a/doc/cmake.dox b/doc/cmake.dox index 73732b990..da9e2b171 100644 --- a/doc/cmake.dox +++ b/doc/cmake.dox @@ -156,7 +156,8 @@ 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 @ref Magnum/Magnum.h: +are also available as preprocessor variables if including +@ref Magnum/Magnum.h "Magnum/Magnum.h": - `MAGNUM_BUILD_DEPRECATED` -- Defined if compiled with deprecated APIs included diff --git a/doc/scenegraph.dox b/doc/scenegraph.dox index 85ec71c42..3a410b60b 100644 --- a/doc/scenegraph.dox +++ b/doc/scenegraph.dox @@ -227,7 +227,7 @@ by calling @ref Object::setClean(). @ref Camera3D "Camera", for example, calls it automatically before it starts rendering, as it needs its own inverse transformation to properly draw the objects. -See @ref AbstractFeature-subclassing-caching for more information. +See @ref SceneGraph-AbstractFeature-subclassing-caching for more information. @section scenegraph-construction-order Construction and destruction order diff --git a/doc/troubleshooting.dox b/doc/troubleshooting.dox index f9a096240..08aaeae5f 100644 --- a/doc/troubleshooting.dox +++ b/doc/troubleshooting.dox @@ -55,7 +55,7 @@ try these things: - Check that you use only extensions that are @ref Context::isExtensionSupported() "available on your system". - Check that you didn't exceed any implementation-defined limit (see - `magnum-info` output for list of all of them). + @ref magnum-info output for list of all of them). - Enable @ref DebugMessage "debug output" to see more detailed errors, warnings and performance hints. - If using framebuffer objects, @ref Framebuffer::checkStatus() "check that they are complete". diff --git a/doc/utilities.dox b/doc/utilities.dox new file mode 100644 index 000000000..dd6cff029 --- /dev/null +++ b/doc/utilities.dox @@ -0,0 +1,35 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014 + Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +namespace Magnum { +/** @page utilities Utilities +@brief Command-line utilities for system information and data conversion + +- @subpage magnum-info -- @copybrief magnum-info +- @subpage magnum-distancefieldconverter -- @copybrief magnum-distancefieldconverter +- @subpage magnum-fontconverter -- @copybrief magnum-fontconverter + +*/ +} diff --git a/package/archlinux/PKGBUILD-emscripten b/package/archlinux/PKGBUILD-emscripten index e25fa841f..acfeed663 100644 --- a/package/archlinux/PKGBUILD-emscripten +++ b/package/archlinux/PKGBUILD-emscripten @@ -7,7 +7,7 @@ arch=('any') url="http://mosra.cz/blog/magnum.php" license=('MIT') depends=('emscripten-corrade') -makedepends=('cmake' 'ninja') +makedepends=('cmake' 'ninja' 'emscripten-git') options=('!strip' '!buildflags' 'staticlibs') build() { @@ -25,7 +25,7 @@ build() { cmake .. \ -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_PREFIX=/usr/emscripten/system \ + -DCMAKE_INSTALL_PREFIX=/usr/lib/emscripten/system \ -DWITH_SDL2APPLICATION=ON \ -DWITH_MAGNUMFONT=ON \ -DWITH_OBJIMPORTER=ON \ diff --git a/src/Magnum/AbstractFramebuffer.h b/src/Magnum/AbstractFramebuffer.h index 6a8523abb..ba4316317 100644 --- a/src/Magnum/AbstractFramebuffer.h +++ b/src/Magnum/AbstractFramebuffer.h @@ -157,7 +157,8 @@ namespace Implementation { struct FramebufferState; } See @ref DefaultFramebuffer and @ref Framebuffer for more information. -@section AbstractFramebuffer-performance-optimization Performance optimizations and security +@anchor AbstractFramebuffer-performance-optimization +## Performance optimizations and security The engine tracks currently bound framebuffer and current viewport to avoid unnecessary calls to @fn_gl{BindFramebuffer} and @fn_gl{Viewport} when diff --git a/src/Magnum/AbstractResourceLoader.h b/src/Magnum/AbstractResourceLoader.h index ba24ebb8a..190b1722b 100644 --- a/src/Magnum/AbstractResourceLoader.h +++ b/src/Magnum/AbstractResourceLoader.h @@ -40,7 +40,7 @@ namespace Magnum { Provides (a)synchronous resource loading for @ref ResourceManager. -@section AbstractResourceLoader-usage Usage and subclassing +## Usage and subclassing Usage is done by subclassing. Subclass instances can be added to @ref ResourceManager using @ref ResourceManager::setLoader(). After adding the diff --git a/src/Magnum/AbstractShaderProgram.h b/src/Magnum/AbstractShaderProgram.h index c545949b9..8fd304461 100644 --- a/src/Magnum/AbstractShaderProgram.h +++ b/src/Magnum/AbstractShaderProgram.h @@ -46,7 +46,8 @@ namespace Implementation { /** @brief Base for shader program implementations -@section AbstractShaderProgram-subclassing Subclassing workflow +@anchor AbstractShaderProgram-subclassing +## Subclassing workflow This class is designed to be used via subclassing. Subclasses define these functions and properties: @@ -116,7 +117,8 @@ MyShader& setSpecularTexture(Texture2D& texture) { } @endcode -@subsection AbstractShaderProgram-attribute-location Binding attribute location +@anchor AbstractShaderProgram-attribute-location +### Binding attribute location The preferred workflow is to specify attribute location for vertex shader input attributes and fragment shader output attributes explicitly in the shader code, @@ -184,7 +186,8 @@ bindFragmentDataLocationIndexed(NormalOutput, 1, "normal"); @todo @es_extension{EXT,separate_shader_objects} supports explicit attrib location -@subsection AbstractShaderProgram-uniform-location Uniform locations +@anchor AbstractShaderProgram-uniform-location +### Uniform locations The preferred workflow is to specify uniform locations directly in the shader code, e.g.: @@ -219,7 +222,8 @@ Int normalMatrixUniform = uniformLocation("normalMatrix"); @ref Magnum::AbstractShaderProgram::uniformLocation() "uniformLocation()" instead. -@subsection AbstractShaderProgram-texture-units Specifying texture binding units +@anchor AbstractShaderProgram-texture-units +### Specifying texture binding units The preferred workflow is to specify texture binding unit directly in the shader code, e.g.: @@ -251,7 +255,8 @@ setUniform(uniformLocation("specularTexture"), 1); @ref Magnum::AbstractShaderProgram::setUniform(Int, const T&) "setUniform(Int, Int)" instead. -@section AbstractShaderProgram-rendering-workflow Rendering workflow +@anchor AbstractShaderProgram-rendering-workflow +## Rendering workflow Basic workflow with %AbstractShaderProgram subclasses is: instance shader class, configure attribute binding in meshes (see @ref Mesh-configuration "Mesh documentation" @@ -268,7 +273,8 @@ shader.setTransformation(transformation) mesh.draw(shader); @endcode -@section AbstractShaderProgram-types Mapping between GLSL and Magnum types +@anchor AbstractShaderProgram-types +## Mapping between GLSL and %Magnum types See @ref types for more information, only types with GLSL equivalent can be used (and their super- or subclasses with the same size and underlying type). See @@ -306,7 +312,8 @@ also @ref Attribute::DataType enum for additional type options. @ref Magnum::Matrix4x3 "Matrix4x3") are not available in OpenGL ES 2.0. @requires_gl Double attributes and uniforms are not available in OpenGL ES. -@section AbstractShaderProgram-performance-optimization Performance optimizations +@anchor AbstractShaderProgram-performance-optimization +## Performance optimizations %Shader limits (such as @ref maxVertexAttributes()) are cached, so repeated queries don't result in repeated @fn_gl{Get} calls. diff --git a/src/Magnum/AbstractTexture.h b/src/Magnum/AbstractTexture.h index 383e81735..8f2d205ba 100644 --- a/src/Magnum/AbstractTexture.h +++ b/src/Magnum/AbstractTexture.h @@ -62,13 +62,14 @@ Encapsulates one OpenGL texture object. See @ref Texture, @ref TextureArray, @ref BufferTexture and @ref MultisampleTexture documentation for more information and usage examples. -@section AbstractTexture-webgl-restrictions WebGL restrictions +## WebGL restrictions @ref MAGNUM_TARGET_WEBGL "WebGL" puts some restrictions on type of data submitted to @ref Texture::setSubImage() "*Texture::setSubImage()", see its documentation for details. -@section AbstractTexture-performance-optimization Performance optimizations and security +@anchor AbstractTexture-performance-optimization +## Performance optimizations and security The engine tracks currently bound textures in all available texture units to avoid unnecessary calls to @fn_gl{ActiveTexture} and @fn_gl{BindTexture}. diff --git a/src/Magnum/Audio/AbstractImporter.h b/src/Magnum/Audio/AbstractImporter.h index 40c388138..443183d19 100644 --- a/src/Magnum/Audio/AbstractImporter.h +++ b/src/Magnum/Audio/AbstractImporter.h @@ -43,7 +43,7 @@ Provides interface for importing various audio formats. See @ref plugins for more information and `*Importer` classes in @ref Audio namespace for available importer plugins. -@section Audio-AbstractImporter-subclassing Subclassing +## Subclassing Plugin implements function @ref doFeatures(), @ref doIsOpened(), one of or both @ref doOpenData() and @ref doOpenFile() functions, function @ref doClose() and diff --git a/src/Magnum/Buffer.h b/src/Magnum/Buffer.h index 03bdaca32..f4fc40f32 100644 --- a/src/Magnum/Buffer.h +++ b/src/Magnum/Buffer.h @@ -122,7 +122,7 @@ namespace Implementation { struct BufferState; } Encapsulates one OpenGL buffer object and provides functions for convenient data updates. -@section Buffer-data Data updating +## Data updating Default way to set or update buffer data with @ref setData() or @ref setSubData() is to use @ref Corrade::Containers::ArrayReference. See its documentation for @@ -138,7 +138,8 @@ std::vector data; buffer.setData(data, BufferUsage::StaticDraw); @endcode -@subsection Buffer-data-mapping Memory mapping +@anchor Buffer-data-mapping +## Memory mapping %Buffer data can be also updated asynchronously. First you need to allocate the buffer to desired size by passing `nullptr` to @ref setData(), e.g.: @@ -166,7 +167,7 @@ for(std::size_t i: {7, 27, 56, 128}) { CORRADE_INTERNAL_ASSERT_OUTPUT(buffer.unmap()); @endcode -@section Buffer-webgl-restrictions WebGL and NaCl restrictions +## WebGL and NaCl restrictions Buffers in @ref MAGNUM_TARGET_WEBGL "WebGL" and @ref CORRADE_TARGET_NACL "NaCl" need to be bound only to one unique target, i.e., @ref Buffer bound to @@ -183,7 +184,7 @@ Buffer indices{Buffer::Target::ElementArray}; To ease up the development, @ref Mesh checks proper target hint when adding vertex and index buffers in both WebGL and NaCl. -@section Buffer-performance-optimization Performance optimizations +## Performance optimizations The engine tracks currently bound buffers to avoid unnecessary calls to @fn_gl{BindBuffer}. If the buffer is already bound to some target, functions diff --git a/src/Magnum/BufferTexture.h b/src/Magnum/BufferTexture.h index f8f55ee04..b5c5880b7 100644 --- a/src/Magnum/BufferTexture.h +++ b/src/Magnum/BufferTexture.h @@ -157,7 +157,7 @@ enum class BufferTextureFormat: GLenum { This texture is, unlike classic textures such as @ref Texture used as simple data source, without any unnecessary interpolation and wrapping methods. -@section BufferTexture-usage Usage +## Usage %Texture data are stored in buffer and after binding the buffer to the texture using @ref setBuffer(), you can fill the buffer at any time using data setting @@ -185,7 +185,7 @@ In shader, the texture is used via `samplerBuffer`, `isamplerBuffer` or are integer coordinates passed to `texelFetch()`. See @ref AbstractShaderProgram documentation for more information about usage in shaders. -@section BufferTexture-performance-optimization Performance optimizations +## Performance optimizations If extension @extension{EXT,direct_state_access} is available, @ref setBuffer() functions use DSA to avoid unnecessary calls to @fn_gl{ActiveTexture} and diff --git a/src/Magnum/CMakeLists.txt b/src/Magnum/CMakeLists.txt index c3b0cf490..dd7499091 100644 --- a/src/Magnum/CMakeLists.txt +++ b/src/Magnum/CMakeLists.txt @@ -62,6 +62,7 @@ set(Magnum_SRCS Implementation/ShaderProgramState.cpp Implementation/State.cpp Implementation/TextureState.cpp + Implementation/detectedDriver.cpp Implementation/maxTextureSize.cpp Implementation/setupDriverWorkarounds.cpp diff --git a/src/Magnum/Context.h b/src/Magnum/Context.h index 8acc9042e..47d8dde2f 100644 --- a/src/Magnum/Context.h +++ b/src/Magnum/Context.h @@ -38,6 +38,7 @@ #include "Magnum/Magnum.h" #include "Magnum/OpenGL.h" #include "Magnum/visibility.h" +#include "MagnumExternal/Optional/optional.hpp" #ifdef CORRADE_GCC45_COMPATIBILITY #include "Version.h" @@ -173,6 +174,35 @@ class MAGNUM_EXPORT Context { */ typedef Containers::EnumSet States; + /** + * @brief Detected driver + * + * @see @ref DetectedDriver, @ref detectedDriver() + */ + enum class DetectedDriver: UnsignedShort { + #ifndef MAGNUM_TARGET_GLES + /** Binary AMD desktop drivers on Windows and Linux */ + AMD = 1 << 0, + #endif + + #ifdef MAGNUM_TARGET_GLES2 + /** + * OpenGL ES 2.0 implementation by ANGLE (translated to D3D9), used + * by browsers on Windows for Native Client and WebGL. As the WebGL + * specification explicitly disallows exposing driver information + * to the application, this check cannot be done reliably. + */ + ProbablyAngle = 1 << 1 + #endif + }; + + /** + * @brief Detected drivers + * + * @see @ref detectedDriver() + */ + typedef Containers::EnumSet DetectedDrivers; + /** * @brief Constructor * @@ -436,6 +466,15 @@ class MAGNUM_EXPORT Context { */ void resetState(States states = ~States{}); + /** + * @brief Detect driver + * + * Tries to detect driver using various OpenGL state queries. Once the + * detection is done, the result is cached, repeated queries don't + * result in repeated GL calls. + */ + DetectedDrivers detectedDriver(); + #ifndef DOXYGEN_GENERATING_OUTPUT Implementation::State& state() { return *_state; } #endif @@ -455,6 +494,8 @@ class MAGNUM_EXPORT Context { std::vector _supportedExtensions; Implementation::State* _state; + + std::optional _detectedDrivers; }; /** @debugoperatorclassenum{Magnum::Context,Magnum::Context::Flag} */ diff --git a/src/Magnum/CubeMapTexture.h b/src/Magnum/CubeMapTexture.h index 3bacb60d3..8158e3ce6 100644 --- a/src/Magnum/CubeMapTexture.h +++ b/src/Magnum/CubeMapTexture.h @@ -50,7 +50,7 @@ turned upside down (+Y is top): | +Y | +----+ -@section CubeMapTexture-usage Basic usage +## Basic usage See @ref Texture documentation for introduction. diff --git a/src/Magnum/CubeMapTextureArray.h b/src/Magnum/CubeMapTextureArray.h index cc5fdbd75..521a0dfec 100644 --- a/src/Magnum/CubeMapTextureArray.h +++ b/src/Magnum/CubeMapTextureArray.h @@ -43,7 +43,7 @@ namespace Magnum { See @ref CubeMapTexture documentation for introduction. -@section CubeMapTextureArray-usage Usage +## Usage See @ref Texture documentation for introduction. diff --git a/src/Magnum/DebugMessage.h b/src/Magnum/DebugMessage.h index c7fafa951..217ebbc68 100644 --- a/src/Magnum/DebugMessage.h +++ b/src/Magnum/DebugMessage.h @@ -46,7 +46,7 @@ Allows retrieving and inserting debug messages from and to OpenGL command stream, for example with conjunction with various debuggers, such as Apitrace or gDEBugger. -@section DebugMessage-usage Basic usage +## Basic usage To retrieve debug messages from either the GL or your application you need to have OpenGL 4.3 or @extension{KHR,debug} desktop/ES extension. You need to diff --git a/src/Magnum/DebugTools/ForceRenderer.h b/src/Magnum/DebugTools/ForceRenderer.h index 134a758db..8523a12ed 100644 --- a/src/Magnum/DebugTools/ForceRenderer.h +++ b/src/Magnum/DebugTools/ForceRenderer.h @@ -85,7 +85,8 @@ class ForceRendererOptions { Visualizes force pushing on object by an arrow of the same direction and size. See @ref debug-tools-renderers for more information. -@section ForceRenderer-usage Basic usage +@anchor DebugTools-ForceRenderer-usage +## Basic usage Example code: @code @@ -109,8 +110,8 @@ template class MAGNUM_DEBUGTOOLS_EXPORT ForceRenderer: p * @param forcePosition Where to render the force, relative to object * @param force Force vector * @param options Options resource key. See - * @ref ForceRenderer-usage "class documentation" for more - * information. + * @ref DebugTools-ForceRenderer-usage "class documentation" for + * more information. * @param drawables Drawable group * * The renderer is automatically added to object's features, @p force is diff --git a/src/Magnum/DebugTools/ObjectRenderer.h b/src/Magnum/DebugTools/ObjectRenderer.h index e5df920d1..5d61a6677 100644 --- a/src/Magnum/DebugTools/ObjectRenderer.h +++ b/src/Magnum/DebugTools/ObjectRenderer.h @@ -69,7 +69,8 @@ class ObjectRendererOptions { Visualizes object position, rotation and scale using colored axes. See @ref debug-tools-renderers for more information. -@section ObjectRenderer-usage Basic usage +@anchor DebugTools-ObjectRenderer-usage +## Basic usage Example code: @code @@ -89,8 +90,8 @@ template class MAGNUM_DEBUGTOOLS_EXPORT ObjectRenderer: * @brief Constructor * @param object Object for which to create debug renderer * @param options Options resource key. See - * @ref ObjectRenderer-usage "class documentation" for more - * information. + * @ref DebugTools-ObjectRenderer-usage "class documentation" for + * more information. * @param drawables Drawable group * * The renderer is automatically added to object's features. diff --git a/src/Magnum/DebugTools/ShapeRenderer.h b/src/Magnum/DebugTools/ShapeRenderer.h index ddb5fb3e3..7113415b8 100644 --- a/src/Magnum/DebugTools/ShapeRenderer.h +++ b/src/Magnum/DebugTools/ShapeRenderer.h @@ -120,7 +120,8 @@ class ShapeRendererOptions { Visualizes collision shapes using wireframe primitives. See @ref debug-tools-renderers for more information. -@section ShapeRenderer-usage Basic usage +@anchor DebugTools-ShapeRenderer-usage +## Basic usage Example code: @code @@ -152,8 +153,8 @@ template class MAGNUM_DEBUGTOOLS_EXPORT ShapeRenderer: p * @brief Constructor * @param shape Shape for which to create debug renderer * @param options Options resource key. See - * @ref ShapeRenderer-usage "class documentation" for more - * information. + * @ref DebugTools-ShapeRenderer-usage "class documentation" for + * more information. * @param drawables Drawable group * * The renderer is automatically added to shape's object features, diff --git a/src/Magnum/DefaultFramebuffer.h b/src/Magnum/DefaultFramebuffer.h index 98fec42de..db2b87b76 100644 --- a/src/Magnum/DefaultFramebuffer.h +++ b/src/Magnum/DefaultFramebuffer.h @@ -41,7 +41,8 @@ created when @ref Context is created and it is available through global variable @ref defaultFramebuffer. It is by default mapped to whole screen surface. -@section DefaultFramebuffer-usage Usage +@anchor DefaultFramebuffer-usage +## Usage When you are using only the default framebuffer, the usage is simple. You must ensure that it is properly resized when application surface is resized, @@ -69,7 +70,7 @@ void drawEvent() { See Framebuffer documentation for more involved usage, usage of non-default or multiple framebuffers. -@section DefaultFramebuffer-performance-optimization Performance optimizations +## Performance optimizations See also @ref AbstractFramebuffer-performance-optimization "relevant section in AbstractFramebuffer". diff --git a/src/Magnum/Framebuffer.h b/src/Magnum/Framebuffer.h index fb38f22f2..4884ead4a 100644 --- a/src/Magnum/Framebuffer.h +++ b/src/Magnum/Framebuffer.h @@ -45,7 +45,8 @@ Unlike @ref DefaultFramebuffer, which is used for on-screen rendering, this class is used for off-screen rendering, usable either in windowless applications, texture generation or for various post-processing effects. -@section Framebuffer-usage Example usage +@anchor Framebuffer-usage +## Example usage See @ref DefaultFramebuffer-usage "DefaultFramebuffer documentation" for introduction. Imagine you have shader with multiple outputs (e.g. for deferred @@ -88,7 +89,7 @@ void drawEvent() { } @endcode -@section Framebuffer-performance-optimization Performance optimizations +## Performance optimizations See also @ref AbstractFramebuffer-performance-optimization "relevant section in AbstractFramebuffer". diff --git a/src/Magnum/Implementation/detectedDriver.cpp b/src/Magnum/Implementation/detectedDriver.cpp new file mode 100644 index 000000000..60ada7803 --- /dev/null +++ b/src/Magnum/Implementation/detectedDriver.cpp @@ -0,0 +1,57 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014 + Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#include "Magnum/Context.h" +#include "Magnum/Math/Range.h" + +namespace Magnum { + +auto Context::detectedDriver() -> Context::DetectedDrivers { + if(_detectedDrivers) return *_detectedDrivers; + + _detectedDrivers = DetectedDrivers{}; + + /* AMD binary desktop drivers */ + #ifndef MAGNUM_TARGET_GLES + const std::string vendor = vendorString(); + if(vendor.find("ATI Technologies Inc.") != std::string::npos) + return *_detectedDrivers |= DetectedDriver::AMD; + #endif + + /* OpenGL ES 2.0 implementation using ANGLE. Taken from + http://stackoverflow.com/a/20149090 */ + #ifdef MAGNUM_TARGET_GLES2 + { + Range1Di range; + glGetIntegerv(GL_ALIASED_LINE_WIDTH_RANGE, range.data()); + if(range.min() == 1 && range.max() == 1) + return *_detectedDrivers |= DetectedDriver::ProbablyAngle; + } + #endif + + return *_detectedDrivers; +} + +} diff --git a/src/Magnum/Implementation/setupDriverWorkarounds.cpp b/src/Magnum/Implementation/setupDriverWorkarounds.cpp index a29332253..ca7c0bb70 100644 --- a/src/Magnum/Implementation/setupDriverWorkarounds.cpp +++ b/src/Magnum/Implementation/setupDriverWorkarounds.cpp @@ -35,8 +35,7 @@ void Context::setupDriverWorkarounds() { #ifndef MAGNUM_TARGET_GLES /* This extension causes crash in GLSL compiler on AMD linux drivers 13.251 */ - const std::string vendor = vendorString(); - if(vendor.find("ATI Technologies Inc.") != std::string::npos) + if(detectedDriver() & DetectedDriver::AMD) _setRequiredVersion(GL::ARB::explicit_uniform_location, None); #endif diff --git a/src/Magnum/Math/Angle.h b/src/Magnum/Math/Angle.h index 64067bbf5..378e100d5 100644 --- a/src/Magnum/Math/Angle.h +++ b/src/Magnum/Math/Angle.h @@ -45,7 +45,7 @@ namespace Magnum { namespace Math { Along with Rad provides convenience classes to make angle specification and conversion less error-prone. -@section Rad-usage Usage +## Usage You can enter the value either by using literal: @code @@ -92,7 +92,7 @@ Float d = Double(b); // 60.0 //Float e = b; // error, no implicit conversion @endcode -@section Rad-conversions Requirement of explicit conversion +## Requirement of explicit conversion The requirement of explicit conversions from and to unitless types helps to reduce unit-based errors. Consider following example with implicit conversions diff --git a/src/Magnum/Math/Range.h b/src/Magnum/Math/Range.h index fc753c5df..a9c1f52f8 100644 --- a/src/Magnum/Math/Range.h +++ b/src/Magnum/Math/Range.h @@ -103,6 +103,13 @@ template class Range { return !operator==(other); } + /** + * @brief Raw data + * @return One-dimensional array of `dimensions`*2 length. + */ + T* data() { return _min.data(); } + constexpr const T* data() const { return _min.data(); } /**< @overload */ + /** * @brief Minimal coordinates (inclusive) * diff --git a/src/Magnum/Mesh.h b/src/Magnum/Mesh.h index d37831ae6..c2d40b3fb 100644 --- a/src/Magnum/Mesh.h +++ b/src/Magnum/Mesh.h @@ -120,7 +120,8 @@ namespace Implementation { struct MeshState; } /** @brief %Mesh -@section Mesh-configuration Mesh configuration +@anchor Mesh-configuration +## %Mesh configuration You have to specify at least primitive and vertex/index count using @ref setPrimitive() and @ref setCount(). Then fill your vertex buffers with @@ -146,9 +147,9 @@ different usage) or store data for more meshes in one buffer. If vertex/index count or instance count is zero, the mesh is empty and no draw commands are issued when calling @ref draw(). -@subsection Mesh-configuration-examples Example mesh configuration +### Example mesh configuration -@subsubsection Mesh-configuration-examples-nonindexed Basic non-indexed mesh +#### Basic non-indexed mesh @code // Custom shader, needing only position data @@ -173,7 +174,7 @@ mesh.setPrimitive(MeshPrimitive::Triangles) .addVertexBuffer(vertexBuffer, 0, MyShader::Position{}); @endcode -@subsubsection Mesh-configuration-examples-nonindexed-phong Interleaved vertex data +#### Interleaved vertex data @code // Non-indexed primitive with positions and normals @@ -190,7 +191,7 @@ mesh.setPrimitive(plane.primitive()) .addVertexBuffer(buffer, 0, Shaders::Phong::Position{}, Shaders::Phong::Normal{}); @endcode -@subsubsection Mesh-configuration-examples-indexed-phong Indexed mesh +#### Indexed mesh @code // Custom shader @@ -254,7 +255,7 @@ mesh.setPrimitive(plane.primitive()) Or, if you plan to use the mesh with stock shaders, you can just use @ref MeshTools::compile(). -@subsubsection Mesh-configuration-examples-data-options Specific formats of vertex data +#### Specific formats of vertex data @code // Custom shader with colors specified as four floating-point values @@ -300,19 +301,20 @@ mesh.addVertexBuffer(colorBuffer, 0, MyShader::Color{ MyShader::Color::DataOption::Normalized}); @endcode -@section Mesh-drawing Rendering meshes +## Rendering meshes Basic workflow is: bind specific framebuffer for drawing (if needed), set up respective shader (see @ref AbstractShaderProgram-rendering-workflow "AbstractShaderProgram documentation" for more infromation) and call @ref Mesh::draw(). -@section Mesh-webgl-restrictions WebGL restrictions +## WebGL restrictions @ref MAGNUM_TARGET_WEBGL "WebGL" puts some restrictions on vertex buffer layout, see @ref addVertexBuffer() documentation for details. -@section Mesh-performance-optimization Performance optimizations +@anchor Mesh-performance-optimization +## Performance optimizations If @extension{APPLE,vertex_array_object} (part of OpenGL 3.0), OpenGL ES 3.0 or @es_extension{OES,vertex_array_object} on OpenGL ES 2.0 is supported, VAOs are diff --git a/src/Magnum/MultisampleTexture.h b/src/Magnum/MultisampleTexture.h index 34148aeff..739c92f07 100644 --- a/src/Magnum/MultisampleTexture.h +++ b/src/Magnum/MultisampleTexture.h @@ -65,7 +65,7 @@ Template class for 2D mulitsample texture and 2D multisample texture array. Used only from shaders for manual multisample resolve and other operations. See also @ref AbstractTexture documentation for more information. -@section MultisampleTexture-usage Usage +## Usage As multisample textures have no sampler state, the only thing you need is to set storage: diff --git a/src/Magnum/Platform/Screen.h b/src/Magnum/Platform/Screen.h index c203c53ef..dafd416e1 100644 --- a/src/Magnum/Platform/Screen.h +++ b/src/Magnum/Platform/Screen.h @@ -53,7 +53,7 @@ See @ref BasicScreenedApplication for more information. If exactly one application header is included, this class is also aliased to `Platform::Screen`. -@section Screen-explicit-specializations Explicit template specializations +## Explicit template specializations The following specialization are explicitly compiled into each particular `*Application` library. For other specializations you have to use diff --git a/src/Magnum/Platform/ScreenedApplication.h b/src/Magnum/Platform/ScreenedApplication.h index 9dde81f08..0891ed9f3 100644 --- a/src/Magnum/Platform/ScreenedApplication.h +++ b/src/Magnum/Platform/ScreenedApplication.h @@ -75,7 +75,7 @@ for(Screen* s = app.backScreen(); s; s = s->nextNearerScreen()) { } @endcode -@section ScreenedApplication-explicit-specializations Explicit template specializations +## Explicit template specializations The following specialization are explicitly compiled into each particular `*Application` library. For other specializations you have to use diff --git a/src/Magnum/Platform/magnum-info.cpp b/src/Magnum/Platform/magnum-info.cpp index f6ddab14a..69d18e660 100644 --- a/src/Magnum/Platform/magnum-info.cpp +++ b/src/Magnum/Platform/magnum-info.cpp @@ -65,6 +65,61 @@ namespace Magnum { +/** @page magnum-info Magnum Info +@brief Displays information about %Magnum engine and OpenGL capabilities + +@section magnum-info-usage Usage + + magnum-info [-h|--help] [--all-extensions] [--limits] + +Arguments: + +- ` -h`, `--help` -- display this help message and exit +- `--all-extensions` -- show extensions also for fully supported versions +- `--limits` -- display also limits and implementation-defined values + +@section magnum-info-example Example output + + +---------------------------------------------------------+ + | Information about Magnum engine and OpenGL capabilities | + +---------------------------------------------------------+ + + Used application: Platform::WindowlessGlxApplication + Compilation flags: + CORRADE_BUILD_DEPRECATED + MAGNUM_BUILD_DEPRECATED + + Vendor: NVIDIA Corporation + Renderer: GeForce GT 740M/PCIe/SSE2 + OpenGL version: OpenGL 4.4 (4.4.0 NVIDIA 337.25) + Context flags: + Supported GLSL versions: + 440 core + 430 core + 420 core + 410 core + 400 core + 330 core + 310 es + 300 es + 100 + + Vendor extension support: + GL_AMD_vertex_shader_layer - + GL_AMD_shader_trinary_minmax - + GL_ARB_robustness SUPPORTED + GL_ATI_texture_mirror_once SUPPORTED + GL_EXT_texture_filter_anisotropic SUPPORTED + GL_EXT_texture_mirror_clamp SUPPORTED + GL_EXT_direct_state_access SUPPORTED + GL_EXT_texture_sRGB_decode SUPPORTED + GL_EXT_shader_integer_mix SUPPORTED + GL_EXT_debug_label - + GL_EXT_debug_marker - + GL_GREMEDY_string_marker - + +*/ + class MagnumInfo: public Platform::WindowlessApplication { public: explicit MagnumInfo(const Arguments& arguments); diff --git a/src/Magnum/RectangleTexture.h b/src/Magnum/RectangleTexture.h index 02c1aa0a5..3bea9918d 100644 --- a/src/Magnum/RectangleTexture.h +++ b/src/Magnum/RectangleTexture.h @@ -43,7 +43,7 @@ namespace Magnum { See also @ref AbstractTexture documentation for more information. -@section RectangleTexture-usage Usage +## Usage Common usage is to fully configure all texture parameters and then set the data from e.g. @ref Image2D. Example configuration: diff --git a/src/Magnum/Renderbuffer.h b/src/Magnum/Renderbuffer.h index 750cfa3d9..cfff3ce93 100644 --- a/src/Magnum/Renderbuffer.h +++ b/src/Magnum/Renderbuffer.h @@ -46,7 +46,7 @@ namespace Implementation { struct FramebufferState; } Attachable to framebuffer as render target, see @ref Framebuffer documentation for more information. -@section Renderbuffer-performance-optimization Performance optimizations +## Performance optimizations The engine tracks currently bound renderbuffer to avoid unnecessary calls to @fn_gl{BindRenderbuffer} in @ref setStorage(). %Renderbuffer limits and diff --git a/src/Magnum/ResourceManager.h b/src/Magnum/ResourceManager.h index cf038f281..389c61798 100644 --- a/src/Magnum/ResourceManager.h +++ b/src/Magnum/ResourceManager.h @@ -163,7 +163,7 @@ template class ResourceManagerData { Provides storage for arbitrary set of types, accessible globally using @ref instance(). -@section ResourceManager-usage Usage +## Usage Each resource is referenced from @ref Resource class. For optimizing performance, each resource can be set as mutable or final. Mutable resources diff --git a/src/Magnum/SceneGraph/AbstractCamera.h b/src/Magnum/SceneGraph/AbstractCamera.h index 1a09b41d2..7bb219ae2 100644 --- a/src/Magnum/SceneGraph/AbstractCamera.h +++ b/src/Magnum/SceneGraph/AbstractCamera.h @@ -58,13 +58,14 @@ See Drawable documentation for more information. This class is not directly instantiatable, use @ref BasicCamera2D or @ref BasicCamera3D subclasses instead. -@section AbstractCamera-explicit-specializations Explicit template specializations +@anchor SceneGraph-AbstractCamera-explicit-specializations +## Explicit template specializations -The following specialization are explicitly compiled into @ref SceneGraph +The following specializations are explicitly compiled into @ref SceneGraph library. For other specializations (e.g. using @ref Double type) you have to use @ref AbstractCamera.hpp implementation file to avoid linker errors. See -also relevant sections in @ref Camera2D-explicit-specializations "Camera2D" -and @ref Camera3D-explicit-specializations "Camera3D" class documentation or +also relevant sections in @ref SceneGraph-Camera2D-explicit-specializations "Camera2D" +and @ref SceneGraph-Camera3D-explicit-specializations "Camera3D" class documentation or @ref compilation-speedup-hpp for more information. - @ref AbstractCamera2D diff --git a/src/Magnum/SceneGraph/AbstractFeature.h b/src/Magnum/SceneGraph/AbstractFeature.h index 9764a6d88..9525963b0 100644 --- a/src/Magnum/SceneGraph/AbstractFeature.h +++ b/src/Magnum/SceneGraph/AbstractFeature.h @@ -84,13 +84,14 @@ Contained in @ref Object, takes care of transformation caching. See Uses @ref Corrade::Containers::LinkedList for accessing holder object and sibling features. -@section AbstractFeature-subclassing Subclassing +## Subclassing Feature is templated on dimension count and underlying transformation type, so it can be used only on object having transformation with the same dimension count and type. -@subsection AbstractFeature-subclassing-caching Caching transformations in features +@anchor SceneGraph-AbstractFeature-subclassing-caching +### Caching transformations in features Features can cache absolute transformation of the object instead of computing it from scratch every time to achieve better performance. See @@ -120,7 +121,7 @@ class CachingFeature: public SceneGraph::AbstractFeature3D { Before using the cached value explicitly request object cleaning by calling `object()->setClean()`. -@subsection AbstractFeature-subclassing-transformation Accessing object transformation +### Accessing object transformation Features has by default access only to @ref AbstractObject, which is base of @ref Object not depending on any particular transformation implementation. This @@ -150,9 +151,9 @@ from @ref AbstractBasicTranslationRotationScaling3D "AbstractTranslationRotation which is derived from @ref AbstractBasicTranslationRotation3D "AbstractTranslationRotation3D", which is automatically extracted from the reference in our constructor. -@section AbstractFeature-explicit-specializations Explicit template specializations +## Explicit template specializations -The following specialization are explicitly compiled into @ref SceneGraph +The following specializations are explicitly compiled into @ref SceneGraph library. For other specializations (e.g. using @ref Double type) you have to use @ref AbstractFeature.hpp implementation file to avoid linker errors. See also @ref compilation-speedup-hpp for more information. diff --git a/src/Magnum/SceneGraph/AbstractGroupedFeature.h b/src/Magnum/SceneGraph/AbstractGroupedFeature.h index a394e849f..f79f32f35 100644 --- a/src/Magnum/SceneGraph/AbstractGroupedFeature.h +++ b/src/Magnum/SceneGraph/AbstractGroupedFeature.h @@ -41,7 +41,7 @@ namespace Magnum { namespace SceneGraph { Used together with @ref FeatureGroup. -@section AbstractGroupedFeature-subclassing Subclassing +## Subclassing Usage is via subclassing the feature using [CRTP](http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern) and typedef'ing @ref FeatureGroup to accept only given type, e.g.: @@ -53,9 +53,9 @@ class Drawable: public SceneGraph::AbstractGroupedFeature3D { typedef SceneGraph::FeatureGroup3D DrawableGroup; @endcode -@section AbstractGroupedFeature-explicit-specializations Explicit template specializations +## Explicit template specializations -The following specialization are explicitly compiled into @ref SceneGraph +The following specializations are explicitly compiled into @ref SceneGraph library. For other specializations (e.g. using @ref Double type) you have to use @ref FeatureGroup.hpp implementation file to avoid linker errors. See also @ref compilation-speedup-hpp for more information. diff --git a/src/Magnum/SceneGraph/AbstractObject.h b/src/Magnum/SceneGraph/AbstractObject.h index 7430b5f22..5ad98a9cf 100644 --- a/src/Magnum/SceneGraph/AbstractObject.h +++ b/src/Magnum/SceneGraph/AbstractObject.h @@ -55,13 +55,14 @@ for(AbstractFeature* feature = o->firstFeature(); feature; feature = feature->ne } @endcode -@section AbstractObject-explicit-specializations Explicit template specializations +@anchor SceneGraph-AbstractObject-explicit-specializations +## Explicit template specializations -The following specialization are explicitly compiled into @ref SceneGraph +The following specializations are explicitly compiled into @ref SceneGraph library. For other specializations (e.g. using @ref Double type) you have to use @ref Object.hpp implementation file to avoid linker errors. See also -relevant sections in @ref Object-explicit-specializations "Object" and -@ref AbstractTransformation-explicit-specializations "AbstractTransformation" +relevant sections in @ref SceneGraph-Object-explicit-specializations "Object" and +@ref SceneGraph-AbstractTransformation-explicit-specializations "AbstractTransformation" class documentation or @ref compilation-speedup-hpp for more information. - @ref AbstractObject2D diff --git a/src/Magnum/SceneGraph/AbstractTransformation.h b/src/Magnum/SceneGraph/AbstractTransformation.h index 4745350c5..94abe4780 100644 --- a/src/Magnum/SceneGraph/AbstractTransformation.h +++ b/src/Magnum/SceneGraph/AbstractTransformation.h @@ -39,9 +39,10 @@ namespace Magnum { namespace SceneGraph { Provides transformation implementation for @ref Object instances. -@section AbstractTransformation-explicit-specializations Explicit template specializations +@anchor SceneGraph-AbstractTransformation-explicit-specializations +## Explicit template specializations -The following specialization are explicitly compiled into @ref SceneGraph +The following specializations are explicitly compiled into @ref SceneGraph library. For other specializations (e.g. using @ref Double type) you have to use @ref Object.hpp implementation file to avoid linker errors. See @ref compilation-speedup-hpp for more information. diff --git a/src/Magnum/SceneGraph/Animable.h b/src/Magnum/SceneGraph/Animable.h index 282fe517b..3d699af52 100644 --- a/src/Magnum/SceneGraph/Animable.h +++ b/src/Magnum/SceneGraph/Animable.h @@ -65,7 +65,7 @@ Debug MAGNUM_SCENEGRAPH_EXPORT operator<<(Debug debug, AnimationState value); Adds animation feature to object. Each %Animable is part of some @ref AnimableGroup, which takes care of running the animations. -@section Animable-usage Usage +## Usage First thing is to add @ref Animable feature to some object and implement @ref animationStep(). You can do it conveniently using multiple inheritance @@ -120,7 +120,7 @@ void MyApplication::drawEvent() { } @endcode -@section Animable-performance Using animable groups to improve performance +## Using animable groups to improve performance @ref AnimableGroup is optimized for case when no animation is running -- it just puts itself to rest and waits until some animation changes its state to @@ -128,7 +128,7 @@ just puts itself to rest and waits until some animation changes its state to pernamently running to separate group, they will not be always traversed when calling @ref AnimableGroup::step(), saving precious frame time. -@section Animable-explicit-specializations Explicit template specializations +## Explicit template specializations The following specializations are explicitly compiled into @ref SceneGraph library. For other specializations (e.g. using @ref Double type) you have to diff --git a/src/Magnum/SceneGraph/Camera2D.h b/src/Magnum/SceneGraph/Camera2D.h index 7af140125..ffde4994c 100644 --- a/src/Magnum/SceneGraph/Camera2D.h +++ b/src/Magnum/SceneGraph/Camera2D.h @@ -45,12 +45,13 @@ camera.setProjection({4.0f/3.0f, 1.0f}) .setAspectRatioPolicy(SceneGraph::AspectRatioPolicy::Extend); @endcode -@section Camera2D-explicit-specializations Explicit template specializations +@anchor SceneGraph-Camera2D-explicit-specializations +## Explicit template specializations -The following specialization are explicitly compiled into @ref SceneGraph +The following specialization is explicitly compiled into @ref SceneGraph library. For other specializations (e.g. using @ref Double type) you have to use @ref Camera2D.hpp implementation file to avoid linker errors. See also -relevant section in @ref AbstractCamera-explicit-specializations "AbstractCamera" +relevant section in @ref SceneGraph-AbstractCamera-explicit-specializations "AbstractCamera" class documentation or @ref compilation-speedup-hpp for more information. - @ref Camera2D diff --git a/src/Magnum/SceneGraph/Camera3D.h b/src/Magnum/SceneGraph/Camera3D.h index d090127a8..f3fe38b9a 100644 --- a/src/Magnum/SceneGraph/Camera3D.h +++ b/src/Magnum/SceneGraph/Camera3D.h @@ -50,12 +50,13 @@ camera.setPerspective({}, 0.001f, 100.0f) .setAspectRatioPolicy(SceneGraph::AspectRatioPolicy::Extend); @endcode -@section Camera3D-explicit-specializations Explicit template specializations +@anchor SceneGraph-Camera3D-explicit-specializations +## Explicit template specializations -The following specialization are explicitly compiled into @ref SceneGraph +The following specialization is explicitly compiled into @ref SceneGraph library. For other specializations (e.g. using @ref Double type) you have to use @ref Camera3D.hpp implementation file to avoid linker errors. See also -relevant section in @ref AbstractCamera-explicit-specializations "AbstractCamera" +relevant section in @ref SceneGraph-AbstractCamera-explicit-specializations "AbstractCamera" class documentation or @ref compilation-speedup-hpp for more information. - @ref Camera3D diff --git a/src/Magnum/SceneGraph/Drawable.h b/src/Magnum/SceneGraph/Drawable.h index 1ad78ef3b..f2c864d31 100644 --- a/src/Magnum/SceneGraph/Drawable.h +++ b/src/Magnum/SceneGraph/Drawable.h @@ -40,7 +40,7 @@ Adds drawing function to the object. Each %Drawable is part of some @ref DrawableGroup and the whole group is drawn with particular camera using @ref AbstractCamera::draw(). -@section Drawable-usage Usage +## Usage First thing is to add @ref Drawable feature to some object and implement @ref draw(). You can do it conveniently using multiple inheritance (see @@ -91,7 +91,7 @@ void MyApplication::drawEvent() { } @endcode -@section Drawable-performance Using drawable groups to improve performance +## Using drawable groups to improve performance You can organize your drawables to multiple groups to minimize OpenGL state changes -- for example put all objects using the same shader, the same light @@ -117,7 +117,7 @@ void MyApplication::drawEvent() { } @endcode -@section Drawable-explicit-specializations Explicit template specializations +## Explicit template specializations The following specializations are explicitly compiled into @ref SceneGraph library. For other specializations (e.g. using @ref Double type) you have to diff --git a/src/Magnum/SceneGraph/Object.h b/src/Magnum/SceneGraph/Object.h index ed0adc8ab..de6ce7964 100644 --- a/src/Magnum/SceneGraph/Object.h +++ b/src/Magnum/SceneGraph/Object.h @@ -72,14 +72,15 @@ for(Object* child = o->firstChild(); child; child = child->nextSibling()) { } @endcode -@section Object-explicit-specializations Explicit template specializations +@anchor SceneGraph-Object-explicit-specializations +## Explicit template specializations -The following specialization are explicitly compiled into @ref SceneGraph +The following specializations are explicitly compiled into @ref SceneGraph library. For other specializations (e.g. using @ref Double type or special transformation class) you have to use @ref Object.hpp implementation file to avoid linker errors. See also relevant sections in -@ref AbstractObject-explicit-specializations "AbstractObject" and -@ref AbstractTransformation-explicit-specializations "AbstractTransformation" +@ref SceneGraph-AbstractObject-explicit-specializations "AbstractObject" and +@ref SceneGraph-AbstractTransformation-explicit-specializations "AbstractTransformation" class documentation or @ref compilation-speedup-hpp for more information. - @ref DualComplexTransformation "Object" diff --git a/src/Magnum/Shader.h b/src/Magnum/Shader.h index b69cd6eef..6c6971b68 100644 --- a/src/Magnum/Shader.h +++ b/src/Magnum/Shader.h @@ -45,11 +45,9 @@ namespace Magnum { /** @brief %Shader -See @ref AbstractShaderProgram for more information. +See @ref AbstractShaderProgram for usage information. -@todoc Usage... - -@section Shader-performance-optimization Performance optimizations +## Performance optimizations %Shader limits and implementation-defined values (such as @ref maxUniformComponents()) are cached, so repeated queries don't result in repeated @fn_gl{Get} calls. diff --git a/src/Magnum/Shaders/MeshVisualizer.cpp b/src/Magnum/Shaders/MeshVisualizer.cpp index a76e53ff4..8d29c4fd4 100644 --- a/src/Magnum/Shaders/MeshVisualizer.cpp +++ b/src/Magnum/Shaders/MeshVisualizer.cpp @@ -61,6 +61,12 @@ MeshVisualizer::MeshVisualizer(const Flags flags): flags(flags), transformationP vert.addSource(flags & Flag::Wireframe ? "#define WIREFRAME_RENDERING\n" : "") .addSource(flags & Flag::NoGeometryShader ? "#define NO_GEOMETRY_SHADER\n" : "") + #ifdef MAGNUM_TARGET_WEBGL + .addSource("#define SUBSCRIPTING_WORKAROUND\n") + #elif defined(MAGNUM_TARGET_GLES) + .addSource(Context::current()->detectedDriver() & Context::DetectedDriver::ProbablyAngle ? + "#define SUBSCRIPTING_WORKAROUND\n" : "") + #endif .addSource(rs.get("generic.glsl")) .addSource(rs.get("MeshVisualizer.vert")); frag.addSource(flags & Flag::Wireframe ? "#define WIREFRAME_RENDERING\n" : "") diff --git a/src/Magnum/Shaders/MeshVisualizer.h b/src/Magnum/Shaders/MeshVisualizer.h index 7239e7caa..8b9805173 100644 --- a/src/Magnum/Shaders/MeshVisualizer.h +++ b/src/Magnum/Shaders/MeshVisualizer.h @@ -44,7 +44,7 @@ Uses geometry shader to visualize wireframe. You need to provide @ref Position attribute in your triangle mesh and call at least @ref setTransformationProjectionMatrix() to be able to render. -@section ShadersMeshVisualizer-wireframe Wireframe visualization +## Wireframe visualization Wireframe visualization is done by enabling @ref Flag::Wireframe. It is done either using geometry shaders or with help of additional vertex information. diff --git a/src/Magnum/Shaders/MeshVisualizer.vert b/src/Magnum/Shaders/MeshVisualizer.vert index 156553f49..b8adcb1ba 100644 --- a/src/Magnum/Shaders/MeshVisualizer.vert +++ b/src/Magnum/Shaders/MeshVisualizer.vert @@ -58,10 +58,17 @@ void main() { #if defined(WIREFRAME_RENDERING) && defined(NO_GEOMETRY_SHADER) barycentric = vec3(0.0); - #ifndef NEW_GLSL + + #ifdef SUBSCRIPTING_WORKAROUND + int i = int(mod(vertexIndex, 3.0)); + if(i == 0) barycentric.x = 1.0; + else if(i == 1) barycentric.y = 1.0; + else barycentric.z = 1.0; + #elif !defined(NEW_GLSL) barycentric[int(mod(vertexIndex, 3.0))] = 1.0; #else barycentric[gl_VertexID % 3] = 1.0; #endif + #endif } diff --git a/src/Magnum/Text/AbstractFont.h b/src/Magnum/Text/AbstractFont.h index 7b033eeda..9d4bd8b74 100644 --- a/src/Magnum/Text/AbstractFont.h +++ b/src/Magnum/Text/AbstractFont.h @@ -48,14 +48,14 @@ Provides interface for opening fonts, filling glyph cache and layouting the glyphs. See @ref plugins for more information and `*Font` classes in @ref Text namespace for available font plugins. -@section AbstractFont-usage Usage +## Usage First step is to open the font using @ref openData(), @ref openSingleData() or @ref openFile(). Next step is to prerender all the glyphs which will be used in text rendering later, see @ref GlyphCache for more information. See @ref Renderer for information about text rendering. -@section AbstractFont-subclassing Subclassing +## Subclassing Plugin implements @ref doFeatures(), @ref doClose(), @ref doLayout(), either @ref doCreateGlyphCache() or @ref doFillGlyphCache() and one or more of @@ -304,7 +304,7 @@ CORRADE_ENUMSET_OPERATORS(AbstractFont::Features) Returned by @ref AbstractFont::layout(). -@section TextAbstractLayouter-subclassing Subclassing +## Subclassing Plugin creates private subclass (no need to expose it to end users) and implements @ref doRenderGlyph(). Bounds checking on @p i is done automatically diff --git a/src/Magnum/Text/AbstractFontConverter.h b/src/Magnum/Text/AbstractFontConverter.h index 4247de6fb..eb28ff7c6 100644 --- a/src/Magnum/Text/AbstractFontConverter.h +++ b/src/Magnum/Text/AbstractFontConverter.h @@ -45,7 +45,10 @@ Provides functionality for converting arbitrary font to different format. See @ref plugins for more information and `*FontConverter` classes in @ref Text namespace for available font converter plugins. -@section AbstractFontConverter-subclassing Subclassing +You can use the @ref magnum-fontconverter "magnum-fontconverter" utility to do +font conversion on command-line. + +## Subclassing Plugin implements @ref doFeatures() and one or more of `exportTo*()` / `importFrom*()` functions based on what features are supported. Characters diff --git a/src/Magnum/Text/CMakeLists.txt b/src/Magnum/Text/CMakeLists.txt index 50e59a4a8..5513a8d5d 100644 --- a/src/Magnum/Text/CMakeLists.txt +++ b/src/Magnum/Text/CMakeLists.txt @@ -60,10 +60,10 @@ install(TARGETS MagnumText install(FILES ${MagnumText_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Text) if(WITH_FONTCONVERTER) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake - ${CMAKE_CURRENT_BINARY_DIR}/configure.h) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fontconverterConfigure.h.cmake + ${CMAKE_CURRENT_BINARY_DIR}/fontconverterConfigure.h) - include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) + include_directories(${CMAKE_CURRENT_BINARY_DIR}) add_executable(magnum-fontconverter fontconverter.cpp) diff --git a/src/Magnum/Text/DistanceFieldGlyphCache.h b/src/Magnum/Text/DistanceFieldGlyphCache.h index 436d25812..0bbd24639 100644 --- a/src/Magnum/Text/DistanceFieldGlyphCache.h +++ b/src/Magnum/Text/DistanceFieldGlyphCache.h @@ -40,7 +40,7 @@ Unlike original @ref GlyphCache converts each binary image to distance field. It is not possible to use non-binary colors with this cache, internal texture format is red channel only. -@section DistanceFieldGlyphCache-usage Usage +## Usage Usage is similar to @ref GlyphCache, additionally you need to specify size of resulting distance field texture. diff --git a/src/Magnum/Text/GlyphCache.h b/src/Magnum/Text/GlyphCache.h index 2f33ecaa5..a2daaeeec 100644 --- a/src/Magnum/Text/GlyphCache.h +++ b/src/Magnum/Text/GlyphCache.h @@ -43,7 +43,7 @@ namespace Magnum { namespace Text { Contains font glyphs prerendered into texture atlas. -@section GlyphCache-usage Usage +## Usage Create %GlyphCache object with sufficient size and then call @ref AbstractFont::createGlyphCache() to fill it with glyphs. diff --git a/src/Magnum/Text/Renderer.h b/src/Magnum/Text/Renderer.h index f3273bda3..94127c4e6 100644 --- a/src/Magnum/Text/Renderer.h +++ b/src/Magnum/Text/Renderer.h @@ -169,7 +169,7 @@ class MAGNUM_TEXT_EXPORT AbstractRenderer { Lays out the text into mesh using given font. Use of ligatures, kerning etc. depends on features supported by particular font and its layouter. -@section Renderer-usage Usage +## Usage Immutable text (e.g. menu items, credits) can be simply rendered using static methods, returning result either as data arrays or as fully configured mesh. @@ -220,7 +220,7 @@ shader.setTransformationProjectionMatrix(projection*Matrix3::translation(-render renderer.mesh().draw(shader); @endcode -@section Renderer-extensions Required OpenGL functionality +## Required OpenGL functionality Mutable text rendering requires @extension{ARB,map_buffer_range} on desktop OpenGL (also part of OpenGL ES 3.0). If neither @es_extension{EXT,map_buffer_range} diff --git a/src/Magnum/Text/fontconverter.cpp b/src/Magnum/Text/fontconverter.cpp index 690c87784..ab890dcb7 100644 --- a/src/Magnum/Text/fontconverter.cpp +++ b/src/Magnum/Text/fontconverter.cpp @@ -42,9 +42,52 @@ #error No windowless application available on this platform #endif -#include "configure.h" +#include "fontconverterConfigure.h" -namespace Magnum { namespace Text { +namespace Magnum { + +/** +@page magnum-fontconverter Font conversion utility +@brief Converts font to raster one of given atlas size + +@section magnum-fontconverter-usage Usage + + magnum-fontconverter [-h|--help] --font FONT --converter CONVERTER [--plugin-dir DIR] [--characters CHARACTERS] [--font-size N] [--atlas-size "X Y"] [--output-size "X Y"] [--radius N] [--] input output + +Arguments: + +- `input` -- input font +- `output` -- output filename prefix +- `-h`, `--help` -- display help message and exit +- `--font FONT` -- font plugin +- `--converter CONVERTER` -- font converter plugin +- `--plugin-dir DIR` -- base plugin dir (defaults to plugin directory in + %Magnum install location) +- `--characters CHARACTERS` -- characters to include in the output (default: + `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789?!:,. `) +- `--font-size N` -- input font size (default: `128`) +- `--atlas-size "X Y"` -- glyph atlas size (default: `"2048 2048"`) +- `--output-size "X Y"` -- output atlas size. If set to zero size, distance + field computation will not be used. (default: `"256 256"`) +- `--radius N` -- distance field computation radius (default: `24`) + +The resulting font files can be then used as specified in the documentation of +`converter` plugin. + +@section magnum-fontconverter-example Example usage + +Making raster font from TTF file with default set of characters using +@ref Text::FreeTypeFont "FreeTypeFont" font plugin and +@ref Text::MagnumFontConverter "MagnumFontConverter" converter plugin: + + magnum-fontconverter --font FreeTypeFont --converter MagnumFontConverter DejaVuSans.ttf myfont + +According to `MagnumFontConverter` plugin documentation, this will generate +files `myfont.conf` and `myfont.tga` in current directory. You can then load +and use them with the @ref Text::MagnumFont "MagnumFont" plugin. +*/ + +namespace Text { class FontConverter: public Platform::WindowlessApplication { public: @@ -59,13 +102,13 @@ class FontConverter: public Platform::WindowlessApplication { FontConverter::FontConverter(const Arguments& arguments): Platform::WindowlessApplication(arguments, nullptr) { args.addArgument("input").setHelp("input", "input font") .addArgument("output").setHelp("output", "output filename prefix") - .addNamedArgument("font").setHelp("font", "plugin for opening the font") - .addNamedArgument("converter").setHelp("converter", "plugin for converting the font") + .addNamedArgument("font").setHelp("font", "font plugin") + .addNamedArgument("converter").setHelp("converter", "font converter plugin") .addOption("plugin-dir", MAGNUM_PLUGINS_DIR).setHelpKey("plugin-dir", "DIR").setHelp("plugin-dir", "base plugin dir") .addOption("characters", "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789?!:,. ").setHelp("characters", "characters to include in the output") - .addOption("font-size", "128").setHelpKey("font-size", "N").setHelp("font-size", "TTF font size") + .addOption("font-size", "128").setHelpKey("font-size", "N").setHelp("font-size", "input font size") .addOption("atlas-size", "2048 2048").setHelpKey("atlas-size", "\"X Y\"").setHelp("atlas-size", "glyph atlas size") .addOption("output-size", "256 256").setHelpKey("output-size", "\"X Y\"").setHelp("output-size", "output atlas size. If set to zero size, distance field computation will not be used.") .addOption("radius", "24").setHelpKey("radius", "N").setHelp("radius", "distance field computation radius") @@ -77,16 +120,16 @@ FontConverter::FontConverter(const Arguments& arguments): Platform::WindowlessAp int FontConverter::exec() { /* Font converter dependencies */ - PluginManager::Manager imageConverterManager(Utility::Directory::join(MAGNUM_PLUGINS_DIR, "imageconverters/")); + PluginManager::Manager imageConverterManager(Utility::Directory::join(args.value("plugin-dir"), "imageconverters/")); /* Load font */ - PluginManager::Manager fontManager(Utility::Directory::join(MAGNUM_PLUGINS_DIR, "fonts/")); + PluginManager::Manager fontManager(Utility::Directory::join(args.value("plugin-dir"), "fonts/")); if(!(fontManager.load(args.value("font")) & PluginManager::LoadState::Loaded)) std::exit(1); std::unique_ptr font = fontManager.instance(args.value("font")); /* Load font converter */ - PluginManager::Manager converterManager(Utility::Directory::join(MAGNUM_PLUGINS_DIR, "fontconverters/")); + PluginManager::Manager converterManager(Utility::Directory::join(args.value("plugin-dir"), "fontconverters/")); if(!(converterManager.load(args.value("converter")) & PluginManager::LoadState::Loaded)) std::exit(1); std::unique_ptr converter = converterManager.instance(args.value("converter")); @@ -130,6 +173,8 @@ int FontConverter::exec() { return 0; } -}} +} + +} MAGNUM_WINDOWLESSAPPLICATION_MAIN(Magnum::Text::FontConverter) diff --git a/src/Magnum/Text/configure.h.cmake b/src/Magnum/Text/fontconverterConfigure.h.cmake similarity index 92% rename from src/Magnum/Text/configure.h.cmake rename to src/Magnum/Text/fontconverterConfigure.h.cmake index fa22c14a9..5fc249d4e 100644 --- a/src/Magnum/Text/configure.h.cmake +++ b/src/Magnum/Text/fontconverterConfigure.h.cmake @@ -23,4 +23,8 @@ DEALINGS IN THE SOFTWARE. */ +#ifdef CORRADE_IS_DEBUG_BUILD +#define MAGNUM_PLUGINS_DIR "${MAGNUM_PLUGINS_DEBUG_INSTALL_DIR}" +#else #define MAGNUM_PLUGINS_DIR "${MAGNUM_PLUGINS_INSTALL_DIR}" +#endif diff --git a/src/Magnum/Texture.h b/src/Magnum/Texture.h index 9fb392780..b6423fc55 100644 --- a/src/Magnum/Texture.h +++ b/src/Magnum/Texture.h @@ -62,7 +62,7 @@ namespace Implementation { Template class for one- to three-dimensional textures. See also @ref AbstractTexture documentation for more information. -@section Texture-usage Usage +## Usage Common usage is to fully configure all texture parameters and then set the data from e.g. @ref Image. Example configuration of high quality texture with diff --git a/src/Magnum/TextureArray.h b/src/Magnum/TextureArray.h index d860b4636..5a8a725e0 100644 --- a/src/Magnum/TextureArray.h +++ b/src/Magnum/TextureArray.h @@ -53,7 +53,7 @@ namespace Implementation { Template class for one- and two-dimensional texture arrays. See also @ref AbstractTexture documentation for more information. -@section TextureArray-usage Usage +## Usage See @ref Texture documentation for introduction. diff --git a/src/Magnum/TextureTools/DistanceField.h b/src/Magnum/TextureTools/DistanceField.h index afe353e1f..342ecb092 100644 --- a/src/Magnum/TextureTools/DistanceField.h +++ b/src/Magnum/TextureTools/DistanceField.h @@ -56,6 +56,13 @@ less memory and can be scaled without aliasing issues. Additionally it provides foundation for features like outlining, glow or drop shadow essentially for free. +You can also use the @ref magnum-distancefieldconverter "magnum-distancefieldconverter" +utility to do distance field conversion on command-line. By extension, this +functionality is also provided through @ref magnum-fontconverter "magnum-fontconverter" +utility. + +### The algorithm + For each pixel inside @p rectangle the algorithm looks at corresponding pixel in @p input and tries to find nearest pixel of opposite color in area given by @p radius. Signed distance between the points is then saved as value of given @@ -67,7 +74,7 @@ that the pixel was originally black and nearest white pixel is farther than The resulting texture can be used with bilinear filtering. It can be converted back to binary form in shader using e.g. GLSL `smoothstep()` function with step around `0.5` to create antialiased edges. Or you can exploit the distance field -features to create many other effects. See also Shaders::DistanceFieldVectorShader. +features to create many other effects. See also @ref Shaders::DistanceFieldVector. Based on: *Chris Green - Improved Alpha-Tested Magnification for Vector Textures and Special Effects, SIGGRAPH 2007, diff --git a/src/Magnum/TextureTools/distancefieldconverter.cpp b/src/Magnum/TextureTools/distancefieldconverter.cpp index e15448bf4..703e2ed3d 100644 --- a/src/Magnum/TextureTools/distancefieldconverter.cpp +++ b/src/Magnum/TextureTools/distancefieldconverter.cpp @@ -24,6 +24,7 @@ */ #include +#include #include #include "Magnum/Math/Range.h" @@ -49,7 +50,42 @@ #include "distancefieldconverterConfigure.h" -namespace Magnum { namespace TextureTools { +namespace Magnum { + +/** @page magnum-distancefieldconverter Distance Field conversion utility +@brief Converts black&white image to distance field representation + +@section magnum-distancefieldconverter-usage Usage + + magnum-distancefieldconverter [-h|--help] [--importer IMPORTER] [--converter CONVERTER] [--plugin-dir DIR] --output-size "X Y" --radius N [--] input output + +Arguments: + +- `input` -- input image +- `output` -- output image +- `-h`, `--help` -- display help message and exit +- `--importer IMPORTER` -- image importer plugin (default: @ref Trade::TgaImporter "TgaImporter") +- `--converter CONVERTER` -- image converter plugin (default: @ref Trade::TgaImageConverter "TgaImageConverter") +- `--plugin-dir DIR` -- base plugin dir (defaults to plugin directory in + %Magnum install location) +- `--output-size "X Y"` -- size of output image +- `--radius N` -- distance field computation radius + +The resulting image can be then used with @ref Shaders::DistanceFieldVector +shader. See also @ref TextureTools::distanceField() for more information about +the algorithm and parameters. + +@section magnum-distancefield-example Example usage + + magnum-distancefieldconverter --importer PngImporter --output-size "256 256" --radius 24 logo.png logo.tga + +This will open binary `logo.png` image using @ref Trade::PngImporter "PngImporter" +plugin and converts it to 256x256 distance field `logo.tga` using +@ref Trade::TgaImageConverter "TgaImageConverter". + +*/ + +namespace TextureTools { class DistanceFieldConverter: public Platform::WindowlessApplication { public: @@ -64,11 +100,12 @@ class DistanceFieldConverter: public Platform::WindowlessApplication { DistanceFieldConverter::DistanceFieldConverter(const Arguments& arguments): Platform::WindowlessApplication(arguments, nullptr) { args.addArgument("input").setHelp("input", "input image") .addArgument("output").setHelp("output", "output image") - .addOption("importer", "TgaImporter").setHelp("image importer plugin") - .addOption("converter", "TgaImageConverter").setHelp("image converter plugin") + .addOption("importer", "TgaImporter").setHelp("importer", "image importer plugin") + .addOption("converter", "TgaImageConverter").setHelp("converter", "image converter plugin") + .addOption("plugin-dir", MAGNUM_PLUGINS_DIR).setHelpKey("plugin-dir", "DIR").setHelp("plugin-dir", "base plugin dir") .addNamedArgument("output-size").setHelpKey("output-size", "\"X Y\"").setHelp("output-size", "size of output image") .addNamedArgument("radius").setHelpKey("radius", "N").setHelp("radius", "distance field computation radius") - .setHelp("Converts black&white image to distance-field representation.") + .setHelp("Converts black&white image to distance field representation.") .parse(arguments.argc, arguments.argv); createContext(); @@ -76,13 +113,13 @@ DistanceFieldConverter::DistanceFieldConverter(const Arguments& arguments): Plat int DistanceFieldConverter::exec() { /* Load importer plugin */ - PluginManager::Manager importerManager(MAGNUM_IMPORTER_PLUGIN_DIR); + PluginManager::Manager importerManager(Utility::Directory::join(args.value("plugin-dir"), "importers/")); if(!(importerManager.load(args.value("importer")) & PluginManager::LoadState::Loaded)) return 1; std::unique_ptr importer = importerManager.instance(args.value("importer")); /* Load converter plugin */ - PluginManager::Manager converterManager(MAGNUM_IMAGECONVERTER_PLUGIN_DIR); + PluginManager::Manager converterManager(Utility::Directory::join(args.value("plugin-dir"), "imageconverters/")); if(!(converterManager.load(args.value("converter")) & PluginManager::LoadState::Loaded)) return 1; std::unique_ptr converter = converterManager.instance(args.value("converter")); diff --git a/src/Magnum/TextureTools/distancefieldconverterConfigure.h.cmake b/src/Magnum/TextureTools/distancefieldconverterConfigure.h.cmake index 8d6b08544..5fc249d4e 100644 --- a/src/Magnum/TextureTools/distancefieldconverterConfigure.h.cmake +++ b/src/Magnum/TextureTools/distancefieldconverterConfigure.h.cmake @@ -23,5 +23,8 @@ DEALINGS IN THE SOFTWARE. */ -#define MAGNUM_IMPORTER_PLUGIN_DIR "${MAGNUM_LIBRARY_INSTALL_DIR}/magnum/importers" -#define MAGNUM_IMAGECONVERTER_PLUGIN_DIR "${MAGNUM_LIBRARY_INSTALL_DIR}/magnum/imageconverters" +#ifdef CORRADE_IS_DEBUG_BUILD +#define MAGNUM_PLUGINS_DIR "${MAGNUM_PLUGINS_DEBUG_INSTALL_DIR}" +#else +#define MAGNUM_PLUGINS_DIR "${MAGNUM_PLUGINS_INSTALL_DIR}" +#endif diff --git a/src/Magnum/Timeline.h b/src/Magnum/Timeline.h index 142e775e1..94de7e176 100644 --- a/src/Magnum/Timeline.h +++ b/src/Magnum/Timeline.h @@ -43,7 +43,7 @@ namespace Magnum { Keeps track of time delta between frames and allows FPS limiting. Can be used as source for animation speed computations. -@section Timeline-usage Basic usage +## Basic usage Construct the timeline on initialization so the instance is available for whole lifetime of the application. Call @ref start() before first draw event is diff --git a/src/Magnum/Trade/AbstractImageConverter.h b/src/Magnum/Trade/AbstractImageConverter.h index 6352b171f..58312001e 100644 --- a/src/Magnum/Trade/AbstractImageConverter.h +++ b/src/Magnum/Trade/AbstractImageConverter.h @@ -44,7 +44,7 @@ Provides functionality for converting images between various internal formats or compressing them. See @ref plugins for more information and `*ImageConverter` classes in @ref Trade namespace for available image converter plugins. -@section AbstractImageConverter-subclassing Subclassing +## Subclassing Plugin implements function @ref doFeatures() and one or more of @ref doExportToImage(), @ref doExportToData() or @ref doExportToFile() diff --git a/src/Magnum/Trade/AbstractImporter.h b/src/Magnum/Trade/AbstractImporter.h index 7bb3482c6..a32bb41ad 100644 --- a/src/Magnum/Trade/AbstractImporter.h +++ b/src/Magnum/Trade/AbstractImporter.h @@ -47,7 +47,7 @@ Provides interface for importing 2D/3D scene, mesh, material, texture and image data. See @ref plugins for more information and `*Importer` classes in @ref Trade namespace for available importer plugins. -@section AbstractImporter-subclassing Subclassing +## Subclassing Plugin implements function @ref doFeatures(), @ref doIsOpened(), one of or both @ref doOpenData() and @ref doOpenFile() functions, function @ref doClose() and diff --git a/toolchains b/toolchains index 19d1e7ee8..7380270cc 160000 --- a/toolchains +++ b/toolchains @@ -1 +1 @@ -Subproject commit 19d1e7ee8bc61a6e1b4871c93e3aca4743e0ca9e +Subproject commit 7380270cc5d8e399cb06f463ac681adcbd591d54