mirror of https://github.com/mosra/magnum.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1306 lines
64 KiB
1306 lines
64 KiB
|
8 years ago
|
#ifndef Magnum_GL_Texture_h
|
||
|
|
#define Magnum_GL_Texture_h
|
||
|
16 years ago
|
/*
|
||
|
|
This file is part of Magnum.
|
||
|
|
|
||
|
8 years ago
|
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
|
||
|
12 years ago
|
Vladimír Vondruš <mosra@centrum.cz>
|
||
|
13 years ago
|
|
||
|
|
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.
|
||
|
16 years ago
|
*/
|
||
|
|
|
||
|
|
/** @file
|
||
|
13 years ago
|
* @brief Class @ref Magnum::Texture, typedef @ref Magnum::Texture1D, @ref Magnum::Texture2D, @ref Magnum::Texture3D
|
||
|
16 years ago
|
*/
|
||
|
|
|
||
|
12 years ago
|
#include "Magnum/Array.h"
|
||
|
13 years ago
|
#include "Magnum/DimensionTraits.h"
|
||
|
8 years ago
|
#include "Magnum/GL/AbstractTexture.h"
|
||
|
12 years ago
|
#include "Magnum/Math/Vector3.h"
|
||
|
16 years ago
|
|
||
|
|
namespace Magnum {
|
||
|
|
|
||
|
12 years ago
|
namespace Implementation {
|
||
|
|
template<UnsignedInt> constexpr GLenum textureTarget();
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
11 years ago
|
template<> constexpr GLenum textureTarget<1>() { return GL_TEXTURE_1D; }
|
||
|
12 years ago
|
#endif
|
||
|
11 years ago
|
template<> constexpr GLenum textureTarget<2>() { return GL_TEXTURE_2D; }
|
||
|
11 years ago
|
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
|
||
|
11 years ago
|
template<> constexpr GLenum textureTarget<3>() {
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
return GL_TEXTURE_3D;
|
||
|
|
#else
|
||
|
|
return GL_TEXTURE_3D_OES;
|
||
|
|
#endif
|
||
|
|
}
|
||
|
11 years ago
|
#endif
|
||
|
12 years ago
|
|
||
|
12 years ago
|
template<UnsignedInt dimensions> VectorTypeFor<dimensions, Int> maxTextureSize();
|
||
|
8 years ago
|
template<> MAGNUM_GL_EXPORT Vector3i maxTextureSize<3>();
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
16 years ago
|
/**
|
||
|
12 years ago
|
@brief Texture
|
||
|
15 years ago
|
|
||
|
14 years ago
|
Template class for one- to three-dimensional textures. See also
|
||
|
13 years ago
|
@ref AbstractTexture documentation for more information.
|
||
|
14 years ago
|
|
||
|
8 years ago
|
@section Texture-usage Usage
|
||
|
14 years ago
|
|
||
|
|
Common usage is to fully configure all texture parameters and then set the
|
||
|
13 years ago
|
data from e.g. @ref Image. Example configuration of high quality texture with
|
||
|
14 years ago
|
trilinear anisotropic filtering, i.e. the best you can ask for:
|
||
|
8 years ago
|
|
||
|
8 years ago
|
@snippet MagnumGL.cpp Texture-usage
|
||
|
14 years ago
|
|
||
|
12 years ago
|
@attention Note that default configuration is to use mipmaps. Be sure to either
|
||
|
|
reduce mip level count using @ref setBaseLevel() and @ref setMaxLevel(),
|
||
|
|
explicitly allocate all mip levels using @ref setStorage(), call
|
||
|
|
@ref generateMipmap() after uploading the base level to generate the rest
|
||
|
|
of the mip chain or call @ref setMinificationFilter() with another value to
|
||
|
|
disable mipmapping.
|
||
|
13 years ago
|
|
||
|
8 years ago
|
In shader, the texture is used via @glsl sampler1D @ce / @glsl sampler2D @ce /
|
||
|
|
@glsl sampler3D @ce, @glsl sampler1DShadow @ce / @glsl sampler2DShadow @ce /
|
||
|
|
@glsl sampler3DShadow @ce, @glsl isampler1D @ce / @glsl isampler2D @ce /
|
||
|
|
@glsl isampler3D @ce or @glsl usampler1D @ce / @glsl usampler2D @ce /
|
||
|
|
@glsl usampler3D @ce. See @ref AbstractShaderProgram documentation for more
|
||
|
|
information about usage in shaders.
|
||
|
12 years ago
|
|
||
|
12 years ago
|
@see @ref Texture1D, @ref Texture2D, @ref Texture3D, @ref TextureArray,
|
||
|
|
@ref CubeMapTexture, @ref CubeMapTextureArray, @ref RectangleTexture,
|
||
|
|
@ref BufferTexture, @ref MultisampleTexture
|
||
|
8 years ago
|
@m_keywords{GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D}
|
||
|
9 years ago
|
@requires_gles30 Extension @extension{OES,texture_3D} for 3D textures in
|
||
|
11 years ago
|
OpenGL ES 2.0.
|
||
|
|
@requires_webgl20 3D textures are not available in WebGL 1.0.
|
||
|
|
@requires_gl 1D textures are not available in OpenGL ES or WebGL.
|
||
|
16 years ago
|
*/
|
||
|
13 years ago
|
template<UnsignedInt dimensions> class Texture: public AbstractTexture {
|
||
|
16 years ago
|
public:
|
||
|
11 years ago
|
enum: UnsignedInt {
|
||
|
|
Dimensions = dimensions /**< Texture dimension count */
|
||
|
|
};
|
||
|
14 years ago
|
|
||
|
12 years ago
|
/**
|
||
|
|
* @brief Max supported texture size
|
||
|
|
*
|
||
|
|
* The result is cached, repeated queries don't result in repeated
|
||
|
|
* OpenGL calls. For 3D textures in OpenGL ES 2.0, if
|
||
|
9 years ago
|
* @extension{OES,texture_3D} extension is not available, returns
|
||
|
12 years ago
|
* zero vector.
|
||
|
8 years ago
|
* @see @fn_gl{Get} with @def_gl_keyword{MAX_TEXTURE_SIZE},
|
||
|
|
* @def_gl_keyword{MAX_3D_TEXTURE_SIZE}
|
||
|
12 years ago
|
*/
|
||
|
12 years ago
|
static VectorTypeFor<dimensions, Int> maxSize() {
|
||
|
12 years ago
|
return Implementation::maxTextureSize<dimensions>();
|
||
|
|
}
|
||
|
|
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
/**
|
||
|
|
* @brief Compressed block size
|
||
|
|
*
|
||
|
|
* If @p format is compressed, returns compressed block size (in
|
||
|
|
* pixels). For uncompressed formats returns zero vector.
|
||
|
8 years ago
|
* @see @ref compressedBlockDataSize(), @fn_gl_keyword{GetInternalformat}
|
||
|
|
* with @def_gl_keyword{TEXTURE_COMPRESSED_BLOCK_WIDTH},
|
||
|
|
* @def_gl_keyword{TEXTURE_COMPRESSED_BLOCK_HEIGHT}
|
||
|
11 years ago
|
* @requires_gl43 Extension @extension{ARB,internalformat_query2}
|
||
|
|
* @requires_gl Compressed texture queries are not available in OpenGL
|
||
|
|
* ES.
|
||
|
|
*/
|
||
|
|
static VectorTypeFor<dimensions, Int> compressedBlockSize(TextureFormat format) {
|
||
|
|
return DataHelper<dimensions>::compressedBlockSize(Implementation::textureTarget<dimensions>(), format);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @brief Compressed block data size
|
||
|
|
*
|
||
|
|
* If @p format is compressed, returns compressed block data size (in
|
||
|
|
* bytes). For uncompressed formats returns zero.
|
||
|
8 years ago
|
* @see @ref compressedBlockSize(), @fn_gl_keyword{GetInternalformat}
|
||
|
|
* with @def_gl_keyword{TEXTURE_COMPRESSED_BLOCK_SIZE}
|
||
|
11 years ago
|
* @requires_gl43 Extension @extension{ARB,internalformat_query2}
|
||
|
|
* @requires_gl Compressed texture queries are not available in OpenGL
|
||
|
|
* ES.
|
||
|
|
*/
|
||
|
|
static Int compressedBlockDataSize(TextureFormat format) {
|
||
|
|
return AbstractTexture::compressedBlockDataSize(Implementation::textureTarget<dimensions>(), format);
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
11 years ago
|
/**
|
||
|
|
* @brief Wrap existing OpenGL texture object
|
||
|
|
* @param id OpenGL texture ID
|
||
|
|
* @param flags Object creation flags
|
||
|
|
*
|
||
|
|
* The @p id is expected to be of an existing OpenGL texture object
|
||
|
|
* with target @def_gl{TEXTURE_1D}, @def_gl{TEXTURE_2D} or
|
||
|
|
* @def_gl{TEXTURE_3D} based on dimension count. Unlike texture created
|
||
|
|
* using constructor, the OpenGL object is by default not deleted on
|
||
|
|
* destruction, use @p flags for different behavior.
|
||
|
|
* @see @ref release()
|
||
|
|
*/
|
||
|
|
static Texture<dimensions> wrap(GLuint id, ObjectFlags flags = {}) {
|
||
|
|
return Texture<dimensions>{id, flags};
|
||
|
|
}
|
||
|
|
|
||
|
16 years ago
|
/**
|
||
|
|
* @brief Constructor
|
||
|
|
*
|
||
|
12 years ago
|
* Creates new OpenGL texture object. If @extension{ARB,direct_state_access}
|
||
|
11 years ago
|
* (part of OpenGL 4.5) is not available, the texture is created on
|
||
|
12 years ago
|
* first use.
|
||
|
8 years ago
|
* @see @ref Texture(NoCreateT), @ref wrap(), @fn_gl_keyword{CreateTextures}
|
||
|
11 years ago
|
* with @def_gl{TEXTURE_1D}, @def_gl{TEXTURE_2D} or
|
||
|
8 years ago
|
* @def_gl{TEXTURE_3D}, eventually @fn_gl_keyword{GenTextures}
|
||
|
16 years ago
|
*/
|
||
|
12 years ago
|
explicit Texture(): AbstractTexture(Implementation::textureTarget<dimensions>()) {}
|
||
|
|
|
||
|
11 years ago
|
/**
|
||
|
|
* @brief Construct without creating the underlying OpenGL object
|
||
|
|
*
|
||
|
|
* The constructed instance is equivalent to moved-from state. Useful
|
||
|
|
* in cases where you will overwrite the instance later anyway. Move
|
||
|
|
* another object over it to make it useful.
|
||
|
9 years ago
|
*
|
||
|
|
* This function can be safely used for constructing (and later
|
||
|
|
* destructing) objects even without any OpenGL context being active.
|
||
|
11 years ago
|
* @see @ref Texture(), @ref wrap()
|
||
|
|
*/
|
||
|
|
explicit Texture(NoCreateT) noexcept: AbstractTexture{NoCreate, Implementation::textureTarget<dimensions>()} {}
|
||
|
|
|
||
|
10 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
|
/**
|
||
|
|
* @brief Bind level of texture to given image unit
|
||
|
|
* @param imageUnit Image unit
|
||
|
|
* @param level Texture level
|
||
|
|
* @param access Image access
|
||
|
|
* @param format Image format
|
||
|
|
*
|
||
|
|
* Available only on 1D and 2D textures.
|
||
|
|
* @note This function is meant to be used only internally from
|
||
|
|
* @ref AbstractShaderProgram subclasses. See its documentation
|
||
|
|
* for more information.
|
||
|
|
* @see @ref bindImages(Int, std::initializer_list<AbstractTexture*>),
|
||
|
|
* @ref bindImageLayered(), @ref unbindImage(), @ref unbindImages(),
|
||
|
|
* @ref AbstractShaderProgram::maxImageUnits(),
|
||
|
8 years ago
|
* @fn_gl_keyword{BindImageTexture}
|
||
|
10 years ago
|
* @requires_gl42 Extension @extension{ARB,shader_image_load_store}
|
||
|
|
* @requires_gles31 Shader image load/store is not available in OpenGL
|
||
|
|
* ES 3.0 and older.
|
||
|
|
* @requires_gles Shader image load/store is not available in WebGL.
|
||
|
|
*/
|
||
|
|
#ifndef DOXYGEN_GENERATING_OUTPUT
|
||
|
|
template<UnsignedInt d = dimensions, class = typename std::enable_if<d == 1 || d == 2>::type>
|
||
|
|
#endif
|
||
|
|
void bindImage(Int imageUnit, Int level, ImageAccess access, ImageFormat format) {
|
||
|
|
bindImageInternal(imageUnit, level, false, 0, access, format);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @brief Bind level of given texture layer to given image unit
|
||
|
|
* @param imageUnit Image unit
|
||
|
|
* @param level Texture level
|
||
|
|
* @param layer Texture layer
|
||
|
|
* @param access Image access
|
||
|
|
* @param format Image format
|
||
|
|
*
|
||
|
|
* Available only on 3D textures.
|
||
|
|
* @note This function is meant to be used only internally from
|
||
|
|
* @ref AbstractShaderProgram subclasses. See its documentation
|
||
|
|
* for more information.
|
||
|
|
* @see @ref bindImages(Int, std::initializer_list<AbstractTexture*>),
|
||
|
|
* @ref bindImageLayered(), @ref unbindImage(), @ref unbindImages(),
|
||
|
|
* @ref AbstractShaderProgram::maxImageUnits(),
|
||
|
8 years ago
|
* @fn_gl_keyword{BindImageTexture}
|
||
|
10 years ago
|
* @requires_gl42 Extension @extension{ARB,shader_image_load_store}
|
||
|
|
* @requires_gles31 Shader image load/store is not available in OpenGL
|
||
|
|
* ES 3.0 and older.
|
||
|
|
* @requires_gles Shader image load/store is not available in WebGL.
|
||
|
|
*/
|
||
|
|
#ifndef DOXYGEN_GENERATING_OUTPUT
|
||
|
|
template<UnsignedInt d = dimensions, class = typename std::enable_if<d == 3>::type>
|
||
|
|
#endif
|
||
|
|
void bindImage(Int imageUnit, Int level, Int layer, ImageAccess access, ImageFormat format) {
|
||
|
|
bindImageInternal(imageUnit, level, false, layer, access, format);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @brief Bind level of layered texture to given image unit
|
||
|
|
* @param imageUnit Image unit
|
||
|
|
* @param level Texture level
|
||
|
|
* @param access Image access
|
||
|
|
* @param format Image format
|
||
|
|
*
|
||
|
|
* Available only on 3D textures.
|
||
|
|
* @note This function is meant to be used only internally from
|
||
|
|
* @ref AbstractShaderProgram subclasses. See its documentation
|
||
|
|
* for more information.
|
||
|
|
* @see @ref bindImages(Int, std::initializer_list<AbstractTexture*>),
|
||
|
|
* @ref bindImage(), @ref unbindImage(), @ref unbindImages(),
|
||
|
|
* @ref AbstractShaderProgram::maxImageUnits(),
|
||
|
|
* @fn_gl{BindImageTexture}
|
||
|
|
* @requires_gl42 Extension @extension{ARB,shader_image_load_store}
|
||
|
|
* @requires_gles31 Shader image load/store is not available in OpenGL
|
||
|
|
* ES 3.0 and older.
|
||
|
|
* @requires_gles Shader image load/store is not available in WebGL.
|
||
|
|
*/
|
||
|
|
#ifndef DOXYGEN_GENERATING_OUTPUT
|
||
|
|
template<UnsignedInt d = dimensions, class = typename std::enable_if<d == 3>::type>
|
||
|
|
#endif
|
||
|
|
void bindImageLayered(Int imageUnit, Int level, ImageAccess access, ImageFormat format) {
|
||
|
|
bindImageInternal(imageUnit, level, true, 0, access, format);
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
/**
|
||
|
|
* @brief Set base mip level
|
||
|
|
* @return Reference to self (for method chaining)
|
||
|
|
*
|
||
|
|
* Taken into account when generating mipmap using @ref generateMipmap()
|
||
|
|
* and when considering texture completeness when using mipmap
|
||
|
11 years ago
|
* filtering. If neither @extension{ARB,direct_state_access} (part of
|
||
|
|
* OpenGL 4.5) nor @extension{EXT,direct_state_access} desktop
|
||
|
|
* extension is available, the texture is bound before the operation
|
||
|
8 years ago
|
* (if not already). Initial value is @cpp 0 @ce.
|
||
|
12 years ago
|
* @see @ref setMaxLevel(), @ref setMinificationFilter(),
|
||
|
8 years ago
|
* @fn_gl2_keyword{TextureParameter,TexParameter},
|
||
|
|
* @fn_gl_extension_keyword{TextureParameter,EXT,direct_state_access},
|
||
|
12 years ago
|
* eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
|
||
|
8 years ago
|
* @fn_gl_keyword{TexParameter} with @def_gl_keyword{TEXTURE_BASE_LEVEL}
|
||
|
12 years ago
|
* @requires_gles30 Base level is always `0` in OpenGL ES 2.0.
|
||
|
11 years ago
|
* @requires_webgl20 Base level is always `0` in WebGL 1.0.
|
||
|
12 years ago
|
*/
|
||
|
|
Texture<dimensions>& setBaseLevel(Int level) {
|
||
|
|
AbstractTexture::setBaseLevel(level);
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
11 years ago
|
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
|
||
|
12 years ago
|
/**
|
||
|
|
* @brief Set max mip level
|
||
|
|
* @return Reference to self (for method chaining)
|
||
|
|
*
|
||
|
|
* Taken into account when generating mipmap using @ref generateMipmap()
|
||
|
|
* and when considering texture completeness when using mipmap
|
||
|
11 years ago
|
* filtering. If neither @extension{ARB,direct_state_access} (part of
|
||
|
|
* OpenGL 4.5) nor @extension{EXT,direct_state_access} desktop
|
||
|
|
* extension is available, the texture is bound before the operation
|
||
|
|
* (if not already). Initial value is `1000`, which is clamped to count
|
||
|
|
* of levels specified when using @ref setStorage().
|
||
|
12 years ago
|
* @see @ref setBaseLevel(), @ref setMinificationFilter(),
|
||
|
8 years ago
|
* @fn_gl2_keyword{TextureParameter,TexParameter},
|
||
|
|
* @fn_gl_extension_keyword{TextureParameter,EXT,direct_state_access},
|
||
|
12 years ago
|
* eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
|
||
|
8 years ago
|
* @fn_gl_keyword{TexParameter} with @def_gl_keyword{TEXTURE_MAX_LEVEL}
|
||
|
9 years ago
|
* @requires_gles30 Extension @extension{APPLE,texture_max_level},
|
||
|
12 years ago
|
* otherwise the max level is always set to largest possible value
|
||
|
|
* in OpenGL ES 2.0.
|
||
|
11 years ago
|
* @requires_webgl20 Always set to largest possible value in WebGL 1.0.
|
||
|
12 years ago
|
*/
|
||
|
|
Texture<dimensions>& setMaxLevel(Int level) {
|
||
|
|
AbstractTexture::setMaxLevel(level);
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
11 years ago
|
#endif
|
||
|
12 years ago
|
|
||
|
12 years ago
|
/**
|
||
|
|
* @brief Set minification filter
|
||
|
|
* @param filter Filter
|
||
|
|
* @param mipmap Mipmap filtering. If set to anything else than
|
||
|
|
* @ref Sampler::Mipmap::Base, make sure textures for all mip
|
||
|
|
* levels are set or call @ref generateMipmap().
|
||
|
|
* @return Reference to self (for method chaining)
|
||
|
|
*
|
||
|
|
* Sets filter used when the object pixel size is smaller than the
|
||
|
11 years ago
|
* texture size. If neither @extension{ARB,direct_state_access} (part
|
||
|
|
* of OpenGL 4.5) nor @extension{EXT,direct_state_access} desktop
|
||
|
|
* extension is available, the texture is bound before the operation
|
||
|
|
* (if not already). Initial value is {@ref Sampler::Filter::Nearest,
|
||
|
12 years ago
|
* @ref Sampler::Mipmap::Linear}.
|
||
|
12 years ago
|
* @see @ref setMagnificationFilter(), @ref setBaseLevel(),
|
||
|
8 years ago
|
* @ref setMaxLevel(), @fn_gl2_keyword{TextureParameter,TexParameter},
|
||
|
|
* @fn_gl_extension_keyword{TextureParameter,EXT,direct_state_access},
|
||
|
12 years ago
|
* eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
|
||
|
8 years ago
|
* @fn_gl_keyword{TexParameter} with @def_gl_keyword{TEXTURE_MIN_FILTER}
|
||
|
12 years ago
|
*/
|
||
|
|
Texture<dimensions>& setMinificationFilter(Sampler::Filter filter, Sampler::Mipmap mipmap = Sampler::Mipmap::Base) {
|
||
|
|
AbstractTexture::setMinificationFilter(filter, mipmap);
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @brief Set magnification filter
|
||
|
|
* @param filter Filter
|
||
|
|
* @return Reference to self (for method chaining)
|
||
|
|
*
|
||
|
|
* Sets filter used when the object pixel size is larger than largest
|
||
|
11 years ago
|
* texture size. If neither @extension{ARB,direct_state_access} (part
|
||
|
|
* of OpenGL 4.5) nor @extension{EXT,direct_state_access} desktop
|
||
|
|
* extension is available, the texture is bound before the operation
|
||
|
|
* (if not already). Initial value is @ref Sampler::Filter::Linear.
|
||
|
8 years ago
|
* @see @ref setMinificationFilter(), @fn_gl2_keyword{TextureParameter,TexParameter},
|
||
|
|
* @fn_gl_extension_keyword{TextureParameter,EXT,direct_state_access},
|
||
|
12 years ago
|
* eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
|
||
|
8 years ago
|
* @fn_gl_keyword{TexParameter} with @def_gl_keyword{TEXTURE_MAG_FILTER}
|
||
|
12 years ago
|
*/
|
||
|
|
Texture<dimensions>& setMagnificationFilter(Sampler::Filter filter) {
|
||
|
|
AbstractTexture::setMagnificationFilter(filter);
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
|
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
/**
|
||
|
|
* @brief Set minimum level-of-detail parameter
|
||
|
|
* @return Reference to self (for method chaining)
|
||
|
|
*
|
||
|
11 years ago
|
* Limits selection of highest resolution mipmap. If neither
|
||
|
|
* @extension{ARB,direct_state_access} (part of OpenGL 4.5) nor
|
||
|
|
* @extension{EXT,direct_state_access} desktop extension is available,
|
||
|
|
* the texture is bound before the operation (if not already). Initial
|
||
|
8 years ago
|
* value is @cpp -1000.0f @ce.
|
||
|
|
* @see @ref setMaxLod(), @ref setLodBias(), @fn_gl2_keyword{TextureParameter,TexParameter},
|
||
|
|
* @fn_gl_extension_keyword{TextureParameter,EXT,direct_state_access},
|
||
|
12 years ago
|
* eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
|
||
|
8 years ago
|
* @fn_gl_keyword{TexParameter} with @def_gl_keyword{TEXTURE_MIN_LOD}
|
||
|
12 years ago
|
* @requires_gles30 Texture LOD parameters are not available in OpenGL
|
||
|
12 years ago
|
* ES 2.0.
|
||
|
11 years ago
|
* @requires_webgl20 Texture LOD parameters are not available in WebGL
|
||
|
|
* 1.0.
|
||
|
12 years ago
|
*/
|
||
|
|
Texture<dimensions>& setMinLod(Float lod) {
|
||
|
|
AbstractTexture::setMinLod(lod);
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @brief Set maximum level-of-detail parameter
|
||
|
|
* @return Reference to self (for method chaining)
|
||
|
|
*
|
||
|
11 years ago
|
* Limits selection of lowest resolution mipmap. If neither
|
||
|
|
* @extension{ARB,direct_state_access} (part of OpenGL 4.5) nor
|
||
|
|
* @extension{EXT,direct_state_access} desktop extension is available,
|
||
|
|
* the texture is bound before the operation (if not already). Initial
|
||
|
8 years ago
|
* value is @cpp 1000.0f @ce.
|
||
|
|
* @see @ref setMinLod(), @ref setLodBias(), @fn_gl2_keyword{TextureParameter,TexParameter},
|
||
|
|
* @fn_gl_extension_keyword{TextureParameter,EXT,direct_state_access},
|
||
|
12 years ago
|
* eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
|
||
|
8 years ago
|
* @fn_gl_keyword{TexParameter} with @def_gl_keyword{TEXTURE_MAX_LOD}
|
||
|
12 years ago
|
* @requires_gles30 Texture LOD parameters are not available in OpenGL
|
||
|
12 years ago
|
* ES 2.0.
|
||
|
11 years ago
|
* @requires_webgl20 Texture LOD parameters are not available in WebGL
|
||
|
|
* 1.0.
|
||
|
12 years ago
|
*/
|
||
|
|
Texture<dimensions>& setMaxLod(Float lod) {
|
||
|
|
AbstractTexture::setMaxLod(lod);
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
/**
|
||
|
|
* @brief Set level-of-detail bias
|
||
|
|
* @return Reference to self (for method chaining)
|
||
|
|
*
|
||
|
|
* Fixed bias value that is added to the level-of-detail parameter. If
|
||
|
12 years ago
|
* neither @extension{ARB,direct_state_access} (part of OpenGL 4.5) nor
|
||
|
|
* @extension{EXT,direct_state_access} is available, the texture is
|
||
|
|
* bound before the operation (if not already). Initial value is
|
||
|
8 years ago
|
* @cpp 0.0f @ce.
|
||
|
12 years ago
|
* @see @ref maxLodBias(), @ref setMinLod(), @ref setMaxLod(),
|
||
|
8 years ago
|
* @fn_gl2_keyword{TextureParameter,TexParameter},
|
||
|
|
* @fn_gl_extension_keyword{TextureParameter,EXT,direct_state_access},
|
||
|
12 years ago
|
* eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
|
||
|
8 years ago
|
* @fn_gl_keyword{TexParameter} with @def_gl_keyword{TEXTURE_LOD_BIAS}
|
||
|
12 years ago
|
* @requires_gl Texture LOD bias can be specified only directly in
|
||
|
11 years ago
|
* fragment shader in OpenGL ES and WebGL.
|
||
|
12 years ago
|
*/
|
||
|
|
Texture<dimensions>& setLodBias(Float bias) {
|
||
|
|
AbstractTexture::setLodBias(bias);
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
16 years ago
|
/**
|
||
|
|
* @brief Set wrapping
|
||
|
14 years ago
|
* @param wrapping Wrapping type for all texture dimensions
|
||
|
13 years ago
|
* @return Reference to self (for method chaining)
|
||
|
16 years ago
|
*
|
||
|
12 years ago
|
* Sets wrapping type for coordinates out of range @f$ [ 0.0, 1.0 ] @f$.
|
||
|
11 years ago
|
* If neither @extension{ARB,direct_state_access} (part of OpenGL 4.5)
|
||
|
|
* nor @extension{EXT,direct_state_access} desktop extension is
|
||
|
|
* available, the texture is bound before the operation (if not
|
||
|
|
* already). Initial value is @ref Sampler::Wrapping::Repeat.
|
||
|
8 years ago
|
* @see @ref setBorderColor(), @fn_gl2_keyword{TextureParameter,TexParameter},
|
||
|
|
* @fn_gl_extension_keyword{TextureParameter,EXT,direct_state_access},
|
||
|
12 years ago
|
* eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
|
||
|
8 years ago
|
* @fn_gl_keyword{TexParameter} with @def_gl_keyword{TEXTURE_WRAP_S},
|
||
|
|
* @def_gl_keyword{TEXTURE_WRAP_T}, @def_gl_keyword{TEXTURE_WRAP_R}
|
||
|
16 years ago
|
*/
|
||
|
12 years ago
|
Texture<dimensions>& setWrapping(const Array<dimensions, Sampler::Wrapping>& wrapping) {
|
||
|
|
DataHelper<dimensions>::setWrapping(*this, wrapping);
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
|
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
12 years ago
|
/**
|
||
|
|
* @brief Set border color
|
||
|
|
* @return Reference to self (for method chaining)
|
||
|
|
*
|
||
|
|
* Border color when wrapping is set to @ref Sampler::Wrapping::ClampToBorder.
|
||
|
11 years ago
|
* If neither @extension{ARB,direct_state_access} (part of OpenGL 4.5)
|
||
|
|
* nor @extension{EXT,direct_state_access} is available, the texture is
|
||
|
|
* bound before the operation (if not already). Initial value is
|
||
|
8 years ago
|
* @cpp 0x00000000_rgbaf @ce.
|
||
|
|
* @see @ref setWrapping(), @fn_gl2_keyword{TextureParameter,TexParameter},
|
||
|
|
* @fn_gl_extension_keyword{TextureParameter,EXT,direct_state_access},
|
||
|
12 years ago
|
* eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
|
||
|
8 years ago
|
* @fn_gl_keyword{TexParameter} with @def_gl_keyword{TEXTURE_BORDER_COLOR}
|
||
|
9 years ago
|
* @requires_gles32 Extension @extension{ANDROID,extension_pack_es31a} /
|
||
|
9 years ago
|
* @extension{EXT,texture_border_clamp} or
|
||
|
|
* @extension{NV,texture_border_clamp}
|
||
|
11 years ago
|
* @requires_gles Border clamp is not available in WebGL.
|
||
|
12 years ago
|
*/
|
||
|
|
Texture<dimensions>& setBorderColor(const Color4& color) {
|
||
|
|
AbstractTexture::setBorderColor(color);
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
|
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
12 years ago
|
/**
|
||
|
|
* @brief Set border color for integer texture
|
||
|
|
* @return Reference to self (for method chaining)
|
||
|
|
*
|
||
|
|
* Border color for integer textures when wrapping is set to
|
||
|
12 years ago
|
* @ref Sampler::Wrapping::ClampToBorder. If neither
|
||
|
|
* @extension{ARB,direct_state_access} (part of OpenGL 4.5) nor
|
||
|
|
* @extension{EXT,direct_state_access} is available, the texture is
|
||
|
|
* bound before the operation (if not already). Initial value is
|
||
|
8 years ago
|
* @cpp {0, 0, 0, 0} @ce.
|
||
|
|
* @see @fn_gl2_keyword{TextureParameter,TexParameter},
|
||
|
|
* @fn_gl_extension_keyword{TextureParameter,EXT,direct_state_access},
|
||
|
12 years ago
|
* eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
|
||
|
8 years ago
|
* @fn_gl_keyword{TexParameter} with @def_gl_keyword{TEXTURE_BORDER_COLOR}
|
||
|
12 years ago
|
* @requires_gl30 Extension @extension{EXT,texture_integer}
|
||
|
11 years ago
|
* @requires_gles30 Not defined in OpenGL ES 2.0.
|
||
|
9 years ago
|
* @requires_gles32 Extension @extension{ANDROID,extension_pack_es31a} /
|
||
|
9 years ago
|
* @extension{EXT,texture_border_clamp}
|
||
|
11 years ago
|
* @requires_gles Border clamp is not available in WebGL.
|
||
|
12 years ago
|
*/
|
||
|
|
Texture<dimensions>& setBorderColor(const Vector4ui& color) {
|
||
|
|
AbstractTexture::setBorderColor(color);
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
|
|
||
|
12 years ago
|
/** @overload
|
||
|
12 years ago
|
* @requires_gl30 Extension @extension{EXT,texture_integer}
|
||
|
11 years ago
|
* @requires_gles30 Not defined in OpenGL ES 2.0.
|
||
|
9 years ago
|
* @requires_gles32 Extension @extension{ANDROID,extension_pack_es31a} /
|
||
|
9 years ago
|
* @extension{EXT,texture_border_clamp}
|
||
|
11 years ago
|
* @requires_gles Border clamp is not available in WebGL.
|
||
|
12 years ago
|
*/
|
||
|
12 years ago
|
Texture<dimensions>& setBorderColor(const Vector4i& color) {
|
||
|
|
AbstractTexture::setBorderColor(color);
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
|
#endif
|
||
|
11 years ago
|
#endif
|
||
|
12 years ago
|
|
||
|
12 years ago
|
/**
|
||
|
|
* @brief Set max anisotropy
|
||
|
|
* @return Reference to self (for method chaining)
|
||
|
|
*
|
||
|
8 years ago
|
* Default value is @cpp 1.0f @ce, which means no anisotropy. Set to
|
||
|
|
* value greater than @cpp 1.0f @ce for anisotropic filtering. If
|
||
|
|
* extension @extension{EXT,texture_filter_anisotropic} (desktop or ES)
|
||
|
|
* is not available, this function does nothing. If neither
|
||
|
12 years ago
|
* @extension{ARB,direct_state_access} (part of OpenGL 4.5) nor
|
||
|
11 years ago
|
* @extension{EXT,direct_state_access} desktop extension is available,
|
||
|
|
* the texture is bound before the operation (if not already).
|
||
|
8 years ago
|
* @see @ref Sampler::maxMaxAnisotropy(), @fn_gl2_keyword{TextureParameter,TexParameter},
|
||
|
|
* @fn_gl_extension_keyword{TextureParameter,EXT,direct_state_access},
|
||
|
12 years ago
|
* eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
|
||
|
8 years ago
|
* @fn_gl_keyword{TexParameter} with
|
||
|
|
* @def_gl_keyword{TEXTURE_MAX_ANISOTROPY_EXT}
|
||
|
12 years ago
|
*/
|
||
|
|
Texture<dimensions>& setMaxAnisotropy(Float anisotropy) {
|
||
|
|
AbstractTexture::setMaxAnisotropy(anisotropy);
|
||
|
13 years ago
|
return *this;
|
||
|
14 years ago
|
}
|
||
|
16 years ago
|
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
12 years ago
|
/**
|
||
|
|
* @brief Set sRGB decoding
|
||
|
|
* @return Reference to self (for method chaining)
|
||
|
|
*
|
||
|
11 years ago
|
* Disables or reenables decoding of sRGB values. If neither
|
||
|
|
* @extension{ARB,direct_state_access} (part of OpenGL 4.5) nor
|
||
|
|
* @extension{EXT,direct_state_access} desktop extension is available,
|
||
|
|
* the texture is bound before the operation (if not already). Initial
|
||
|
8 years ago
|
* value is @cpp true @ce.
|
||
|
|
* @see @fn_gl2_keyword{TextureParameter,TexParameter},
|
||
|
|
* @fn_gl_extension_keyword{TextureParameter,EXT,direct_state_access},
|
||
|
12 years ago
|
* eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
|
||
|
8 years ago
|
* @fn_gl_keyword{TexParameter} with @def_gl_keyword{TEXTURE_SRGB_DECODE_EXT}
|
||
|
12 years ago
|
* @requires_extension Extension @extension{EXT,texture_sRGB_decode}
|
||
|
12 years ago
|
* @requires_es_extension OpenGL ES 3.0 or extension
|
||
|
9 years ago
|
* @extension{EXT,sRGB} and
|
||
|
8 years ago
|
* @extension{ANDROID,extension_pack_es31a} /
|
||
|
9 years ago
|
* @extension2{EXT,texture_sRGB_decode,texture_sRGB_decode}
|
||
|
11 years ago
|
* @requires_gles SRGB decode is not available in WebGL.
|
||
|
12 years ago
|
*/
|
||
|
|
Texture<dimensions>& setSRGBDecode(bool decode) {
|
||
|
|
AbstractTexture::setSRGBDecode(decode);
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
11 years ago
|
#endif
|
||
|
12 years ago
|
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
12 years ago
|
/**
|
||
|
|
* @brief Set component swizzle
|
||
|
|
* @return Reference to self (for method chaining)
|
||
|
|
*
|
||
|
8 years ago
|
* You can use letters @cpp 'r' @ce, @cpp 'g' @ce, @cpp 'b' @ce,
|
||
|
|
* @cpp 'a' @ce for addressing components or letters @cpp '0' @ce and
|
||
|
|
* @cpp '1' @ce for zero and one, similarly as in the
|
||
|
12 years ago
|
* @ref Math::swizzle() function. Example usage:
|
||
|
8 years ago
|
*
|
||
|
8 years ago
|
* @snippet MagnumGL.cpp Texture-setSwizzle
|
||
|
8 years ago
|
*
|
||
|
11 years ago
|
* If neither @extension{ARB,direct_state_access} (part of OpenGL 4.5)
|
||
|
|
* nor @extension{EXT,direct_state_access} desktop extension is
|
||
|
|
* available, the texture is bound before the operation (if not
|
||
|
8 years ago
|
* already). Initial value is @cpp 'r', 'g', 'b', 'a' @ce.
|
||
|
|
* @see @fn_gl2_keyword{TextureParameter,TexParameter},
|
||
|
|
* @fn_gl_extension_keyword{TextureParameter,EXT,direct_state_access},
|
||
|
12 years ago
|
* eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
|
||
|
8 years ago
|
* @fn_gl_keyword{TexParameter} with @def_gl_keyword{TEXTURE_SWIZZLE_RGBA} (or
|
||
|
|
* @def_gl_keyword{TEXTURE_SWIZZLE_R}, @def_gl_keyword{TEXTURE_SWIZZLE_G},
|
||
|
|
* @def_gl_keyword{TEXTURE_SWIZZLE_B} and @def_gl_keyword{TEXTURE_SWIZZLE_A}
|
||
|
12 years ago
|
* separately in OpenGL ES)
|
||
|
12 years ago
|
* @requires_gl33 Extension @extension{ARB,texture_swizzle}
|
||
|
|
* @requires_gles30 Texture swizzle is not available in OpenGL ES 2.0.
|
||
|
11 years ago
|
* @requires_gles Texture swizzle is not available in WebGL.
|
||
|
12 years ago
|
*/
|
||
|
|
template<char r, char g, char b, char a> Texture<dimensions>& setSwizzle() {
|
||
|
|
AbstractTexture::setSwizzle<r, g, b, a>();
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
11 years ago
|
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
|
||
|
12 years ago
|
/**
|
||
|
|
* @brief Set depth texture comparison mode
|
||
|
|
* @return Reference to self (for method chaining)
|
||
|
|
*
|
||
|
11 years ago
|
* If neither @extension{ARB,direct_state_access} (part of OpenGL 4.5)
|
||
|
|
* nor @extension{EXT,direct_state_access} desktop extension is
|
||
|
|
* available, the texture is bound before the operation (if not
|
||
|
|
* already). Initial value is @ref Sampler::CompareMode::None.
|
||
|
12 years ago
|
* @note Depth textures can be only 1D or 2D.
|
||
|
8 years ago
|
* @see @ref setCompareFunction(), @fn_gl2_keyword{TextureParameter,TexParameter},
|
||
|
|
* @fn_gl_extension_keyword{TextureParameter,EXT,direct_state_access},
|
||
|
12 years ago
|
* eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
|
||
|
8 years ago
|
* @fn_gl_keyword{TexParameter} with @def_gl_keyword{TEXTURE_COMPARE_MODE}
|
||
|
9 years ago
|
* @requires_gles30 Extension @extension{EXT,shadow_samplers} in
|
||
|
11 years ago
|
* OpenGL ES 2.0.
|
||
|
|
* @requires_webgl20 Depth texture comparison is not available in WebGL
|
||
|
|
* 1.0.
|
||
|
12 years ago
|
*/
|
||
|
|
Texture<dimensions>& setCompareMode(Sampler::CompareMode mode) {
|
||
|
|
AbstractTexture::setCompareMode(mode);
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @brief Set depth texture comparison function
|
||
|
|
* @return Reference to self (for method chaining)
|
||
|
|
*
|
||
|
|
* Comparison operator used when comparison mode is set to
|
||
|
11 years ago
|
* @ref Sampler::CompareMode::CompareRefToTexture. If neither
|
||
|
|
* @extension{ARB,direct_state_access} (part of OpenGL 4.5) nor
|
||
|
|
* @extension{EXT,direct_state_access} desktop extension is available,
|
||
|
|
* the texture is bound before the operation (if not already). Initial
|
||
|
|
* value is @ref Sampler::CompareFunction::LessOrEqual.
|
||
|
12 years ago
|
* @note Depth textures can be only 1D or 2D.
|
||
|
8 years ago
|
* @see @ref setCompareMode(), @fn_gl2_keyword{TextureParameter,TexParameter},
|
||
|
|
* @fn_gl_extension_keyword{TextureParameter,EXT,direct_state_access},
|
||
|
12 years ago
|
* eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
|
||
|
8 years ago
|
* @fn_gl_keyword{TexParameter} with @def_gl_keyword{TEXTURE_COMPARE_FUNC}
|
||
|
9 years ago
|
* @requires_gles30 Extension @extension{EXT,shadow_samplers} in
|
||
|
11 years ago
|
* OpenGL ES 2.0.
|
||
|
|
* @requires_webgl20 Depth texture comparison is not available in WebGL
|
||
|
|
* 1.0.
|
||
|
12 years ago
|
*/
|
||
|
|
Texture<dimensions>& setCompareFunction(Sampler::CompareFunction function) {
|
||
|
|
AbstractTexture::setCompareFunction(function);
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
11 years ago
|
#endif
|
||
|
12 years ago
|
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
12 years ago
|
/**
|
||
|
|
* @brief Set depth/stencil texture mode
|
||
|
12 years ago
|
* @return Reference to self (for method chaining)
|
||
|
12 years ago
|
*
|
||
|
|
* Selects which component of packed depth/stencil texture is used for
|
||
|
11 years ago
|
* texturing. If neither @extension{ARB,direct_state_access} (part of
|
||
|
|
* OpenGL 4.5) nor @extension{EXT,direct_state_access} is available,
|
||
|
|
* the texture is bound before the operation (if not already). Initial
|
||
|
|
* value is @ref Sampler::DepthStencilMode::DepthComponent.
|
||
|
12 years ago
|
* @note Depth textures can be only 1D or 2D.
|
||
|
8 years ago
|
* @see @fn_gl2_keyword{TextureParameter,TexParameter},
|
||
|
|
* @fn_gl_extension_keyword{TextureParameter,EXT,direct_state_access},
|
||
|
12 years ago
|
* eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
|
||
|
8 years ago
|
* @fn_gl_keyword{TexParameter} with @def_gl_keyword{DEPTH_STENCIL_TEXTURE_MODE}
|
||
|
12 years ago
|
* @requires_gl43 Extension @extension{ARB,stencil_texturing}
|
||
|
12 years ago
|
* @requires_gles31 Stencil texturing is not available in OpenGL ES 3.0
|
||
|
|
* and older.
|
||
|
11 years ago
|
* @requires_gles Stencil texturing is not available in WebGL.
|
||
|
12 years ago
|
*/
|
||
|
|
Texture<dimensions>& setDepthStencilMode(Sampler::DepthStencilMode mode) {
|
||
|
|
AbstractTexture::setDepthStencilMode(mode);
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
14 years ago
|
/**
|
||
|
|
* @brief Set storage
|
||
|
|
* @param levels Mip level count
|
||
|
|
* @param internalFormat Internal format
|
||
|
|
* @param size Size of largest mip level
|
||
|
13 years ago
|
* @return Reference to self (for method chaining)
|
||
|
14 years ago
|
*
|
||
|
12 years ago
|
* After calling this function the texture is immutable and calling
|
||
|
|
* @ref setStorage() or @ref setImage() is not allowed.
|
||
|
14 years ago
|
*
|
||
|
11 years ago
|
* If neither @extension{ARB,direct_state_access} (part of OpenGL 4.5)
|
||
|
|
* nor @extension{EXT,direct_state_access} desktop extension is
|
||
|
12 years ago
|
* available, the texture is bound before the operation (if not
|
||
|
|
* already). If neither @extension{ARB,texture_storage} (part of OpenGL
|
||
|
9 years ago
|
* 4.2), OpenGL ES 3.0 nor @extension{EXT,texture_storage} in OpenGL
|
||
|
12 years ago
|
* ES 2.0 is available, the feature is emulated with sequence of
|
||
|
|
* @ref setImage() calls.
|
||
|
8 years ago
|
* @see @ref maxSize(), @ref setMaxLevel(),
|
||
|
|
* @fn_gl2_keyword{TextureStorage1D,TexStorage1D} /
|
||
|
|
* @fn_gl2_keyword{TextureStorage2D,TexStorage2D} /
|
||
|
|
* @fn_gl2_keyword{TextureStorage3D,TexStorage3D},
|
||
|
|
* @fn_gl_extension_keyword{TextureStorage1D,EXT,direct_state_access} /
|
||
|
|
* @fn_gl_extension_keyword{TextureStorage2D,EXT,direct_state_access} /
|
||
|
|
* @fn_gl_extension_keyword{TextureStorage3D,EXT,direct_state_access},
|
||
|
12 years ago
|
* eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
|
||
|
8 years ago
|
* @fn_gl_keyword{TexStorage1D} / @fn_gl_keyword{TexStorage2D} /
|
||
|
|
* @fn_gl_keyword{TexStorage3D}
|
||
|
11 years ago
|
* @todo allow the user to specify PixelType explicitly to avoid
|
||
|
12 years ago
|
* issues in WebGL (see setSubImage())
|
||
|
14 years ago
|
*/
|
||
|
12 years ago
|
Texture<dimensions>& setStorage(Int levels, TextureFormat internalFormat, const VectorTypeFor<dimensions, Int>& size) {
|
||
|
12 years ago
|
DataHelper<dimensions>::setStorage(*this, levels, internalFormat, size);
|
||
|
13 years ago
|
return *this;
|
||
|
14 years ago
|
}
|
||
|
|
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
/**
|
||
|
|
* @brief Image size in given mip level
|
||
|
|
*
|
||
|
11 years ago
|
* The result is not cached in any way. If neither
|
||
|
12 years ago
|
* @extension{ARB,direct_state_access} (part of OpenGL 4.5) nor
|
||
|
11 years ago
|
* @extension{EXT,direct_state_access} desktop extension is available,
|
||
|
|
* the texture is bound before the operation (if not already).
|
||
|
8 years ago
|
* @see @ref image(), @fn_gl2_keyword{GetTextureLevelParameter,GetTexLevelParameter},
|
||
|
12 years ago
|
* @fn_gl_extension{GetTextureLevelParameter,EXT,direct_state_access},
|
||
|
|
* eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
|
||
|
8 years ago
|
* @fn_gl_keyword{GetTexLevelParameter} with
|
||
|
|
* @def_gl_keyword{TEXTURE_WIDTH}, @def_gl_keyword{TEXTURE_HEIGHT},
|
||
|
|
* @def_gl_keyword{TEXTURE_DEPTH}
|
||
|
12 years ago
|
* @requires_gles31 Texture image size queries are not available in
|
||
|
|
* OpenGL ES 3.0 and older.
|
||
|
11 years ago
|
* @requires_gles Texture image size queries are not available in
|
||
|
|
* WebGL.
|
||
|
12 years ago
|
*/
|
||
|
|
VectorTypeFor<dimensions, Int> imageSize(Int level) {
|
||
|
11 years ago
|
return DataHelper<dimensions>::imageSize(*this, level);
|
||
|
12 years ago
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
13 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
/**
|
||
|
|
* @brief Read given mip level of texture to image
|
||
|
|
* @param level Mip level
|
||
|
12 years ago
|
* @param image Image where to put the data
|
||
|
13 years ago
|
*
|
||
|
12 years ago
|
* Image parameters like format and type of pixel data are taken from
|
||
|
13 years ago
|
* given image, image size is taken from the texture using
|
||
|
11 years ago
|
* @ref imageSize(). The storage is not reallocated if it is large
|
||
|
|
* enough to contain the new data.
|
||
|
13 years ago
|
*
|
||
|
12 years ago
|
* If neither @extension{ARB,direct_state_access} (part of OpenGL 4.5)
|
||
|
|
* nor @extension{EXT,direct_state_access} is available, the texture is
|
||
|
|
* bound before the operation (if not already). If either
|
||
|
|
* @extension{ARB,direct_state_access} or @extension{ARB,robustness}
|
||
|
|
* is available, the operation is protected from buffer overflow.
|
||
|
|
* However, if @extension{ARB,direct_state_access} is not available and
|
||
|
|
* both @extension{EXT,direct_state_access} and @extension{ARB,robustness}
|
||
|
|
* are available, the robust operation is preferred over DSA.
|
||
|
|
* @see @fn_gl2{GetTextureLevelParameter,GetTexLevelParameter},
|
||
|
|
* @fn_gl_extension{GetTextureLevelParameter,EXT,direct_state_access},
|
||
|
|
* eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
|
||
|
|
* @fn_gl{GetTexLevelParameter} with @def_gl{TEXTURE_WIDTH},
|
||
|
|
* @def_gl{TEXTURE_HEIGHT}, @def_gl{TEXTURE_DEPTH}, then
|
||
|
8 years ago
|
* @fn_gl{PixelStore}, then @fn_gl2_keyword{GetTextureImage,GetTexImage},
|
||
|
|
* @fn_gl_extension_keyword{GetnTexImage,ARB,robustness},
|
||
|
|
* @fn_gl_extension_keyword{GetTextureImage,EXT,direct_state_access},
|
||
|
|
* eventually @fn_gl_keyword{GetTexImage}
|
||
|
11 years ago
|
* @requires_gl Texture image queries are not available in OpenGL ES or
|
||
|
8 years ago
|
* WebGL. See @ref Framebuffer::read() or @ref DebugTools::textureSubImage()
|
||
|
|
* for possible workarounds.
|
||
|
13 years ago
|
*/
|
||
|
13 years ago
|
void image(Int level, Image<dimensions>& image) {
|
||
|
12 years ago
|
AbstractTexture::image<dimensions>(level, image);
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
11 years ago
|
/** @overload
|
||
|
|
*
|
||
|
|
* Convenience alternative to the above, example usage:
|
||
|
8 years ago
|
*
|
||
|
8 years ago
|
* @snippet MagnumGL.cpp Texture-image1
|
||
|
11 years ago
|
*/
|
||
|
|
Image<dimensions> image(Int level, Image<dimensions>&& image);
|
||
|
|
|
||
|
13 years ago
|
/**
|
||
|
|
* @brief Read given mip level of texture to buffer image
|
||
|
|
* @param level Mip level
|
||
|
12 years ago
|
* @param image Buffer image where to put the data
|
||
|
|
* @param usage Buffer usage
|
||
|
13 years ago
|
*
|
||
|
11 years ago
|
* See @ref image(Int, Image&) for more information. The storage is not
|
||
|
|
* reallocated if it is large enough to contain the new data, which
|
||
|
|
* means that @p usage might get ignored.
|
||
|
11 years ago
|
* @requires_gl Texture image queries are not available in OpenGL ES or
|
||
|
8 years ago
|
* WebGL. See @ref Framebuffer::read() or @ref DebugTools::textureSubImage()
|
||
|
|
* for possible workarounds.
|
||
|
12 years ago
|
* @todo Make it more flexible (usable with
|
||
|
|
* @extension{ARB,buffer_storage}, avoiding relocations...)
|
||
|
13 years ago
|
*/
|
||
|
13 years ago
|
void image(Int level, BufferImage<dimensions>& image, BufferUsage usage) {
|
||
|
12 years ago
|
AbstractTexture::image<dimensions>(level, image, usage);
|
||
|
13 years ago
|
}
|
||
|
11 years ago
|
|
||
|
|
/** @overload
|
||
|
|
*
|
||
|
|
* Convenience alternative to the above, example usage:
|
||
|
8 years ago
|
*
|
||
|
8 years ago
|
* @snippet MagnumGL.cpp Texture-image2
|
||
|
11 years ago
|
*/
|
||
|
|
BufferImage<dimensions> image(Int level, BufferImage<dimensions>&& image, BufferUsage usage);
|
||
|
11 years ago
|
|
||
|
11 years ago
|
/**
|
||
|
|
* @brief Read given mip level of compressed texture to image
|
||
|
|
* @param level Mip level
|
||
|
|
* @param image Image where to put the compressed data
|
||
|
|
*
|
||
|
|
* Compression format and data size are taken from the texture, image
|
||
|
11 years ago
|
* size is taken using @ref imageSize(). The storage is not reallocated
|
||
|
|
* if it is large enough to contain the new data.
|
||
|
11 years ago
|
*
|
||
|
|
* If neither @extension{ARB,direct_state_access} (part of OpenGL 4.5)
|
||
|
|
* nor @extension{EXT,direct_state_access} is available, the texture is
|
||
|
|
* bound before the operation (if not already). If either
|
||
|
|
* @extension{ARB,direct_state_access} or @extension{ARB,robustness}
|
||
|
|
* is available, the operation is protected from buffer overflow.
|
||
|
|
* However, if @extension{ARB,direct_state_access} is not available and
|
||
|
|
* both @extension{EXT,direct_state_access} and @extension{ARB,robustness}
|
||
|
|
* are available, the robust operation is preferred over DSA.
|
||
|
|
* @see @fn_gl2{GetTextureLevelParameter,GetTexLevelParameter},
|
||
|
|
* @fn_gl_extension{GetTextureLevelParameter,EXT,direct_state_access},
|
||
|
|
* eventually @fn_gl{GetTexLevelParameter} with
|
||
|
|
* @def_gl{TEXTURE_COMPRESSED_IMAGE_SIZE},
|
||
|
|
* @def_gl{TEXTURE_INTERNAL_FORMAT}, @def_gl{TEXTURE_WIDTH},
|
||
|
|
* @def_gl{TEXTURE_HEIGHT}, @def_gl{TEXTURE_DEPTH}, then
|
||
|
11 years ago
|
* @fn_gl{PixelStore}, then
|
||
|
8 years ago
|
* @fn_gl2_keyword{GetCompressedTextureImage,GetCompressedTexImage},
|
||
|
|
* @fn_gl_extension_keyword{GetnCompressedTexImage,ARB,robustness},
|
||
|
|
* @fn_gl_extension_keyword{GetCompressedTextureImage,EXT,direct_state_access},
|
||
|
|
* eventually @fn_gl_keyword{GetCompressedTexImage}
|
||
|
11 years ago
|
* @requires_gl Texture image queries are not available in OpenGL ES or
|
||
|
8 years ago
|
* WebGL. See @ref Framebuffer::read() or @ref DebugTools::textureSubImage()
|
||
|
|
* for possible workarounds.
|
||
|
11 years ago
|
*/
|
||
|
|
void compressedImage(Int level, CompressedImage<dimensions>& image) {
|
||
|
|
AbstractTexture::compressedImage<dimensions>(level, image);
|
||
|
|
}
|
||
|
|
|
||
|
|
/** @overload
|
||
|
|
*
|
||
|
|
* Convenience alternative to the above, example usage:
|
||
|
8 years ago
|
*
|
||
|
8 years ago
|
* @snippet MagnumGL.cpp Texture-compressedImage1
|
||
|
11 years ago
|
*/
|
||
|
|
CompressedImage<dimensions> compressedImage(Int level, CompressedImage<dimensions>&& image);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @brief Read given mip level of compressed texture to buffer image
|
||
|
|
* @param level Mip level
|
||
|
|
* @param image Buffer image where to put the compressed data
|
||
|
|
* @param usage Buffer usage
|
||
|
|
*
|
||
|
|
* See @ref compressedImage(Int, CompressedImage&) for more
|
||
|
11 years ago
|
* information. The storage is not reallocated if it is large enough to
|
||
|
|
* contain the new data, which means that @p usage might get ignored.
|
||
|
11 years ago
|
* @requires_gl Texture image queries are not available in OpenGL ES or
|
||
|
8 years ago
|
* WebGL. See @ref Framebuffer::read() or @ref DebugTools::textureSubImage()
|
||
|
|
* for possible workarounds.
|
||
|
11 years ago
|
* @todo Make it more flexible (usable with
|
||
|
|
* @extension{ARB,buffer_storage}, avoiding relocations...)
|
||
|
|
*/
|
||
|
|
void compressedImage(Int level, CompressedBufferImage<dimensions>& image, BufferUsage usage) {
|
||
|
|
AbstractTexture::compressedImage<dimensions>(level, image, usage);
|
||
|
|
}
|
||
|
|
|
||
|
|
/** @overload
|
||
|
|
*
|
||
|
|
* Convenience alternative to the above, example usage:
|
||
|
8 years ago
|
*
|
||
|
8 years ago
|
* @snippet MagnumGL.cpp Texture-compressedImage2
|
||
|
11 years ago
|
*/
|
||
|
|
CompressedBufferImage<dimensions> compressedImage(Int level, CompressedBufferImage<dimensions>&& image, BufferUsage usage);
|
||
|
|
|
||
|
11 years ago
|
/**
|
||
|
|
* @brief Read range of given texture mip level to image
|
||
|
|
* @param level Mip level
|
||
|
|
* @param range Range to read
|
||
|
|
* @param image Image where to put the data
|
||
|
|
*
|
||
|
|
* Image parameters like format and type of pixel data are taken from
|
||
|
11 years ago
|
* given image. The storage is not reallocated if it is large enough to
|
||
|
|
* contain the new data.
|
||
|
|
*
|
||
|
|
* The operation is protected from buffer overflow.
|
||
|
8 years ago
|
* @see @fn_gl_keyword{GetTextureSubImage}
|
||
|
11 years ago
|
* @requires_gl45 Extension @extension{ARB,get_texture_sub_image}
|
||
|
11 years ago
|
* @requires_gl Texture image queries are not available in OpenGL ES or
|
||
|
|
* WebGL. See @ref Framebuffer::read() for possible workaround.
|
||
|
11 years ago
|
*/
|
||
|
|
void subImage(Int level, const RangeTypeFor<dimensions, Int>& range, Image<dimensions>& image) {
|
||
|
|
AbstractTexture::subImage<dimensions>(level, range, image);
|
||
|
|
}
|
||
|
|
|
||
|
|
/** @overload
|
||
|
|
*
|
||
|
|
* Convenience alternative to the above, example usage:
|
||
|
8 years ago
|
*
|
||
|
8 years ago
|
* @snippet MagnumGL.cpp Texture-subImage1
|
||
|
11 years ago
|
*/
|
||
|
|
Image<dimensions> subImage(Int level, const RangeTypeFor<dimensions, Int>& range, Image<dimensions>&& image);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @brief Read range of given texture mip level to buffer image
|
||
|
|
* @param level Mip level
|
||
|
|
* @param range Range to read
|
||
|
|
* @param image Buffer image where to put the data
|
||
|
|
* @param usage Buffer usage
|
||
|
|
*
|
||
|
|
* See @ref subImage(Int, const RangeTypeFor<dimensions, Int>&, Image&)
|
||
|
11 years ago
|
* for more information. The storage is not reallocated if it is large
|
||
|
|
* enough to contain the new data, which means that @p usage might get
|
||
|
|
* ignored.
|
||
|
11 years ago
|
* @requires_gl45 Extension @extension{ARB,get_texture_sub_image}
|
||
|
11 years ago
|
* @requires_gl Texture image queries are not available in OpenGL ES or
|
||
|
|
* WebGL. See @ref Framebuffer::read() for possible workaround.
|
||
|
11 years ago
|
*/
|
||
|
|
void subImage(Int level, const RangeTypeFor<dimensions, Int>& range, BufferImage<dimensions>& image, BufferUsage usage) {
|
||
|
|
AbstractTexture::subImage<dimensions>(level, range, image, usage);
|
||
|
|
}
|
||
|
|
|
||
|
|
/** @overload
|
||
|
|
*
|
||
|
|
* Convenience alternative to the above, example usage:
|
||
|
8 years ago
|
*
|
||
|
8 years ago
|
* @snippet MagnumGL.cpp Texture-subImage2
|
||
|
11 years ago
|
*/
|
||
|
|
BufferImage<dimensions> subImage(Int level, const RangeTypeFor<dimensions, Int>& range, BufferImage<dimensions>&& image, BufferUsage usage);
|
||
|
11 years ago
|
|
||
|
|
/**
|
||
|
|
* @brief Read range of given compressed texture mip level to image
|
||
|
|
* @param level Mip level
|
||
|
|
* @param range Range to read
|
||
|
|
* @param image Image where to put the compressed data
|
||
|
|
*
|
||
|
|
* Compression format and data size are taken from the texture.
|
||
|
|
* @see @fn_gl2{GetTextureLevelParameter,GetTexLevelParameter},
|
||
|
|
* @fn_gl_extension{GetTextureLevelParameter,EXT,direct_state_access},
|
||
|
|
* eventually @fn_gl{GetTexLevelParameter} with
|
||
|
9 years ago
|
* @def_gl{TEXTURE_INTERNAL_FORMAT}, then possibly
|
||
|
|
* @fn_gl{GetInternalformat} with @def_gl{TEXTURE_COMPRESSED_BLOCK_SIZE},
|
||
|
|
* @def_gl{TEXTURE_COMPRESSED_BLOCK_WIDTH} and
|
||
|
|
* @def_gl{TEXTURE_COMPRESSED_BLOCK_HEIGHT}, then
|
||
|
8 years ago
|
* @fn_gl_keyword{GetCompressedTextureSubImage}
|
||
|
11 years ago
|
* @requires_gl45 Extension @extension{ARB,get_texture_sub_image}
|
||
|
9 years ago
|
* @requires_gl43 Extension @extension{ARB,internalformat_query2} if
|
||
|
|
* @ref CompressedPixelStorage::compressedBlockSize() and
|
||
|
|
* @ref CompressedPixelStorage::compressedBlockDataSize() are not
|
||
|
|
* set to non-zero values
|
||
|
11 years ago
|
* @requires_gl Texture image queries are not available in OpenGL ES or
|
||
|
8 years ago
|
* WebGL. See @ref Framebuffer::read() or @ref DebugTools::textureSubImage()
|
||
|
|
* for possible workarounds.
|
||
|
11 years ago
|
*/
|
||
|
|
void compressedSubImage(Int level, const RangeTypeFor<dimensions, Int>& range, CompressedImage<dimensions>& image) {
|
||
|
|
AbstractTexture::compressedSubImage<dimensions>(level, range, image);
|
||
|
|
}
|
||
|
|
|
||
|
|
/** @overload
|
||
|
|
*
|
||
|
|
* Convenience alternative to the above, example usage:
|
||
|
8 years ago
|
*
|
||
|
8 years ago
|
* @snippet MagnumGL.cpp Texture-compressedSubImage1
|
||
|
11 years ago
|
*/
|
||
|
|
CompressedImage<dimensions> compressedSubImage(Int level, const RangeTypeFor<dimensions, Int>& range, CompressedImage<dimensions>&& image);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @brief Read range of given compressed texture mip level to buffer image
|
||
|
|
* @param level Mip level
|
||
|
|
* @param range Range to read
|
||
|
|
* @param image Buffer image where to put the compressed data
|
||
|
|
* @param usage Buffer usage
|
||
|
|
*
|
||
|
|
* See @ref compressedSubImage(Int, const RangeTypeFor<dimensions, Int>&, CompressedBufferImage&, BufferUsage)
|
||
|
|
* for more information.
|
||
|
|
* @requires_gl45 Extension @extension{ARB,get_texture_sub_image}
|
||
|
9 years ago
|
* @requires_gl43 Extension @extension{ARB,internalformat_query2} if
|
||
|
|
* @ref CompressedPixelStorage::compressedBlockSize() and
|
||
|
|
* @ref CompressedPixelStorage::compressedBlockDataSize() are not
|
||
|
|
* set to non-zero values
|
||
|
11 years ago
|
* @requires_gl Texture image queries are not available in OpenGL ES or
|
||
|
8 years ago
|
* WebGL. See @ref Framebuffer::read() or @ref DebugTools::textureSubImage()
|
||
|
|
* for possible workarounds.
|
||
|
11 years ago
|
*/
|
||
|
|
void compressedSubImage(Int level, const RangeTypeFor<dimensions, Int>& range, CompressedBufferImage<dimensions>& image, BufferUsage usage) {
|
||
|
|
AbstractTexture::compressedSubImage<dimensions>(level, range, image, usage);
|
||
|
|
}
|
||
|
|
|
||
|
|
/** @overload
|
||
|
|
*
|
||
|
|
* Convenience alternative to the above, example usage:
|
||
|
8 years ago
|
*
|
||
|
8 years ago
|
* @snippet MagnumGL.cpp Texture-compressedSubImage2
|
||
|
11 years ago
|
*/
|
||
|
|
CompressedBufferImage<dimensions> compressedSubImage(Int level, const RangeTypeFor<dimensions, Int>& range, CompressedBufferImage<dimensions>&& image, BufferUsage usage);
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
16 years ago
|
/**
|
||
|
14 years ago
|
* @brief Set image data
|
||
|
|
* @param level Mip level
|
||
|
14 years ago
|
* @param internalFormat Internal format
|
||
|
11 years ago
|
* @param image @ref Image, @ref ImageView or
|
||
|
13 years ago
|
* @ref Trade::ImageData of the same dimension count
|
||
|
13 years ago
|
* @return Reference to self (for method chaining)
|
||
|
15 years ago
|
*
|
||
|
12 years ago
|
* On platforms that support it prefer to use @ref setStorage() and
|
||
|
|
* @ref setSubImage() instead, as it avoids unnecessary reallocations
|
||
|
|
* and has better performance characteristics. This call also has no
|
||
|
|
* equivalent in @extension{ARB,direct_state_access}, thus the texture
|
||
|
|
* needs to be bound to some texture unit before the operation.
|
||
|
10 years ago
|
* @see @ref maxSize(), @ref Framebuffer::copyImage(), @fn_gl{PixelStore},
|
||
|
8 years ago
|
* then @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
|
||
|
|
* @fn_gl_keyword{TexImage1D} / @fn_gl_keyword{TexImage2D} /
|
||
|
|
* @fn_gl_keyword{TexImage3D}
|
||
|
11 years ago
|
* @deprecated_gl Prefer to use @ref setStorage() and @ref setSubImage()
|
||
|
12 years ago
|
* instead.
|
||
|
15 years ago
|
*/
|
||
|
11 years ago
|
Texture<dimensions>& setImage(Int level, TextureFormat internalFormat, const ImageView<dimensions>& image) {
|
||
|
12 years ago
|
DataHelper<dimensions>::setImage(*this, level, internalFormat, image);
|
||
|
13 years ago
|
return *this;
|
||
|
15 years ago
|
}
|
||
|
|
|
||
|
13 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
12 years ago
|
/** @overload
|
||
|
|
* @requires_gles30 Pixel buffer objects are not available in OpenGL ES
|
||
|
|
* 2.0.
|
||
|
11 years ago
|
* @requires_webgl20 Pixel buffer objects are not available in WebGL
|
||
|
|
* 1.0.
|
||
|
11 years ago
|
* @deprecated_gl Prefer to use @ref setStorage() and @ref setSubImage()
|
||
|
12 years ago
|
* instead.
|
||
|
|
*/
|
||
|
12 years ago
|
Texture<dimensions>& setImage(Int level, TextureFormat internalFormat, BufferImage<dimensions>& image) {
|
||
|
12 years ago
|
DataHelper<dimensions>::setImage(*this, level, internalFormat, image);
|
||
|
13 years ago
|
return *this;
|
||
|
13 years ago
|
}
|
||
|
13 years ago
|
|
||
|
12 years ago
|
/** @overload
|
||
|
|
* @requires_gles30 Pixel buffer objects are not available in OpenGL ES
|
||
|
|
* 2.0.
|
||
|
11 years ago
|
* @requires_webgl20 Pixel buffer objects are not available in WebGL
|
||
|
|
* 1.0.
|
||
|
11 years ago
|
* @deprecated_gl Prefer to use @ref setStorage() and @ref setSubImage()
|
||
|
12 years ago
|
* instead.
|
||
|
|
*/
|
||
|
12 years ago
|
Texture<dimensions>& setImage(Int level, TextureFormat internalFormat, BufferImage<dimensions>&& image) {
|
||
|
13 years ago
|
return setImage(level, internalFormat, image);
|
||
|
|
}
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
11 years ago
|
/**
|
||
|
|
* @brief Set compressed image data
|
||
|
|
* @param level Mip level
|
||
|
|
* @param image @ref CompressedImage, @ref CompressedImageView
|
||
|
|
* or compressed @ref Trade::ImageData of the same dimension count
|
||
|
|
* @return Reference to self (for method chaining)
|
||
|
|
*
|
||
|
|
* On platforms that support it prefer to use @ref setStorage() and
|
||
|
|
* @ref setCompressedSubImage() instead, as it avoids unnecessary
|
||
|
|
* reallocations and has better performance characteristics. This call
|
||
|
|
* also has no equivalent in @extension{ARB,direct_state_access}, thus
|
||
|
|
* the texture needs to be bound to some texture unit before the
|
||
|
|
* operation.
|
||
|
11 years ago
|
* @see @ref maxSize(), @fn_gl{PixelStore}, then @fn_gl{ActiveTexture},
|
||
|
8 years ago
|
* @fn_gl{BindTexture} and @fn_gl_keyword{CompressedTexImage1D} /
|
||
|
|
* @fn_gl_keyword{CompressedTexImage2D} /
|
||
|
|
* @fn_gl_keyword{CompressedTexImage3D}
|
||
|
11 years ago
|
* @deprecated_gl Prefer to use @ref setStorage() and
|
||
|
|
* @ref setCompressedSubImage() instead.
|
||
|
|
*/
|
||
|
|
Texture<dimensions>& setCompressedImage(Int level, const CompressedImageView<dimensions>& image) {
|
||
|
|
DataHelper<dimensions>::setCompressedImage(*this, level, image);
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
/** @overload
|
||
|
|
* @requires_gles30 Pixel buffer objects are not available in OpenGL ES
|
||
|
|
* 2.0.
|
||
|
|
* @requires_webgl20 Pixel buffer objects are not available in WebGL
|
||
|
|
* 1.0.
|
||
|
|
* @deprecated_gl Prefer to use @ref setStorage() and
|
||
|
|
* @ref setCompressedSubImage() instead.
|
||
|
|
*/
|
||
|
|
Texture<dimensions>& setCompressedImage(Int level, CompressedBufferImage<dimensions>& image) {
|
||
|
|
DataHelper<dimensions>::setCompressedImage(*this, level, image);
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** @overload
|
||
|
|
* @requires_gles30 Pixel buffer objects are not available in OpenGL ES
|
||
|
|
* 2.0.
|
||
|
|
* @requires_webgl20 Pixel buffer objects are not available in WebGL
|
||
|
|
* 1.0.
|
||
|
|
* @deprecated_gl Prefer to use @ref setStorage() and
|
||
|
|
* @ref setCompressedSubImage() instead.
|
||
|
|
*/
|
||
|
|
Texture<dimensions>& setCompressedImage(Int level, CompressedBufferImage<dimensions>&& image) {
|
||
|
|
return setCompressedImage(level, image);
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
15 years ago
|
/**
|
||
|
14 years ago
|
* @brief Set image subdata
|
||
|
|
* @param level Mip level
|
||
|
15 years ago
|
* @param offset Offset where to put data in the texture
|
||
|
11 years ago
|
* @param image @ref Image, @ref ImageView or
|
||
|
13 years ago
|
* @ref Trade::ImageData of the same dimension count
|
||
|
13 years ago
|
* @return Reference to self (for method chaining)
|
||
|
15 years ago
|
*
|
||
|
11 years ago
|
* If neither @extension{ARB,direct_state_access} (part of OpenGL 4.5)
|
||
|
|
* nor @extension{EXT,direct_state_access} desktop extension is
|
||
|
|
* available, the texture is bound before the operation (if not
|
||
|
|
* already).
|
||
|
10 years ago
|
* @see @ref setStorage(), @ref Framebuffer::copySubImage(),
|
||
|
8 years ago
|
* @fn_gl{PixelStore}, @fn_gl2_keyword{TextureSubImage1D,TexSubImage1D} /
|
||
|
|
* @fn_gl2_keyword{TextureSubImage2D,TexSubImage2D} /
|
||
|
|
* @fn_gl2_keyword{TextureSubImage3D,TexSubImage3D},
|
||
|
|
* @fn_gl_extension_keyword{TextureSubImage1D,EXT,direct_state_access} /
|
||
|
|
* @fn_gl_extension_keyword{TextureSubImage2D,EXT,direct_state_access} /
|
||
|
|
* @fn_gl_extension_keyword{TextureSubImage3D,EXT,direct_state_access},
|
||
|
12 years ago
|
* eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
|
||
|
8 years ago
|
* @fn_gl_keyword{TexSubImage1D} / @fn_gl_keyword{TexSubImage2D} /
|
||
|
|
* @fn_gl_keyword{TexSubImage3D}
|
||
|
11 years ago
|
* @requires_gles In @ref MAGNUM_TARGET_WEBGL "WebGL" the @ref PixelType
|
||
|
11 years ago
|
* of data passed in @p image must match the original one
|
||
|
|
* specified in @ref setImage(). It means that you might not be
|
||
|
11 years ago
|
* able to use @ref setStorage() as it uses implicit @ref PixelType
|
||
|
11 years ago
|
* value.
|
||
|
15 years ago
|
*/
|
||
|
11 years ago
|
Texture<dimensions>& setSubImage(Int level, const VectorTypeFor<dimensions, Int>& offset, const ImageView<dimensions>& image) {
|
||
|
12 years ago
|
DataHelper<Dimensions>::setSubImage(*this, level, offset, image);
|
||
|
13 years ago
|
return *this;
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
12 years ago
|
/** @overload
|
||
|
|
* @requires_gles30 Pixel buffer objects are not available in OpenGL ES
|
||
|
|
* 2.0.
|
||
|
11 years ago
|
* @requires_webgl20 Pixel buffer objects are not available in WebGL
|
||
|
|
* 1.0.
|
||
|
12 years ago
|
*/
|
||
|
12 years ago
|
Texture<dimensions>& setSubImage(Int level, const VectorTypeFor<dimensions, Int>& offset, BufferImage<dimensions>& image) {
|
||
|
12 years ago
|
DataHelper<Dimensions>::setSubImage(*this, level, offset, image);
|
||
|
13 years ago
|
return *this;
|
||
|
15 years ago
|
}
|
||
|
13 years ago
|
|
||
|
12 years ago
|
/** @overload
|
||
|
|
* @requires_gles30 Pixel buffer objects are not available in OpenGL ES
|
||
|
|
* 2.0.
|
||
|
11 years ago
|
* @requires_webgl20 Pixel buffer objects are not available in WebGL
|
||
|
|
* 1.0.
|
||
|
12 years ago
|
*/
|
||
|
12 years ago
|
Texture<dimensions>& setSubImage(Int level, const VectorTypeFor<dimensions, Int>& offset, BufferImage<dimensions>&& image) {
|
||
|
13 years ago
|
return setSubImage(level, offset, image);
|
||
|
|
}
|
||
|
13 years ago
|
#endif
|
||
|
14 years ago
|
|
||
|
11 years ago
|
/**
|
||
|
|
* @brief Set compressed image subdata
|
||
|
|
* @param level Mip level
|
||
|
|
* @param offset Offset where to put data in the texture
|
||
|
|
* @param image @ref CompressedImage, @ref CompressedImageView
|
||
|
|
* or compressed @ref Trade::ImageData of the same dimension count
|
||
|
|
* @return Reference to self (for method chaining)
|
||
|
|
*
|
||
|
|
* If neither @extension{ARB,direct_state_access} (part of OpenGL 4.5)
|
||
|
|
* nor @extension{EXT,direct_state_access} desktop extension is
|
||
|
|
* available, the texture is bound before the operation (if not
|
||
|
|
* already).
|
||
|
11 years ago
|
* @see @ref setStorage(), @fn_gl{PixelStore},
|
||
|
8 years ago
|
* @fn_gl2_keyword{CompressedTextureSubImage1D,CompressedTexSubImage1D} /
|
||
|
|
* @fn_gl2_keyword{CompressedTextureSubImage2D,CompressedTexSubImage2D} /
|
||
|
|
* @fn_gl2_keyword{CompressedTextureSubImage3D,CompressedTexSubImage3D},
|
||
|
|
* @fn_gl_extension_keyword{CompressedTextureSubImage1D,EXT,direct_state_access} /
|
||
|
|
* @fn_gl_extension_keyword{CompressedTextureSubImage2D,EXT,direct_state_access} /
|
||
|
|
* @fn_gl_extension_keyword{CompressedTextureSubImage3D,EXT,direct_state_access},
|
||
|
11 years ago
|
* eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
|
||
|
8 years ago
|
* @fn_gl_keyword{CompressedTexSubImage1D} /
|
||
|
|
* @fn_gl_keyword{CompressedTexSubImage2D} /
|
||
|
|
* @fn_gl_keyword{CompressedTexSubImage3D}
|
||
|
11 years ago
|
*/
|
||
|
|
Texture<dimensions>& setCompressedSubImage(Int level, const VectorTypeFor<dimensions, Int>& offset, const CompressedImageView<dimensions>& image) {
|
||
|
|
DataHelper<Dimensions>::setCompressedSubImage(*this, level, offset, image);
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
/** @overload
|
||
|
|
* @requires_gles30 Pixel buffer objects are not available in OpenGL ES
|
||
|
|
* 2.0.
|
||
|
|
* @requires_webgl20 Pixel buffer objects are not available in WebGL
|
||
|
|
* 1.0.
|
||
|
|
*/
|
||
|
|
Texture<dimensions>& setCompressedSubImage(Int level, const VectorTypeFor<dimensions, Int>& offset, CompressedBufferImage<dimensions>& image) {
|
||
|
|
DataHelper<Dimensions>::setCompressedSubImage(*this, level, offset, image);
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** @overload
|
||
|
|
* @requires_gles30 Pixel buffer objects are not available in OpenGL ES
|
||
|
|
* 2.0.
|
||
|
|
* @requires_webgl20 Pixel buffer objects are not available in WebGL
|
||
|
|
* 1.0.
|
||
|
|
*/
|
||
|
|
Texture<dimensions>& setCompressedSubImage(Int level, const VectorTypeFor<dimensions, Int>& offset, CompressedBufferImage<dimensions>&& image) {
|
||
|
|
return setCompressedSubImage(level, offset, image);
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
12 years ago
|
/**
|
||
|
|
* @brief Generate mipmap
|
||
|
|
* @return Reference to self (for method chaining)
|
||
|
|
*
|
||
|
11 years ago
|
* If neither @extension{ARB,direct_state_access} (part of OpenGL 4.5)
|
||
|
|
* nor @extension{EXT,direct_state_access} desktop extension is
|
||
|
|
* available, the texture is bound before the operation (if not
|
||
|
|
* already).
|
||
|
8 years ago
|
* @see @ref setMinificationFilter(), @fn_gl2_keyword{GenerateTextureMipmap,GenerateMipmap},
|
||
|
|
* @fn_gl_extension_keyword{GenerateTextureMipmap,EXT,direct_state_access},
|
||
|
12 years ago
|
* eventually @fn_gl{ActiveTexture}, @fn_gl{BindTexture} and
|
||
|
8 years ago
|
* @fn_gl_keyword{GenerateMipmap}
|
||
|
12 years ago
|
* @requires_gl30 Extension @extension{ARB,framebuffer_object}
|
||
|
12 years ago
|
*/
|
||
|
|
Texture<dimensions>& generateMipmap() {
|
||
|
|
AbstractTexture::generateMipmap();
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @brief Invalidate texture image
|
||
|
|
* @param level Mip level
|
||
|
|
*
|
||
|
|
* If running on OpenGL ES or extension @extension{ARB,invalidate_subdata}
|
||
|
|
* (part of OpenGL 4.3) is not available, this function does nothing.
|
||
|
8 years ago
|
* @see @ref invalidateSubImage(), @fn_gl_keyword{InvalidateTexImage}
|
||
|
12 years ago
|
*/
|
||
|
|
void invalidateImage(Int level) { AbstractTexture::invalidateImage(level); }
|
||
|
|
|
||
|
14 years ago
|
/**
|
||
|
|
* @brief Invalidate texture subimage
|
||
|
|
* @param level Mip level
|
||
|
|
* @param offset Offset into the texture
|
||
|
|
* @param size Size of invalidated data
|
||
|
|
*
|
||
|
14 years ago
|
* If running on OpenGL ES or extension @extension{ARB,invalidate_subdata}
|
||
|
13 years ago
|
* (part of OpenGL 4.3) is not available, this function does nothing.
|
||
|
8 years ago
|
* @see @ref invalidateImage(), @fn_gl_keyword{InvalidateTexSubImage}
|
||
|
14 years ago
|
*/
|
||
|
12 years ago
|
void invalidateSubImage(Int level, const VectorTypeFor<dimensions, Int>& offset, const VectorTypeFor<dimensions, Int>& size) {
|
||
|
12 years ago
|
DataHelper<dimensions>::invalidateSubImage(*this, level, offset, size);
|
||
|
14 years ago
|
}
|
||
|
|
|
||
|
14 years ago
|
/* Overloads to remove WTF-factor from method chaining order */
|
||
|
11 years ago
|
#if !defined(DOXYGEN_GENERATING_OUTPUT) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
12 years ago
|
Texture<dimensions>& setLabel(const std::string& label) {
|
||
|
13 years ago
|
AbstractTexture::setLabel(label);
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
12 years ago
|
template<std::size_t size> Texture<dimensions>& setLabel(const char(&label)[size]) {
|
||
|
|
AbstractTexture::setLabel<size>(label);
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
14 years ago
|
#endif
|
||
|
11 years ago
|
|
||
|
|
private:
|
||
|
|
explicit Texture(GLuint id, ObjectFlags flags) noexcept: AbstractTexture{id, Implementation::textureTarget<dimensions>(), flags} {}
|
||
|
16 years ago
|
};
|
||
|
|
|
||
|
14 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
/**
|
||
|
|
@brief One-dimensional texture
|
||
|
|
|
||
|
11 years ago
|
@requires_gl Only 2D and 3D textures are available in OpenGL ES and WebGL.
|
||
|
14 years ago
|
*/
|
||
|
16 years ago
|
typedef Texture<1> Texture1D;
|
||
|
14 years ago
|
#endif
|
||
|
16 years ago
|
|
||
|
|
/** @brief Two-dimensional texture */
|
||
|
|
typedef Texture<2> Texture2D;
|
||
|
|
|
||
|
9 years ago
|
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
|
||
|
14 years ago
|
/**
|
||
|
|
@brief Three-dimensional texture
|
||
|
|
|
||
|
9 years ago
|
@requires_gles30 Extension @extension{OES,texture_3D} in OpenGL ES 2.0
|
||
|
11 years ago
|
@requires_webgl20 3D textures are not available in WebGL 1.0.
|
||
|
14 years ago
|
*/
|
||
|
16 years ago
|
typedef Texture<3> Texture3D;
|
||
|
9 years ago
|
#endif
|
||
|
16 years ago
|
|
||
|
|
}
|
||
|
|
|
||
|
|
#endif
|