Browse Source

Updated, documented and added missing texture targets.

Nothing else except the target is done for multisample textures.
pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
f5e4b8a90f
  1. 9
      src/AbstractTexture.h
  2. 8
      src/BufferTexture.h
  3. 15
      src/CubeMapTexture.h
  4. 14
      src/CubeMapTextureArray.h
  5. 82
      src/Texture.h

9
src/AbstractTexture.h

@ -454,9 +454,9 @@ template<> struct AbstractTexture::DataHelper<1> {
#endif #endif
template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<2> { template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<2> {
enum class Target: GLenum { enum class Target: GLenum {
Texture2D = GL_TEXTURE_2D Texture2D = GL_TEXTURE_2D,
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
, Texture2DMultisample = GL_TEXTURE_2D_MULTISAMPLE,
Texture1DArray = GL_TEXTURE_1D_ARRAY, Texture1DArray = GL_TEXTURE_1D_ARRAY,
Rectangle = GL_TEXTURE_RECTANGLE Rectangle = GL_TEXTURE_RECTANGLE
#endif #endif
@ -494,7 +494,10 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<3> {
enum class Target: GLenum { enum class Target: GLenum {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
Texture3D = GL_TEXTURE_3D, Texture3D = GL_TEXTURE_3D,
Texture2DArray = GL_TEXTURE_2D_ARRAY Texture2DArray = GL_TEXTURE_2D_ARRAY,
#ifndef MAGNUM_TARGET_GLES
Texture2DMultisampleArray = GL_TEXTURE_2D_MULTISAMPLE_ARRAY,
#endif
#else #else
Texture3D = GL_TEXTURE_3D_OES Texture3D = GL_TEXTURE_3D_OES
#endif #endif

8
src/BufferTexture.h

@ -65,9 +65,10 @@ buffer.setData(data, Buffer::Usage::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 bind(). In shader, the
texture is used via `samplerBuffer`. Unlike in classic textures, coordinates texture is used via `samplerBuffer`, `isamplerBuffer` or `usamplerBuffer`.
for buffer textures are integer coordinates passed to `texelFetch()`. See also Unlike in classic textures, coordinates for buffer textures are integer
AbstractShaderProgram documentation for more information. coordinates passed to `texelFetch()`. See also AbstractShaderProgram
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, setBuffer()
@ -76,6 +77,7 @@ functions use DSA to avoid unnecessary calls to @fn_gl{ActiveTexture} and
"relevant section in AbstractTexture documentation" and respective function "relevant section in AbstractTexture documentation" and respective function
documentation for more information. documentation for more information.
@see Texture, CubeMapTexture, 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.
*/ */

15
src/CubeMapTexture.h

@ -67,13 +67,14 @@ 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 bind(). In shader, the
texture is used via `samplerCube`. Unlike in classic textures, coordinates for texture is used via `samplerCube`, `samplerCubeShadow`, `isamplerCube` or
cube map textures is signed three-part vector from the center of the cube, `usamplerCube`. Unlike in classic textures, coordinates for cube map textures
which intersects one of the six sides of the cube map. See also is signed three-part vector from the center of the cube, which intersects one
AbstractShaderProgram for more information. of the six sides of the cube map. See also AbstractShaderProgram for more
information about usage in shaders.
@see @ref Renderer::Feature "Renderer::Feature::SeamlessCubeMapTexture"
@see CubeMapTextureArray @see @ref Renderer::Feature "Renderer::Feature::SeamlessCubeMapTexture",
CubeMapTextureArray, Texture, BufferTexture
*/ */
class CubeMapTexture: public AbstractTexture { class CubeMapTexture: public AbstractTexture {
public: public:

14
src/CubeMapTextureArray.h

@ -68,13 +68,15 @@ 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 bind(). In shader, the
texture is used via `samplerCubeArray`. Unlike in classic textures, texture is used via `samplerCubeArray`, `samplerCubeArrayShadow`,
coordinates for cube map texture arrays is signed four-part vector. First `isamplerCubeArray` or `usamplerCubeArray`. Unlike in classic textures,
three parts define vector from the center of the cube which intersects with coordinates for cube map texture arrays is signed four-part vector. First three
one of the six sides of the cube map, fourth part is layer in the array. See parts define vector from the center of the cube which intersects with one of
also AbstractShaderProgram for more information. the six sides of the cube map, fourth part is layer in the array. See also
AbstractShaderProgram for more information about usage in shaders.
@see @ref Renderer::Feature "Renderer::Feature::SeamlessCubeMapTexture" @see @ref Renderer::Feature "Renderer::Feature::SeamlessCubeMapTexture",
CubeMapTexture, Texture, BufferTexture
@requires_gl40 %Extension @extension{ARB,texture_cube_map_array} @requires_gl40 %Extension @extension{ARB,texture_cube_map_array}
@requires_gl Cube map texture arrays are not available in OpenGL ES. @requires_gl Cube map texture arrays are not available in OpenGL ES.
*/ */

82
src/Texture.h

@ -67,14 +67,14 @@ texture.setMagnificationFilter(Sampler::Filter::Linear)
textures. See also setMagnificationFilter() and setBorderColor(). textures. See also setMagnificationFilter() and setBorderColor().
The texture is bound to layer specified by shader via bind(). In shader, the The texture is bound to layer specified by shader via bind(). In shader, the
texture is used via `sampler1D`, `sampler2D` or `sampler3D` depending on texture is used via `sampler2D` and friends, see @ref Target enum documentation
dimension count. See also AbstractShaderProgram documentation for more for more information. See also AbstractShaderProgram documentation for more
information. information about usage in shaders.
@section Texture-array Texture arrays @section Texture-array Texture arrays
You can create texture arrays by passing @ref Texture::Target "Texture2D::Target::Texture1DArray" You can create texture arrays by passing @ref Target "Texture2D::Target::Texture1DArray"
or @ref Texture::Target "Texture3D::Target::Texture2DArray" to constructor. or @ref Target "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 setSubImage(), but you
have to allocate the memory for all layers first either by calling setStorage() have to allocate the memory for all layers first either by calling setStorage()
@ -99,21 +99,36 @@ Similar approach can be used for any other texture types (e.g. setting
Texture3D data using 2D layers, Texture2D data using one-dimensional chunks Texture3D data using 2D layers, Texture2D data using one-dimensional chunks
etc.). etc.).
@requires_gl30 %Extension @extension{EXT,texture_array} for texture arrays.
@requires_gles30 %Array textures are not available in OpenGL ES 2.0.
@section Texture-multisample Multisample textures
You can create multisample textures by passing @ref Target "Texture2D::Target::Texture2DMultisample"
or @ref Target "Texture3D::Target::Texture2DMultisampleArray" to constructor.
@todoc finish this when fully implemented
@requires_gl32 %Extension @extension{ARB,texture_multisample} for multisample
textures.
@requires_gl Multisample textures are not available in OpenGL ES.
@section Texture-rectangle Rectangle textures @section Texture-rectangle Rectangle textures
Rectangle texture is created by passing @ref Texture::Target "Texture::Target::Rectangle" Rectangle texture is created by passing @ref Target "Target::Rectangle" to
to constructor. In shader, the texture is used via sampler2DRect`. Unlike constructor. In shader, the texture is used via `sampler2DRect` and friends.
`sampler2D`, which accepts coordinates between 0 and 1, `sampler2DRect` Unlike `sampler2D`, which accepts coordinates between 0 and 1, `sampler2DRect`
accepts coordinates between 0 and `textureSizeInGivenDirection-1`. Note that accepts coordinates between 0 and `textureSizeInGivenDirection-1`. Note that
rectangle textures don't support mipmapping and repeating wrapping modes, see rectangle textures don't support mipmapping and repeating wrapping modes, see
@ref Sampler::Filter "Sampler::Filter", @ref Sampler::Mipmap "Sampler::Mipmap" @ref Sampler::Filter "Sampler::Filter", @ref Sampler::Mipmap "Sampler::Mipmap"
and generateMipmap() documentation for more information. and generateMipmap() documentation for more information.
@requires_gl31 %Extension @extension{ARB,texture_rectangle} for rectangle
textures.
@requires_gl Rectangle textures are not available in OpenGL ES. @requires_gl Rectangle textures are not available in OpenGL ES.
@requires_gl31 %Extension @extension{ARB,texture_rectangle} (rectangle
textures)
@see Texture1D, Texture2D, Texture3D, CubeMapTexture, CubeMapTextureArray @see Texture1D, Texture2D, Texture3D, CubeMapTexture, CubeMapTextureArray,
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 {
@ -128,22 +143,30 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
*/ */
enum class Target: GLenum { enum class Target: GLenum {
/** /**
* One-dimensional texture * One-dimensional texture. Use `sampler1D`, `sampler1DShadow`,
* `isampler1D` or `usampler1D` in shader.
* @requires_gl Only 2D and 3D textures are available in OpenGL * @requires_gl Only 2D and 3D textures are available in OpenGL
* ES. * ES.
*/ */
Texture1D = GL_TEXTURE_1D, Texture1D = GL_TEXTURE_1D,
Texture2D = GL_TEXTURE_2D, /**< Two-dimensional texture */ /**
* Two-dimensional texture. Use `sampler2D`, `sampler2DShadow`,
* `isampler2D` or `usampler2D` in shader.
*/
Texture2D = GL_TEXTURE_2D,
/** /**
* Three-dimensional texture * Three-dimensional texture. Use `sampler3D`, `isampler3D` or
* `usampler3D` in shader.
* @requires_gles30 %Extension @es_extension{OES,texture_3D} * @requires_gles30 %Extension @es_extension{OES,texture_3D}
*/ */
Texture3D = GL_TEXTURE_3D, Texture3D = GL_TEXTURE_3D,
/** /**
* One-dimensional texture array (i.e. two dimensions in total) * One-dimensional texture array (i.e. two dimensions in total).
* Use `sampler1DArray`, `sampler1DArrayShadow`, `isampler1DArray`
* or `usampler1DArray` in shader.
* @requires_gl30 %Extension @extension{EXT,texture_array} * @requires_gl30 %Extension @extension{EXT,texture_array}
* @requires_gl Only 2D and 3D textures are available in OpenGL * @requires_gl Only 2D and 3D textures are available in OpenGL
* ES. * ES.
@ -151,15 +174,38 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
Texture1DArray = GL_TEXTURE_1D_ARRAY, Texture1DArray = GL_TEXTURE_1D_ARRAY,
/** /**
* Two-dimensional texture array (i.e. three dimensions in total) * Two-dimensional texture array (i.e. three dimensions in total).
* Use `sampler2DArray`, `sampler2DArrayShadow`, `isampler2DArray`
* or `usampler2DArray` in shader.
* @requires_gl30 %Extension @extension{EXT,texture_array} * @requires_gl30 %Extension @extension{EXT,texture_array}
* @requires_gles30 Array textures are not available in OpenGL ES * @requires_gles30 %Array textures are not available in OpenGL ES
* 2.0. * 2.0.
*/ */
Texture2DArray = GL_TEXTURE_2D_ARRAY, Texture2DArray = GL_TEXTURE_2D_ARRAY,
/** /**
* Rectangle texture (i.e. two dimensions) * Multisampled two-dimensional texture. Use `sampler2DMS`,
* `isampler2DMS` or `usampler2DMS` in shader.
* @requires_gl32 %Extension @extension{ARB,texture_multisample}
* @requires_gl Multisample textures are not available in OpenGL
* ES.
*/
Texture2DMultisample = GL_TEXTURE_2D_MULTISAMPLE,
/**
* Multisampled two-dimensional texture array (i.e. three
* dimensions in total). Use `sampler2DMSArray`,
* `isampler2DMSArray` or `usampler2DMSArray` in shader.
* @requires_gl32 %Extension @extension{ARB,texture_multisample}
* @requires_gl Multisample textures are not available in OpenGL
* ES.
*/
Texture2DMultisampleArray = GL_TEXTURE_2D_MULTISAMPLE_ARRAY,
/**
* Rectangle texture (i.e. two dimensions). Use `sampler2DRect`,
* `sampler2DRectShadow`, `isampler2DRect` or `usampler2DRect` in
* shader.
* @requires_gl31 %Extension @extension{ARB,texture_rectangle} * @requires_gl31 %Extension @extension{ARB,texture_rectangle}
* @requires_gl Rectangle textures are not available in OpenGL ES. * @requires_gl Rectangle textures are not available in OpenGL ES.
*/ */

Loading…
Cancel
Save