Browse Source

Merge branch 'master' into compatibility

Conflicts:
	src/Primitives/Plane.cpp
	src/Primitives/Square.cpp
	src/SceneGraph/SceneGraph.h
Vladimír Vondruš 13 years ago
parent
commit
e2635345fa
  1. 5
      CMakeLists.txt
  2. 2
      PKGBUILD
  3. 10
      doc/best-practices.dox
  4. 5
      doc/building.dox
  5. 6
      doc/portability.dox
  6. 12
      doc/required-extensions.dox
  7. 15
      src/AbstractFramebuffer.h
  8. 17
      src/AbstractResourceLoader.h
  9. 11
      src/AbstractShaderProgram.h
  10. 11
      src/AbstractTexture.h
  11. 5
      src/Audio/AbstractImporter.cpp
  12. 13
      src/Audio/AbstractImporter.h
  13. 2
      src/Audio/Renderer.h
  14. 7
      src/Audio/Source.h
  15. 3
      src/Buffer.cpp
  16. 47
      src/Buffer.h
  17. 8
      src/Context.h
  18. 10
      src/CubeMapTexture.h
  19. 4
      src/CubeMapTextureArray.h
  20. 3
      src/DebugTools/DebugTools.h
  21. 11
      src/DebugTools/ShapeRenderer.h
  22. 8
      src/DefaultFramebuffer.h
  23. 63
      src/Magnum.h
  24. 3
      src/Math/Math.h
  25. 32
      src/Mesh.cpp
  26. 23
      src/Mesh.h
  27. 2
      src/MeshTools/CMakeLists.txt
  28. 59
      src/MeshTools/FullScreenTriangle.cpp
  29. 87
      src/MeshTools/FullScreenTriangle.h
  30. 2
      src/Platform/GlutApplication.h
  31. 8
      src/Platform/NaClApplication.h
  32. 4
      src/Platform/Sdl2Application.h
  33. 12
      src/Primitives/Plane.cpp
  34. 11
      src/Primitives/Plane.h
  35. 12
      src/Primitives/Square.cpp
  36. 11
      src/Primitives/Square.h
  37. 4
      src/Query.h
  38. 129
      src/Renderer.h
  39. 6
      src/Resource.h
  40. 4
      src/ResourceManager.h
  41. 16
      src/SceneGraph/AbstractFeature.h
  42. 89
      src/SceneGraph/Animable.h
  43. 3
      src/SceneGraph/SceneGraph.h
  44. 26
      src/Shaders/MeshVisualizer.h
  45. 17
      src/Shaders/Phong.h
  46. 4
      src/Shaders/Shaders.h
  47. 3
      src/Shapes/Shapes.h
  48. 5
      src/Text/AbstractFont.cpp
  49. 41
      src/Text/AbstractFont.h
  50. 204
      src/Text/AbstractFontConverter.h
  51. 2
      src/Text/DistanceFieldGlyphCache.h
  52. 2
      src/Text/GlyphCache.h
  53. 24
      src/Texture.h
  54. 15
      src/TextureTools/CMakeLists.txt
  55. 11
      src/TextureTools/DistanceField.h
  56. 26
      src/TextureTools/configure.h.cmake
  57. 134
      src/TextureTools/distance-field.cpp
  58. 22
      src/Trade/AbstractImageConverter.h
  59. 5
      src/Trade/AbstractImporter.cpp
  60. 22
      src/Trade/AbstractImporter.h
  61. 12
      src/Trade/PhongMaterialData.h
  62. 2
      src/Trade/TextureData.h
  63. 3
      src/Trade/Trade.h

5
CMakeLists.txt

@ -45,8 +45,9 @@ cmake_dependent_option(WITH_SCENEGRAPH "Build SceneGraph library" ON "NOT WITH_D
cmake_dependent_option(WITH_SHADERS "Build Shaders library" ON "NOT WITH_DEBUGTOOLS" ON)
cmake_dependent_option(WITH_SHAPES "Build Shapes library" ON "NOT WITH_DEBUGTOOLS" ON)
option(WITH_TEXT "Build Text library" ON)
cmake_dependent_option(WITH_TEXTURETOOLS "Build TextureTools library" ON "NOT WITH_TEXT" ON)
cmake_dependent_option(WITH_TEXTURETOOLS "Build TextureTools library" ON "NOT WITH_TEXT;NOT WITH_DISTANCEFIELDCONVERTER" ON)
option(WITH_MAGNUMINFO "Build magnum-info utility" OFF)
cmake_dependent_option(WITH_DISTANCEFIELDCONVERTER "Build magnum-distancefield utility" OFF "NOT TARGET_GLES" OFF)
# Application libraries
if(CORRADE_TARGET_NACL)
@ -54,7 +55,7 @@ if(CORRADE_TARGET_NACL)
cmake_dependent_option(WITH_WINDOWLESSNACLAPPLICATION "Build WindowlessNaClApplication library" OFF "NOT WITH_MAGNUMINFO" ON)
else()
option(WITH_GLXAPPLICATION "Build GlxApplication library" OFF)
cmake_dependent_option(WITH_WINDOWLESSGLXAPPLICATION "Build WindowlessGlxApplication library" OFF "NOT WITH_MAGNUMINFO" ON)
cmake_dependent_option(WITH_WINDOWLESSGLXAPPLICATION "Build WindowlessGlxApplication library" OFF "NOT WITH_MAGNUMINFO;NOT WITH_DISTANCEFIELDCONVERTER" ON)
cmake_dependent_option(WITH_XEGLAPPLICATION "Build XEglApplication library" OFF "TARGET_GLES" OFF)
cmake_dependent_option(WITH_GLUTAPPLICATION "Build GlutApplication library" OFF "NOT TARGET_GLES" OFF)
option(WITH_SDL2APPLICATION "Build Sdl2Application library" OFF)

2
PKGBUILD

@ -6,7 +6,7 @@ pkgdesc="OpenGL graphics engine"
arch=('i686' 'x86_64')
url="https://github.com/mosra/magnum"
license=('MIT')
depends=('corrade' 'glew' 'sdl-hg' 'freeglut')
depends=('corrade' 'glew' 'freeglut' 'sdl2')
makedepends=('cmake')
options=(!strip)
provides=('magnum-git')

10
doc/best-practices.dox

@ -56,11 +56,11 @@ information.
@subsubsection best-practices-nacl-buffer-types Native Client requires unique buffer binding
As noted in the above link, buffers in NaCl implementation need to be bound
only to one unique target, i.e., Buffer bound to @ref Buffer::Target "Target::Array"
cannot be later rebound to @ref Buffer::Target "Target::ElementArray". However,
%Magnum by default uses any sufficient target when binding the buffer
internally (e.g. for setting data or copying). To avoid this, set target hint
to desired target, either in constructor or using Buffer::setTargetHint().
only to one unique target, i.e., @ref Buffer bound to @ref Buffer::Target::Array
cannot be later rebound to @ref Buffer::Target::ElementArray. However, %Magnum
by default uses any sufficient target when binding the buffer internally (e.g.
for setting data or copying). To avoid this, set target hint to desired target,
either in constructor or using @ref Buffer::setTargetHint().
To ease up the development, @ref Mesh checks proper target hint when adding
vertex and index buffers.

5
doc/building.dox

@ -169,9 +169,12 @@ be built and which not:
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`
is enabled.
or `WITH_DISTANCEFIELDCONVERTER` is enabled.
- `WITH_MAGNUMINFO` - `magnum-info` executable, provides information about the
engine and OpenGL capabilities.
- `WITH_DISTANCEFIELDCONVERTER` - `magnum-distancefield` executable for
converting black&white images to distance field textures. Enables also
building of TextureTools library.
None of the @ref Platform "application libraries" is built by default (and you
need at least one). Choose the one which suits your requirements and your

6
doc/portability.dox

@ -39,9 +39,9 @@ format is not supported.
If you include Magnum.h, you get these predefined macros:
- @ref MAGNUM_TARGET_GLES_ "MAGNUM_TARGET_GLES" if targeting OpenGL ES 2.0 or
3.0
- @ref MAGNUM_TARGET_GLES2_ "MAGNUM_TARGET_GLES2" if targeting OpenGL ES 2.0
- @ref MAGNUM_TARGET_GLES if targeting OpenGL ES
- @ref MAGNUM_TARGET_GLES2 if targeting OpenGL ES 2.0
- @ref MAGNUM_TARGET_GLES3 if targeting OpenGL ES 3.0
Example usage:
@code

12
doc/required-extensions.dox

@ -29,8 +29,8 @@ The engine is meant to be run on OpenGL 3 capable hardware, but most of the
functionality is working in OpenGL 2.1 hardware too (i.e. integrated Intel
GPUs), unless stated otherwise. OpenGL ES is also supported.
@see @ref building, @ref cmake, @ref MAGNUM_TARGET_GLES_ "MAGNUM_TARGET_GLES",
@ref MAGNUM_TARGET_GLES2_ "MAGNUM_TARGET_GLES2"
@see @ref building, @ref cmake, @ref MAGNUM_TARGET_GLES,
@ref MAGNUM_TARGET_GLES2
Following are lists of functionality requiring specific OpenGL version. In
most cases it is also specified which extension is required for given
@ -67,15 +67,15 @@ supported on Intel GPUs even if they are capable of OpenGL 2.1 only).
@page requires-extension Functionality requiring specific OpenGL extension
@page requires-gl Functionality requiring desktop OpenGL (not available on OpenGL ES)
@see @ref MAGNUM_TARGET_GLES_ "MAGNUM_TARGET_GLES"
@see @ref MAGNUM_TARGET_GLES
@page requires-gles20 Functionality requiring OpenGL ES 2.0 (not available in ES 3.0 and desktop OpenGL)
@see @ref MAGNUM_TARGET_GLES2_ "MAGNUM_TARGET_GLES2"
@see @ref MAGNUM_TARGET_GLES2
@page requires-gles30 Functionality requiring OpenGL ES 3.0
@see @ref MAGNUM_TARGET_GLES3_ "MAGNUM_TARGET_GLES3"
@see @ref MAGNUM_TARGET_GLES3
@page requires-es-extension Functionality requiring specific OpenGL ES extension
@see @ref MAGNUM_TARGET_GLES2_ "MAGNUM_TARGET_GLES2"
@see @ref MAGNUM_TARGET_GLES2
*/

15
src/AbstractFramebuffer.h

@ -161,12 +161,12 @@ class MAGNUM_EXPORT AbstractFramebuffer {
* @param mask Which buffers to perform blit operation on
* @param filter Interpolation filter
*
* Binds @p source framebuffer to @ref FramebufferTarget "FramebufferTarget::Read"
* and @p destination framebuffer to @ref FramebufferTarget "FramebufferTarget::Draw"
* and performs blitting operation. See DefaultFramebuffer::mapForRead(),
* Framebuffer::mapForRead(), DefaultFramebuffer::mapForDraw() and
* Framebuffer::mapForDraw() for specifying particular buffers for
* blitting operation.
* Binds @p source framebuffer to @ref FramebufferTarget::Read and
* @p destination framebuffer to @ref FramebufferTarget::Draw and
* performs blitting operation. See @ref DefaultFramebuffer::mapForRead(),
* @ref Framebuffer::mapForRead(), @ref DefaultFramebuffer::mapForDraw()
* and @ref Framebuffer::mapForDraw() for specifying particular buffers
* for blitting operation.
* @see @fn_gl{BlitFramebuffer}
* @requires_gles30 %Extension @es_extension{ANGLE,framebuffer_blit} or
* @es_extension{NV,framebuffer_blit}
@ -183,8 +183,7 @@ class MAGNUM_EXPORT AbstractFramebuffer {
* Convenience alternative to above function when source rectangle is
* the same as destination rectangle. As the image is copied
* pixel-by-pixel, no interpolation is needed and thus
* @ref FramebufferBlitFilter "FramebufferBlitFilter::Nearest"
* filtering is used by default.
* @ref FramebufferBlitFilter::Nearest filtering is used by default.
* @see @fn_gl{BlitFramebuffer}
* @requires_gles30 %Extension @es_extension{ANGLE,framebuffer_blit} or
* @es_extension{NV,framebuffer_blit}

17
src/AbstractResourceLoader.h

@ -140,9 +140,9 @@ template<class T> class AbstractResourceLoader {
* @brief Request resource to be loaded
*
* If the resource isn't yet loaded or loading, state of the resource
* is set to @ref Resource::ResourceState "ResourceState::Loading" and count of
* requested features is incremented. Depending on implementation the
* resource might be loaded synchronously or asynchronously.
* is set to @ref ResourceState::Loading and count of requested
* features is incremented. Depending on implementation the resource
* might be loaded synchronously or asynchronously.
*
* @see ResourceManager::state(), requestedCount(), notFoundCount(),
* loadedCount()
@ -153,10 +153,9 @@ template<class T> class AbstractResourceLoader {
/**
* @brief Set loaded resource to resource manager
*
* Also increments count of loaded resources. Parameter @p state
* must be either @ref ResourceManager::ResourceDataState "ResourceDataState::Mutable"
* or @ref ResourceManager::ResourceDataState "ResourceDataState::Final". See
* ResourceManager::set() for more information.
* Also increments count of loaded resources. Parameter @p state must
* be either @ref ResourceDataState::Mutable or @ref ResourceDataState::Final.
* See @ref ResourceManager::set() for more information.
* @see loadedCount()
*/
void set(ResourceKey key, T* data, ResourceDataState state, ResourcePolicy policy);
@ -169,8 +168,8 @@ template<class T> class AbstractResourceLoader {
/**
* @brief Set loaded resource to resource manager
*
* Same as above function with state set to @ref ResourceDataState "ResourceDataState::Final"
* and policy to @ref ResourcePolicy "ResourcePolicy::Resident".
* Same as above function with state set to @ref ResourceDataState::Final
* and policy to @ref ResourcePolicy::Resident.
*/
void set(ResourceKey key, T* data) {
set(key, data, ResourceDataState::Final, ResourcePolicy::Resident);

11
src/AbstractShaderProgram.h

@ -951,10 +951,9 @@ always have vertex attribute with location `0`.
Template parameter @p T is the type which is used for shader attribute, e.g.
@ref Vector4i for `ivec4`. DataType is type of passed data when adding vertex
buffers to mesh. By default it is the same as type used in shader (e.g.
@ref DataType "DataType::Int" for @ref Vector4i). It's also possible to pass
integer data to floating-point shader inputs. In this case you may want to
normalize the values (e.g. color components from 0-255 to 0.0f - 1.0f) -- see
@ref DataOption "DataOption::Normalize".
@ref DataType::Int for @ref Vector4i). It's also possible to pass integer data
to floating-point shader inputs. In this case you may want to normalize the
values (e.g. color components from 0-255 to 0.0f - 1.0f) -- see @ref DataOption::Normalize.
Only some types are allowed as attribute types, see @ref AbstractShaderProgram-types
or TypeTraits::AttributeType for more information.
@ -1123,11 +1122,11 @@ template<UnsignedInt location, class T> class AbstractShaderProgram::Attribute {
/**
* @brief Constructor
* @param dataType Type of passed data. Default is the same as
* type used in shader (e.g. DataType::Integer for Vector4i).
* type used in shader (e.g. @ref DataType::Int for @ref Vector4i).
* @param dataOptions Data options. Default is no options.
*
* Component count is set to the same value as in type used in shader
* (e.g. @ref Components "Components::Three" for Vector3).
* (e.g. @ref Components::Three for @ref Vector3).
*/
constexpr Attribute(DataType dataType = Implementation::Attribute<T>::DefaultDataType, DataOptions dataOptions = DataOptions()): _components(Implementation::Attribute<T>::DefaultComponents), _dataType(dataType), _dataOptions(dataOptions) {}

11
src/AbstractTexture.h

@ -151,11 +151,10 @@ class MAGNUM_EXPORT AbstractTexture {
* Sets filter used when the object pixel size is smaller than the
* texture size. If @extension{EXT,direct_state_access} is not
* available, the texture is bound to some layer before the operation.
* Initial value is (@ref Sampler::Filter "Sampler::Filter::Nearest",
* @ref Sampler::Mipmap "Sampler::Mipmap::Linear").
* Initial value is (@ref Sampler::Filter::Nearest, @ref Sampler::Mipmap::Linear).
* @attention For rectangle textures only some modes are supported,
* see @ref Sampler::Filter "Sampler::Filter" and @ref Sampler::Mipmap "Sampler::Mipmap"
* documentation for more information.
* see @ref Sampler::Filter and @ref Sampler::Mipmap documentation
* for more information.
* @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexParameter}
* or @fn_gl_extension{TextureParameter,EXT,direct_state_access}
* with @def_gl{TEXTURE_MIN_FILTER}
@ -170,7 +169,7 @@ class MAGNUM_EXPORT AbstractTexture {
* Sets filter used when the object pixel size is larger than largest
* texture size. If @extension{EXT,direct_state_access} is not
* available, the texture is bound to some layer before the operation.
* Initial value is @ref Sampler::Filter "Sampler::Filter::Linear".
* Initial value is @ref Sampler::Filter::Linear.
* @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexParameter}
* or @fn_gl_extension{TextureParameter,EXT,direct_state_access}
* with @def_gl{TEXTURE_MAG_FILTER}
@ -185,7 +184,7 @@ class MAGNUM_EXPORT AbstractTexture {
* @brief Set border color
* @return Reference to self (for method chaining)
*
* Border color when wrapping is set to @ref Sampler::Wrapping "Sampler::Wrapping::ClampToBorder".
* Border color when wrapping is set to @ref Sampler::Wrapping::ClampToBorder.
* If @extension{EXT,direct_state_access} is not available, the texture
* is bound to some layer before the operation. Initial value is
* `{0.0f, 0.0f, 0.0f, 0.0f}`.

5
src/Audio/AbstractImporter.cpp

@ -76,7 +76,10 @@ void AbstractImporter::doOpenFile(const std::string& filename) {
}
void AbstractImporter::close() {
if(isOpened()) doClose();
if(isOpened()) {
doClose();
CORRADE_INTERNAL_ASSERT(!isOpened());
}
}
Buffer::Format AbstractImporter::format() const {

13
src/Audio/AbstractImporter.h

@ -49,8 +49,8 @@ checked by the implementation:
- Functions doOpenData() and doOpenFile() are called after the previous file
was closed, function doClose() is called only if there is any file opened.
- Function doOpenData() is called only if @ref Feature "Feature::OpenData"
is supported.
- Function doOpenData() is called only if @ref Feature::OpenData is
supported.
- All `do*()` implementations working on opened file are called only if
there is any file opened.
*/
@ -91,8 +91,8 @@ class MAGNUM_AUDIO_EXPORT AbstractImporter: public PluginManager::AbstractPlugin
* @brief Open raw data
*
* Closes previous file, if it was opened, and tries to open given
* file. Available only if @ref Feature "Feature::OpenData" is
* supported. Returns `true` on success, `false` otherwise.
* file. Available only if @ref Feature::OpenData is supported. Returns
* `true` on success, `false` otherwise.
* @see features(), openFile()
*/
bool openData(Containers::ArrayReference<const unsigned char> data);
@ -139,9 +139,8 @@ class MAGNUM_AUDIO_EXPORT AbstractImporter: public PluginManager::AbstractPlugin
/**
* @brief Implementation for openFile()
*
* If @ref Feature "Feature::OpenData" is supported, default
* implementation opens the file and calls doOpenData() with its
* contents.
* If @ref Feature::OpenData is supported, default implementation opens
* the file and calls @ref doOpenData() with its contents.
*/
virtual void doOpenFile(const std::string& filename);

2
src/Audio/Renderer.h

@ -174,7 +174,7 @@ class Renderer {
/**
* @brief Set distance model
*
* Default is @ref DistanceModel "DistanceModel::InverseClamped".
* Default is @ref DistanceModel::InverseClamped.
* @see @fn_al{DistanceModel}
*/
static void setDistanceModel(DistanceModel model) {

7
src/Audio/Source.h

@ -347,10 +347,9 @@ class MAGNUM_AUDIO_EXPORT Source {
* @param buffer Buffer to attach or `nullptr`
* @return Reference to self (for method chaining)
*
* If an buffer is attached, changes source type to
* @ref Type "Type::Static", if detached, changes source type to
* @ref Type "Type::Undetermined". The buffer must be already filled
* with data.
* If an buffer is attached, changes source type to @ref Type::Static,
* if detached, changes source type to @ref Type::Undetermined. The
* buffer must be already filled with data.
* @see @ref type(), @fn_al{Sourcei} with @def_al{BUFFER}
*/
Source& setBuffer(Buffer* buffer);

3
src/Buffer.cpp

@ -87,6 +87,9 @@ Buffer::Buffer(Buffer::Target targetHint): _targetHint(targetHint)
}
Buffer::~Buffer() {
/* Moved out, nothing to do */
if(!_id) return;
GLuint* bindings = Context::current()->state().buffer->bindings;
/* Remove all current bindings from the state */

47
src/Buffer.h

@ -89,8 +89,8 @@ for(std::size_t i = 0; i != 200; ++i)
CORRADE_INTERNAL_ASSERT_OUTPUT(buffer.unmap());
@endcode
If you are updating only a few discrete portions of the buffer, you can use
@ref MapFlag "MapFlag::FlushExplicit" and flushMappedRange() to reduce number
of memory operations performed by OpenGL on unmapping. Example:
@ref MapFlag::FlushExplicit and flushMappedRange() to reduce number of memory
operations performed by OpenGL on unmapping. Example:
@code
Vector3* data = static_cast<Vector3*>(buffer.map(0, 200*sizeof(Vector3), Buffer::MapFlag::Write|Buffer::MapFlag::FlushExplicit));
for(std::size_t i: {7, 27, 56, 128}) {
@ -125,11 +125,6 @@ nothing.
class MAGNUM_EXPORT Buffer {
friend class Context;
Buffer(const Buffer&) = delete;
Buffer(Buffer&&) = delete;
Buffer& operator=(const Buffer&) = delete;
Buffer& operator=(Buffer&&) = delete;
public:
/**
* @brief %Buffer target
@ -382,7 +377,7 @@ class MAGNUM_EXPORT Buffer {
/**
* Previous contents of the entire buffer may be discarded. May
* not be used in combination with @ref MapFlag "MapFlag::Read".
* not be used in combination with @ref MapFlag::Read.
* @see invalidateData()
*/
#ifndef MAGNUM_TARGET_GLES2
@ -393,7 +388,7 @@ class MAGNUM_EXPORT Buffer {
/**
* Previous contents of mapped range may be discarded. May not
* be used in combination with @ref MapFlag "MapFlag::Read".
* be used in combination with @ref MapFlag::Read.
* @see invalidateSubData()
*/
#ifndef MAGNUM_TARGET_GLES2
@ -405,7 +400,7 @@ class MAGNUM_EXPORT Buffer {
/**
* Only one or more discrete subranges of the mapping will be
* modified. See flushMappedRange() for more information. May only
* be used in conjuction with @ref MapFlag "MapFlag::Write".
* be used in conjuction with @ref MapFlag::Write.
*/
#ifndef MAGNUM_TARGET_GLES2
FlushExplicit = GL_MAP_FLUSH_EXPLICIT_BIT,
@ -474,6 +469,12 @@ class MAGNUM_EXPORT Buffer {
*/
explicit Buffer(Target targetHint = Target::Array);
/** @brief Copying is not allowed */
Buffer(const Buffer&) = delete;
/** @brief Move constructor */
Buffer(Buffer&& other) noexcept;
/**
* @brief Destructor
*
@ -482,6 +483,12 @@ class MAGNUM_EXPORT Buffer {
*/
~Buffer();
/** @brief Copying is not allowed */
Buffer& operator=(const Buffer&) = delete;
/** @brief Move assignment */
Buffer& operator=(Buffer&& other) noexcept;
/** @brief OpenGL buffer ID */
GLuint id() const { return _id; }
@ -683,7 +690,7 @@ class MAGNUM_EXPORT Buffer {
*
* If running on OpenGL ES or extension @extension{ARB,invalidate_subdata}
* is not available, this function does nothing.
* @see @ref MapFlag "MapFlag::InvalidateBuffer", @fn_gl{InvalidateBufferData}
* @see @ref MapFlag::InvalidateBuffer, @fn_gl{InvalidateBufferData}
*/
Buffer& invalidateData() {
(this->*invalidateImplementation)();
@ -698,7 +705,7 @@ class MAGNUM_EXPORT Buffer {
*
* If running on OpenGL ES or extension @extension{ARB,invalidate_subdata}
* is not available, this function does nothing.
* @see @ref MapFlag "MapFlag::InvalidateRange", @fn_gl{InvalidateBufferData}
* @see @ref MapFlag::InvalidateRange, @fn_gl{InvalidateBufferData}
*/
Buffer& invalidateSubData(GLintptr offset, GLsizeiptr length) {
(this->*invalidateSubImplementation)(offset, length);
@ -753,8 +760,8 @@ class MAGNUM_EXPORT Buffer {
* @brief Map buffer to client memory
* @param offset Offset into the buffer
* @param length Length of the mapped memory
* @param flags Flags. At least @ref MapFlag "MapFlag::Read" or
* @ref MapFlag "MapFlag::Write" must be specified.
* @param flags Flags. At least @ref MapFlag::Read or @ref MapFlag::Write
* must be specified.
* @return Pointer to buffer data
*
* If @extension{EXT,direct_state_access} is not available and the
@ -776,7 +783,7 @@ class MAGNUM_EXPORT Buffer {
* @return Reference to self (for method chaining)
*
* Flushes specified subsection of mapped range. Use only if you called
* map() with @ref MapFlag "MapFlag::FlushExplicit" flag. See
* map() with @ref MapFlag::FlushExplicit flag. See
* @ref Buffer-data-mapping "class documentation" for usage example.
*
* If @extension{EXT,direct_state_access} is not available and the
@ -924,6 +931,16 @@ CORRADE_ENUMSET_OPERATORS(Buffer::MapFlags)
/** @debugoperator{Magnum::Buffer} */
Debug MAGNUM_EXPORT operator<<(Debug debug, Buffer::Target value);
inline Buffer::Buffer(Buffer&& other) noexcept: _id(other._id), _targetHint(other._targetHint) {
other._id = 0;
}
inline Buffer& Buffer::operator=(Buffer&& other) noexcept {
std::swap(_id, other._id);
std::swap(_targetHint, other._targetHint);
return *this;
}
#ifndef MAGNUM_TARGET_GLES
template<class T> Containers::Array<T> inline Buffer::data() {
const Int bufferSize = size();

8
src/Context.h

@ -67,7 +67,7 @@ enum class Version: Int {
*
* All the functionality is present in OpenGL 4.2 (extension
* @extension{ARB,ES2_compatibility}), so on desktop OpenGL this is
* equivalent to @ref Version "Version::GL410".
* equivalent to @ref Version::GL410.
*/
#ifndef MAGNUM_TARGET_GLES
GLES200 = 410,
@ -80,7 +80,7 @@ enum class Version: Int {
*
* All the functionality is present in OpenGL 4.3 (extension
* @extension{ARB,ES3_compatibility}), so on desktop OpenGL this is the
* equivalent to @ref Version "Version::GL430".
* equivalent to @ref Version::GL430.
*/
#ifndef MAGNUM_TARGET_GLES
GLES300 = 430
@ -319,8 +319,8 @@ class MAGNUM_EXPORT Context {
* @endcode
*
* If no version from the list is supported, returns lowest available
* OpenGL version (@ref Version "Version::GL210" for desktop OpenGL,
* @ref Version "Version::GLES200" for OpenGL ES).
* OpenGL version (@ref Version::GL210 for desktop OpenGL, @ref Version::GLES200
* for OpenGL ES).
*/
Version supportedVersion(std::initializer_list<Version> versions) const;

10
src/CubeMapTexture.h

@ -73,8 +73,8 @@ is signed three-part vector from the center of the cube, which intersects one
of the six sides of the cube map. See also AbstractShaderProgram for more
information about usage in shaders.
@see @ref Renderer::Feature "Renderer::Feature::SeamlessCubeMapTexture",
CubeMapTextureArray, Texture, BufferTexture
@see @ref Renderer::Feature::SeamlessCubeMapTexture, @ref CubeMapTextureArray,
@ref Texture, @ref BufferTexture
*/
class CubeMapTexture: public AbstractTexture {
public:
@ -213,10 +213,10 @@ class CubeMapTexture: public AbstractTexture {
* @param size Size of invalidated data
*
* Z coordinate is equivalent to number of texture face, i.e.
* @ref Coordinate "Coordinate::PositiveX" is `0` and so on, in the
* same order as in the enum.
* @ref Coordinate::PositiveX is `0` and so on, in the same order as in
* the enum.
*
* See Texture::invalidateSubImage() for more information.
* See @ref Texture::invalidateSubImage() for more information.
*/
void invalidateSubImage(Int level, const Vector3i& offset, const Vector3i& size) {
DataHelper<3>::invalidateSubImage(this, level, offset, size);

4
src/CubeMapTextureArray.h

@ -75,8 +75,8 @@ parts define vector from the center of the cube which intersects with one of
the six sides of the cube map, fourth part is layer in the array. See also
AbstractShaderProgram for more information about usage in shaders.
@see @ref Renderer::Feature "Renderer::Feature::SeamlessCubeMapTexture",
CubeMapTexture, Texture, BufferTexture
@see @ref Renderer::Feature::SeamlessCubeMapTexture, @ref CubeMapTexture,
@ref Texture, @ref BufferTexture
@requires_gl40 %Extension @extension{ARB,texture_cube_map_array}
@requires_gl Cube map texture arrays are not available in OpenGL ES.
*/

3
src/DebugTools/DebugTools.h

@ -32,8 +32,6 @@
namespace Magnum { namespace DebugTools {
/** @todoc Remove `ifndef` when Doxygen is sane again */
#ifndef DOXYGEN_GENERATING_OUTPUT
template<UnsignedInt> class ForceRenderer;
typedef ForceRenderer<2> ForceRenderer2D;
typedef ForceRenderer<3> ForceRenderer3D;
@ -51,7 +49,6 @@ template<UnsignedInt> class ShapeRenderer;
typedef ShapeRenderer<2> ShapeRenderer2D;
typedef ShapeRenderer<3> ShapeRenderer3D;
class ShapeRendererOptions;
#endif
}}

11
src/DebugTools/ShapeRenderer.h

@ -38,10 +38,7 @@
namespace Magnum { namespace DebugTools {
/** @todoc Remove `ifndef` when Doxygen is sane again */
#ifndef DOXYGEN_GENERATING_OUTPUT
template<UnsignedInt> class ShapeRenderer;
#endif
namespace Implementation {
template<UnsignedInt> class AbstractShapeRenderer;
@ -62,8 +59,8 @@ class ShapeRendererOptions {
* @see setRenderMode()
*/
enum class RenderMode: UnsignedByte {
Wireframe,
Solid
Wireframe, /**< Wireframe rendering */
Solid /**< Solid rendering */
};
constexpr ShapeRendererOptions(): _color(1.0f), _pointSize(0.25f), _renderMode(RenderMode::Wireframe) {}
@ -75,7 +72,7 @@ class ShapeRendererOptions {
* @brief Set shape rendering mode
* @return Reference to self (for method chaining)
*
* Default is @ref RenderMode "RenderMode::Wireframe".
* Default is @ref RenderMode::Wireframe.
*/
ShapeRendererOptions& setRenderMode(RenderMode mode) {
_renderMode = mode;
@ -103,7 +100,7 @@ class ShapeRendererOptions {
* @brief Set point size
* @return Reference to self (for method chaining)
*
* Size of rendered crosshairs, representing Shapes::Point shapes.
* Size of rendered crosshairs, representing @ref Shapes::Point shapes.
* Default is `0.25f`.
*/
ShapeRendererOptions& setPointSize(Float size) {

8
src/DefaultFramebuffer.h

@ -142,7 +142,7 @@ class MAGNUM_EXPORT DefaultFramebuffer: public AbstractFramebuffer {
/**
* Write output to back buffer.
*
* On desktop OpenGL, this is equal to @ref DrawAttachment "DrawAttachment::BackLeft".
* On desktop OpenGL, this is equal to @ref DrawAttachment::BackLeft.
*/
#ifdef MAGNUM_TARGET_GLES
Back = GL_BACK,
@ -153,7 +153,7 @@ class MAGNUM_EXPORT DefaultFramebuffer: public AbstractFramebuffer {
/**
* Write output to front buffer.
*
* On desktop OpenGL, this is equal to @ref DrawAttachment "DrawAttachment::FrontLeft".
* On desktop OpenGL, this is equal to @ref DrawAttachment::FrontLeft.
*/
#ifdef MAGNUM_TARGET_GLES
Front = GL_FRONT
@ -313,8 +313,8 @@ class MAGNUM_EXPORT DefaultFramebuffer: public AbstractFramebuffer {
*
* @p attachments is list of shader outputs mapped to buffer
* attachments. %Shader outputs which are not listed are not used, you
* can achieve the same by passing @ref DrawAttachment "DrawAttachment::None"
* as attachment. Example usage:
* can achieve the same by passing @ref DrawAttachment::None as
* attachment. Example usage:
* @code
* framebuffer.mapForDraw({{MyShader::ColorOutput, DefaultFramebuffer::DrawAttachment::BackLeft},
* {MyShader::NormalOutput, DefaultFramebuffer::DrawAttachment::None}});

63
src/Magnum.h

@ -40,11 +40,11 @@ typedef unsigned int GLenum; /* Needed for *Format and *Type enums */
namespace Magnum {
/** @todoc Remove `ifndef` when Doxygen is sane again */
#ifndef DOXYGEN_GENERATING_OUTPUT
namespace Math {
template<class T> struct Constants;
/** @todoc Remove `ifndef` when Doxygen is able to handle operator"" */
#ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef CORRADE_GCC46_COMPATIBILITY
#ifndef MAGNUM_TARGET_GLES
constexpr Rad<Double> operator "" _rad(long double);
@ -53,6 +53,7 @@ namespace Math {
constexpr Rad<Float> operator "" _radf(long double);
constexpr Deg<Float> operator "" _degf(long double);
#endif
#endif
}
/* Bring whole Corrade namespace */
@ -62,65 +63,56 @@ using namespace Corrade;
using Corrade::Utility::Debug;
using Corrade::Utility::Warning;
using Corrade::Utility::Error;
#endif
#ifdef DOXYGEN_GENERATING_OUTPUT
/** @todoc remove trailing underscores when Doxygen can handle `undef` */
/**
@brief Static library build
`MAGNUM_BUILD_STATIC` is defined if build as static libraries. Default are
shared libraries.
Defined if built as static libraries. Default are shared libraries.
@see @ref building-corrade
*/
#define MAGNUM_BUILD_STATIC_
#define MAGNUM_BUILD_STATIC
#undef MAGNUM_BUILD_STATIC
/**
@brief OpenGL ES target
`MAGNUM_TARGET_GLES` is defined if the engine is built for OpenGL ES 3.0 or
OpenGL ES 2.0.
@see @ref MAGNUM_TARGET_GLES2_ "MAGNUM_TARGET_GLES2",
@ref MAGNUM_TARGET_GLES3_ "MAGNUM_TARGET_GLES3",
@ref MAGNUM_TARGET_DESKTOP_GLES_ "MAGNUM_TARGET_DESKTOP_GLES",
@ref building
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
*/
#define MAGNUM_TARGET_GLES_
#define MAGNUM_TARGET_GLES
#undef MAGNUM_TARGET_GLES
/**
@brief OpenGL ES 2.0 target.
`MAGNUM_TARGET_GLES2` is defined if the engine is built for OpenGL ES 2.0.
Implies also @ref MAGNUM_TARGET_GLES_ "MAGNUM_TARGET_GLES".
@see @ref MAGNUM_TARGET_GLES3_ "MAGNUM_TARGET_GLES3",
@ref MAGNUM_TARGET_DESKTOP_GLES_ "MAGNUM_TARGET_DESKTOP_GLES",
@ref building
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
*/
#define MAGNUM_TARGET_GLES2_
#define MAGNUM_TARGET_GLES2
#undef MAGNUM_TARGET_GLES2
/**
@brief OpenGL ES 3.0 target.
`MAGNUM_TARGET_GLES3` is defined if the engine is built for OpenGL ES 3.0.
Implies also @ref MAGNUM_TARGET_GLES_ "MAGNUM_TARGET_GLES".
@see @ref MAGNUM_TARGET_GLES2_ "MAGNUM_TARGET_GLES2",
@ref MAGNUM_TARGET_DESKTOP_GLES_ "MAGNUM_TARGET_DESKTOP_GLES",
@ref building
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
*/
#define MAGNUM_TARGET_GLES3_
#define MAGNUM_TARGET_GLES3
#undef MAGNUM_TARGET_GLES3
/**
@brief Desktop emulation of OpenGL ES target
`MAGNUM_TARGET_DESKTOP_GLES` is 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_ "MAGNUM_TARGET_GLES".
@see @ref MAGNUM_TARGET_GLES2_ "MAGNUM_TARGET_GLES2", @ref building
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 building
*/
#define MAGNUM_TARGET_DESKTOP_GLES_
#define MAGNUM_TARGET_DESKTOP_GLES
#undef MAGNUM_TARGET_DESKTOP_GLES
#endif
/** @{ @name Basic type definitions
@ -321,8 +313,6 @@ using Math::operator "" _degf;
using Math::operator "" _radf;
#endif
/** @todoc Remove `ifndef` when Doxygen is sane again */
#ifndef DOXYGEN_GENERATING_OUTPUT
/* Forward declarations for all types in root namespace */
/* FramebufferClear[Mask], FramebufferBlit[Mask], FramebufferBlitFilter,
@ -428,7 +418,6 @@ enum class TextureFormat: GLenum;
#endif
class Timeline;
#endif
}

3
src/Math/Math.h

@ -34,8 +34,6 @@ namespace Magnum { namespace Math {
/** @todo Denormals to zero */
/** @todoc Remove `ifndef` when Doxygen is sane again */
#ifndef DOXYGEN_GENERATING_OUTPUT
/* Class Constants used only statically */
template<class> class Complex;
@ -63,7 +61,6 @@ template<class> class Vector4;
namespace Geometry {
template<class> class Rectangle;
}
#endif
}}

32
src/Mesh.cpp

@ -75,7 +75,7 @@ Mesh::~Mesh() {
(this->*destroyImplementation)();
}
Mesh::Mesh(Mesh&& other): _id(other._id), _primitive(other._primitive), _vertexCount(other._vertexCount), _indexCount(other._indexCount)
Mesh::Mesh(Mesh&& other) noexcept: _id(other._id), _primitive(other._primitive), _vertexCount(other._vertexCount), _indexCount(other._indexCount)
#ifndef MAGNUM_TARGET_GLES2
, _indexStart(other._indexStart), _indexEnd(other._indexEnd)
#endif
@ -90,30 +90,26 @@ Mesh::Mesh(Mesh&& other): _id(other._id), _primitive(other._primitive), _vertexC
other._id = 0;
}
Mesh& Mesh::operator=(Mesh&& other) {
(this->*destroyImplementation)();
_id = other._id;
_primitive = other._primitive;
_vertexCount = other._vertexCount;
_indexCount = other._indexCount;
Mesh& Mesh::operator=(Mesh&& other) noexcept {
std::swap(_id, other._id);
std::swap(_primitive, other._primitive);
std::swap(_vertexCount, other._vertexCount);
std::swap(_indexCount, other._indexCount);
#ifndef MAGNUM_TARGET_GLES2
_indexStart = other._indexStart;
_indexEnd = other._indexEnd;
std::swap(_indexStart, other._indexStart);
std::swap(_indexEnd, other._indexEnd);
#endif
_indexOffset = other._indexOffset;
_indexType = other._indexType;
_indexBuffer = other._indexBuffer;
_attributes = std::move(other._attributes);
std::swap(_indexOffset, other._indexOffset);
std::swap(_indexType, other._indexType);
std::swap(_indexBuffer, other._indexBuffer);
std::swap(_attributes, other._attributes);
#ifndef MAGNUM_TARGET_GLES2
_integerAttributes = std::move(other._integerAttributes);
std::swap(_integerAttributes, other._integerAttributes);
#ifndef MAGNUM_TARGET_GLES
_longAttributes = std::move(other._longAttributes);
std::swap(_longAttributes, other._longAttributes);
#endif
#endif
other._id = 0;
return *this;
}

23
src/Mesh.h

@ -242,9 +242,6 @@ class MAGNUM_EXPORT Mesh {
friend class Context;
friend class MeshView;
Mesh(const Mesh&) = delete;
Mesh& operator=(const Mesh&) = delete;
public:
/**
* @brief Primitive type
@ -353,8 +350,11 @@ class MAGNUM_EXPORT Mesh {
*/
explicit Mesh(Primitive primitive = Primitive::Triangles);
/** @brief Copying is not allowed */
Mesh(const Mesh&) = delete;
/** @brief Move constructor */
Mesh(Mesh&& other);
Mesh(Mesh&& other) noexcept;
/**
* @brief Destructor
@ -364,8 +364,11 @@ class MAGNUM_EXPORT Mesh {
*/
~Mesh();
/** @brief Copying is not allowed */
Mesh& operator=(const Mesh&) = delete;
/** @brief Move assignment */
Mesh& operator=(Mesh&& other);
Mesh& operator=(Mesh&& other) noexcept;
/**
* @brief Index size
@ -381,9 +384,9 @@ class MAGNUM_EXPORT Mesh {
* @brief Set primitive type
* @return Reference to self (for method chaining)
*
* Default is @ref Primitive "Primitive::Triangles".
* @see setVertexCount(), addVertexBuffer(),
* addInterleavedVertexBuffer(), addVertexBufferStride()
* Default is @ref Primitive::Triangles.
* @see @ref setVertexCount(), @ref addVertexBuffer(),
* @ref addInterleavedVertexBuffer(), @ref addVertexBufferStride()
*/
Mesh& setPrimitive(Primitive primitive) {
_primitive = primitive;
@ -834,7 +837,7 @@ template<> struct MAGNUM_EXPORT ConfigurationValue<Magnum::Mesh::Primitive> {
/**
* @brief Reads enum value as string
*
* If the value is invalid, returns @ref Magnum::Mesh::Primitive "Mesh::Primitive::Points".
* If the value is invalid, returns @ref Magnum::Mesh::Primitive::Points "Mesh::Primitive::Points".
*/
static Magnum::Mesh::Primitive fromString(const std::string& stringValue, ConfigurationValueFlags);
};
@ -853,7 +856,7 @@ template<> struct MAGNUM_EXPORT ConfigurationValue<Magnum::Mesh::IndexType> {
/**
* @brief Read enum value as string
*
* If the value is invalid, returns @ref Magnum::Mesh::IndexType "Mesh::IndexType::UnsignedInt".
* If the value is invalid, returns @ref Magnum::Mesh::IndexType::UnsignedInt "Mesh::IndexType::UnsignedInt".
*/
static Magnum::Mesh::IndexType fromString(const std::string& stringValue, ConfigurationValueFlags);
};

2
src/MeshTools/CMakeLists.txt

@ -25,6 +25,7 @@
# Files shared between main library and unit test library
set(MagnumMeshTools_SRCS
CompressIndices.cpp
FullScreenTriangle.cpp
Tipsify.cpp)
# Files compiled with different flags for main library and unit test library
@ -37,6 +38,7 @@ set(MagnumMeshTools_HEADERS
CompressIndices.h
Duplicate.h
FlipNormals.h
FullScreenTriangle.h
GenerateFlatNormals.h
Interleave.h
RemoveDuplicates.h

59
src/MeshTools/FullScreenTriangle.cpp

@ -0,0 +1,59 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš <mosra@centrum.cz>
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 "FullScreenTriangle.h"
#include "Math/Vector2.h"
#include "AbstractShaderProgram.h"
#include "Buffer.h"
#include "Context.h"
#include "Mesh.h"
namespace Magnum { namespace MeshTools {
std::pair<Buffer, Mesh> fullScreenTriangle() {
Mesh mesh;
mesh.setPrimitive(Mesh::Primitive::Triangles)
.setVertexCount(3);
Buffer buffer;
#ifndef MAGNUM_TARGET_GLES
if(!Context::current()->isVersionSupported(Version::GL300))
#else
if(!Context::current()->isVersionSupported(Version::GLES300))
#endif
{
constexpr Vector2 triangle[] = {
Vector2(-1.0, 1.0),
Vector2(-1.0, -3.0),
Vector2( 3.0, 1.0)
};
buffer.setData(triangle, Buffer::Usage::StaticDraw);
mesh.addVertexBuffer(buffer, 0, AbstractShaderProgram::Attribute<0, Vector2>());
}
return {std::move(buffer), std::move(mesh)};
}
}}

87
src/MeshTools/FullScreenTriangle.h

@ -0,0 +1,87 @@
#ifndef Magnum_MeshTools_FullScreenTriangle_h
#define Magnum_MeshTools_FullScreenTriangle_h
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš <mosra@centrum.cz>
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.
*/
/** @file
* @brief Function @ref Magnum::MeshTools::fullScreenTriangle()
*/
#include <utility>
#include "Magnum.h"
#include "MeshTools/magnumMeshToolsVisibility.h"
namespace Magnum { namespace MeshTools {
/**
@brief Create full screen triangle mesh
Returns pre-configured mesh along with vertex buffer which can be used for
full-screen post-processing effects. The mesh is single triangle covering whole
screen area (@f$ (-1, -1) - (1, 1) @f$ on both dimensions) and provides only
vertex positions, as other attributes (such as texture coordinates) can be
computed from them. The vertex positions are, in order:
@f[
\begin{pmatrix} -1 \\ 1 \end{pmatrix},
\begin{pmatrix} -1 \\ -3 \end{pmatrix},
\begin{pmatrix} 3 \\ 1 \end{pmatrix}
@f]
On OpenGL 2.1 and OpenGL ES 2.0 the vertex positions are passed explicitly as
attribute `0`, contained in the buffer. On OpenGL 3.0+ and OpenGL ES 3.0+ the
mesh is attribute-less and the vertex positions can be computed using
`gl_VertexID` builtin shader variable, thus the returned vertex buffer is empty
and basically useless.
Computing positions in vertex shader in a portable way might be done like this.
For OpenGL 2.1 and OpenGL ES 2.0 you then need to bind the location of `position`
attribute to `0`.
@code
#if (!defined(GL_ES) && __VERSION__ >= 130) || (defined(GL_ES) && __VERSION__ >= 300)
#define NEW_GLSL
#endif
#ifndef NEW_GLSL
attribute lowp vec4 position;
#endif
void main() {
#ifdef NEW_GLSL
gl_Position = vec4((gl_VertexID == 2) ? 3.0 : -1.0,
(gl_VertexID == 1) ? -3.0 : 1.0, 0.0, 1.0);
#else
gl_Position = position;
#endif
}
@endcode
@attention The implementation needs to check OpenGL version, so it expects
active context.
*/
std::pair<Buffer, Mesh> MAGNUM_MESHTOOLS_EXPORT fullScreenTriangle();
}}
#endif

2
src/Platform/GlutApplication.h

@ -326,7 +326,7 @@ class GlutApplication::Configuration {
*
* Default is `0`, thus no multisampling. The actual sample count is
* ignored, GLUT either enables it or disables. See also
* @ref Renderer::Feature "Renderer::Feature::Multisampling".
* @ref Renderer::Feature::Multisampling.
*/
Configuration& setSampleCount(Int count) {
_sampleCount = count;

8
src/Platform/NaClApplication.h

@ -105,8 +105,8 @@ status displayed in the remaining two `&lt;div&gt;`s, if they are available.
The CSS file contains rudimentary style to avoid eye bleeding.
The `&lt;embed&gt;` file references NMF file which you need to provide too. If
you target @ref CORRADE_TARGET_NACL_NEWLIB_ "newlib", the file is pretty
simple, for example:
you target @ref CORRADE_TARGET_NACL_NEWLIB "newlib", the file is pretty simple,
for example:
@code
{
"program": {
@ -116,7 +116,7 @@ simple, for example:
}
@endcode
If you target @ref CORRADE_TARGET_NACL_GLIBC_ "glibc", you need to specify also
If you target @ref CORRADE_TARGET_NACL_GLIBC "glibc", you need to specify also
all additional dependencies. See [Native Client](https://developers.google.com/native-client/)
documentation for more information.
@ -337,7 +337,7 @@ class NaClApplication::Configuration {
* @return Reference to self (for method chaining)
*
* Default is `0`, thus no multisampling. See also
* @ref Renderer::Feature "Renderer::Feature::Multisampling".
* @ref Renderer::Feature::Multisampling.
*/
Configuration& setSampleCount(Int count) {
_sampleCount = count;

4
src/Platform/Sdl2Application.h

@ -271,7 +271,7 @@ class Sdl2Application::Configuration {
* @brief Set window flags
* @return Reference to self (for method chaining)
*
* Default is @ref Flag "Flag::Resizable".
* Default is @ref Flag::Resizable.
*/
Configuration& setFlags(const Flags flags) {
_flags = flags;
@ -286,7 +286,7 @@ class Sdl2Application::Configuration {
* @return Reference to self (for method chaining)
*
* Default is `0`, thus no multisampling. See also
* @ref Renderer::Feature "Renderer::Feature::Multisampling".
* @ref Renderer::Feature::Multisampling.
*/
Configuration& setSampleCount(Int count) {
_sampleCount = count;

12
src/Primitives/Plane.cpp

@ -29,7 +29,15 @@
namespace Magnum { namespace Primitives {
Trade::MeshData3D Plane::solid() {
Trade::MeshData3D Plane::solid(const TextureCoords textureCoords) {
std::vector<std::vector<Vector2>> coords;
if(textureCoords == TextureCoords::Generate) coords.push_back({
{1.0f, 0.0f},
{1.0f, 1.0f},
{0.0f, 0.0f},
{0.0f, 1.0f}
});
return Trade::MeshData3D(Mesh::Primitive::TriangleStrip, {}, {std::vector<Vector3>{
{1.0f, -1.0f, 0.0f},
{1.0f, 1.0f, 0.0f},
@ -40,7 +48,7 @@ Trade::MeshData3D Plane::solid() {
{0.0f, 0.0f, 1.0f},
{0.0f, 0.0f, 1.0f},
{0.0f, 0.0f, 1.0f}
}}, {});
}}, std::move(coords));
}
Trade::MeshData3D Plane::wireframe() {

11
src/Primitives/Plane.h

@ -38,16 +38,25 @@ namespace Magnum { namespace Primitives {
@brief 3D plane primitive
2x2 plane.
@see @ref Square
*/
class MAGNUM_PRIMITIVES_EXPORT Plane {
public:
/** @brief Whether to generate texture coordinates */
enum class TextureCoords: UnsignedByte {
DontGenerate, /**< Don't generate texture coordinates */
/** Generate texture coordinates with origin in bottom left corner. */
Generate
};
/**
* @brief Solid plane
*
* Non-indexed @ref Mesh::Primitive "TriangleStrip" with normals in
* positive Z direction.
*/
static Trade::MeshData3D solid();
static Trade::MeshData3D solid(TextureCoords textureCoords = TextureCoords::DontGenerate);
/**
* @brief Wireframe plane

12
src/Primitives/Square.cpp

@ -29,13 +29,21 @@
namespace Magnum { namespace Primitives {
Trade::MeshData2D Square::solid() {
Trade::MeshData2D Square::solid(const TextureCoords textureCoords) {
std::vector<std::vector<Vector2>> coords;
if(textureCoords == TextureCoords::Generate) coords.push_back({
{1.0f, 0.0f},
{1.0f, 1.0f},
{0.0f, 0.0f},
{0.0f, 1.0f}
});
return Trade::MeshData2D(Mesh::Primitive::TriangleStrip, {}, {std::vector<Vector2>{
{1.0f, -1.0f},
{1.0f, 1.0f},
{-1.0f, -1.0f},
{-1.0f, 1.0f}
}}, {});
}}, std::move(coords));
}
Trade::MeshData2D Square::wireframe() {

11
src/Primitives/Square.h

@ -38,15 +38,24 @@ namespace Magnum { namespace Primitives {
@brief 2D square primitive
2x2 square.
@see @ref Plane
*/
class MAGNUM_PRIMITIVES_EXPORT Square {
public:
/** @brief Whether to generate texture coordinates */
enum class TextureCoords: UnsignedByte {
DontGenerate, /**< Don't generate texture coordinates */
/** Generate texture coordinates with origin in bottom left corner. */
Generate
};
/**
* @brief Solid square
*
* Non-indexed @ref Mesh::Primitive "TriangleStrip".
*/
static Trade::MeshData2D solid();
static Trade::MeshData2D solid(TextureCoords textureCoords = TextureCoords::DontGenerate);
/**
* @brief Wireframe square

4
src/Query.h

@ -144,7 +144,7 @@ UnsignedInt primitiveCount = q.result<UnsignedInt>();
class PrimitiveQuery: public AbstractQuery {
public:
/** @brief Query target */
enum Target: GLenum {
enum class Target: GLenum {
#ifndef MAGNUM_TARGET_GLES
/**
* Count of primitives generated from vertex shader or geometry
@ -210,7 +210,7 @@ q.endConditionalRender();
class SampleQuery: public AbstractQuery {
public:
/** @brief Query target */
enum Target: GLenum {
enum class Target: GLenum {
#ifndef MAGNUM_TARGET_GLES
/**
* Count of samples passed from fragment shader

129
src/Renderer.h

@ -222,7 +222,7 @@ class MAGNUM_EXPORT Renderer {
/**
* @brief Set hint
*
* Initial value is @ref HintMode "HintMode::DontCare" for all targets.
* Initial value is @ref HintMode::DontCare for all targets.
* @see @fn_gl{Hint}
*/
static void setHint(Hint target, HintMode mode);
@ -244,7 +244,7 @@ class MAGNUM_EXPORT Renderer {
* @brief Set clear depth
*
* Initial value is `1.0`.
* @see @ref Feature "Feature::DepthTest", @fn_gl{ClearDepth}
* @see @ref Feature::DepthTest, @fn_gl{ClearDepth}
* @requires_gl See setClearDepth(Float), which is available in OpenGL ES.
*/
static void setClearDepth(Double depth);
@ -253,7 +253,7 @@ class MAGNUM_EXPORT Renderer {
/**
* @overload
*
* @see @ref Feature "Feature::DepthTest", @fn_gl{ClearDepth}
* @see @ref Feature::DepthTest, @fn_gl{ClearDepth}
* If OpenGL ES, OpenGL 4.1 or extension @extension{ARB,ES2_compatibility}
* is not available, this function behaves exactly as setClearDepth(Double).
*/
@ -265,7 +265,7 @@ class MAGNUM_EXPORT Renderer {
* @brief Set clear stencil
*
* Initial value is `0`.
* @see @ref Feature "Feature::StencilTest", @fn_gl{ClearStencil}
* @see @ref Feature::StencilTest, @fn_gl{ClearStencil}
*/
static void setClearStencil(Int stencil);
@ -278,7 +278,7 @@ class MAGNUM_EXPORT Renderer {
*
* @see setFrontFace()
*/
enum FrontFace: GLenum {
enum class FrontFace: GLenum {
/** @brief Counterclockwise polygons are front facing (default). */
CounterClockWise = GL_CCW,
@ -297,9 +297,9 @@ class MAGNUM_EXPORT Renderer {
/**
* @brief Which polygon facing to cull
*
* Initial value is @ref PolygonFacing "PolygonFacing::Back". If set to
* both front and back, only points and lines are drawn.
* @see @ref Feature "Feature::FaceCulling", setFrontFace(),
* Initial value is @ref PolygonFacing::Back. If set to both front and
* back, only points and lines are drawn.
* @see @ref Feature::FaceCulling, setFrontFace(),
* @fn_gl{CullFace}
*/
static void setFaceCullingMode(PolygonFacing mode);
@ -326,7 +326,7 @@ class MAGNUM_EXPORT Renderer {
/**
* @brief Set provoking vertex
*
* Initial value is @ref ProvokingVertex "ProvokingVertex::LastVertexConvention".
* Initial value is @ref ProvokingVertex::LastVertexConvention.
* @see @fn_gl{ProvokingVertex}
* @requires_gl32 %Extension @extension{ARB,provoking_vertex}. Older
* versions behave always like the default.
@ -363,7 +363,7 @@ class MAGNUM_EXPORT Renderer {
/**
* @brief Set polygon drawing mode
*
* Initial value is @ref PolygonMode "PolygonMode::Fill".
* Initial value is @ref PolygonMode::Fill.
* @see @fn_gl{PolygonMode}
* @requires_gl OpenGL ES behaves always like the default. See
* @ref Magnum::Mesh::setPrimitive() "Mesh::setPrimitive()" for
@ -377,10 +377,8 @@ class MAGNUM_EXPORT Renderer {
* @param factor Scale factor
* @param units Offset units
*
* @see @ref Feature "Feature::PolygonOffsetFill",
* @ref Feature "Feature::PolygonOffsetLine",
* @ref Feature "Feature::PolygonOffsetPoint",
* @fn_gl{PolygonOffset}
* @see @ref Feature::PolygonOffsetFill, @ref Feature::PolygonOffsetLine,
* @ref Feature::PolygonOffsetPoint, @fn_gl{PolygonOffset}
*/
static void setPolygonOffset(Float factor, Float units);
@ -397,7 +395,7 @@ class MAGNUM_EXPORT Renderer {
* @brief Set point size
*
* Initial value is `1.0f`.
* @see @ref Feature "Feature::ProgramPointSize", @fn_gl{PointSize}
* @see @ref Feature::ProgramPointSize, @fn_gl{PointSize}
* @requires_gl In OpenGL ES use `gl_PointSize` builtin vertex shader
* variable.
*/
@ -411,7 +409,7 @@ class MAGNUM_EXPORT Renderer {
/**
* @brief Set scissor rectangle
*
* @see @ref Feature "Feature::ScissorTest", @fn_gl{Scissor}
* @see @ref Feature::ScissorTest, @fn_gl{Scissor}
*/
static void setScissor(const Rectanglei& rectangle);
@ -484,24 +482,22 @@ class MAGNUM_EXPORT Renderer {
* @brief Set stencil function
* @param facing Affected polygon facing
* @param function Stencil function. Initial value is
* @ref StencilFunction "StencilFunction::Always".
* @ref StencilFunction::Always.
* @param referenceValue Reference value. Initial value is `0`.
* @param mask Mask for both reference and buffer value.
* Initial value is all `1`s.
*
* @see @ref Feature "Feature::StencilTest",
* setStencilFunction(StencilFunction, Int, UnsignedInt),
* setStencilOperation(),
* @fn_gl{StencilFuncSeparate}
* @see @ref Feature::StencilTest, @ref setStencilFunction(StencilFunction, Int, UnsignedInt),
* @ref setStencilOperation(), @fn_gl{StencilFuncSeparate}
*/
static void setStencilFunction(PolygonFacing facing, StencilFunction function, Int referenceValue, UnsignedInt mask);
/**
* @brief Set stencil function
*
* The same as setStencilFunction(PolygonFacing, StencilFunction, Int, UnsignedInt)
* with @p facing set to @ref PolygonFacing "PolygonFacing::FrontAndBack".
* @see @ref Feature "Feature::StencilTest", setStencilOperation(),
* The same as @ref setStencilFunction(PolygonFacing, StencilFunction, Int, UnsignedInt)
* with @p facing set to @ref PolygonFacing::FrontAndBack.
* @see @ref Feature::StencilTest, @ref setStencilOperation(),
* @fn_gl{StencilFunc}
*/
static void setStencilFunction(StencilFunction function, Int referenceValue, UnsignedInt mask);
@ -515,19 +511,18 @@ class MAGNUM_EXPORT Renderer {
* @param depthPass Action when both stencil and depth test
* pass
*
* Initial value for all fields is @ref StencilOperation "StencilOperation::Keep".
* @see @ref Feature "Feature::StencilTest",
* setStencilOperation(StencilOperation, StencilOperation, StencilOperation),
* setStencilFunction(), @fn_gl{StencilOpSeparate}
* Initial value for all fields is @ref StencilOperation::Keep.
* @see @ref Feature::StencilTest, @ref setStencilOperation(StencilOperation, StencilOperation, StencilOperation),
* @ref setStencilFunction(), @fn_gl{StencilOpSeparate}
*/
static void setStencilOperation(PolygonFacing facing, StencilOperation stencilFail, StencilOperation depthFail, StencilOperation depthPass);
/**
* @brief Set stencil operation
*
* The same as setStencilOperation(PolygonFacing, StencilOperation, StencilOperation, StencilOperation)
* with @p facing set to @ref PolygonFacing "PolygonFacing::FrontAndBack".
* @see @ref Feature "Feature::StencilTest", setStencilFunction(),
* The same as @ref setStencilOperation(PolygonFacing, StencilOperation, StencilOperation, StencilOperation)
* with @p facing set to @ref PolygonFacing::FrontAndBack.
* @see @ref Feature::StencilTest, @ref setStencilFunction(),
* @fn_gl{StencilOp}
*/
static void setStencilOperation(StencilOperation stencilFail, StencilOperation depthFail, StencilOperation depthPass);
@ -546,8 +541,8 @@ class MAGNUM_EXPORT Renderer {
/**
* @brief Set depth function
*
* Initial value is @ref DepthFunction "DepthFunction::Less".
* @see @ref Feature "Feature::DepthTest", @fn_gl{DepthFunc}
* Initial value is @ref DepthFunction::Less.
* @see @ref Feature::DepthTest, @fn_gl{DepthFunc}
*/
static void setDepthFunction(DepthFunction function);
@ -560,7 +555,7 @@ class MAGNUM_EXPORT Renderer {
*
* Set to `false` to disallow writing to given color channel. Initial
* values are all `true`.
* @see setDepthMask(), setStencilMask(), @fn_gl{ColorMask}
* @see @ref setDepthMask(), @ref setStencilMask(), @fn_gl{ColorMask}
* @todo Masking only given draw buffer
*/
static void setColorMask(GLboolean allowRed, GLboolean allowGreen, GLboolean allowBlue, GLboolean allowAlpha);
@ -587,8 +582,8 @@ class MAGNUM_EXPORT Renderer {
/**
* @brief Mask stencil writes
*
* The same as calling setStencilMask(PolygonFacing, UnsignedInt) with
* `facing` set to @ref PolygonFacing "PolygonFacing::FrontAndBack".
* The same as calling @ref setStencilMask(PolygonFacing, UnsignedInt)
* with `facing` set to @ref PolygonFacing::FrontAndBack.
* @see @fn_gl{StencilMask}
*/
static void setStencilMask(UnsignedInt allowBits);
@ -760,53 +755,52 @@ class MAGNUM_EXPORT Renderer {
* @brief Set blend equation
*
* How to combine source color (pixel value) with destination color
* (framebuffer). Initial value is @ref BlendEquation "BlendEquation::Add".
* @see @ref Feature "Feature::Blending", setBlendEquation(BlendEquation, BlendEquation),
* setBlendFunction(), setBlendColor(), @fn_gl{BlendEquation}
* (framebuffer). Initial value is @ref BlendEquation::Add.
* @see @ref Feature::Blending, @ref setBlendEquation(BlendEquation, BlendEquation),
* @ref setBlendFunction(), @ref setBlendColor(),
* @fn_gl{BlendEquation}
*/
static void setBlendEquation(BlendEquation equation);
/**
* @brief Set blend equation separately for RGB and alpha components
*
* See setBlendEquation(BlendEquation) for more information.
* @see @ref Feature "Feature::Blending", setBlendFunction(),
* setBlendColor(), @fn_gl{BlendEquationSeparate}
* See @ref setBlendEquation(BlendEquation) for more information.
* @see @ref Feature::Blending, @ref setBlendFunction(),
* @ref setBlendColor(), @fn_gl{BlendEquationSeparate}
*/
static void setBlendEquation(BlendEquation rgb, BlendEquation alpha);
/**
* @brief Set blend function
* @param source How the source blending factor is computed
* from pixel value. Initial value is @ref BlendFunction "BlendFunction::One".
* from pixel value. Initial value is @ref BlendFunction::One.
* @param destination How the destination blending factor is
* computed from framebuffer. Initial value is @ref BlendFunction "BlendFunction::Zero".
* computed from framebuffer. Initial value is @ref BlendFunction::Zero.
*
* @see @ref Feature "Feature::Blending",
* setBlendFunction(BlendFunction, BlendFunction, BlendFunction, BlendFunction),
* setBlendEquation(), setBlendColor(), @fn_gl{BlendFunc}
* @see @ref Feature::Blending, @ref setBlendFunction(BlendFunction, BlendFunction, BlendFunction, BlendFunction),
* @ref setBlendEquation(), @ref setBlendColor(),
* @fn_gl{BlendFunc}
*/
static void setBlendFunction(BlendFunction source, BlendFunction destination);
/**
* @brief Set blend function separately for RGB and alpha components
*
* See setBlendFunction(BlendFunction, BlendFunction) for more information.
* @see @ref Feature "Feature::Blending", setBlendEquation(),
* setBlendColor(), @fn_gl{BlendFuncSeparate}
* See @ref setBlendFunction(BlendFunction, BlendFunction) for more information.
* @see @ref Feature::Blending, @ref setBlendEquation(),
* @ref setBlendColor(), @fn_gl{BlendFuncSeparate}
*/
static void setBlendFunction(BlendFunction sourceRgb, BlendFunction destinationRgb, BlendFunction sourceAlpha, BlendFunction destinationAlpha);
/**
* @brief Set blend color
*
* Sets constant color used in setBlendFunction() by
* @ref BlendFunction "BlendFunction::ConstantColor",
* @ref BlendFunction "BlendFunction::OneMinusConstantColor",
* @ref BlendFunction "BlendFunction::ConstantAlpha" and
* @ref BlendFunction "BlendFunction::OneMinusConstantAlpha".
* @see @ref Feature "Feature::Blending", setBlendEquation(),
* setBlendFunction(), @fn_gl{BlendColor}
* Sets constant color used in @ref setBlendFunction() by
* @ref BlendFunction::ConstantColor, @ref BlendFunction::OneMinusConstantColor,
* @ref BlendFunction::ConstantAlpha and @ref BlendFunction::OneMinusConstantAlpha.
* @see @ref Feature::Blending, @ref setBlendEquation(),
* @ref setBlendFunction(), @fn_gl{BlendColor}
*/
static void setBlendColor(const Color4& color);
@ -818,7 +812,7 @@ class MAGNUM_EXPORT Renderer {
/**
* @brief Logical operation
*
* @see setLogicOperation()
* @see @ref setLogicOperation()
* @requires_gl Logical operations on framebuffer are not available in
* OpenGL ES.
*/
@ -844,7 +838,7 @@ class MAGNUM_EXPORT Renderer {
/**
* @brief Set logical operation
*
* @see @ref Feature "Feature::LogicOperation", @fn_gl{LogicOp}
* @see @ref Feature::LogicOperation, @fn_gl{LogicOp}
* @requires_gl Logical operations on framebuffer are not available in
* OpenGL ES.
*/
@ -927,8 +921,8 @@ class MAGNUM_EXPORT Renderer {
* @brief Error status
*
* Returns error flag, if any set. If there aren't any more error
* flags, returns @ref Error "Error::NoError". Thus this function
* should be always called in a loop until it returns @ref Error "Error::NoError".
* flags, returns @ref Error::NoError. Thus this function should be
* always called in a loop until it returns @ref Error::NoError.
* @see @fn_gl{GetError}
*/
static Error error() { return static_cast<Error>(glGetError()); }
@ -943,8 +937,8 @@ class MAGNUM_EXPORT Renderer {
*/
enum class ResetNotificationStrategy: GLint {
/**
* No reset notification, thus graphicsResetStatus() will always
* return @ref GraphicsResetStatus "GraphicsResetStatus::NoError".
* No reset notification, thus @ref graphicsResetStatus() will
* always return @ref GraphicsResetStatus::NoError.
* However this doesn't mean that the context cannot be lost.
*/
#ifndef MAGNUM_TARGET_GLES
@ -955,7 +949,7 @@ class MAGNUM_EXPORT Renderer {
/**
* Graphics reset will result in context loss, cause of the reset
* can be queried with graphicsResetStatus().
* can be queried with @ref graphicsResetStatus().
*/
#ifndef MAGNUM_TARGET_GLES
LoseContextOnReset = GL_LOSE_CONTEXT_ON_RESET_ARB
@ -970,7 +964,7 @@ class MAGNUM_EXPORT Renderer {
* The result is cached, repeated queries don't result in repeated
* OpenGL calls. If OpenGL extension @extension{ARB,robustness} or ES
* extension @es_extension{EXT,robustness} is not available, this
* function always returns @ref ResetNotificationStrategy "ResetNotificationStrategy::NoResetNotification".
* function always returns @ref ResetNotificationStrategy::NoResetNotification.
* @see graphicsResetStatus(), @fn_gl{Get} with @def_gl{RESET_NOTIFICATION_STRATEGY_ARB}
*/
static ResetNotificationStrategy resetNotificationStrategy();
@ -1013,9 +1007,8 @@ class MAGNUM_EXPORT Renderer {
*
* Reset causes all context state to be lost. If OpenGL extension
* @extension{ARB,robustness} or ES extension @es_extension{EXT,robustness}
* is not available, this function always returns
* @ref GraphicsResetStatus "GraphicsResetStatus::NoError".
* @see resetNotificationStrategy(), @fn_gl_extension{GetGraphicsResetStatus,ARB,robustness}
* is not available, this function always returns @ref GraphicsResetStatus::NoError.
* @see @ref resetNotificationStrategy(), @fn_gl_extension{GetGraphicsResetStatus,ARB,robustness}
*/
static GraphicsResetStatus graphicsResetStatus() {
return graphicsResetStatusImplementation();

6
src/Resource.h

@ -169,9 +169,9 @@ class Resource {
* @brief Whether the resource is available
*
* Returns `false` when resource is not loaded and no fallback is
* available (i.e. state() is either @ref ResourceState "ResourceState::NotLoaded",
* @ref ResourceState "ResourceState::Loading" or
* @ref ResourceState "ResourceState::NotFound"), true otherwise.
* available (i.e. state() is either @ref ResourceState::NotLoaded,
* @ref ResourceState::Loading or @ref ResourceState::NotFound), `true`
* otherwise.
*/
operator bool() {
acquire();

4
src/ResourceManager.h

@ -322,8 +322,8 @@ template<class... Types> class ResourceManager: private Implementation::Resource
* @brief Set resource data
* @return Reference to self (for method chaining)
*
* Same as above with state set to @ref ResourceDataState "ResourceDataState::Final"
* and policy to @ref ResourcePolicy "ResourcePolicy::Resident".
* Same as above with state set to @ref ResourceDataState::Final and
* policy to @ref ResourcePolicy::Resident.
*/
template<class T> ResourceManager<Types...>& set(ResourceKey key, T* data) {
return set(key, data, ResourceDataState::Final, ResourcePolicy::Resident);

16
src/SceneGraph/AbstractFeature.h

@ -267,23 +267,21 @@ template<UnsignedInt dimensions, class T> class MAGNUM_SCENEGRAPH_EXPORT Abstrac
/**
* @brief Clean data based on absolute transformation
*
* When object is cleaned and
* @ref CachedTransformation "CachedTransformation::Absolute" is
* enabled in setCachedTransformations(), this function is called to
* recalculate data based on absolute object transformation.
* When object is cleaned and @ref CachedTransformation::Absolute is
* enabled in @ref setCachedTransformations(), this function is called
* to recalculate data based on absolute object transformation.
*
* Default implementation does nothing.
* @see @ref scenegraph-caching, cleanInverted()
* @see @ref scenegraph-caching, @ref cleanInverted()
*/
virtual void clean(const typename DimensionTraits<dimensions, T>::MatrixType& absoluteTransformationMatrix);
/**
* @brief Clean data based on inverted absolute transformation
*
* When object is cleaned and
* @ref CachedTransformation "CachedTransformation::InvertedAbsolute"
* is enabled in setCachedTransformations(), this function is called
* to recalculate data based on inverted absolute object
* When object is cleaned and @ref CachedTransformation::InvertedAbsolute
* is enabled in @ref setCachedTransformations(), this function is
* called to recalculate data based on inverted absolute object
* transformation.
*
* Default implementation does nothing.

89
src/SceneGraph/Animable.h

@ -42,13 +42,13 @@ namespace Magnum { namespace SceneGraph {
enum class AnimationState: UnsignedByte {
/**
* The animation is stopped. The animation will be started from the
* beginning when state is changed to @ref AnimationState "AnimationState::Running".
* beginning when state is changed to @ref AnimationState::Running.
*/
Stopped,
/**
* The animation is stopped. The animation will continue from paused
* position when state is changed to @ref AnimationState "AnimationState::Running".
* position when state is changed to @ref AnimationState::Running.
*/
Paused,
@ -121,11 +121,11 @@ void MyApplication::drawEvent() {
@section Animable-performance Using animable groups to improve performance
AnimableGroup is optimized for case when no animation is running - it just
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
@ref AnimationState "AnimationState::Running" again. If you put animations
which are not pernamently running to separate group, they will not be always
traversed when calling AnimableGroup::step(), saving precious frame time.
@ref AnimationState::Running again. If you put animations which are not
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
@ -167,12 +167,12 @@ template<UnsignedInt dimensions, class T> class MAGNUM_SCENEGRAPH_EXPORT Animabl
* @brief Set animation state
* @return Reference to self (for method chaining)
*
* Note that changing state from @ref AnimationState "AnimationState::Stopped"
* to @ref AnimationState "AnimationState::Paused" is ignored and
* animation remains in @ref AnimationState "AnimationState::Stopped"
* state. See also animationStep() for more information.
* @see animationStarted(), animationPaused(), animationResumed(),
* animationStopped()
* Note that changing state from @ref AnimationState::Stopped to
* @ref AnimationState::Paused is ignored and animation remains in
* @ref AnimationState::Stopped state. See also @ref animationStep()
* for more information.
* @see @ref animationStarted(), @ref animationPaused(),
* @ref animationResumed(), @ref animationStopped()
*/
Animable<dimensions, T>& setState(AnimationState state);
@ -242,78 +242,69 @@ template<UnsignedInt dimensions, class T> class MAGNUM_SCENEGRAPH_EXPORT Animabl
* @param time Time from start of the animation
* @param delta Time delta for current frame
*
* This function is periodically called from AnimableGroup::step() if
* the animation state is set to @ref AnimationState "AnimationState::Running".
* After animation duration is exceeded and repeat is not enabled or
* repeat count is exceeded, the animation state is set to
* @ref AnimationState "AnimationState::Stopped".
* This function is periodically called from @ref AnimableGroup::step()
* if the animation state is set to @ref AnimationState::Running. After
* animation duration is exceeded and repeat is not enabled or repeat
* count is exceeded, the animation state is set to @ref AnimationState::Stopped.
*
* If the animation is resumed from @ref AnimationState "AnimationState::Paused",
* this function is called with @p time continuing from the point
* when it was paused. If the animation is resumed from
* @ref AnimationState "AnimationState::Stopped", @p time starts with
* zero.
* If the animation is resumed from @ref AnimationState::Paused, this
* function is called with @p time continuing from the point when it
* was paused. If the animation is resumed from @ref AnimationState::Stopped,
* @p time starts with zero.
*
* @see state(), duration(), isRepeated(), repeatCount()
* @see @ref state(), @ref duration(), @ref isRepeated(),
* @ref repeatCount()
*/
virtual void animationStep(Float time, Float delta) = 0;
/**
* @brief Action on animation start
*
* Called from AnimableGroup::step() when state is changed from
* @ref AnimationState "AnimationState::Stopped" to
* @ref AnimationState "AnimationState::Running" and before first
* animationStep() is called.
* Called from @ref AnimableGroup::step() when state is changed from
* @ref AnimationState::Stopped to @ref AnimationState::Running and
* before first @ref animationStep() is called.
*
* Default implementation does nothing.
*
* @see setState()
* @see @ref setState()
*/
virtual void animationStarted() {}
/**
* @brief Action on animation pause
*
* Called from AnimableGroup::step() when state changes from
* @ref AnimationState "AnimationState::Running" to
* @ref AnimationState "AnimationState::Paused" and after last
* animationStep() is called.
* Called from @ref AnimableGroup::step() when state changes from
* @ref AnimationState::Running to @ref AnimationState::Paused and
* after last @ref animationStep() is called.
*
* Default implementation does nothing.
*
* @see setState()
* @see @ref setState()
*/
virtual void animationPaused() {}
/**
* @brief Action on animation resume
*
* Called from AnimableGroup::step() when state changes from
* @ref AnimationState "AnimationState::Paused" to
* @ref AnimationState "AnimationState::Running" and before first
* animationStep() is called.
* Called from @ref AnimableGroup::step() when state changes from
* @ref AnimationState::Paused to @ref AnimationState::Running and
* before first @ref animationStep() is called.
*
* Default implementation does nothing.
*
* @see setState()
* @see @ref setState()
*/
virtual void animationResumed() {}
/**
* @brief Action on animation stop
*
* Called from AnimableGroup::step() when state changes from either
* @ref AnimationState "AnimationState::Running" or
* @ref AnimationState "AnimationState::Paused" to
* @ref AnimationState "AnimationState::Stopped" and after last
* animationStep() is called.
* Called from @ref AnimableGroup::step() when state changes from
* either @ref AnimationState::Running or @ref AnimationState::Paused
* to @ref AnimationState::Stopped and after last @ref animationStep()
* is called.
*
* You may want to use this function to properly finish the animation
* in case the framerate is not high enough to have animationStep()
* in case the framerate is not high enough to have @ref animationStep()
* called enough times. Default implementation does nothing.
*
* @see setState()
* @see @ref setState()
*/
virtual void animationStopped() {}

3
src/SceneGraph/SceneGraph.h

@ -34,8 +34,6 @@
namespace Magnum { namespace SceneGraph {
/** @todoc remove when doxygen is sane again */
#ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef CORRADE_GCC45_COMPATIBILITY
enum class AspectRatioPolicy: UnsignedByte;
#endif
@ -187,7 +185,6 @@ typedef BasicRigidMatrixTransformation2D<Float> RigidMatrixTransformation2D;
typedef BasicRigidMatrixTransformation3D<Float> RigidMatrixTransformation3D;
template<class Transformation> class Scene;
#endif
}}

26
src/Shaders/MeshVisualizer.h

@ -45,15 +45,15 @@ to be able to render.
@section ShadersMeshVisualizer-wireframe Wireframe visualization
Wireframe visualization is done by enabling @ref Flag "Flag::Wireframe". It is
done either using geometry shaders or with help of additional vertex information.
Wireframe visualization is done by enabling @ref Flag::Wireframe. It is done
either using geometry shaders or with help of additional vertex information.
If you have geometry shaders available, you don't need to do anything else.
@requires_gl32 %Extension @extension{ARB,geometry_shader4} for wireframe
rendering using geometry shaders.
If you don't have geometry shaders, you need to set @ref Flag "Flag::NoGeometryShader"
If you don't have geometry shaders, you need to set @ref Flag::NoGeometryShader
(it's enabled by default in OpenGL ES) and use only **non-indexed** triangle
meshes (see MeshTools::duplicate() for possible solution). Additionaly, if you
have OpenGL < 3.1 or OpenGL ES 2.0, you need to provide also @ref VertexIndex
@ -71,7 +71,7 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer: public AbstractShaderProgram {
/**
* @brief Vertex index
*
* Used only in OpenGL < 3.1 and OpenGL ES 2.0 if @ref Flag "Flag::Wireframe"
* Used only in OpenGL < 3.1 and OpenGL ES 2.0 if @ref Flag::Wireframe
* is enabled. This attribute specifies index of given vertex in
* triangle, i.e. `0` for first, `1` for second, `2` for third. In
* OpenGL 3.1, OpenGL ES 3.0 and newer this value is provided by the
@ -87,7 +87,7 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer: public AbstractShaderProgram {
enum class Flag: UnsignedByte {
/**
* Visualize wireframe. On OpenGL ES this also enables
* @ref Flag "Flag::NoGeometryShader".
* @ref Flag::NoGeometryShader.
*/
#ifndef MAGNUM_TARGET_GLES
Wireframe = 1 << 0,
@ -98,7 +98,7 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer: public AbstractShaderProgram {
/**
* Don't use geometry shader for wireframe visualization. If
* enabled, you might need to provide also VertexIndex attribute in
* the mesh. In OpenGL ES enabled alongside @ref Flag "Flag::Wireframe".
* the mesh. In OpenGL ES enabled alongside @ref Flag::Wireframe.
*/
NoGeometryShader = 1 << 1
};
@ -125,8 +125,8 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer: public AbstractShaderProgram {
* @brief Set viewport size
* @return Reference to self (for method chaining)
*
* Has effect only if @ref Flag "Flag::Wireframe" is enabled and
* geometry shaders are used.
* Has effect only if @ref Flag::Wireframe is enabled and geometry
* shaders are used.
*/
MeshVisualizer& setViewportSize(const Vector2& size) {
if(flags & Flag::Wireframe && !(flags & Flag::NoGeometryShader))
@ -150,7 +150,7 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer: public AbstractShaderProgram {
* @return Reference to self (for method chaining)
*
* Initial value is fully opaque black. Has effect only if
* @ref Flag "Flag::Wireframe" is enabled.
* @ref Flag::Wireframe is enabled.
*/
MeshVisualizer& setWireframeColor(const Color4& color) {
if(flags & Flag::Wireframe) setUniform(wireframeColorUniform, color);
@ -161,8 +161,8 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer: public AbstractShaderProgram {
* @brief Set wireframe width
* @return Reference to self (for method chaining)
*
* Initial value is `1.0f`. Has effect only if
* @ref Flag "Flag::Wireframe" is enabled.
* Initial value is `1.0f`. Has effect only if @ref Flag::Wireframe is
* enabled.
*/
MeshVisualizer& setWireframeWidth(Float width) {
if(flags & Flag::Wireframe) setUniform(wireframeWidthUniform, width);
@ -173,8 +173,8 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer: public AbstractShaderProgram {
* @brief Set line smoothness
* @return Reference to self (for method chaining)
*
* Initial value is `2.0f`. Has effect only if
* @ref Flag "Flag::Wireframe" is enabled.
* Initial value is `2.0f`. Has effect only if @ref Flag::Wireframe is
* enabled.
*/
MeshVisualizer& setSmoothness(Float smoothness);

17
src/Shaders/Phong.h

@ -64,27 +64,26 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram {
/**
* @brief Texture coordinates
*
* Used only if one of @ref Flag "Flag::AmbientTexture",
* @ref Flag "Flag::DiffuseTexture" or @ref Flag "Flag::SpecularTexture"
* is set.
* Used only if one of @ref Flag::AmbientTexture, @ref Flag::DiffuseTexture
* or @ref Flag::SpecularTexture is set.
*/
typedef Attribute<2, Vector2> TextureCoordinates;
enum: Int {
/**
* Layer for ambient texture. Used only if @ref Flag "Flag::AmbientTexture"
* Layer for ambient texture. Used only if @ref Flag::AmbientTexture
* is set.
*/
AmbientTextureLayer = 0,
/**
* Layer for diffuse texture. Used only if @ref Flag "Flag::DiffuseTexture"
* Layer for diffuse texture. Used only if @ref Flag::DiffuseTexture
* is set.
*/
DiffuseTextureLayer = 1,
/**
* Layer for specular texture. Used only if @ref Flag "Flag::SpecularTexture"
* Layer for specular texture. Used only if @ref Flag::SpecularTexture
* is set.
*/
SpecularTextureLayer = 2
@ -122,7 +121,7 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram {
* @return Reference to self (for method chaining)
*
* If not set, default value is `(0.0f, 0.0f, 0.0f)`. Has no effect if
* @ref Flag "Flag::AmbientTexture" is set.
* @ref Flag::AmbientTexture is set.
*/
Phong& setAmbientColor(const Color3& color);
@ -130,7 +129,7 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram {
* @brief Set diffuse color
* @return Reference to self (for method chaining)
*
* Has no effect if @ref Flag "Flag::AmbientTexture" is used.
* Has no effect if @ref Flag::AmbientTexture is used.
*/
Phong& setDiffuseColor(const Color3& color);
@ -139,7 +138,7 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram {
* @return Reference to self (for method chaining)
*
* If not set, default value is `(1.0f, 1.0f, 1.0f)`. Has no effect if
* @ref Flag "Flag::SpecularTexture" is set.
* @ref Flag::SpecularTexture is set.
*/
Phong& setSpecularColor(const Color3& color);

4
src/Shaders/Shaders.h

@ -32,9 +32,6 @@
namespace Magnum { namespace Shaders {
/** @todoc remove when doxygen is sane again */
#ifndef DOXYGEN_GENERATING_OUTPUT
template<UnsignedInt> class DistanceFieldVector;
typedef DistanceFieldVector<2> DistanceFieldVector2D;
typedef DistanceFieldVector<3> DistanceFieldVector3D;
@ -57,7 +54,6 @@ typedef Vector<3> Vector3D;
template<UnsignedInt> class VertexColor;
typedef VertexColor<2> VertexColor2D;
typedef VertexColor<3> VertexColor3D;
#endif
}}

3
src/Shapes/Shapes.h

@ -32,8 +32,6 @@
namespace Magnum { namespace Shapes {
/** @todoc remove when doxygen is sane again */
#ifndef DOXYGEN_GENERATING_OUTPUT
template<UnsignedInt> class AbstractShape;
typedef AbstractShape<2> AbstractShape2D;
typedef AbstractShape<3> AbstractShape3D;
@ -75,7 +73,6 @@ typedef ShapeGroup<3> ShapeGroup3D;
template<UnsignedInt> class Sphere;
typedef Sphere<2> Sphere2D;
typedef Sphere<3> Sphere3D;
#endif
class Plane;

5
src/Text/AbstractFont.cpp

@ -100,7 +100,10 @@ void AbstractFont::doOpenFile(const std::string& filename, const Float size) {
}
void AbstractFont::close() {
if(isOpened()) doClose();
if(isOpened()) {
doClose();
CORRADE_INTERNAL_ASSERT(!isOpened());
}
}
UnsignedInt AbstractFont::glyphId(const char32_t character) {

41
src/Text/AbstractFont.h

@ -60,7 +60,7 @@ checked by the implementation:
after the previous file was closed, function doClose() is called only if
there is any file opened.
- Functions doOpenData() and doOpenSingleData() are called only if
@ref Feature "Feature::OpenData" is supported.
@ref Feature::OpenData is supported.
- All `do*()` implementations working on opened file are called only if
there is any file opened.
*/
@ -112,8 +112,8 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
* @param size Font size
*
* Closes previous file, if it was opened, and tries to open given
* file. Available only if @ref Feature "Feature::OpenData" is
* supported. Returns `true` on success, `false` otherwise.
* file. Available only if @ref Feature::OpenData is supported. Returns
* `true` on success, `false` otherwise.
*/
bool openData(const std::vector<std::pair<std::string, Containers::ArrayReference<const unsigned char>>>& data, Float size);
@ -123,9 +123,9 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
* @param size Font size
*
* Closes previous file, if it was opened, and tries to open given
* file. Available only if @ref Feature "Feature::OpenData" is
* supported and the plugin doesn't have @ref Feature "Feature::MultiFile".
* Returns `true` on success, `false` otherwise.
* file. Available only if @ref Feature::OpenData is supported and the
* plugin doesn't have @ref Feature::MultiFile. Returns `true` on
* success, `false` otherwise.
*/
bool openSingleData(Containers::ArrayReference<const unsigned char> data, Float size);
@ -135,10 +135,10 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
* @param size Font size
*
* Closes previous file, if it was opened, and tries to open given
* file. If the plugin has @ref Feature "Feature::MultiFile", the
* function will use additional files in given path, all sharing common
* basename derived from @p filename. Returns `true` on success,
* `false` otherwise.
* file. If the plugin has @ref Feature::MultiFile, the function will
* use additional files in given path, all sharing common basename
* derived from @p filename. Returns `true` on success, `false`
* otherwise.
*/
bool openFile(const std::string& filename, Float size);
@ -172,8 +172,8 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
* @param characters UTF-8 characters to render
*
* Fills the cache with given characters. Fonts having
* @ref Feature "Feature::PreparedGlyphCache" do not support partial
* glyph cache filling, use createGlyphCache() instead.
* @ref Feature::PreparedGlyphCache do not support partial glyph cache
* filling, use @ref createGlyphCache() instead.
*/
void fillGlyphCache(GlyphCache& cache, const std::string& characters);
@ -181,9 +181,9 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
* @brief Create glyph cache
*
* Configures and fills glyph cache with the contents of whole font.
* Available only if @ref Feature "Feature::PreparedGlyphCache" is
* supported. Other fonts support only partial glyph cache filling,
* see fillGlyphCache().
* Available only if @ref Feature::PreparedGlyphCache is supported.
* Other fonts support only partial glyph cache filling, see
* @ref fillGlyphCache().
*/
GlyphCache* createGlyphCache();
@ -218,8 +218,8 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
/**
* @brief Implementation for openData()
*
* If the plugin doesn't have @ref Feature "Feature::MultiFile",
* default implementation calls doOpenSingleData().
* If the plugin doesn't have @ref Feature::MultiFile, default
* implementation calls @ref doOpenSingleData().
*/
virtual void doOpenData(const std::vector<std::pair<std::string, Containers::ArrayReference<const unsigned char>>>& data, Float size);
@ -229,10 +229,9 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin {
/**
* @brief Implementation for openFile()
*
* If @ref Feature "Feature::OpenData" is supported and the plugin
* doesn't have @ref Feature "Feature::MultiFile", default
* implementation opens the file and calls doOpenSingleData() with its
* contents.
* If @ref Feature::OpenData is supported and the plugin doesn't have
* @ref Feature::MultiFile, default implementation opens the file and
* calls @ref doOpenSingleData() with its contents.
*/
virtual void doOpenFile(const std::string& filename, Float size);

204
src/Text/AbstractFontConverter.h

@ -50,13 +50,13 @@ exporting functions are converted to list of unique UTF-32 characters.
You don't need to do most of the redundant sanity checks, these things are
checked by the implementation:
- Functions `doExportFontTo*()` are called only if @ref Feature "Feature::ExportFont"
- Functions `doExportFontTo*()` are called only if @ref Feature::ExportFont
is supported, functions `doExportGlyphCacheTo*()` are called only if
@ref Feature "Feature::ExportGlyphCache" is supported.
@ref Feature::ExportGlyphCache is supported.
- Functions `doImportGlyphCacheFrom*()` are called only if
@ref Feature "Feature::ImportGlyphCache" is supported.
@ref Feature::ImportGlyphCache is supported.
- Functions `doExport*To*Data()` and `doImport*From*Data()` are called only
if @ref Feature "Feature::ConvertData" is supported.
if @ref Feature::ConvertData is supported.
- Function `doImport*FromData()` is called only if there is at least one data
array passed.
*/
@ -67,33 +67,42 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
/**
* @brief Features supported by this converter
*
* @see Features, features()
* @see @ref Features, @ref features()
*/
enum class Feature: UnsignedByte {
/**
* Exporting font using exportToFile() or exportToData()
* @see @ref Feature "Feature::ConvertData"
* Exporting font using @ref exportFontToFile(), @ref exportFontToData()
* or @ref exportFontToSingleData()
* @see @ref Feature::ConvertData
*/
ExportFont = 1 << 0,
/**
* Export glyph cache using exportToFile() or exportToData()
* @see @ref Feature "Feature::ConvertData"
* Export glyph cache using @ref exportGlyphCacheToFile(),
* @ref exportGlyphCacheToData() or @ref exportGlyphCacheToSingleData()
* @see @ref Feature::ConvertData
*/
ExportGlyphCache = 1 << 1,
/**
* Import glyph cache using importFromFile() or importFromData()
* @see @ref Feature "Feature::ConvertData"
* Import glyph cache using @ref importGlyphCacheFromFile(),
* @ref importGlyphCacheFromData() or @ref importGlyphCacheFromSingleData()
* @see @ref Feature::ConvertData
*/
ImportGlyphCache = 1 << 2,
/** Convert from/to data using exportToData() or importFromData() */
/**
* Convert from/to data using @ref exportFontToData(),
* @ref exportFontToSingleData(), @ref exportGlyphCacheToData(),
* @ref exportGlyphCacheToSingleData(), @ref importGlyphCacheFromData()
* or @ref importGlyphCacheFromSingleData()
*/
ConvertData = 1 << 4,
/**
* The format is multi-file, thus exportToSingleData() and
* importFromSingleData() convenience functions cannot be used.
* The format is multi-file, thus @ref exportFontToSingleData(),
* @ref exportGlyphCacheToSingleData() and @ref importGlyphCacheFromSingleData()
* convenience functions cannot be used.
*/
MultiFile = 1 << 5
};
@ -121,38 +130,39 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
* @param filename Output filename
* @param characters Characters to export
*
* Available only if @ref Feature "Feature::ConvertData" and
* @ref Feature "Feature::ExportFont" is supported. Returns pairs of
* filename and data on success, empty vector otherwise. All data will
* be sharing common basename derived from @p filename. If the plugin
* doesn't have @ref Feature "Feature::MultiFile", only one pair is
* returned, thus using exportFontToSingleData() might be more convenient
* in that case.
* @see features(), exportFontToFile(), exportGlyphCacheToData()
* Available only if @ref Feature::ConvertData and @ref Feature::ExportFont
* is supported. Returns pairs of filename and data on success, empty
* vector otherwise. All data will be sharing common basename derived
* from @p filename. If the plugin doesn't have @ref Feature::MultiFile,
* only one pair is returned, thus using @ref exportFontToSingleData()
* might be more convenient in that case.
* @see @ref features(), @ref exportFontToFile(),
* @ref exportGlyphCacheToData()
*/
std::vector<std::pair<std::string, Containers::Array<unsigned char>>> exportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::string& characters) const;
/**
* @brief Export font to single raw data
*
* Available only if @ref Feature "Feature::ConvertData" and
* @ref Feature "Feature::ExportFont" is supported and the plugin
* doesn't have @ref Feature "Feature::MultiFile". Returns data on
* success, zero-sized array otherwise. See exportFontToData() for
* more information.
* @see features(), exportFontToFile(), importFromSingleData()
* Available only if @ref Feature::ConvertData and @ref Feature::ExportFont
* is supported and the plugin doesn't have @ref Feature::MultiFile.
* Returns data on success, zero-sized array otherwise. See
* @ref exportFontToData() for more information.
* @see @ref features(), @ref exportFontToFile(),
* @ref exportGlyphCacheToSingleData()
*/
Containers::Array<unsigned char> exportFontToSingleData(AbstractFont& font, GlyphCache& cache, const std::string& characters) const;
/**
* @brief Export font to file
*
* Available only if @ref Feature "Feature::ExportFont" is supported.
* If the plugin has @ref Feature "Feature::MultiFile", the function
* will create more than one file in given path, all sharing common
* basename derived from @p filename. Returns `true` on success,
* `false` otherwise. See exportFontToData() for more information.
* @see features(), exportFontToData(), exportGlyphCacheToFile()
* Available only if @ref Feature::ExportFont is supported. If the
* plugin has @ref Feature::MultiFile, the function will create more
* than one file in given path, all sharing common basename derived
* from @p filename. Returns `true` on success, `false` otherwise. See
* @ref exportFontToData() for more information.
* @see @ref features(), @ref exportFontToData(),
* @ref exportGlyphCacheToFile()
*/
bool exportFontToFile(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::string& characters) const;
@ -161,41 +171,42 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
* @param cache Populated glyph cache
* @param filename Output filename
*
* Available only if @ref Feature "Feature::ConvertData" and
* @ref Feature "Feature::ExportGlyphCache" is supported. Returns pairs
* of filename and data on success, empty vector otherwise. All data
* will be sharing common basename derived from @p filename. If the
* plugin doesn't have @ref Feature "Feature::MultiFile", only one pair
* is returned, thus using exportGlyphCacheToSingleData() might be more
* convenient in that case.
* Available only if @ref Feature::ConvertData and @ref Feature::ExportGlyphCache
* is supported. Returns pairs of filename and data on success, empty
* vector otherwise. All data will be sharing common basename derived
* from @p filename. If the plugin doesn't have @ref Feature::MultiFile,
* only one pair is returned, thus using @ref exportGlyphCacheToSingleData()
* might be more convenient in that case.
*
* All glyphs from given cache will be exported. If you want to export
* smaller subset, fill the cache with less characters.
* @see features(), exportGlyphCacheToFile(), exportFontToData()
* @see @ref features(), @ref exportGlyphCacheToFile(),
* @ref exportFontToData()
*/
std::vector<std::pair<std::string, Containers::Array<unsigned char>>> exportGlyphCacheToData(GlyphCache& cache, const std::string& filename) const;
/**
* @brief Export glyph cache to single raw data
*
* Available only if @ref Feature "Feature::ConvertData" and
* @ref Feature "Feature::ExportGlyphCache" is supported and the plugin
* doesn't have @ref Feature "Feature::MultiFile". Returns data on
* success, zero-sized array otherwise. See exportGlyphCacheToData()
* for more information.
* @see features(), exportGlyphCacheToFile(), importGlyphCacheFromSingleData()
* Available only if @ref Feature::ConvertData and @ref Feature::ExportGlyphCache
* is supported and the plugin doesn't have @ref Feature::MultiFile.
* Returns data on success, zero-sized array otherwise. See
* @ref exportGlyphCacheToData() for more information.
* @see @ref features(), @ref exportGlyphCacheToFile(),
* @ref importGlyphCacheFromSingleData()
*/
Containers::Array<unsigned char> exportGlyphCacheToSingleData(GlyphCache& cache) const;
/**
* @brief Export glyph cache to file
*
* Available only if @ref Feature "Feature::ExportGlyphCache" is
* supported. If the plugin has @ref Feature "Feature::MultiFile", the
* function will create more than one file in given path, all sharing
* common basename derived from @p filename. Returns `true` on success,
* `false` otherwise.
* @see features(), exportGlyphCacheToData(), exportFontToFile()
* Available only if @ref Feature::ExportGlyphCache is supported. If
* the plugin has @ref Feature::MultiFile, the function will create
* more than one file in given path, all sharing common basename
* derived from @p filename. Returns `true` on success, `false`
* otherwise.
* @see @ref features(), @ref exportGlyphCacheToData(),
* @ref exportFontToFile()
*/
bool exportGlyphCacheToFile(GlyphCache& cache, const std::string& filename) const;
@ -203,37 +214,38 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
* @brief Import glyph cache from raw data
* @param data Pairs of filename and file data
*
* Available only if @ref Feature "Feature::ConvertData" and
* @ref Feature "Feature::ImportGlyphCache" is supported. Returns
* imported cache on success, `nullptr` otherwise. If the plugin
* doesn't have @ref Feature "Feature::MultiFile", only one file is
* needed, thus using convertToSingleData() might be more convenient in
* that case.
* @see features(), importFromFile(), exportToData()
* Available only if @ref Feature::ConvertData and @ref Feature::ImportGlyphCache
* is supported. Returns imported cache on success, `nullptr`
* otherwise. If the plugin doesn't have @ref Feature::MultiFile, only
* one file is needed, thus using @ref importGlyphCacheFromSingleData()
* might be more convenient in that case.
* @see @ref features(), @ref importGlyphCacheFromFile(),
* @ref exportGlyphCacheToData()
*/
GlyphCache* importGlyphCacheFromData(const std::vector<std::pair<std::string, Containers::ArrayReference<const unsigned char>>>& data) const;
/**
* @brief Import glyph cache from single raw data
*
* Available only if @ref Feature "Feature::ConvertData" and
* @ref Feature "Feature::ImportGlyphCache" is supported and the plugin
* doesn't have @ref Feature "Feature::MultiFile". Returns imported
* cache on success, `nullptr` otherwise. See importFromData() for
* multi-file conversion.
* @see features(), importFromFile(), exportToSingleData()
* Available only if @ref Feature::ConvertData and @ref Feature::ImportGlyphCache
* is supported and the plugin doesn't have @ref Feature::MultiFile.
* Returns imported cache on success, `nullptr` otherwise. See
* @ref importGlyphCacheFromData() for multi-file conversion.
* @see @ref features(), @ref importGlyphCacheFromFile(),
* @ref exportFontToSingleData()
*/
GlyphCache* importGlyphCacheFromSingleData(Containers::ArrayReference<const unsigned char> data) const;
/**
* @brief Import glyph cache from file
*
* Available only if @ref Feature "Feature::ImportGlyphCache" is
* supported. If the plugin has @ref Feature "Feature::MultiFile", the
* function will use additional files in given path, all sharing common
* basename derived from @p filename. Returns imported cache on
* success, `nullptr` otherwise.
* @see features(), importFromData(), exportToFile()
* Available only if @ref Feature::ImportGlyphCache is supported. If
* the plugin has @ref Feature::MultiFile, the function will use
* additional files in given path, all sharing common basename derived
* from @p filename. Returns imported cache on success, `nullptr`
* otherwise.
* @see @ref features(), @ref importGlyphCacheFromData(),
* @ref exportGlyphCacheToFile()
*/
GlyphCache* importGlyphCacheFromFile(const std::string& filename) const;
@ -242,14 +254,14 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
#else
protected:
#endif
/** @brief Implementation for features() */
/** @brief Implementation for @ref features() */
virtual Features doFeatures() const = 0;
/**
* @brief Implementation for exportFontToData()
* @brief Implementation for @ref exportFontToData()
*
* If the plugin doesn't have @ref Feature "Feature::MultiFile",
* default implementation calls doExportFontToSingleData().
* If the plugin doesn't have @ref Feature::MultiFile, default
* implementation calls @ref doExportFontToSingleData().
* @note On Windows uses `std::vector<char32_t>` instead of
* `std::u32string`. See @ref Corrade::Utility::Unicode::utf32()
* for more information.
@ -261,7 +273,7 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
#endif
/**
* @brief Implementation for exportFontToSingleData()
* @brief Implementation for @ref exportFontToSingleData()
*
* @note On Windows uses `std::vector<char32_t>` instead of
* `std::u32string`. See @ref Corrade::Utility::Unicode::utf32()
@ -274,11 +286,10 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
#endif
/**
* @brief Implementation for exportFontToFile()
* @brief Implementation for @ref exportFontToFile()
*
* If @ref Feature "Feature::ConvertData" is supported, default
* implementation calls doExportFontToData() and saves the result to
* given file(s).
* If @ref Feature::ConvertData is supported, default implementation
* calls doExportFontToData() and saves the result to given file(s).
* @note On Windows uses `std::vector<char32_t>` instead of
* `std::u32string`. See @ref Corrade::Utility::Unicode::utf32()
* for more information.
@ -290,10 +301,10 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
#endif
/**
* @brief Implementation for exportGlyphCacheToData()
* @brief Implementation for @ref exportGlyphCacheToData()
*
* If the plugin doesn't have @ref Feature "Feature::MultiFile",
* default implementation calls doExportGlyphCacheToSingleData().
* If the plugin doesn't have @ref Feature::MultiFile, default
* implementation calls @ref doExportGlyphCacheToSingleData().
*/
virtual std::vector<std::pair<std::string, Containers::Array<unsigned char>>> doExportGlyphCacheToData(GlyphCache& cache, const std::string& filename) const;
@ -301,19 +312,19 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
virtual Containers::Array<unsigned char> doExportGlyphCacheToSingleData(GlyphCache& cache) const;
/**
* @brief Implementation for exportGlyphCacheToFile()
* @brief Implementation for @ref exportGlyphCacheToFile()
*
* If @ref Feature "Feature::ConvertData" is supported, default
* implementation calls doExportGlyphCacheToData() and saves the result
* to given file(s).
* If @ref Feature::ConvertData is supported, default implementation
* calls @ref doExportGlyphCacheToData() and saves the result to given
* file(s).
*/
virtual bool doExportGlyphCacheToFile(GlyphCache& cache, const std::string& filename) const;
/**
* @brief Implementation for importGlyphCacheFromData()
* @brief Implementation for @ref importGlyphCacheFromData()
*
* If the plugin doesn't have @ref Feature "Feature::MultiFile",
* default implementation calls doImportGlyphCacheFromSingleData().
* If the plugin doesn't have @ref Feature::MultiFile, default
* implementation calls @ref doImportGlyphCacheFromSingleData().
*/
virtual GlyphCache* doImportGlyphCacheFromData(const std::vector<std::pair<std::string, Containers::ArrayReference<const unsigned char>>>& data) const;
@ -321,12 +332,11 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl
virtual GlyphCache* doImportGlyphCacheFromSingleData(Containers::ArrayReference<const unsigned char> data) const;
/**
* @brief Implementation for importGlyphCacheFromFile()
* @brief Implementation for @ref importGlyphCacheFromFile()
*
* If @ref Feature "Feature::ConvertData" is supported and the plugin
* doesn't have @ref Feature "Feature::MultiFile", default
* implementation opens the file and calls doImportGlyphCacheFromSingleData()
* with its contents.
* If @ref Feature::ConvertData is supported and the plugin doesn't
* have @ref Feature::MultiFile, default implementation opens the file
* and calls @ref doImportGlyphCacheFromSingleData() with its contents.
*/
virtual GlyphCache* doImportGlyphCacheFromFile(const std::string& filename) const;

2
src/Text/DistanceFieldGlyphCache.h

@ -65,7 +65,7 @@ class MAGNUM_TEXT_EXPORT DistanceFieldGlyphCache: public GlyphCache {
* parameters. Sets internal texture format to red channel only. On
* desktop OpenGL requires @extension{ARB,texture_rg} (also part of
* OpenGL ES 3.0), in ES2 uses @es_extension{EXT,texture_rg} if
* available or @ref TextureFormat "TextureFormat::RGB" as fallback.
* available or @ref TextureFormat::RGB as fallback.
* @todo Is Luminance format renderable anywhere? Also would it be
* possible to convert the RGB texture to Luminance after it has
* been rendered when blitting is not supported to save memory?

2
src/Text/GlyphCache.h

@ -87,7 +87,7 @@ class MAGNUM_TEXT_EXPORT GlyphCache {
* Sets internal texture format to red channel only. On desktop OpenGL
* requires @extension{ARB,texture_rg} (also part of OpenGL ES 3.0), in
* ES2 uses @es_extension{EXT,texture_rg}, if available, or
* @ref TextureFormat "TextureFormat::Luminance" as fallback.
* @ref TextureFormat::Luminance as fallback.
*/
explicit GlyphCache(const Vector2i& originalSize, const Vector2i& size, const Vector2i& padding = Vector2i());

24
src/Texture.h

@ -73,8 +73,9 @@ information about usage in shaders.
@section Texture-array Texture arrays
You can create texture arrays by passing @ref Target "Texture2D::Target::Texture1DArray"
or @ref Target "Texture3D::Target::Texture2DArray" to constructor.
You can create texture arrays by passing
@ref Target::Texture1DArray "Texture2D::Target::Texture1DArray" or
@ref Target::Texture2DArray "Texture3D::Target::Texture2DArray" to constructor.
It is possible to specify each layer separately using setSubImage(), but you
have to allocate the memory for all layers first either by calling setStorage()
@ -104,8 +105,10 @@ etc.).
@section Texture-multisample Multisample textures
You can create multisample textures by passing @ref Target "Texture2D::Target::Texture2DMultisample"
or @ref Target "Texture3D::Target::Texture2DMultisampleArray" to constructor.
You can create multisample textures by passing
@ref Target::Texture2DMultisample "Texture2D::Target::Texture2DMultisample" or
@ref Target::Texture2DMultisampleArray "Texture3D::Target::Texture2DMultisampleArray"
to constructor.
@todoc finish this when fully implemented
@ -115,13 +118,13 @@ or @ref Target "Texture3D::Target::Texture2DMultisampleArray" to constructor.
@section Texture-rectangle Rectangle textures
Rectangle texture is created by passing @ref Target "Target::Rectangle" to
constructor. In shader, the texture is used via `sampler2DRect` and friends.
Rectangle texture is created by passing @ref Target::Rectangle "Texture2D::Target::Rectangle"
to constructor. In shader, the texture is used via `sampler2DRect` and friends.
Unlike `sampler2D`, which accepts coordinates between 0 and 1, `sampler2DRect`
accepts coordinates between 0 and `textureSizeInGivenDirection-1`. Note that
rectangle textures don't support mipmapping and repeating wrapping modes, see
@ref Sampler::Filter "Sampler::Filter", @ref Sampler::Mipmap "Sampler::Mipmap"
and generateMipmap() documentation for more information.
@ref Sampler::Filter, @ref Sampler::Mipmap and @ref generateMipmap()
documentation for more information.
@requires_gl31 %Extension @extension{ARB,texture_rectangle} for rectangle
textures.
@ -255,10 +258,9 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* textures and (0, textureSizeInGivenDirection-1) for rectangle
* textures. If @extension{EXT,direct_state_access} is not available,
* the texture is bound to some layer before the operation. Initial
* value is @ref Sampler::Wrapping "Sampler::Wrapping::Repeat".
* value is @ref Sampler::Wrapping::Repeat.
* @attention For rectangle textures only some modes are supported,
* see @ref Sampler::Wrapping "Sampler::Wrapping" documentation
* for more information.
* see @ref Sampler::Wrapping documentation for more information.
* @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexParameter}
* or @fn_gl_extension{TextureParameter,EXT,direct_state_access}
* with @def_gl{TEXTURE_WRAP_S}, @def_gl{TEXTURE_WRAP_T},

15
src/TextureTools/CMakeLists.txt

@ -46,6 +46,21 @@ if(BUILD_STATIC_PIC)
endif()
target_link_libraries(MagnumTextureTools Magnum)
if(WITH_DISTANCEFIELDCONVERTER)
if(NOT UNIX OR TARGET_GLES)
message(FATAL_ERROR "magnum-distancefield is not available on this platform. Set WITH_DISTANCEFIELDCONVERTER to OFF to suppress this warning.")
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/configure.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_executable(magnum-distancefield distance-field.cpp)
target_link_libraries(magnum-distancefield MagnumTextureTools Magnum MagnumWindowlessGlxApplication ${X11_LIBRARIES})
install(TARGETS magnum-distancefield DESTINATION ${MAGNUM_BINARY_INSTALL_DIR})
endif()
install(TARGETS MagnumTextureTools DESTINATION ${MAGNUM_LIBRARY_INSTALL_DIR})
install(FILES ${MagnumTextureTools_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/TextureTools)

11
src/TextureTools/DistanceField.h

@ -75,12 +75,11 @@ http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_AlphaTestedMagnifica
@note If internal format of @p output texture is not renderable, this function
prints message to error output and does nothing. In desktop OpenGL and
OpenGL ES 3.0 it's common to render to @ref TextureFormat "TextureFormat::R8".
In OpenGL ES 2.0 you can use @ref TextureFormat "TextureFormat::Red" if
@es_extension{EXT,texture_rg} is available, if not, the smallest but still
inefficient supported format is in most cases @ref TextureFormat "TextureFormat::RGB",
rendering to @ref TextureFormat "TextureFormat::Luminance" is not supported
in most cases.
OpenGL ES 3.0 it's common to render to @ref TextureFormat::R8. In OpenGL ES
2.0 you can use @ref TextureFormat::Red if @es_extension{EXT,texture_rg} is
available, if not, the smallest but still inefficient supported format is
in most cases @ref TextureFormat::RGB, rendering to @ref TextureFormat::Luminance
is not supported in most cases.
@bug ES (and maybe GL < 3.20) implementation behaves slightly different
(jaggies, visible e.g. when rendering outlined fonts)

26
src/TextureTools/configure.h.cmake

@ -0,0 +1,26 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš <mosra@centrum.cz>
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.
*/
#define MAGNUM_IMPORTER_PLUGIN_DIR "${MAGNUM_LIBRARY_INSTALL_DIR}/magnum/importers"
#define MAGNUM_IMAGECONVERTER_PLUGIN_DIR "${MAGNUM_LIBRARY_INSTALL_DIR}/magnum/imageconverters"

134
src/TextureTools/distance-field.cpp

@ -0,0 +1,134 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš <mosra@centrum.cz>
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 <Utility/Arguments.h>
#include <PluginManager/Manager.h>
#include "Math/Geometry/Rectangle.h"
#include "Image.h"
#include "ImageFormat.h"
#include "Renderer.h"
#include "Texture.h"
#include "TextureFormat.h"
#include "Platform/WindowlessGlxApplication.h"
#include "TextureTools/DistanceField.h"
#include "Trade/AbstractImporter.h"
#include "Trade/AbstractImageConverter.h"
#include "Trade/ImageData.h"
#include "configure.h"
namespace Magnum {
class DistanceFieldConverter: public Platform::WindowlessApplication {
public:
explicit DistanceFieldConverter(const Arguments& arguments);
int exec() override;
private:
Utility::Arguments args;
};
DistanceFieldConverter::DistanceFieldConverter(const Arguments& arguments): WindowlessGlxApplication(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")
.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.")
.parse(arguments.argc, arguments.argv);
createContext({});
}
int DistanceFieldConverter::exec() {
/* Load plugins */
PluginManager::Manager<Trade::AbstractImporter> importerManager(MAGNUM_IMPORTER_PLUGIN_DIR);
if(!(importerManager.load(args.value("importer")) & PluginManager::LoadState::Loaded)) {
Error() << "Cannot load importer plugin" << args.value("importer") << "from" << MAGNUM_IMPORTER_PLUGIN_DIR;
return 1;
}
PluginManager::Manager<Trade::AbstractImageConverter> converterManager(MAGNUM_IMAGECONVERTER_PLUGIN_DIR);
if(!(converterManager.load(args.value("converter")) & PluginManager::LoadState::Loaded)) {
Error() << "Cannot load converter plugin" << args.value("converter") << "from" << MAGNUM_IMAGECONVERTER_PLUGIN_DIR;
return 1;
}
/* Instance plugins */
Trade::AbstractImporter* importer = importerManager.instance(args.value("importer"));
Trade::AbstractImageConverter* converter = converterManager.instance(args.value("converter"));
CORRADE_INTERNAL_ASSERT(importer && converter);
/* Open input file */
Trade::ImageData2D* image = nullptr;
if(!importer->openFile(args.value("input")) || !(image = importer->image2D(0))) {
Error() << "Cannot open file" << args.value("input");
delete importer;
delete converter;
return 1;
}
delete importer;
if(image->format() != ImageFormat::Red) {
Error() << "Unsupported image format" << image->format();
delete converter;
return 1;
}
/* Input texture */
Texture2D input;
input.setMinificationFilter(Sampler::Filter::Linear)
.setMagnificationFilter(Sampler::Filter::Linear)
.setWrapping(Sampler::Wrapping::ClampToEdge)
.setImage(0, TextureFormat::R8, *image);
/* Output texture */
Texture2D output;
output.setStorage(1, TextureFormat::R8, args.value<Vector2i>("output-size"));
CORRADE_INTERNAL_ASSERT(Renderer::error() == Renderer::Error::NoError);
/* Do it */
Debug() << "Converting image of size" << image->size() << "to distance field...";
TextureTools::distanceField(input, output, {{}, args.value<Vector2i>("output-size")}, args.value<Int>("radius"), image->size());
delete image;
/* Save image */
Image2D result(ImageFormat::Red, ImageType::UnsignedByte);
output.image(0, result);
if(!converter->exportToFile(result, args.value("output"))) {
Error() << "Cannot save file" << args.value("output");
delete converter;
return 1;
}
delete converter;
return 0;
}
}
MAGNUM_WINDOWLESSAPPLICATION_MAIN(Magnum::DistanceFieldConverter)

22
src/Trade/AbstractImageConverter.h

@ -51,9 +51,8 @@ supported.
You don't need to do most of the redundant sanity checks, these things are
checked by the implementation:
- Functions doExportToImage() or doExportToData() are called only if
@ref Feature "Feature::ConvertImage" or @ref Feature "Feature::ConvertData"
is supported.
- Functions @ref doExportToImage() or @ref doExportToData() are called only
if @ref Feature::ConvertImage or @ref Feature::ConvertData is supported.
*/
class MAGNUM_EXPORT AbstractImageConverter: public PluginManager::AbstractPlugin {
CORRADE_PLUGIN_INTERFACE("cz.mosra.magnum.Trade.AbstractImageConverter/0.2.1")
@ -91,18 +90,18 @@ class MAGNUM_EXPORT AbstractImageConverter: public PluginManager::AbstractPlugin
/**
* @brief Convert image to different format
*
* Available only if @ref Feature "Feature::ConvertImage" is supported.
* Returns converted image on success, `nullptr` otherwise.
* @see features(), exportToData(), exportToFile()
* Available only if @ref Feature::ConvertImage is supported. Returns
* converted image on success, `nullptr` otherwise.
* @see @ref features(), @ref exportToData(), @ref exportToFile()
*/
Image2D* exportToImage(const ImageReference2D& image) const;
/**
* @brief Export image to raw data
*
* Available only if @ref Feature "Feature::ConvertData" is supported.
* Returns data on success, zero-sized array otherwise.
* @see features(), exportToImage(), exportToFile()
* Available only if @ref Feature::ConvertData is supported. Returns
* data on success, zero-sized array otherwise.
* @see @ref features(), @ref exportToImage(), @ref exportToFile()
*/
Containers::Array<unsigned char> exportToData(const ImageReference2D& image) const;
@ -131,9 +130,8 @@ class MAGNUM_EXPORT AbstractImageConverter: public PluginManager::AbstractPlugin
/**
* @brief Implementation of exportToFile()
*
* If @ref Feature "Feature::ConvertData" is supported, default
* implementation calls doExportToData() and saves the result to given
* file.
* If @ref Feature::ConvertData is supported, default implementation
* calls @ref doExportToData() and saves the result to given file.
*/
virtual bool doExportToFile(const ImageReference2D& image, const std::string& filename) const;
};

5
src/Trade/AbstractImporter.cpp

@ -76,7 +76,10 @@ void AbstractImporter::doOpenFile(const std::string& filename) {
}
void AbstractImporter::close() {
if(isOpened()) doClose();
if(isOpened()) {
doClose();
CORRADE_INTERNAL_ASSERT(!isOpened());
}
}
Int AbstractImporter::defaultScene() {

22
src/Trade/AbstractImporter.h

@ -58,12 +58,13 @@ as the file contains all data user wants to import.
You don't need to do most of the redundant sanity checks, these things are
checked by the implementation:
- Functions doOpenData() and doOpenFile() are called after the previous file
was closed, function doClose() is called only if there is any file opened.
- Function doOpenData() is called only if @ref Feature "Feature::OpenData"
is supported.
- All `do*()` implementations working on opened file are called only if
there is any file opened.
- Functions @ref doOpenData() and @ref doOpenFile() are called after the
previous file was closed, function @ref doClose() is called only if there
is any file opened.
- Function @ref doOpenData() is called only if @ref Feature::OpenData is
supported.
- All `do*()` implementations working on opened file are called only if there
is any file opened.
- All `do*()` implementations taking data ID as parameter are called only if
the ID is from valid range.
*/
@ -100,8 +101,8 @@ class MAGNUM_EXPORT AbstractImporter: public PluginManager::AbstractPlugin {
* @brief Open raw data
*
* Closes previous file, if it was opened, and tries to open given
* file. Available only if @ref Feature "Feature::OpenData" is
* supported. Returns `true` on success, `false` otherwise.
* file. Available only if @ref Feature::OpenData is supported. Returns
* `true` on success, `false` otherwise.
* @see features(), openFile()
*/
bool openData(Containers::ArrayReference<const unsigned char> data);
@ -488,9 +489,8 @@ class MAGNUM_EXPORT AbstractImporter: public PluginManager::AbstractPlugin {
/**
* @brief Implementation for openFile()
*
* If @ref Feature "Feature::OpenData" is supported, default
* implementation opens the file and calls doOpenData() with its
* contents.
* If @ref Feature::OpenData is supported, default implementation opens
* the file and calls @ref doOpenData() with its contents.
*/
virtual void doOpenFile(const std::string& filename);

12
src/Trade/PhongMaterialData.h

@ -79,7 +79,7 @@ class MAGNUM_EXPORT PhongMaterialData: public AbstractMaterialData {
/**
* @brief Ambient color
*
* Available only if the material doesn't have @ref Flag "Flag::AmbientTexture".
* Available only if the material doesn't have @ref Flag::AmbientTexture.
* @see @ref flags()
*/
Vector3& ambientColor();
@ -88,7 +88,7 @@ class MAGNUM_EXPORT PhongMaterialData: public AbstractMaterialData {
/**
* @brief Ambient texture ID
*
* Available only if the material has @ref Flag "Flag::AmbientTexture".
* Available only if the material has @ref Flag::AmbientTexture.
* @see @ref flags(), @ref AbstractImporter::texture()
*/
UnsignedInt& ambientTexture();
@ -97,7 +97,7 @@ class MAGNUM_EXPORT PhongMaterialData: public AbstractMaterialData {
/**
* @brief Diffuse color
*
* Available only if the material doesn't have @ref Flag "Flag::DiffuseTexture".
* Available only if the material doesn't have @ref Flag::DiffuseTexture.
* @see @ref flags()
*/
Vector3& diffuseColor();
@ -106,7 +106,7 @@ class MAGNUM_EXPORT PhongMaterialData: public AbstractMaterialData {
/**
* @brief Diffuse texture ID
*
* Available only if the material has @ref Flag "Flag::DiffuseTexture".
* Available only if the material has @ref Flag::DiffuseTexture.
* @see @ref flags(), @ref AbstractImporter::texture()
*/
UnsignedInt& diffuseTexture();
@ -115,7 +115,7 @@ class MAGNUM_EXPORT PhongMaterialData: public AbstractMaterialData {
/**
* @brief Specular color
*
* Available only if the material doesn't have @ref Flag "Flag::SpecularTexture".
* Available only if the material doesn't have @ref Flag::SpecularTexture.
* @see @ref flags()
*/
Vector3& specularColor();
@ -124,7 +124,7 @@ class MAGNUM_EXPORT PhongMaterialData: public AbstractMaterialData {
/**
* @brief Specular texture ID
*
* Available only if the material has @ref Flag "Flag::SpecularTexture".
* Available only if the material has @ref Flag::SpecularTexture.
* @see @ref flags(), @ref AbstractImporter::texture()
*/
UnsignedInt& specularTexture();

2
src/Trade/TextureData.h

@ -93,7 +93,7 @@ class TextureData {
* @brief Image ID
*
* ID of 1D, 2D or 3D image based on texture type. If type is
* @ref Type "Type::Cube" the function returns first of six consecutive
* @ref Type::Cube the function returns first of six consecutive
* IDs of cube map sides, ordered +X, -X, +Y, -Y, +Z, -Z.
* @see @ref type(), @ref AbstractImporter::image1D(),
* @ref AbstractImporter::image2D(), @ref AbstractImporter::image3D()

3
src/Trade/Trade.h

@ -32,8 +32,6 @@
namespace Magnum { namespace Trade {
/** @todoc Remove `ifndef` when Doxygen is sane again */
#ifndef DOXYGEN_GENERATING_OUTPUT
class AbstractImageConverter;
class AbstractImporter;
class AbstractMaterialData;
@ -54,7 +52,6 @@ class ObjectData3D;
class PhongMaterialData;
class TextureData;
class SceneData;
#endif
}}

Loading…
Cancel
Save