Browse Source

Clarified and fixed cube map texture image retrieval methods.

Because ARB_DSA doesn't have any way to extract image of single cube map
coordinate, we have to use ARB_get_texture_sub_image instead, thus for
cube maps the whole thing is different. That was implemented, but wasn't
mentioned in the docs and wasn't properly accounted for in
implementation switcher (I was under assumption that ARB_DSA is
equivalent to ARB_get_texture_sub_image, which is not).
pull/94/head
Vladimír Vondruš 11 years ago
parent
commit
11b2247bf5
  1. 29
      src/Magnum/CubeMapTexture.h
  2. 22
      src/Magnum/Implementation/TextureState.cpp
  3. 3
      src/Magnum/Texture.h

29
src/Magnum/CubeMapTexture.h

@ -379,9 +379,29 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture {
#ifndef MAGNUM_TARGET_GLES
/**
* @copybrief Texture::image(Int, Image&)
* @brief Read given mip level and coordinate of texture to image
*
* See @ref Texture::image(Int, Image&) for more information.
* Image parameters like format and type of pixel data are taken from
* given image, image size is taken from the texture using
* @ref imageSize().
*
* If neither @extension{ARB,get_texture_sub_image} (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,get_texture_sub_image} or @extension{ARB,robustness}
* is available, the operation is protected from buffer overflow.
* However, if @extension{ARB,get_texture_sub_image} 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}, then @fn_gl{GetTextureSubImage},
* @fn_gl_extension{GetnTexImage,ARB,robustness},
* @fn_gl_extension{GetTextureImage,EXT,direct_state_access},
* eventually @fn_gl{GetTexImage}
* @requires_gl Texture image queries are not available in OpenGL ES.
*/
void image(Coordinate coordinate, Int level, Image2D& image);
@ -396,10 +416,9 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture {
Image2D image(Coordinate coordinate, Int level, Image2D&& image);
/**
* @copybrief Texture::image(Int, BufferImage&, BufferUsage)
* @brief Read given mip level and coordinate of texture to buffer image
*
* See @ref Texture::image(Int, BufferImage&, BufferUsage) for more
* information.
* See @ref image(Coordinate, Int, Image2D&) for more information.
* @requires_gl Texture image queries are not available in OpenGL ES.
*/
void image(Coordinate coordinate, Int level, BufferImage2D& image, BufferUsage usage);

22
src/Magnum/Implementation/TextureState.cpp

@ -205,23 +205,31 @@ TextureState::TextureState(Context& context, std::vector<std::string>& extension
if(context.isExtensionSupported<Extensions::GL::ARB::direct_state_access>()) {
/* Extension name added above */
getImageImplementation = &AbstractTexture::getImageImplementationDSA;
getCubeImageImplementation = &CubeMapTexture::getImageImplementationDSA;
} else if(context.isExtensionSupported<Extensions::GL::ARB::robustness>()) {
extensions.push_back(Extensions::GL::ARB::robustness::string());
getImageImplementation = &AbstractTexture::getImageImplementationRobustness;
getCubeImageImplementation = &CubeMapTexture::getImageImplementationRobustness;
} else if(context.isExtensionSupported<Extensions::GL::EXT::direct_state_access>()) {
/* Extension name added above */
getImageImplementation = &AbstractTexture::getImageImplementationDSAEXT;
} else getImageImplementation = &AbstractTexture::getImageImplementationDefault;
/* Image retrieval implementation for cube map */
if(context.isExtensionSupported<Extensions::GL::ARB::get_texture_sub_image>()) {
extensions.push_back(Extensions::GL::ARB::get_texture_sub_image::string());
getCubeImageImplementation = &CubeMapTexture::getImageImplementationDSA;
} else if(context.isExtensionSupported<Extensions::GL::ARB::robustness>()) {
/* Extension name added above */
getCubeImageImplementation = &CubeMapTexture::getImageImplementationRobustness;
} else if(context.isExtensionSupported<Extensions::GL::EXT::direct_state_access>()) {
/* Extension name added above */
getCubeImageImplementation = &CubeMapTexture::getImageImplementationDSAEXT;
} else {
getImageImplementation = &AbstractTexture::getImageImplementationDefault;
getCubeImageImplementation = &CubeMapTexture::getImageImplementationDefault;
}
} else getCubeImageImplementation = &CubeMapTexture::getImageImplementationDefault;
#endif
/* Texture storage implementation */

3
src/Magnum/Texture.h

@ -645,8 +645,9 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* @fn_gl{GetTexLevelParameter} with @def_gl{TEXTURE_WIDTH},
* @def_gl{TEXTURE_HEIGHT}, @def_gl{TEXTURE_DEPTH}, then
* @fn_gl2{GetTextureImage,GetTexImage},
* @fn_gl_extension{GetnTexImage,ARB,robustness} or
* @fn_gl_extension{GetnTexImage,ARB,robustness},
* @fn_gl_extension{GetTextureImage,EXT,direct_state_access},
* eventually @fn_gl{GetTexImage}
* @requires_gl Texture image queries are not available in OpenGL ES.
*/
void image(Int level, Image<dimensions>& image) {

Loading…
Cancel
Save