Browse Source

Shotgun documentation updates.

Fixed old references to Buffer::Usage, fixed parameter order in Image
constructor, fixed some function references. Added explicit references
to linkable stuff.
pull/34/head
Vladimír Vondruš 13 years ago
parent
commit
794c934dc1
  1. 32
      src/AbstractTexture.h
  2. 192
      src/Buffer.h
  3. 37
      src/BufferTexture.h
  4. 26
      src/CubeMapTexture.h
  5. 57
      src/CubeMapTextureArray.h
  6. 2
      src/Math/Geometry/Rectangle.h
  7. 73
      src/Mesh.h
  8. 10
      src/MeshTools/CompressIndices.h
  9. 14
      src/MeshTools/Interleave.h
  10. 6
      src/Text/Renderer.h
  11. 79
      src/Texture.h

32
src/AbstractTexture.h

@ -25,7 +25,7 @@
*/ */
/** @file /** @file
* @brief Class Magnum::AbstractTexture * @brief Class @ref Magnum::AbstractTexture
*/ */
#include "Array.h" #include "Array.h"
@ -37,8 +37,9 @@ namespace Magnum {
/** /**
@brief Base for textures @brief Base for textures
See Texture, CubeMapTexture and CubeMapTextureArray documentation for more Encapsulates one OpenGL texture object. See @ref Texture, @ref CubeMapTexture
information and usage examples. and @ref CubeMapTextureArray documentation for more information and usage
examples.
@section AbstractTexture-performance-optimization Performance optimizations and security @section AbstractTexture-performance-optimization Performance optimizations and security
@ -49,15 +50,15 @@ affect active bindings in user layers. %Texture limits and
implementation-defined values (such as @ref maxColorSamples()) are cached, so implementation-defined values (such as @ref maxColorSamples()) are cached, so
repeated queries don't result in repeated @fn_gl{Get} calls. repeated queries don't result in repeated @fn_gl{Get} calls.
If extension @extension{EXT,direct_state_access} is available, bind() uses DSA If extension @extension{EXT,direct_state_access} is available, @ref bind() uses
function to avoid unnecessary calls to @fn_gl{ActiveTexture}. Also all texture DSA function to avoid unnecessary calls to @fn_gl{ActiveTexture}. Also all
configuration and data updating functions use DSA functions to avoid texture configuration and data updating functions use DSA functions to avoid
unnecessary calls to @fn_gl{ActiveTexture} and @fn_gl{BindTexture}. See unnecessary calls to @fn_gl{ActiveTexture} and @fn_gl{BindTexture}. See
respective function documentation for more information. respective function documentation for more information.
If extension @extension{ARB,robustness} is available, image reading operations If extension @extension{ARB,robustness} is available, image reading operations
(such as Texture::image()) are protected from buffer overflow. However, if both (such as @ref Texture::image()) are protected from buffer overflow. However, if
@extension{EXT,direct_state_access} and @extension{ARB,robustness} are both @extension{EXT,direct_state_access} and @extension{ARB,robustness} are
available, the DSA version is used, because it is better for performance and available, the DSA version is used, because it is better for performance and
there isn't any function combining both features. there isn't any function combining both features.
@ -76,11 +77,12 @@ OpenGL ES 3.0 or @es_extension{EXT,texture_storage} in OpenGL ES 2.0 is not
available, the feature is emulated with sequence of @ref Texture::setImage() "setImage()" available, the feature is emulated with sequence of @ref Texture::setImage() "setImage()"
calls. calls.
You can use functions invalidateImage() and @ref Texture::invalidateSubImage() "invalidateSubImage()" You can use functions @ref invalidateImage() and
if you don't need texture data anymore to avoid unnecessary memory operations @ref Texture::invalidateSubImage() "invalidateSubImage()" if you don't need
performed by OpenGL in order to preserve the data. If running on OpenGL ES or texture data anymore to avoid unnecessary memory operations performed by OpenGL
extension @extension{ARB,invalidate_subdata} is not available, these functions in order to preserve the data. If running on OpenGL ES or extension
do nothing. @extension{ARB,invalidate_subdata} is not available, these functions do
nothing.
@todo all texture [level] parameters, global texture parameters @todo all texture [level] parameters, global texture parameters
@todo Add glPixelStore encapsulation @todo Add glPixelStore encapsulation
@ -182,8 +184,8 @@ class MAGNUM_EXPORT AbstractTexture {
* @brief Set minification filter * @brief Set minification filter
* @param filter Filter * @param filter Filter
* @param mipmap Mipmap filtering. If set to anything else than * @param mipmap Mipmap filtering. If set to anything else than
* BaseMipLevel, make sure textures for all mip levels are set or * @ref Sampler::Mipmap::Base, make sure textures for all mip
* call generateMipmap(). * levels are set or call @ref generateMipmap().
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)
* *
* Sets filter used when the object pixel size is smaller than the * Sets filter used when the object pixel size is smaller than the

192
src/Buffer.h

@ -42,78 +42,72 @@
namespace Magnum { namespace Magnum {
/** /**
* @brief %Buffer usage @brief %Buffer usage
*
* @see @ref Buffer::setData(Containers::ArrayReference<const void>, BufferUsage) @see @ref Buffer, @ref Buffer::setData(Containers::ArrayReference<const void>, BufferUsage)
*/ */
enum class BufferUsage: GLenum { enum class BufferUsage: GLenum {
/** /** Set once by the application and used infrequently for drawing. */
* Set once by the application and used infrequently for drawing.
*/
StreamDraw = GL_STREAM_DRAW, StreamDraw = GL_STREAM_DRAW,
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
/** /**
* Set once as output from an OpenGL command and used infequently * Set once as output from an OpenGL command and used infequently for
* for drawing. * drawing.
* @requires_gles30 Only @ref Magnum::Buffer::Usage "Usage::StreamDraw" * @requires_gles30 Only @ref Magnum::BufferUsage::StreamDraw "BufferUsage::StreamDraw"
* is available in OpenGL ES 2.0. * is available in OpenGL ES 2.0.
*/ */
StreamRead = GL_STREAM_READ, StreamRead = GL_STREAM_READ,
/** /**
* Set once as output from an OpenGL command and used infrequently * Set once as output from an OpenGL command and used infrequently for
* for drawing or copying to other buffers. * drawing or copying to other buffers.
* @requires_gles30 Only @ref Magnum::Buffer::Usage "Usage::StreamDraw" * @requires_gles30 Only @ref Magnum::BufferUsage::StreamDraw "BufferUsage::StreamDraw"
* is available in OpenGL ES 2.0. * is available in OpenGL ES 2.0.
*/ */
StreamCopy = GL_STREAM_COPY, StreamCopy = GL_STREAM_COPY,
#endif #endif
/** /** Set once by the application and used frequently for drawing. */
* Set once by the application and used frequently for drawing.
*/
StaticDraw = GL_STATIC_DRAW, StaticDraw = GL_STATIC_DRAW,
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
/** /**
* Set once as output from an OpenGL command and queried many * Set once as output from an OpenGL command and queried many times by the
* times by the application. * application.
* @requires_gles30 Only @ref Magnum::Buffer::Usage "Usage::StaticDraw" * @requires_gles30 Only @ref Magnum::BufferUsage::StaticDraw "BufferUsage::StaticDraw"
* is available in OpenGL ES 2.0. * is available in OpenGL ES 2.0.
*/ */
StaticRead = GL_STATIC_READ, StaticRead = GL_STATIC_READ,
/** /**
* Set once as output from an OpenGL command and used frequently * Set once as output from an OpenGL command and used frequently for
* for drawing or copying to other buffers. * drawing or copying to other buffers.
* @requires_gles30 Only @ref Magnum::Buffer::Usage "Usage::StaticDraw" * @requires_gles30 Only @ref Magnum::BufferUsage::StaticDraw "BufferUsage::StaticDraw"
* is available in OpenGL ES 2.0. * is available in OpenGL ES 2.0.
*/ */
StaticCopy = GL_STATIC_COPY, StaticCopy = GL_STATIC_COPY,
#endif #endif
/** /**
* Updated frequently by the application and used frequently * Updated frequently by the application and used frequently for drawing or
* for drawing or copying to other images. * copying to other images.
*/ */
DynamicDraw = GL_DYNAMIC_DRAW DynamicDraw = GL_DYNAMIC_DRAW,
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
,
/** /**
* Updated frequently as output from OpenGL command and queried * Updated frequently as output from OpenGL command and queried many times
* many times from the application. * from the application.
* @requires_gles30 Only @ref Magnum::Buffer::Usage "Usage::DynamicDraw" * @requires_gles30 Only @ref Magnum::BufferUsage::DynamicDraw "BufferUsage::DynamicDraw"
* is available in OpenGL ES 2.0. * is available in OpenGL ES 2.0.
*/ */
DynamicRead = GL_DYNAMIC_READ, DynamicRead = GL_DYNAMIC_READ,
/** /**
* Updated frequently as output from OpenGL command and used * Updated frequently as output from OpenGL command and used frequently for
* frequently for drawing or copying to other images. * drawing or copying to other images.
* @requires_gles30 Only @ref Magnum::Buffer::Usage "Usage::DynamicDraw" * @requires_gles30 Only @ref Magnum::BufferUsage::DynamicDraw "BufferUsage::DynamicDraw"
* is available in OpenGL ES 2.0. * is available in OpenGL ES 2.0.
*/ */
DynamicCopy = GL_DYNAMIC_COPY DynamicCopy = GL_DYNAMIC_COPY
@ -128,18 +122,18 @@ data updates.
@section Buffer-data Data updating @section Buffer-data Data updating
Default way to set or update buffer data with setData() or setSubData() is to Default way to set or update buffer data with @ref setData() or @ref setSubData()
use @ref Corrade::Containers::ArrayReference. See its documentation for more is to use @ref Corrade::Containers::ArrayReference. See its documentation for
information about automatic conversions etc. more information about automatic conversions etc.
@code @code
Containers::ArrayReference<Vector3> data; Containers::ArrayReference<Vector3> data;
buffer.setData(data, Buffer::Usage::StaticDraw); buffer.setData(data, BufferUsage::StaticDraw);
@endcode @endcode
There is also overload for array-like containers from STL, such as `std::vector` There is also overload for array-like containers from STL, such as `std::vector`
or `std::array`: or `std::array`:
@code @code
std::vector<Vector3> data; std::vector<Vector3> data;
buffer.setData(data, Buffer::Usage::StaticDraw); buffer.setData(data, BufferUsage::StaticDraw);
@endcode @endcode
@subsection Buffer-data-mapping Memory mapping @subsection Buffer-data-mapping Memory mapping
@ -147,7 +141,7 @@ buffer.setData(data, Buffer::Usage::StaticDraw);
%Buffer data can be also updated asynchronously. First you need to allocate %Buffer data can be also updated asynchronously. First you need to allocate
the buffer to desired size by passing `nullptr` to @ref setData(), e.g.: the buffer to desired size by passing `nullptr` to @ref setData(), e.g.:
@code @code
buffer.setData({nullptr, 200*sizeof(Vector3)}, Buffer::Usage::StaticDraw); buffer.setData({nullptr, 200*sizeof(Vector3)}, BufferUsage::StaticDraw);
@endcode @endcode
Then you can map the buffer to client memory and operate with the memory Then you can map the buffer to client memory and operate with the memory
directly. After you are done with the operation, call @ref unmap() to unmap the directly. After you are done with the operation, call @ref unmap() to unmap the
@ -174,20 +168,21 @@ CORRADE_INTERNAL_ASSERT_OUTPUT(buffer.unmap());
The engine tracks currently bound buffers to avoid unnecessary calls to The engine tracks currently bound buffers to avoid unnecessary calls to
@fn_gl{BindBuffer}. If the buffer is already bound to some target, functions @fn_gl{BindBuffer}. If the buffer is already bound to some target, functions
copy(), setData(), setSubData(), map(), flushMappedRange() and unmap() use @ref copy(), @ref setData(), @ref setSubData(), @ref map(), @ref flushMappedRange()
that target instead of binding the buffer to some specific target. You can and @ref unmap() use that target instead of binding the buffer to some specific
also use setTargetHint() to possibly reduce unnecessary rebinding. %Buffer target. You can also use @ref setTargetHint() to possibly reduce unnecessary
limits and implementation-defined values (such as @ref maxVertexAttributeBindings()) rebinding. %Buffer limits and implementation-defined values (such as
are cached, so repeated queries don't result in repeated @fn_gl{Get} calls. @ref maxVertexAttributeBindings()) are cached, so repeated queries don't result
in repeated @fn_gl{Get} calls.
If extension @extension{EXT,direct_state_access} is available, functions If extension @extension{EXT,direct_state_access} is available, functions
copy(), setData(), setSubData(), map(), flushMappedRange() and unmap() use DSA @ref copy(), @ref setData(), @ref setSubData(), @ref map(), @ref flushMappedRange()
functions to avoid unnecessary calls to @fn_gl{BindBuffer}. See their and @ref unmap() use DSA functions to avoid unnecessary calls to
respective documentation for more information. @fn_gl{BindBuffer}. See their respective documentation for more information.
You can use functions invalidateData() and invalidateSubData() if you don't You can use functions @ref invalidateData() and @ref invalidateSubData() if you
need buffer data anymore to avoid unnecessary memory operations performed by don't need buffer data anymore to avoid unnecessary memory operations performed
OpenGL in order to preserve the data. If running on OpenGL ES or extension by OpenGL in order to preserve the data. If running on OpenGL ES or extension
@extension{ARB,invalidate_subdata} is not available, these functions do @extension{ARB,invalidate_subdata} is not available, these functions do
nothing. nothing.
@ -201,7 +196,7 @@ class MAGNUM_EXPORT Buffer {
/** /**
* @brief %Buffer target * @brief %Buffer target
* *
* @see bind(Target), unbind(Target) * @see @ref bind(Target), @ref unbind(Target)
*/ */
enum class Target: GLenum { enum class Target: GLenum {
/** Used for storing vertex attributes. */ /** Used for storing vertex attributes. */
@ -218,7 +213,7 @@ class MAGNUM_EXPORT Buffer {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
/** /**
* Source for copies. See copy(). * Source for copies. See @ref copy().
* @requires_gl31 %Extension @extension{ARB,copy_buffer} * @requires_gl31 %Extension @extension{ARB,copy_buffer}
* @requires_gles30 Buffer copying is not available in OpenGL ES * @requires_gles30 Buffer copying is not available in OpenGL ES
* 2.0. * 2.0.
@ -226,7 +221,7 @@ class MAGNUM_EXPORT Buffer {
CopyRead = GL_COPY_READ_BUFFER, CopyRead = GL_COPY_READ_BUFFER,
/** /**
* Target for copies. See copy(). * Target for copies. See @ref copy().
* @requires_gl31 %Extension @extension{ARB,copy_buffer} * @requires_gl31 %Extension @extension{ARB,copy_buffer}
* @requires_gles30 Buffer copying is not available in OpenGL ES * @requires_gles30 Buffer copying is not available in OpenGL ES
* 2.0. * 2.0.
@ -319,7 +314,7 @@ class MAGNUM_EXPORT Buffer {
* *
* @deprecated_gl Prefer to use @ref Magnum::Buffer::map(GLintptr, GLsizeiptr, MapFlags) "map(GLintptr, GLsizeiptr, MapFlags)" * @deprecated_gl Prefer to use @ref Magnum::Buffer::map(GLintptr, GLsizeiptr, MapFlags) "map(GLintptr, GLsizeiptr, MapFlags)"
* instead, as it has more complete set of features. * instead, as it has more complete set of features.
* @see map(MapAccess), mapSub() * @see @ref map(MapAccess), @ref mapSub()
* @requires_es_extension %Extension @es_extension{OES,mapbuffer} or * @requires_es_extension %Extension @es_extension{OES,mapbuffer} or
* @es_extension{CHROMIUM,map_sub} * @es_extension{CHROMIUM,map_sub}
*/ */
@ -333,9 +328,7 @@ class MAGNUM_EXPORT Buffer {
ReadOnly = GL_READ_ONLY, ReadOnly = GL_READ_ONLY,
#endif #endif
/** /** Map buffer for writing only. */
* Map buffer for writing only.
*/
#ifdef MAGNUM_TARGET_GLES #ifdef MAGNUM_TARGET_GLES
WriteOnly = GL_WRITE_ONLY_OES WriteOnly = GL_WRITE_ONLY_OES
#else #else
@ -353,7 +346,7 @@ class MAGNUM_EXPORT Buffer {
/** /**
* @brief Memory mapping flag * @brief Memory mapping flag
* *
* @see MapFlags, map(GLintptr, GLsizeiptr, MapFlags) * @see @ref MapFlags, @ref map(GLintptr, GLsizeiptr, MapFlags)
* @requires_gl30 %Extension @extension{ARB,map_buffer_range} * @requires_gl30 %Extension @extension{ARB,map_buffer_range}
* @requires_gles30 %Extension @es_extension{EXT,map_buffer_range} * @requires_gles30 %Extension @es_extension{EXT,map_buffer_range}
*/ */
@ -373,9 +366,9 @@ class MAGNUM_EXPORT Buffer {
#endif #endif
/** /**
* Previous contents of the entire buffer may be discarded. May * Previous contents of the entire buffer may be discarded. May not
* not be used in combination with @ref MapFlag::Read. * be used in combination with @ref MapFlag::Read.
* @see invalidateData() * @see @ref invalidateData()
*/ */
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
InvalidateBuffer = GL_MAP_INVALIDATE_BUFFER_BIT, InvalidateBuffer = GL_MAP_INVALIDATE_BUFFER_BIT,
@ -384,9 +377,9 @@ class MAGNUM_EXPORT Buffer {
#endif #endif
/** /**
* Previous contents of mapped range may be discarded. May not * Previous contents of mapped range may be discarded. May not be
* be used in combination with @ref MapFlag::Read. * used in combination with @ref MapFlag::Read.
* @see invalidateSubData() * @see @ref invalidateSubData()
*/ */
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
InvalidateRange = GL_MAP_INVALIDATE_RANGE_BIT, InvalidateRange = GL_MAP_INVALIDATE_RANGE_BIT,
@ -396,8 +389,8 @@ class MAGNUM_EXPORT Buffer {
/** /**
* Only one or more discrete subranges of the mapping will be * Only one or more discrete subranges of the mapping will be
* modified. See flushMappedRange() for more information. May only * modified. See @ref flushMappedRange() for more information. May
* be used in conjuction with @ref MapFlag::Write. * only be used in conjuction with @ref MapFlag::Write.
*/ */
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
FlushExplicit = GL_MAP_FLUSH_EXPLICIT_BIT, FlushExplicit = GL_MAP_FLUSH_EXPLICIT_BIT,
@ -419,7 +412,7 @@ class MAGNUM_EXPORT Buffer {
/** /**
* @brief Memory mapping flags * @brief Memory mapping flags
* *
* @see map(GLintptr, GLsizeiptr, MapFlags) * @see @ref map(GLintptr, GLsizeiptr, MapFlags)
* @requires_gl30 %Extension @extension{ARB,map_buffer_range} * @requires_gl30 %Extension @extension{ARB,map_buffer_range}
* @requires_gles30 %Extension @es_extension{EXT,map_buffer_range} * @requires_gles30 %Extension @es_extension{EXT,map_buffer_range}
*/ */
@ -511,7 +504,7 @@ class MAGNUM_EXPORT Buffer {
* *
* If @extension{EXT,direct_state_access} is not available and the * If @extension{EXT,direct_state_access} is not available and the
* buffers aren't already bound somewhere, they are bound to * buffers aren't already bound somewhere, they are bound to
* `Target::CopyRead` and `Target::CopyWrite` before the copy is * @ref Target::CopyRead and @ref Target::CopyWrite before the copy is
* performed. * performed.
* @see @fn_gl{BindBuffer} and @fn_gl{CopyBufferSubData} or * @see @fn_gl{BindBuffer} and @fn_gl{CopyBufferSubData} or
* @fn_gl_extension{NamedCopyBufferSubData,EXT,direct_state_access} * @fn_gl_extension{NamedCopyBufferSubData,EXT,direct_state_access}
@ -525,10 +518,10 @@ class MAGNUM_EXPORT Buffer {
/** /**
* @brief Constructor * @brief Constructor
* @param targetHint Target hint, see setTargetHint() for more * @param targetHint Target hint, see @ref setTargetHint() for more
* information * information
* *
* Generates new OpenGL buffer. * Creates new OpenGL buffer.
* @see @fn_gl{GenBuffers} * @see @fn_gl{GenBuffers}
*/ */
explicit Buffer(Target targetHint = Target::Array); explicit Buffer(Target targetHint = Target::Array);
@ -565,11 +558,11 @@ class MAGNUM_EXPORT Buffer {
* *
* If @extension{EXT,direct_state_access} is not available, the buffer * If @extension{EXT,direct_state_access} is not available, the buffer
* must be internally bound to some target before any operation. You * must be internally bound to some target before any operation. You
* can specify target which will always be used when binding the * can specify target which will always be used when binding the buffer
* buffer internally, possibly saving some calls to @fn_gl{BindBuffer}. * internally, possibly saving some calls to @fn_gl{BindBuffer}.
* *
* Default target hint is `Target::Array`. * Default target hint is @ref Target::Array.
* @see setData(), setSubData() * @see @ref setData(), @ref setSubData()
* @todo Target::ElementArray cannot be used when no VAO is bound - * @todo Target::ElementArray cannot be used when no VAO is bound -
* http://www.opengl.org/wiki/Vertex_Specification#Index_buffers * http://www.opengl.org/wiki/Vertex_Specification#Index_buffers
* ... damned GL state * ... damned GL state
@ -610,7 +603,8 @@ class MAGNUM_EXPORT Buffer {
* Returns data of whole buffer. If @extension{EXT,direct_state_access} * Returns data of whole buffer. If @extension{EXT,direct_state_access}
* is not available and the buffer is not already bound somewhere, it * is not available and the buffer is not already bound somewhere, it
* is bound to hinted target before the operation. * is bound to hinted target before the operation.
* @see size(), subData(), setData(), @fn_gl{BindBuffer} and @fn_gl{GetBufferParameter} or * @see @ref size(), @ref subData(), @ref setData(), @fn_gl{BindBuffer}
* and @fn_gl{GetBufferParameter} or
* @fn_gl_extension{GetNamedBufferParameter,EXT,direct_state_access} * @fn_gl_extension{GetNamedBufferParameter,EXT,direct_state_access}
* with @def_gl{BUFFER_SIZE}, @fn_gl{GetBufferSubData} or * with @def_gl{BUFFER_SIZE}, @fn_gl{GetBufferSubData} or
* @fn_gl_extension{GetNamedBufferSubData,EXT,direct_state_access} * @fn_gl_extension{GetNamedBufferSubData,EXT,direct_state_access}
@ -627,8 +621,9 @@ class MAGNUM_EXPORT Buffer {
* Returns data of given buffer portion. If @extension{EXT,direct_state_access} * Returns data of given buffer portion. If @extension{EXT,direct_state_access}
* is not available and the buffer is not already bound somewhere, it * is not available and the buffer is not already bound somewhere, it
* is bound to hinted target before the operation. * is bound to hinted target before the operation.
* @see size(), data(), setSubData(), @fn_gl{BindBuffer} and @fn_gl{GetBufferSubData} * @see @ref size(), @ref data(), @ref setSubData(), @fn_gl{BindBuffer}
* or @fn_gl_extension{GetNamedBufferSubData,EXT,direct_state_access} * and @fn_gl{GetBufferSubData} or
* @fn_gl_extension{GetNamedBufferSubData,EXT,direct_state_access}
* @requires_gl %Buffer data queries are not available in OpenGL ES. * @requires_gl %Buffer data queries are not available in OpenGL ES.
* Use @ref Magnum::Buffer::map() "map()" instead. * Use @ref Magnum::Buffer::map() "map()" instead.
*/ */
@ -644,8 +639,8 @@ class MAGNUM_EXPORT Buffer {
* If @extension{EXT,direct_state_access} is not available and the * If @extension{EXT,direct_state_access} is not available and the
* buffer is not already bound somewhere, it is bound to hinted target * buffer is not already bound somewhere, it is bound to hinted target
* before the operation. * before the operation.
* @see setTargetHint(), @fn_gl{BindBuffer} and @fn_gl{BufferData} or * @see @ref setTargetHint(), @fn_gl{BindBuffer} and @fn_gl{BufferData}
* @fn_gl_extension{NamedBufferData,EXT,direct_state_access} * or @fn_gl_extension{NamedBufferData,EXT,direct_state_access}
*/ */
Buffer& setData(Containers::ArrayReference<const void> data, BufferUsage usage) { Buffer& setData(Containers::ArrayReference<const void> data, BufferUsage usage) {
(this->*dataImplementation)(data.size(), data, usage); (this->*dataImplementation)(data.size(), data, usage);
@ -655,22 +650,15 @@ class MAGNUM_EXPORT Buffer {
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
/** /**
* @brief Set buffer data * @brief Set buffer data
* @deprecated Use @ref Magnum::Buffer::setData(Containers::ArrayReference<const void>, Usage) "setData(Containers::ArrayReference<const void>, Usage)" * @deprecated Use @ref Magnum::Buffer::setData(Containers::ArrayReference<const void>, BufferUsage) "setData(Containers::ArrayReference<const void>, BufferUsage)"
* instead. * instead.
*/ */
Buffer& setData(GLsizeiptr size, const GLvoid* data, Usage usage) { Buffer& setData(GLsizeiptr size, const GLvoid* data, BufferUsage usage) {
return setData({data, std::size_t(size)}, usage); return setData({data, std::size_t(size)}, usage);
} }
#endif #endif
/** /** @overload */
* @brief Set buffer data
* @param data Vector with data
* @param usage %Buffer usage
* @return Reference to self (for method chaining)
*
* @see setData(GLsizeiptr, const GLvoid*, Usage)
*/
template<class T> Buffer& setData(const std::vector<T>& data, BufferUsage usage) { template<class T> Buffer& setData(const std::vector<T>& data, BufferUsage usage) {
setData({data.data(), data.size()}, usage); setData({data.data(), data.size()}, usage);
return *this; return *this;
@ -691,7 +679,7 @@ class MAGNUM_EXPORT Buffer {
* If @extension{EXT,direct_state_access} is not available and the * If @extension{EXT,direct_state_access} is not available and the
* buffer is not already bound somewhere, it is bound to hinted target * buffer is not already bound somewhere, it is bound to hinted target
* before the operation. * before the operation.
* @see setTargetHint(), @fn_gl{BindBuffer} and @fn_gl{BufferSubData} * @see @ref setTargetHint(), @fn_gl{BindBuffer} and @fn_gl{BufferSubData}
* or @fn_gl_extension{NamedBufferSubData,EXT,direct_state_access} * or @fn_gl_extension{NamedBufferSubData,EXT,direct_state_access}
*/ */
Buffer& setSubData(GLintptr offset, Containers::ArrayReference<const void> data) { Buffer& setSubData(GLintptr offset, Containers::ArrayReference<const void> data) {
@ -710,14 +698,7 @@ class MAGNUM_EXPORT Buffer {
} }
#endif #endif
/** /** @overload */
* @brief Set buffer subdata
* @param offset Offset in the buffer
* @param data Vector with data
* @return Reference to self (for method chaining)
*
* @see setSubData(GLintptr, GLsizeiptr, const GLvoid*)
*/
template<class T> Buffer& setSubData(GLintptr offset, const std::vector<T>& data) { template<class T> Buffer& setSubData(GLintptr offset, const std::vector<T>& data) {
setSubData(offset, {data.data(), data.size()}); setSubData(offset, {data.data(), data.size()});
return *this; return *this;
@ -792,7 +773,8 @@ class MAGNUM_EXPORT Buffer {
* target before the operation. * target before the operation.
* @deprecated_gl Prefer to use @ref Magnum::Buffer::map(GLintptr, GLsizeiptr, MapFlags) "map(GLintptr, GLsizeiptr, MapFlags)" * @deprecated_gl Prefer to use @ref Magnum::Buffer::map(GLintptr, GLsizeiptr, MapFlags) "map(GLintptr, GLsizeiptr, MapFlags)"
* instead, as it has more complete set of features. * instead, as it has more complete set of features.
* @see unmapSub(), setTargetHint(), @fn_gl_extension{MapBufferSubData,CHROMIUM,map_sub} * @see @ref unmapSub(), @ref setTargetHint(),
* @fn_gl_extension{MapBufferSubData,CHROMIUM,map_sub}
* @requires_gles20 Not available in ES 3.0 or desktop OpenGL. Use * @requires_gles20 Not available in ES 3.0 or desktop OpenGL. Use
* @ref Magnum::Buffer::map(GLintptr, GLsizeiptr, MapFlags) "map(GLintptr, GLsizeiptr, MapFlags)" * @ref Magnum::Buffer::map(GLintptr, GLsizeiptr, MapFlags) "map(GLintptr, GLsizeiptr, MapFlags)"
* instead. * instead.
@ -805,8 +787,8 @@ class MAGNUM_EXPORT Buffer {
* @brief Map buffer to client memory * @brief Map buffer to client memory
* @param offset Offset into the buffer * @param offset Offset into the buffer
* @param length Length of the mapped memory * @param length Length of the mapped memory
* @param flags Flags. At least @ref MapFlag::Read or @ref MapFlag::Write * @param flags Flags. At least @ref MapFlag::Read or
* must be specified. * @ref MapFlag::Write must be specified.
* @return Pointer to buffer data * @return Pointer to buffer data
* *
* If @extension{EXT,direct_state_access} is not available and the * If @extension{EXT,direct_state_access} is not available and the
@ -829,13 +811,13 @@ class MAGNUM_EXPORT Buffer {
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)
* *
* Flushes specified subsection of mapped range. Use only if you called * Flushes specified subsection of mapped range. Use only if you called
* map() with @ref MapFlag::FlushExplicit flag. See * @ref map() with @ref MapFlag::FlushExplicit flag. See
* @ref Buffer-data-mapping "class documentation" for usage example. * @ref Buffer-data-mapping "class documentation" for usage example.
* *
* If @extension{EXT,direct_state_access} is not available and the * If @extension{EXT,direct_state_access} is not available and the
* buffer is not already bound somewhere, it is bound to hinted target * buffer is not already bound somewhere, it is bound to hinted target
* before the operation. * before the operation.
* @see setTargetHint(), @fn_gl{BindBuffer} and @fn_gl{FlushMappedBufferRange} * @see @ref setTargetHint(), @fn_gl{BindBuffer} and @fn_gl{FlushMappedBufferRange}
* or @fn_gl_extension{FlushMappedNamedBufferRange,EXT,direct_state_access} * or @fn_gl_extension{FlushMappedNamedBufferRange,EXT,direct_state_access}
* @requires_gl30 %Extension @extension{ARB,map_buffer_range} * @requires_gl30 %Extension @extension{ARB,map_buffer_range}
* @requires_gles30 %Extension @es_extension{EXT,map_buffer_range} * @requires_gles30 %Extension @es_extension{EXT,map_buffer_range}
@ -851,7 +833,7 @@ class MAGNUM_EXPORT Buffer {
* the buffer was mapped (e.g. after screen was resized), `true` * the buffer was mapped (e.g. after screen was resized), `true`
* otherwise. * otherwise.
* *
* Unmaps buffer previously mapped with map(), invalidating the * Unmaps buffer previously mapped with @ref map(), invalidating the
* pointer returned by these functions. If @extension{EXT,direct_state_access} * pointer returned by these functions. If @extension{EXT,direct_state_access}
* is not available and the buffer is not already bound somewhere, it * is not available and the buffer is not already bound somewhere, it
* is bound to hinted target before the operation. * is bound to hinted target before the operation.
@ -867,7 +849,7 @@ class MAGNUM_EXPORT Buffer {
/** /**
* @brief Unmap portion of buffer * @brief Unmap portion of buffer
* *
* Unmaps portion of buffer previously mapped with mapSub(), * Unmaps portion of buffer previously mapped with @ref mapSub(),
* invalidating the pointer returned by the function. * invalidating the pointer returned by the function.
* @see @fn_gl_extension{UnmapBufferSubData,CHROMIUM,map_sub} * @see @fn_gl_extension{UnmapBufferSubData,CHROMIUM,map_sub}
* @requires_gles20 Not available in ES 3.0 or desktop OpenGL. Use * @requires_gles20 Not available in ES 3.0 or desktop OpenGL. Use

37
src/BufferTexture.h

@ -26,7 +26,7 @@
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
/** @file /** @file
* @brief Class Magnum::BufferTexture, enum Magnum::BufferTextureFormat * @brief Class @ref Magnum::BufferTexture, enum @ref Magnum::BufferTextureFormat
*/ */
#endif #endif
@ -38,7 +38,7 @@ namespace Magnum {
/** /**
@brief Internal buffer texture format @brief Internal buffer texture format
@see BufferTexture @see @ref BufferTexture
*/ */
enum class BufferTextureFormat: GLenum { enum class BufferTextureFormat: GLenum {
/** Red component, normalized unsigned byte. */ /** Red component, normalized unsigned byte. */
@ -153,14 +153,14 @@ enum class BufferTextureFormat: GLenum {
/** /**
@brief %Buffer texture @brief %Buffer texture
This texture is, unlike classic textures such as Texture or CubeMapTexture, This texture is, unlike classic textures such as @ref Texture or
used as simple data source, without any unnecessary interpolation and @ref CubeMapTexture, used as simple data source, without any unnecessary
wrapping methods. interpolation and wrapping methods.
@section BufferTexture-usage Usage @section BufferTexture-usage Usage
%Texture data are stored in buffer and after binding the buffer to the texture %Texture data are stored in buffer and after binding the buffer to the texture
using setBuffer(), you can fill the buffer at any time using data setting using @ref setBuffer(), you can fill the buffer at any time using data setting
functions in Buffer itself. functions in Buffer itself.
Note that the buffer is not managed (e.g. deleted on destruction) by the Note that the buffer is not managed (e.g. deleted on destruction) by the
@ -177,23 +177,24 @@ texture.setBuffer(BufferTextureFormat::RGB32F, buffer);
constexpr static Vector3 data[] = { constexpr static Vector3 data[] = {
// ... // ...
}; };
buffer.setData(data, Buffer::Usage::StaticDraw); buffer.setData(data, BufferUsage::StaticDraw);
@endcode @endcode
The texture is bound to layer specified by shader via bind(). In shader, the The texture is bound to layer specified by shader via @ref bind(). In shader,
texture is used via `samplerBuffer`, `isamplerBuffer` or `usamplerBuffer`. the texture is used via `samplerBuffer`, `isamplerBuffer` or `usamplerBuffer`.
Unlike in classic textures, coordinates for buffer textures are integer Unlike in classic textures, coordinates for buffer textures are integer
coordinates passed to `texelFetch()`. See also AbstractShaderProgram coordinates passed to `texelFetch()`. See also @ref AbstractShaderProgram
documentation for more information. documentation for more information.
@section BufferTexture-performance-optimization Performance optimizations @section BufferTexture-performance-optimization Performance optimizations
If extension @extension{EXT,direct_state_access} is available, setBuffer()
If extension @extension{EXT,direct_state_access} is available, @ref setBuffer()
functions use DSA to avoid unnecessary calls to @fn_gl{ActiveTexture} and functions use DSA to avoid unnecessary calls to @fn_gl{ActiveTexture} and
@fn_gl{BindTexture}. See @ref AbstractTexture-performance-optimization @fn_gl{BindTexture}. See
"relevant section in AbstractTexture documentation" and respective function @ref AbstractTexture-performance-optimization "relevant section in AbstractTexture documentation"
documentation for more information. and respective function documentation for more information.
@see Texture, CubeMapTexture, CubeMapTextureArray @see @ref Texture, @ref CubeMapTexture, @ref CubeMapTextureArray
@requires_gl31 %Extension @extension{ARB,texture_buffer_object} @requires_gl31 %Extension @extension{ARB,texture_buffer_object}
@requires_gl Texture buffers are not available in OpenGL ES. @requires_gl Texture buffers are not available in OpenGL ES.
*/ */
@ -217,8 +218,8 @@ class MAGNUM_EXPORT BufferTexture: private AbstractTexture {
* @param buffer %Buffer with data * @param buffer %Buffer with data
* *
* Binds given buffer to this texture. The buffer itself can be then * Binds given buffer to this texture. The buffer itself can be then
* filled with data of proper format at any time using Buffer own data * filled with data of proper format at any time using @ref Buffer "Buffer"'s
* setting functions. * own data setting functions.
* @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexBuffer} * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexBuffer}
* or @fn_gl_extension{TextureBuffer,EXT,direct_state_access} * or @fn_gl_extension{TextureBuffer,EXT,direct_state_access}
*/ */
@ -234,7 +235,7 @@ class MAGNUM_EXPORT BufferTexture: private AbstractTexture {
* @param size Data size * @param size Data size
* *
* Binds range of given buffer to this texture. The buffer itself can * Binds range of given buffer to this texture. The buffer itself can
* be then filled with data of proper format at any time using Buffer * be then filled with data of proper format at any time using @ref Buffer "Buffer"'s
* own data setting functions. * own data setting functions.
* @requires_gl43 %Extension @extension{ARB,texture_buffer_range} * @requires_gl43 %Extension @extension{ARB,texture_buffer_range}
* @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexBufferRange} * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and @fn_gl{TexBufferRange}

26
src/CubeMapTexture.h

@ -25,7 +25,7 @@
*/ */
/** @file /** @file
* @brief Class Magnum::CubeMapTexture * @brief Class @ref Magnum::CubeMapTexture
*/ */
#include "AbstractTexture.h" #include "AbstractTexture.h"
@ -49,12 +49,12 @@ turned upside down (+Y is top):
@section CubeMapTexture-usage Basic usage @section CubeMapTexture-usage Basic usage
See Texture documentation for introduction. See @ref Texture documentation for introduction.
Common usage is to fully configure all texture parameters and then set the Common usage is to fully configure all texture parameters and then set the
data from e.g. set of Image objects: data from e.g. set of Image objects:
@code @code
Image2D positiveX({256, 256}, ColorFormat::RGBA, ColorType::UnsignedByte, dataPositiveX); Image2D positiveX(ColorFormat::RGBA, ColorType::UnsignedByte, {256, 256}, data);
// ... // ...
CubeMapTexture texture; CubeMapTexture texture;
@ -66,11 +66,11 @@ texture.setMagnificationFilter(Sampler::Filter::Linear)
// ... // ...
@endcode @endcode
The texture is bound to layer specified by shader via bind(). In shader, the The texture is bound to layer specified by shader via @ref bind(). In shader,
texture is used via `samplerCube`, `samplerCubeShadow`, `isamplerCube` or the texture is used via `samplerCube`, `samplerCubeShadow`, `isamplerCube` or
`usamplerCube`. Unlike in classic textures, coordinates for cube map textures `usamplerCube`. Unlike in classic textures, coordinates for cube map textures
is signed three-part vector from the center of the cube, which intersects one 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 of the six sides of the cube map. See also @ref AbstractShaderProgram for more
information about usage in shaders. information about usage in shaders.
@see @ref Renderer::Feature::SeamlessCubeMapTexture, @ref CubeMapTextureArray, @see @ref Renderer::Feature::SeamlessCubeMapTexture, @ref CubeMapTextureArray,
@ -99,7 +99,7 @@ class CubeMapTexture: public AbstractTexture {
/** /**
* @brief Set wrapping * @brief Set wrapping
* *
* See Texture::setWrapping() for more information. * See @ref Texture::setWrapping() for more information.
*/ */
CubeMapTexture& setWrapping(const Array3D<Sampler::Wrapping>& wrapping) { CubeMapTexture& setWrapping(const Array3D<Sampler::Wrapping>& wrapping) {
DataHelper<3>::setWrapping(this, wrapping); DataHelper<3>::setWrapping(this, wrapping);
@ -112,7 +112,7 @@ class CubeMapTexture: public AbstractTexture {
* @param coordinate Coordinate * @param coordinate Coordinate
* @param level Mip level * @param level Mip level
* *
* See Texture::imageSize() for more information. * See @ref Texture::imageSize() for more information.
* @requires_gl %Texture image queries are not available in OpenGL ES. * @requires_gl %Texture image queries are not available in OpenGL ES.
*/ */
Vector2i imageSize(Coordinate coordinate, Int level) { Vector2i imageSize(Coordinate coordinate, Int level) {
@ -123,7 +123,7 @@ class CubeMapTexture: public AbstractTexture {
/** /**
* @brief Set storage * @brief Set storage
* *
* See Texture::setStorage() for more information. * See @ref Texture::setStorage() for more information.
*/ */
CubeMapTexture& setStorage(Int levels, TextureFormat internalFormat, const Vector2i& size) { CubeMapTexture& setStorage(Int levels, TextureFormat internalFormat, const Vector2i& size) {
DataHelper<2>::setStorage(this, _target, levels, internalFormat, size); DataHelper<2>::setStorage(this, _target, levels, internalFormat, size);
@ -137,7 +137,7 @@ class CubeMapTexture: public AbstractTexture {
* @param level Mip level * @param level Mip level
* @param image %Image where to put the data * @param image %Image where to put the data
* *
* See Texture::image(Int, Image&) for more information. * See @ref Texture::image(Int, Image&) for more information.
* @requires_gl %Texture image queries are not available in OpenGL ES. * @requires_gl %Texture image queries are not available in OpenGL ES.
*/ */
void image(Coordinate coordinate, Int level, Image2D& image) { void image(Coordinate coordinate, Int level, Image2D& image) {
@ -151,7 +151,7 @@ class CubeMapTexture: public AbstractTexture {
* @param image %Buffer image where to put the data * @param image %Buffer image where to put the data
* @param usage %Buffer usage * @param usage %Buffer usage
* *
* See Texture::image(Int, BufferImage&, Buffer::Usage) for more * See @ref Texture::image(Int, BufferImage&, BufferUsage) for more
* information. * information.
* @requires_gl %Texture image queries are not available in OpenGL ES. * @requires_gl %Texture image queries are not available in OpenGL ES.
*/ */
@ -168,7 +168,7 @@ class CubeMapTexture: public AbstractTexture {
* @param image %Image * @param image %Image
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)
* *
* See Texture::setImage() for more information. * See @ref Texture::setImage() for more information.
*/ */
CubeMapTexture& setImage(Coordinate coordinate, Int level, TextureFormat internalFormat, const ImageReference2D& image) { CubeMapTexture& setImage(Coordinate coordinate, Int level, TextureFormat internalFormat, const ImageReference2D& image) {
DataHelper<2>::setImage(this, GLenum(coordinate), level, internalFormat, image); DataHelper<2>::setImage(this, GLenum(coordinate), level, internalFormat, image);
@ -191,7 +191,7 @@ class CubeMapTexture: public AbstractTexture {
* @param image %Image * @param image %Image
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)
* *
* See Texture::setSubImage() for more information. * See @ref Texture::setSubImage() for more information.
*/ */
CubeMapTexture& setSubImage(Coordinate coordinate, Int level, const Vector2i& offset, const ImageReference2D& image) { CubeMapTexture& setSubImage(Coordinate coordinate, Int level, const Vector2i& offset, const ImageReference2D& image) {
DataHelper<2>::setSubImage(this, GLenum(coordinate), level, offset, image); DataHelper<2>::setSubImage(this, GLenum(coordinate), level, offset, image);

57
src/CubeMapTextureArray.h

@ -26,7 +26,7 @@
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
/** @file /** @file
* @brief Class Magnum::CubeMapTextureArray * @brief Class @ref Magnum::CubeMapTextureArray
*/ */
#endif #endif
@ -38,26 +38,23 @@ namespace Magnum {
/** /**
@brief Cube map texture array @brief Cube map texture array
See CubeMapTexture documentation for introduction. See @ref CubeMapTexture documentation for introduction.
@section CubeMapTextureArray-usage Usage @section CubeMapTextureArray-usage Usage
Common usage is to specify each layer and face separately using setSubImage(). Common usage is to specify each layer and face separately using @ref setSubImage().
You have to allocate the memory for all layers and faces first either by You have to allocate the memory for all layers and faces first either by
calling setStorage() or by passing properly sized empty Image to setImage(). calling @ref setStorage() or by passing properly sized empty image to
Example: array with 16 layers of cube map faces, each face consisting of six @ref setImage(). Example: array with 16 layers of cube map faces, each face
64x64 images: consisting of six 64x64 images:
@code @code
Image3D dummy({64, 64, 16*6}, ColorFormat::RGBA, ColorType::UnsignedByte, nullptr);
CubeMapTextureArray texture; CubeMapTextureArray texture;
texture.setMagnificationFilter(Sampler::Filter::Linear) texture.setMagnificationFilter(Sampler::Filter::Linear)
// ... // ...
.setStorage(Math::log2(64)+1, TextureFormat::RGBA8, {64, 64, 16}); .setStorage(Math::log2(64)+1, TextureFormat::RGBA8, {64, 64, 16});
for(std::size_t i = 0; i != 16; ++i) { for(std::size_t i = 0; i != 16; ++i) {
void* dataPositiveX = ...; Image2D imagePositiveX(ColorFormat::RGBA, ColorType::UnsignedByte, {64, 64}, data);
Image2D imagePositiveX({64, 64}, ColorFormat::RGBA, ColorType::UnsignedByte, imagePositiveX);
// ... // ...
texture.setSubImage(i, CubeMapTextureArray::Coordinate::PositiveX, 0, {}, imagePositiveX); texture.setSubImage(i, CubeMapTextureArray::Coordinate::PositiveX, 0, {}, imagePositiveX);
texture.setSubImage(i, CubeMapTextureArray::Coordinate::NegativeX, 0, {}, imageNegativeX); texture.setSubImage(i, CubeMapTextureArray::Coordinate::NegativeX, 0, {}, imageNegativeX);
@ -67,13 +64,13 @@ for(std::size_t i = 0; i != 16; ++i) {
// ... // ...
@endcode @endcode
The texture is bound to layer specified by shader via bind(). In shader, the The texture is bound to layer specified by shader via @ref bind(). In shader,
texture is used via `samplerCubeArray`, `samplerCubeArrayShadow`, the texture is used via `samplerCubeArray`, `samplerCubeArrayShadow`,
`isamplerCubeArray` or `usamplerCubeArray`. Unlike in classic textures, `isamplerCubeArray` or `usamplerCubeArray`. Unlike in classic textures,
coordinates for cube map texture arrays is signed four-part vector. First three coordinates for cube map texture arrays is signed four-part vector. First three
parts define vector from the center of the cube which intersects with one of 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 the six sides of the cube map, fourth part is layer in the array. See also
AbstractShaderProgram for more information about usage in shaders. @ref AbstractShaderProgram for more information about usage in shaders.
@see @ref Renderer::Feature::SeamlessCubeMapTexture, @ref CubeMapTexture, @see @ref Renderer::Feature::SeamlessCubeMapTexture, @ref CubeMapTexture,
@ref Texture, @ref BufferTexture @ref Texture, @ref BufferTexture
@ -103,7 +100,7 @@ class CubeMapTextureArray: public AbstractTexture {
/** /**
* @brief Set wrapping * @brief Set wrapping
* *
* See Texture::setWrapping() for more information. * See @ref Texture::setWrapping() for more information.
*/ */
CubeMapTextureArray& setWrapping(const Array3D<Sampler::Wrapping>& wrapping) { CubeMapTextureArray& setWrapping(const Array3D<Sampler::Wrapping>& wrapping) {
DataHelper<3>::setWrapping(this, wrapping); DataHelper<3>::setWrapping(this, wrapping);
@ -115,7 +112,7 @@ class CubeMapTextureArray: public AbstractTexture {
* @param coordinate Coordinate * @param coordinate Coordinate
* @param level Mip level * @param level Mip level
* *
* See Texture::imageSize() for more information. * See @ref Texture::imageSize() for more information.
*/ */
Vector3i imageSize(Coordinate coordinate, Int level) { Vector3i imageSize(Coordinate coordinate, Int level) {
return DataHelper<3>::imageSize(this, GL_TEXTURE_CUBE_MAP_POSITIVE_X + GLenum(coordinate), level); return DataHelper<3>::imageSize(this, GL_TEXTURE_CUBE_MAP_POSITIVE_X + GLenum(coordinate), level);
@ -124,7 +121,7 @@ class CubeMapTextureArray: public AbstractTexture {
/** /**
* @brief Set storage * @brief Set storage
* *
* See Texture::setStorage() for more information. * See @ref Texture::setStorage() for more information.
*/ */
CubeMapTextureArray& setStorage(Int levels, TextureFormat internalFormat, const Vector3i& size) { CubeMapTextureArray& setStorage(Int levels, TextureFormat internalFormat, const Vector3i& size) {
DataHelper<3>::setStorage(this, _target, levels, internalFormat, size); DataHelper<3>::setStorage(this, _target, levels, internalFormat, size);
@ -138,7 +135,7 @@ class CubeMapTextureArray: public AbstractTexture {
* @param level Mip level * @param level Mip level
* @param image %Image where to put the data * @param image %Image where to put the data
* *
* See Texture::image(Int, Image&) for more information. * See @ref Texture::image(Int, Image&) for more information.
* @requires_gl %Texture image queries are not available in OpenGL ES. * @requires_gl %Texture image queries are not available in OpenGL ES.
*/ */
void image(Coordinate coordinate, Int level, Image3D& image) { void image(Coordinate coordinate, Int level, Image3D& image) {
@ -152,11 +149,11 @@ class CubeMapTextureArray: public AbstractTexture {
* @param image %Buffer image where to put the data * @param image %Buffer image where to put the data
* @param usage %Buffer usage * @param usage %Buffer usage
* *
* See Texture::image(Int, BufferImage&, Buffer::Usage) for more * See @ref Texture::image(Int, BufferImage&, BufferUsage) for more
* information. * information.
* @requires_gl %Texture image queries are not available in OpenGL ES. * @requires_gl %Texture image queries are not available in OpenGL ES.
*/ */
void image(Coordinate coordinate, Int level, BufferImage3D& image, Buffer::Usage usage) { void image(Coordinate coordinate, Int level, BufferImage3D& image, BufferUsage usage) {
AbstractTexture::image<3>(GL_TEXTURE_CUBE_MAP_POSITIVE_X + GLenum(coordinate), level, image, usage); AbstractTexture::image<3>(GL_TEXTURE_CUBE_MAP_POSITIVE_X + GLenum(coordinate), level, image, usage);
} }
#endif #endif
@ -165,15 +162,15 @@ class CubeMapTextureArray: public AbstractTexture {
* @brief Set image data * @brief Set image data
* @param level Mip level * @param level Mip level
* @param internalFormat Internal format * @param internalFormat Internal format
* @param image Image, ImageReference, BufferImage or * @param image @ref Image, @ref ImageReference, @ref BufferImage
* Trade::ImageData of the same dimension count * or @ref Trade::ImageData of the same dimension count
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)
* *
* Sets texture image data from three-dimensional image for all cube * Sets texture image data from three-dimensional image for all cube
* faces for all layers. Each group of 6 2D images is one cube map * faces for all layers. Each group of 6 2D images is one cube map
* layer. The images are ordered the same way as Coordinate enum. * layer. The images are ordered the same way as Coordinate enum.
* *
* See Texture::setImage() for more information. * See @ref Texture::setImage() for more information.
*/ */
CubeMapTextureArray& setImage(Int level, TextureFormat internalFormat, const ImageReference3D& image) { CubeMapTextureArray& setImage(Int level, TextureFormat internalFormat, const ImageReference3D& image) {
DataHelper<3>::setImage(this, GL_TEXTURE_CUBE_MAP_ARRAY, level, internalFormat, image); DataHelper<3>::setImage(this, GL_TEXTURE_CUBE_MAP_ARRAY, level, internalFormat, image);
@ -190,8 +187,8 @@ class CubeMapTextureArray: public AbstractTexture {
* @brief Set texture image 3D subdata * @brief Set texture image 3D subdata
* @param level Mip level * @param level Mip level
* @param offset Offset where to put data in the texture * @param offset Offset where to put data in the texture
* @param image Image3D, ImageReference3D, BufferImage3D or * @param image @ref Image3D, @ref ImageReference3D, @ref BufferImage3D
* Trade::ImageData3D * or @ref Trade::ImageData3D
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)
* *
* Sets texture image subdata for more than one level/face at once. * Sets texture image subdata for more than one level/face at once.
@ -199,11 +196,9 @@ class CubeMapTextureArray: public AbstractTexture {
* Z coordinate of @p offset specifies layer and cube map face. If * Z coordinate of @p offset specifies layer and cube map face. If
* you want to start at given face in layer *n*, you have to specify * you want to start at given face in layer *n*, you have to specify
* Z coordinate as @f$ 6n + i @f$, where i is face index as specified * Z coordinate as @f$ 6n + i @f$, where i is face index as specified
* in Coordinate enum. * in @ref Coordinate enum.
*
* See Texture::setSubImage() for more information.
* *
* @see setSubImage(Int, Coordinate, Int, const Math::Vector<2, Int>&, const Image*) * See @ref Texture::setSubImage() for more information.
*/ */
CubeMapTextureArray& setSubImage(Int level, const Vector3i& offset, const ImageReference3D& image) { CubeMapTextureArray& setSubImage(Int level, const Vector3i& offset, const ImageReference3D& image) {
DataHelper<3>::setSubImage(this, GL_TEXTURE_CUBE_MAP_ARRAY, level, offset, image); DataHelper<3>::setSubImage(this, GL_TEXTURE_CUBE_MAP_ARRAY, level, offset, image);
@ -223,10 +218,10 @@ class CubeMapTextureArray: public AbstractTexture {
* @param size Size of invalidated data * @param size Size of invalidated data
* *
* Z coordinate is equivalent to layer * 6 + number of texture face, * Z coordinate is equivalent to layer * 6 + number of texture face,
* i.e. @ref Coordinate "Coordinate::PositiveX" is `0` and so on, in * i.e. @ref Coordinate::PositiveX is `0` and so on, in the same order
* the same order as in the enum. * 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) { void invalidateSubImage(Int level, const Vector3i& offset, const Vector3i& size) {
DataHelper<3>::invalidateSubImage(this, level, offset, size); DataHelper<3>::invalidateSubImage(this, level, offset, size);

2
src/Math/Geometry/Rectangle.h

@ -36,7 +36,7 @@ namespace Magnum { namespace Math { namespace Geometry {
/** /**
@copybrief Math::Range2D @copybrief Math::Range2D
@deprecated Use @ref Math::Range2D instead. @deprecated Use @ref Magnum::Math::Range2D instead.
*/ */
template<class T> class Rectangle: public Range2D<T> { template<class T> class Rectangle: public Range2D<T> {
public: public:

73
src/Mesh.h

@ -83,7 +83,7 @@ Mesh mesh;
static constexpr Vector3 positions[30] = { static constexpr Vector3 positions[30] = {
// ... // ...
}; };
vertexBuffer.setData(positions, Buffer::Usage::StaticDraw); vertexBuffer.setData(positions, BufferUsage::StaticDraw);
// Set primitive and vertex count, add the buffer and specify its layout // Set primitive and vertex count, add the buffer and specify its layout
mesh.setPrimitive(Mesh::Primitive::Triangles) mesh.setPrimitive(Mesh::Primitive::Triangles)
@ -100,7 +100,7 @@ Buffer vertexBuffer;
Mesh mesh; Mesh mesh;
// Fill vertex buffer with interleaved position and normal data // Fill vertex buffer with interleaved position and normal data
MeshTools::interleave(mesh, buffer, Buffer::Usage::StaticDraw, MeshTools::interleave(mesh, buffer, BufferUsage::StaticDraw,
plane.positions(0), plane.normals(0)); plane.positions(0), plane.normals(0));
// Set primitive and specify layout of interleaved vertex buffer, vertex count // Set primitive and specify layout of interleaved vertex buffer, vertex count
@ -126,13 +126,13 @@ Mesh mesh;
static constexpr Vector3 positions[300] = { static constexpr Vector3 positions[300] = {
// ... // ...
}; };
vertexBuffer.setData(positions, Buffer::Usage::StaticDraw); vertexBuffer.setData(positions, BufferUsage::StaticDraw);
// Fill index buffer with index data // Fill index buffer with index data
static constexpr GLubyte indices[75] = { static constexpr GLubyte indices[75] = {
// ... // ...
}; };
indexBuffer.setData(indices, Buffer::Usage::StaticDraw); indexBuffer.setData(indices, BufferUsage::StaticDraw);
// Set primitive, index count, specify the buffers // Set primitive, index count, specify the buffers
mesh.setPrimitive(Mesh::Primitive::Triangles) mesh.setPrimitive(Mesh::Primitive::Triangles)
@ -148,11 +148,11 @@ Buffer vertexBuffer, indexBuffer;
Mesh mesh; Mesh mesh;
// Fill vertex buffer with interleaved position and normal data // Fill vertex buffer with interleaved position and normal data
MeshTools::interleave(mesh, vertexBuffer, Buffer::Usage::StaticDraw, MeshTools::interleave(mesh, vertexBuffer, BufferUsage::StaticDraw,
cube.positions(0), cube.normals(0)); cube.positions(0), cube.normals(0));
// Fill index buffer with compressed index data // Fill index buffer with compressed index data
MeshTools::compressIndices(mesh, indexBuffer, Buffer::Usage::StaticDraw, MeshTools::compressIndices(mesh, indexBuffer, BufferUsage::StaticDraw,
cube.indices()); cube.indices());
// Set primitive and specify layout of interleaved vertex buffer. Index count // Set primitive and specify layout of interleaved vertex buffer. Index count
@ -192,7 +192,7 @@ Buffer colorBuffer;
GLubyte colors[4*30] = { GLubyte colors[4*30] = {
// ... // ...
}; };
colorBuffer.setData(colors, Buffer::Usage::StaticDraw); colorBuffer.setData(colors, BufferUsage::StaticDraw);
// Specify layout of color buffer -- BGRA, each component unsigned byte and we // Specify layout of color buffer -- BGRA, each component unsigned byte and we
// want to normalize them from [0, 255] to [0.0f, 1.0f] // want to normalize them from [0, 255] to [0.0f, 1.0f]
@ -241,7 +241,7 @@ class MAGNUM_EXPORT Mesh {
/** /**
* @brief Primitive type * @brief Primitive type
* *
* @see primitive(), setPrimitive() * @see @ref primitive(), @ref setPrimitive()
*/ */
enum class Primitive: GLenum { enum class Primitive: GLenum {
/** Single points. */ /** Single points. */
@ -315,7 +315,7 @@ class MAGNUM_EXPORT Mesh {
/** /**
* @brief Index type * @brief Index type
* *
* @see setIndexBuffer(), indexSize() * @see @ref setIndexBuffer(), @ref indexSize()
*/ */
enum class IndexType: GLenum { enum class IndexType: GLenum {
UnsignedByte = GL_UNSIGNED_BYTE, /**< Unsigned byte */ UnsignedByte = GL_UNSIGNED_BYTE, /**< Unsigned byte */
@ -365,7 +365,7 @@ class MAGNUM_EXPORT Mesh {
/** /**
* @brief Size of given index type * @brief Size of given index type
* *
* @see indexSize() const * @see @ref indexSize() const
*/ */
static std::size_t indexSize(IndexType type); static std::size_t indexSize(IndexType type);
@ -374,8 +374,8 @@ class MAGNUM_EXPORT Mesh {
* @param primitive Primitive type * @param primitive Primitive type
* *
* Creates mesh with no vertex buffers and zero vertex count. * Creates mesh with no vertex buffers and zero vertex count.
* @see setPrimitive(), setVertexCount(), @fn_gl{GenVertexArrays} (if * @see @ref setPrimitive(), @ref setVertexCount(), @fn_gl{GenVertexArrays}
* @extension{APPLE,vertex_array_object} is available) * (if @extension{APPLE,vertex_array_object} is available)
*/ */
explicit Mesh(Primitive primitive = Primitive::Triangles); explicit Mesh(Primitive primitive = Primitive::Triangles);
@ -402,7 +402,7 @@ class MAGNUM_EXPORT Mesh {
/** /**
* @brief Index size * @brief Index size
* *
* @see indexSize(IndexType) * @see @ref indexSize(IndexType)
*/ */
std::size_t indexSize() const { return indexSize(_indexType); } std::size_t indexSize() const { return indexSize(_indexType); }
@ -429,7 +429,8 @@ class MAGNUM_EXPORT Mesh {
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)
* *
* Default is zero. * Default is zero.
* @see setPrimitive(), addVertexBuffer(), MeshTools::interleave() * @see @ref setPrimitive(), @ref addVertexBuffer(),
* @ref MeshTools::interleave()
*/ */
Mesh& setVertexCount(Int vertexCount) { Mesh& setVertexCount(Int vertexCount) {
_vertexCount = vertexCount; _vertexCount = vertexCount;
@ -444,7 +445,7 @@ class MAGNUM_EXPORT Mesh {
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)
* *
* Default is zero. * Default is zero.
* @see setIndexBuffer(), MeshTools::compressIndices() * @see @ref setIndexBuffer(), @ref MeshTools::compressIndices()
*/ */
Mesh& setIndexCount(Int count) { Mesh& setIndexCount(Int count) {
_indexCount = count; _indexCount = count;
@ -469,34 +470,34 @@ class MAGNUM_EXPORT Mesh {
* position and normal, so you have to skip weight and texture * position and normal, so you have to skip weight and texture
* coordinate in each vertex: * coordinate in each vertex:
* @code * @code
Buffer buffer; * Buffer buffer;
Mesh mesh; * Mesh mesh;
mesh.addVertexBuffer(buffer, 76, // initial array offset * mesh.addVertexBuffer(buffer, 76, // initial array offset
4, // skip vertex weight (Float) * 4, // skip vertex weight (Float)
Shaders::Phong::Position(), // vertex position * Shaders::Phong::Position(), // vertex position
8, // skip texture coordinates (Vector2) * 8, // skip texture coordinates (Vector2)
Shaders::Phong::Normal()); // vertex normal * Shaders::Phong::Normal()); // vertex normal
@endcode * @endcode
* *
* You can also achieve the same effect by calling @ref addVertexBuffer() * You can also achieve the same effect by calling @ref addVertexBuffer()
* more times with explicitly specified gaps before and after the * more times with explicitly specified gaps before and after the
* attributes. This can be used for e.g. runtime-dependent * attributes. This can be used for e.g. runtime-dependent
* configuration, as it isn't dependent on the variadic template: * configuration, as it isn't dependent on the variadic template:
@code * @code
mesh.addVertexBuffer(buffer, 76, 4, Shaders::Phong::Position(), 20) * mesh.addVertexBuffer(buffer, 76, 4, Shaders::Phong::Position(), 20)
.addVertexBuffer(buffer, 76, 24, Shaders::Phong::Normal(), 0); * .addVertexBuffer(buffer, 76, 24, Shaders::Phong::Normal(), 0);
@endcode * @endcode
* *
* If specifying more than one attribute, the function assumes that * If specifying more than one attribute, the function assumes that
* the array is interleaved. Adding non-interleaved vertex buffer can * the array is interleaved. Adding non-interleaved vertex buffer can
* be done by specifying one attribute at a time with specific offset. * be done by specifying one attribute at a time with specific offset.
* Above example with weight, position, texture coordinate and normal * Above example with weight, position, texture coordinate and normal
* arrays one after another (non-interleaved): * arrays one after another (non-interleaved):
@code * @code
Int vertexCount = 352; * Int vertexCount = 352;
mesh.addVertexBuffer(buffer, 76 + 4*vertexCount, Shaders::Phong::Position()) * mesh.addVertexBuffer(buffer, 76 + 4*vertexCount, Shaders::Phong::Position())
.addVertexBuffer(buffer, 76 + 24*vertexCount, Shaders::Phong::Normal()); * .addVertexBuffer(buffer, 76 + 24*vertexCount, Shaders::Phong::Normal());
@endcode * @endcode
* *
* @attention The buffer passed as parameter is not managed by the * @attention The buffer passed as parameter is not managed by the
* mesh, you must ensure it will exist for whole lifetime of the * mesh, you must ensure it will exist for whole lifetime of the
@ -528,10 +529,10 @@ class MAGNUM_EXPORT Mesh {
* The smaller range is specified with @p start and @p end the less * The smaller range is specified with @p start and @p end the less
* memory operations are needed (and possibly some optimizations), * memory operations are needed (and possibly some optimizations),
* improving draw performance. Specifying `0` for both parameters * improving draw performance. Specifying `0` for both parameters
* behaves the same as setIndexBuffer(Buffer*, GLintptr, IndexType). * behaves the same as @ref setIndexBuffer(Buffer&, GLintptr, IndexType).
* On OpenGL ES 2.0 this function behaves always as * On OpenGL ES 2.0 this function behaves always as
* setIndexBuffer(Buffer*, GLintptr, IndexType), as this functionality * @ref setIndexBuffer(Buffer&, GLintptr, IndexType), as this
* is not available there. * functionality is not available there.
* @see @ref maxElementsIndices(), @ref maxElementsVertices(), * @see @ref maxElementsIndices(), @ref maxElementsVertices(),
* @ref setIndexCount(), @ref MeshTools::compressIndices(), * @ref setIndexCount(), @ref MeshTools::compressIndices(),
* @fn_gl{BindVertexArray}, @fn_gl{BindBuffer} (if * @fn_gl{BindVertexArray}, @fn_gl{BindBuffer} (if
@ -546,7 +547,7 @@ class MAGNUM_EXPORT Mesh {
* @param type Index data type * @param type Index data type
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)
* *
* Prefer to use setIndexBuffer(Buffer*, GLintptr, IndexType, UnsignedInt, UnsignedInt) * Prefer to use @ref setIndexBuffer(Buffer&, GLintptr, IndexType, UnsignedInt, UnsignedInt)
* for better performance. * for better performance.
* @see setIndexCount(), MeshTools::compressIndices(), * @see setIndexCount(), MeshTools::compressIndices(),
* @fn_gl{BindVertexArray}, @fn_gl{BindBuffer} (if * @fn_gl{BindVertexArray}, @fn_gl{BindBuffer} (if

10
src/MeshTools/CompressIndices.h

@ -25,7 +25,7 @@
*/ */
/** @file /** @file
* @brief Function Magnum::MeshTools::compressIndices() * @brief Function @ref Magnum::MeshTools::compressIndices()
*/ */
#include <tuple> #include <tuple>
@ -52,7 +52,7 @@ Containers::Array<char> data;
std::tie(indexCount, indexType, data) = MeshTools::compressIndices(indices); std::tie(indexCount, indexType, data) = MeshTools::compressIndices(indices);
@endcode @endcode
See also compressIndices(Mesh*, Buffer*, Buffer::Usage, const std::vector<UnsignedInt>&), See also @ref compressIndices(Mesh&, Buffer&, BufferUsage, const std::vector<UnsignedInt>&),
which writes the compressed data directly into index buffer of given mesh. which writes the compressed data directly into index buffer of given mesh.
*/ */
std::tuple<std::size_t, Mesh::IndexType, Containers::Array<char>> MAGNUM_MESHTOOLS_EXPORT compressIndices(const std::vector<UnsignedInt>& indices); std::tuple<std::size_t, Mesh::IndexType, Containers::Array<char>> MAGNUM_MESHTOOLS_EXPORT compressIndices(const std::vector<UnsignedInt>& indices);
@ -64,12 +64,12 @@ std::tuple<std::size_t, Mesh::IndexType, Containers::Array<char>> MAGNUM_MESHTOO
@param usage Index buffer usage @param usage Index buffer usage
@param indices Index array @param indices Index array
The same as compressIndices(const std::vector<UnsignedInt>&), but this The same as @ref compressIndices(const std::vector<UnsignedInt>&), but this
function writes the output to given buffer, updates index count and specifies function writes the output to given buffer, updates index count and specifies
index buffer with proper index range in the mesh, so you don't have to call index buffer with proper index range in the mesh, so you don't have to call
Mesh::setIndexCount() and Mesh::setIndexBuffer() on your own. @ref Mesh::setIndexCount() and @ref Mesh::setIndexBuffer() on your own.
@see MeshTools::interleave() @see @ref MeshTools::interleave()
*/ */
void MAGNUM_MESHTOOLS_EXPORT compressIndices(Mesh& mesh, Buffer& buffer, BufferUsage usage, const std::vector<UnsignedInt>& indices); void MAGNUM_MESHTOOLS_EXPORT compressIndices(Mesh& mesh, Buffer& buffer, BufferUsage usage, const std::vector<UnsignedInt>& indices);

14
src/MeshTools/Interleave.h

@ -25,7 +25,7 @@
*/ */
/** @file /** @file
* @brief Function Magnum::MeshTools::interleave() * @brief Function @ref Magnum::MeshTools::interleave()
*/ */
#include <cstring> #include <cstring>
@ -171,7 +171,7 @@ possible performance loss.
for) and function `size()` returning count of elements. In most cases it for) and function `size()` returning count of elements. In most cases it
will be `std::vector` or `std::array`. will be `std::vector` or `std::array`.
See also interleave(Mesh*, Buffer*, Buffer::Usage, const T&...), See also @ref interleave(Mesh&, Buffer&, BufferUsage, const T&...),
which writes the interleaved array directly into buffer of given mesh. which writes the interleaved array directly into buffer of given mesh.
*/ */
/* enable_if to avoid clash with overloaded function below */ /* enable_if to avoid clash with overloaded function below */
@ -186,9 +186,9 @@ template<class T, class ...U> inline typename std::enable_if<!std::is_same<T, Me
@param usage Vertex buffer usage @param usage Vertex buffer usage
@param attributes Attribute arrays and gaps @param attributes Attribute arrays and gaps
The same as interleave(const T&, const U&...), but this function writes the The same as @ref interleave(const T&, const U&...), but this function writes the
output to given array buffer and updates vertex count in the mesh accordingly, output to given array buffer and updates vertex count in the mesh accordingly,
so you don't have to call Mesh::setVertexCount() on your own. so you don't have to call @ref Mesh::setVertexCount() on your own.
@attention Setting primitive type and binding the attributes to shader is left @attention Setting primitive type and binding the attributes to shader is left
to user - see @ref Mesh-configuration "Mesh documentation". to user - see @ref Mesh-configuration "Mesh documentation".
@ -196,11 +196,11 @@ so you don't have to call Mesh::setVertexCount() on your own.
For only one attribute array this function is convenient equivalent to the For only one attribute array this function is convenient equivalent to the
following, without any performance loss: following, without any performance loss:
@code @code
buffer->setData(attribute, usage); buffer.setData(attribute, usage);
mesh->setVertexCount(attribute.size()); mesh.setVertexCount(attribute.size());
@endcode @endcode
@see MeshTools::compressIndices() @see @ref MeshTools::compressIndices()
*/ */
template<class ...T> inline void interleave(Mesh& mesh, Buffer& buffer, BufferUsage usage, const T&... attributes) { template<class ...T> inline void interleave(Mesh& mesh, Buffer& buffer, BufferUsage usage, const T&... attributes) {
return Implementation::Interleave()(mesh, buffer, usage, attributes...); return Implementation::Interleave()(mesh, buffer, usage, attributes...);

6
src/Text/Renderer.h

@ -186,7 +186,7 @@ Mesh mesh;
// Render the text // Render the text
Range2D rectangle; Range2D rectangle;
std::tie(mesh, rectangle) = Text::Renderer2D::render(*font, cache, 0.15f, std::tie(mesh, rectangle) = Text::Renderer2D::render(*font, cache, 0.15f,
"Hello World!", vertexBuffer, indexBuffer, Buffer::Usage::StaticDraw); "Hello World!", vertexBuffer, indexBuffer, BufferUsage::StaticDraw);
// Draw white text centered on the screen // Draw white text centered on the screen
shader.setTransformationProjectionMatrix(projection*Matrix3::translation(-rectangle.width()/2.0f)) shader.setTransformationProjectionMatrix(projection*Matrix3::translation(-rectangle.width()/2.0f))
@ -196,7 +196,7 @@ glyphCache->texture()->bind(Shaders::VectorShader2D::FontTextureLayer);
mesh.draw(); mesh.draw();
@endcode @endcode
See @ref render(AbstractFont&, const GlyphCache&, Float, const std::string&, Alignment) and See @ref render(AbstractFont&, const GlyphCache&, Float, const std::string&, Alignment) and
@ref render(AbstractFont&, const GlyphCache&, Float, const std::string&, Buffer&, Buffer&, Buffer::Usage, Alignment) @ref render(AbstractFont&, const GlyphCache&, Float, const std::string&, Buffer&, Buffer&, BufferUsage, Alignment)
for more information. for more information.
While this method is sufficient for one-shot rendering of static texts, for While this method is sufficient for one-shot rendering of static texts, for
@ -209,7 +209,7 @@ Shaders::VectorShader2D shader;
// Initialize renderer and reserve memory for enough glyphs // Initialize renderer and reserve memory for enough glyphs
Text::Renderer2D renderer(*font, cache, 0.15f); Text::Renderer2D renderer(*font, cache, 0.15f);
renderer.reserve(32, Buffer::Usage::DynamicDraw, Buffer::Usage::StaticDraw); renderer.reserve(32, BufferUsage::DynamicDraw, BufferUsage::StaticDraw);
// Update the text occasionally // Update the text occasionally
renderer.render("Hello World Countdown: 10"); renderer.render("Hello World Countdown: 10");

79
src/Texture.h

@ -25,7 +25,7 @@
*/ */
/** @file /** @file
* @brief Class Magnum::Texture, typedef Magnum::Texture1D, Magnum::Texture2D, Magnum::Texture3D * @brief Class @ref Magnum::Texture, typedef @ref Magnum::Texture1D, @ref Magnum::Texture2D, @ref Magnum::Texture3D
*/ */
#include "AbstractTexture.h" #include "AbstractTexture.h"
@ -37,16 +37,15 @@ namespace Magnum {
@brief %Texture @brief %Texture
Template class for one- to three-dimensional textures. See also Template class for one- to three-dimensional textures. See also
AbstractTexture documentation for more information. @ref AbstractTexture documentation for more information.
@section Texture-usage Usage @section Texture-usage Usage
Common usage is to fully configure all texture parameters and then set the Common usage is to fully configure all texture parameters and then set the
data from e.g. Image. Example configuration of high quality texture with data from e.g. @ref Image. Example configuration of high quality texture with
trilinear anisotropic filtering, i.e. the best you can ask for: trilinear anisotropic filtering, i.e. the best you can ask for:
@code @code
void* data; Image2D image(ColorFormat::RGBA, ColorType::UnsignedByte, {4096, 4096}, data);
Image2D image({4096, 4096}, ColorFormat::RGBA, ColorType::UnsignedByte, data);
Texture2D texture; Texture2D texture;
texture.setMagnificationFilter(Sampler::Filter::Linear) texture.setMagnificationFilter(Sampler::Filter::Linear)
@ -54,22 +53,23 @@ texture.setMagnificationFilter(Sampler::Filter::Linear)
.setWrapping(Sampler::Wrapping::ClampToEdge) .setWrapping(Sampler::Wrapping::ClampToEdge)
.setMaxAnisotropy(Sampler::maxAnisotropy()) .setMaxAnisotropy(Sampler::maxAnisotropy())
.setStorage(Math::log2(4096)+1, TextureFormat::RGBA8, {4096, 4096}) .setStorage(Math::log2(4096)+1, TextureFormat::RGBA8, {4096, 4096})
.setSubImage(0, {}, &image) .setSubImage(0, {}, image)
.generateMipmap(); .generateMipmap();
@endcode @endcode
@attention Don't forget to fully configure the texture before use. Note that @attention Don't forget to fully configure the texture before use. Note that
default configuration (if setMinificationFilter() is not called with default configuration (if @ref setMinificationFilter() is not called with
another value) is to use mipmaps, so be sure to either call setMinificationFilter(), another value) is to use mipmaps, so be sure to either call @ref setMinificationFilter(),
explicitly specify all mip levels with setStorage() and setImage() or call explicitly specify all mip levels with @ref setStorage() and @ref setImage()
generateMipmap(). If using rectangle texture, you must also call or call @ref generateMipmap(). If using rectangle texture, you must also
setWrapping(), because the initial value is not supported on rectangle call @ref setWrapping(), because the initial value is not supported on
textures. See also setMagnificationFilter() and setBorderColor(). rectangle textures. See also @ref setMagnificationFilter() and
@ref setBorderColor().
The texture is bound to layer specified by shader via bind(). In shader, the
texture is used via `sampler2D` and friends, see @ref Target enum documentation The texture is bound to layer specified by shader via @ref bind(). In shader,
for more information. See also AbstractShaderProgram documentation for more the texture is used via `sampler2D` and friends, see @ref Target enum
information about usage in shaders. documentation for more information. See also AbstractShaderProgram
documentation for more information about usage in shaders.
@section Texture-array Texture arrays @section Texture-array Texture arrays
@ -77,10 +77,10 @@ You can create texture arrays by passing
@ref Target::Texture1DArray "Texture2D::Target::Texture1DArray" or @ref Target::Texture1DArray "Texture2D::Target::Texture1DArray" or
@ref Target::Texture2DArray "Texture3D::Target::Texture2DArray" to constructor. @ref Target::Texture2DArray "Texture3D::Target::Texture2DArray" to constructor.
It is possible to specify each layer separately using setSubImage(), but you It is possible to specify each layer separately using @ref setSubImage(), but
have to allocate the memory for all layers first either by calling setStorage() you have to allocate the memory for all layers first either by calling
or by passing properly sized empty Image to setImage(). Example: 2D texture @ref setStorage() or by passing properly sized empty image to @ref setImage().
array with 16 layers of 64x64 images: Example: 2D texture array with 16 layers of 64x64 images:
@code @code
Texture3D texture(Texture3D::Target::Texture2DArray); Texture3D texture(Texture3D::Target::Texture2DArray);
texture.setMagnificationFilter(Sampler::Filter::Linear) texture.setMagnificationFilter(Sampler::Filter::Linear)
@ -88,8 +88,8 @@ texture.setMagnificationFilter(Sampler::Filter::Linear)
.setStorage(levels, TextureFormat::RGBA8, {64, 64,16}); .setStorage(levels, TextureFormat::RGBA8, {64, 64,16});
for(std::size_t i = 0; i != 16; ++i) { for(std::size_t i = 0; i != 16; ++i) {
void* data = ...; // ...
Image2D image({64, 64}, ColorFormat::RGBA, ColorType::UnsignedByte, image); Image2D image(ColorFormat::RGBA, ColorType::UnsignedByte, {64, 64}, data[i]);
texture.setSubImage(0, Vector3i::zAxis(i), image); texture.setSubImage(0, Vector3i::zAxis(i), image);
} }
@ -97,8 +97,8 @@ for(std::size_t i = 0; i != 16; ++i) {
@endcode @endcode
Similar approach can be used for any other texture types (e.g. setting Similar approach can be used for any other texture types (e.g. setting
Texture3D data using 2D layers, Texture2D data using one-dimensional chunks @ref Texture3D data using 2D layers, @ref Texture2D data using one-dimensional
etc.). chunks etc.).
@requires_gl30 %Extension @extension{EXT,texture_array} for texture arrays. @requires_gl30 %Extension @extension{EXT,texture_array} for texture arrays.
@requires_gles30 %Array textures are not available in OpenGL ES 2.0. @requires_gles30 %Array textures are not available in OpenGL ES 2.0.
@ -130,8 +130,8 @@ documentation for more information.
textures. textures.
@requires_gl Rectangle textures are not available in OpenGL ES. @requires_gl Rectangle textures are not available in OpenGL ES.
@see Texture1D, Texture2D, Texture3D, CubeMapTexture, CubeMapTextureArray, @see @ref Texture1D, @ref Texture2D, @ref Texture3D, @ref CubeMapTexture,
BufferTexture @ref CubeMapTextureArray, @ref BufferTexture
@todo @extension{AMD,sparse_texture} @todo @extension{AMD,sparse_texture}
*/ */
template<UnsignedInt dimensions> class Texture: public AbstractTexture { template<UnsignedInt dimensions> class Texture: public AbstractTexture {
@ -224,7 +224,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* is `Target::Texture1D`, `Target::Texture2D` or * is `Target::Texture1D`, `Target::Texture2D` or
* `Target::Texture3D` based on dimension count. * `Target::Texture3D` based on dimension count.
* *
* Creates one OpenGL texture. * Creates new OpenGL texture.
* @see @fn_gl{GenTextures} * @see @fn_gl{GenTextures}
*/ */
explicit Texture(Target target = DataHelper<Dimensions>::target()): AbstractTexture(GLenum(target)) {} explicit Texture(Target target = DataHelper<Dimensions>::target()): AbstractTexture(GLenum(target)) {}
@ -281,13 +281,14 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* Specifies entire structure of a texture at once, removing the need * Specifies entire structure of a texture at once, removing the need
* for additional consistency checks and memory reallocations when * for additional consistency checks and memory reallocations when
* updating the data later. After calling this function the texture * updating the data later. After calling this function the texture
* is immutable and calling setStorage() or setImage() is not allowed. * is immutable and calling @ref setStorage() or @ref setImage() is not
* allowed.
* *
* If @extension{EXT,direct_state_access} is not available, the * If @extension{EXT,direct_state_access} is not available, the
* texture is bound to some layer before the operation. If * texture is bound to some layer before the operation. If
* OpenGL 4.2, @extension{ARB,texture_storage}, OpenGL ES 3.0 or @es_extension{EXT,texture_storage} * OpenGL 4.2, @extension{ARB,texture_storage}, OpenGL ES 3.0 or @es_extension{EXT,texture_storage}
* in OpenGL ES 2.0 is not available, the feature is emulated with * in OpenGL ES 2.0 is not available, the feature is emulated with
* sequence of setImage() calls. * sequence of @ref setImage() calls.
* @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and * @see @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
* @fn_gl{TexStorage1D}/@fn_gl{TexStorage2D}/@fn_gl{TexStorage3D} * @fn_gl{TexStorage1D}/@fn_gl{TexStorage2D}/@fn_gl{TexStorage3D}
* or @fn_gl_extension{TextureStorage1D,EXT,direct_state_access}/ * or @fn_gl_extension{TextureStorage1D,EXT,direct_state_access}/
@ -310,7 +311,8 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* @param image %Image where to put the data * @param image %Image where to put the data
* *
* %Image parameters like format and type of pixel data are taken from * %Image parameters like format and type of pixel data are taken from
* given image, image size is taken from the texture using imageSize(). * given image, image size is taken from the texture using
* @ref imageSize().
* *
* If @extension{EXT,direct_state_access} is not available, the * If @extension{EXT,direct_state_access} is not available, the
* texture is bound to some layer before the operation. If * texture is bound to some layer before the operation. If
@ -336,7 +338,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* @param image %Buffer image where to put the data * @param image %Buffer image where to put the data
* @param usage %Buffer usage * @param usage %Buffer usage
* *
* See image(Int, Image&) for more information. * See @ref image(Int, Image&) for more information.
* @requires_gl %Texture image queries are not available in OpenGL ES. * @requires_gl %Texture image queries are not available in OpenGL ES.
*/ */
void image(Int level, BufferImage<dimensions>& image, BufferUsage usage) { void image(Int level, BufferImage<dimensions>& image, BufferUsage usage) {
@ -352,8 +354,8 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)
* *
* For better performance when generating mipmaps using * For better performance when generating mipmaps using
* generateMipmap() or calling setImage() more than once use * @ref generateMipmap() or calling @ref setImage() more than once use
* setStorage() and setSubImage() instead. * @ref setStorage() and @ref setSubImage() instead.
* *
* If @extension{EXT,direct_state_access} is not available, the * If @extension{EXT,direct_state_access} is not available, the
* texture is bound to some layer before the operation. * texture is bound to some layer before the operation.
@ -385,9 +387,10 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* *
* If @extension{EXT,direct_state_access} is not available, the * If @extension{EXT,direct_state_access} is not available, the
* texture is bound to some layer before the operation. * texture is bound to some layer before the operation.
* @see setStorage(), setImage(), @fn_gl{ActiveTexture}, @fn_gl{BindTexture} * @see @ref setStorage(), @ref setImage(), @fn_gl{ActiveTexture},
* and @fn_gl{TexSubImage1D}/@fn_gl{TexSubImage2D}/@fn_gl{TexSubImage3D} * @fn_gl{BindTexture} and @fn_gl{TexSubImage1D}/
* or @fn_gl_extension{TextureSubImage1D,EXT,direct_state_access}/ * @fn_gl{TexSubImage2D}/@fn_gl{TexSubImage3D} or
* @fn_gl_extension{TextureSubImage1D,EXT,direct_state_access}/
* @fn_gl_extension{TextureSubImage2D,EXT,direct_state_access}/ * @fn_gl_extension{TextureSubImage2D,EXT,direct_state_access}/
* @fn_gl_extension{TextureSubImage3D,EXT,direct_state_access} * @fn_gl_extension{TextureSubImage3D,EXT,direct_state_access}
*/ */
@ -412,7 +415,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* *
* If running on OpenGL ES or extension @extension{ARB,invalidate_subdata} * If running on OpenGL ES or extension @extension{ARB,invalidate_subdata}
* is not available, this function does nothing. * is not available, this function does nothing.
* @see invalidateImage(), @fn_gl{InvalidateTexSubImage} * @see @ref invalidateImage(), @fn_gl{InvalidateTexSubImage}
*/ */
void invalidateSubImage(Int level, const typename DimensionTraits<Dimensions, Int>::VectorType& offset, const typename DimensionTraits<Dimensions, Int>::VectorType& size) { void invalidateSubImage(Int level, const typename DimensionTraits<Dimensions, Int>::VectorType& offset, const typename DimensionTraits<Dimensions, Int>::VectorType& size) {
DataHelper<dimensions>::invalidateSubImage(this, level, offset, size); DataHelper<dimensions>::invalidateSubImage(this, level, offset, size);

Loading…
Cancel
Save