Browse Source

Enabled texture image size queries in ES 3.1.

pull/68/head
Vladimír Vondruš 12 years ago
parent
commit
10faa49363
  1. 6
      src/Magnum/AbstractTexture.cpp
  2. 8
      src/Magnum/AbstractTexture.h
  3. 5
      src/Magnum/CubeMapTexture.h
  4. 2
      src/Magnum/Implementation/TextureState.cpp
  5. 2
      src/Magnum/Implementation/TextureState.h
  6. 8
      src/Magnum/Test/CubeMapTextureGLTest.cpp
  7. 8
      src/Magnum/Test/TextureArrayGLTest.cpp
  8. 16
      src/Magnum/Test/TextureGLTest.cpp
  9. 5
      src/Magnum/Texture.h
  10. 2
      src/Magnum/TextureArray.h

6
src/Magnum/AbstractTexture.cpp

@ -817,16 +817,18 @@ void AbstractTexture::setMaxAnisotropyImplementationExt(GLfloat anisotropy) {
(this->*Context::current()->state().texture->parameterfImplementation)(GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy); (this->*Context::current()->state().texture->parameterfImplementation)(GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy);
} }
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES2
void AbstractTexture::getLevelParameterImplementationDefault(GLenum target, GLint level, GLenum parameter, GLint* values) { void AbstractTexture::getLevelParameterImplementationDefault(GLenum target, GLint level, GLenum parameter, GLint* values) {
bindInternal(); bindInternal();
glGetTexLevelParameteriv(target, level, parameter, values); glGetTexLevelParameteriv(target, level, parameter, values);
} }
#ifndef MAGNUM_TARGET_GLES
void AbstractTexture::getLevelParameterImplementationDSA(GLenum target, GLint level, GLenum parameter, GLint* values) { void AbstractTexture::getLevelParameterImplementationDSA(GLenum target, GLint level, GLenum parameter, GLint* values) {
glGetTextureLevelParameterivEXT(_id, target, level, parameter, values); glGetTextureLevelParameterivEXT(_id, target, level, parameter, values);
} }
#endif #endif
#endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
void AbstractTexture::storageImplementationFallback(const GLenum target, const GLsizei levels, const TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) { void AbstractTexture::storageImplementationFallback(const GLenum target, const GLsizei levels, const TextureFormat internalFormat, const Math::Vector<1, GLsizei>& size) {
@ -1155,7 +1157,9 @@ Math::Vector<1, GLint> AbstractTexture::DataHelper<1>::imageSize(AbstractTexture
(texture.*Context::current()->state().texture->getLevelParameterivImplementation)(target, level, GL_TEXTURE_WIDTH, &value[0]); (texture.*Context::current()->state().texture->getLevelParameterivImplementation)(target, level, GL_TEXTURE_WIDTH, &value[0]);
return value; return value;
} }
#endif
#ifndef MAGNUM_TARGET_GLES2
Vector2i AbstractTexture::DataHelper<2>::imageSize(AbstractTexture& texture, const GLenum target, const GLint level) { Vector2i AbstractTexture::DataHelper<2>::imageSize(AbstractTexture& texture, const GLenum target, const GLint level) {
const Implementation::TextureState& state = *Context::current()->state().texture; const Implementation::TextureState& state = *Context::current()->state().texture;

8
src/Magnum/AbstractTexture.h

@ -388,10 +388,12 @@ class MAGNUM_EXPORT AbstractTexture: public AbstractObject {
void MAGNUM_LOCAL setMaxAnisotropyImplementationNoOp(GLfloat); void MAGNUM_LOCAL setMaxAnisotropyImplementationNoOp(GLfloat);
void MAGNUM_LOCAL setMaxAnisotropyImplementationExt(GLfloat anisotropy); void MAGNUM_LOCAL setMaxAnisotropyImplementationExt(GLfloat anisotropy);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES2
void MAGNUM_LOCAL getLevelParameterImplementationDefault(GLenum target, GLint level, GLenum parameter, GLint* values); void MAGNUM_LOCAL getLevelParameterImplementationDefault(GLenum target, GLint level, GLenum parameter, GLint* values);
#ifndef MAGNUM_TARGET_GLES
void MAGNUM_LOCAL getLevelParameterImplementationDSA(GLenum target, GLint level, GLenum parameter, GLint* values); void MAGNUM_LOCAL getLevelParameterImplementationDSA(GLenum target, GLint level, GLenum parameter, GLint* values);
#endif #endif
#endif
void MAGNUM_LOCAL mipmapImplementationDefault(); void MAGNUM_LOCAL mipmapImplementationDefault();
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
@ -514,7 +516,7 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<2> {
}; };
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES2
static Vector2i imageSize(AbstractTexture& texture, GLenum target, GLint level); static Vector2i imageSize(AbstractTexture& texture, GLenum target, GLint level);
#endif #endif
@ -551,7 +553,7 @@ template<> struct MAGNUM_EXPORT AbstractTexture::DataHelper<3> {
}; };
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES2
static Vector3i imageSize(AbstractTexture& texture, GLenum target, GLint level); static Vector3i imageSize(AbstractTexture& texture, GLenum target, GLint level);
#endif #endif

5
src/Magnum/CubeMapTexture.h

@ -236,14 +236,15 @@ class MAGNUM_EXPORT CubeMapTexture: public AbstractTexture {
} }
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES2
/** /**
* @brief %Image size in given mip level * @brief %Image size in given mip level
* @param coordinate Coordinate * @param coordinate Coordinate
* @param level Mip level * @param level Mip level
* *
* See @ref Texture::imageSize() for more information. * See @ref Texture::imageSize() for more information.
* @requires_gl %Texture image queries are not available in OpenGL ES. * @requires_gles31 %Texture image size queries are not available in
* OpenGL ES 3.0 and older.
*/ */
Vector2i imageSize(Coordinate coordinate, Int level) { Vector2i imageSize(Coordinate coordinate, Int level) {
return DataHelper<2>::imageSize(*this, GLenum(coordinate), level); return DataHelper<2>::imageSize(*this, GLenum(coordinate), level);

2
src/Magnum/Implementation/TextureState.cpp

@ -113,6 +113,8 @@ TextureState::TextureState(Context& context, std::vector<std::string>& extension
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
parameterIuivImplementation = &AbstractTexture::parameterIImplementationDefault; parameterIuivImplementation = &AbstractTexture::parameterIImplementationDefault;
parameterIivImplementation = &AbstractTexture::parameterIImplementationDefault; parameterIivImplementation = &AbstractTexture::parameterIImplementationDefault;
#endif
#ifndef MAGNUM_TARGET_GLES2
getLevelParameterivImplementation = &AbstractTexture::getLevelParameterImplementationDefault; getLevelParameterivImplementation = &AbstractTexture::getLevelParameterImplementationDefault;
#endif #endif
mipmapImplementation = &AbstractTexture::mipmapImplementationDefault; mipmapImplementation = &AbstractTexture::mipmapImplementationDefault;

2
src/Magnum/Implementation/TextureState.h

@ -53,7 +53,7 @@ struct TextureState {
void(AbstractTexture::*parameterIivImplementation)(GLenum, const GLint*); void(AbstractTexture::*parameterIivImplementation)(GLenum, const GLint*);
#endif #endif
void(AbstractTexture::*setMaxAnisotropyImplementation)(GLfloat); void(AbstractTexture::*setMaxAnisotropyImplementation)(GLfloat);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES2
void(AbstractTexture::*getLevelParameterivImplementation)(GLenum, GLint, GLenum, GLint*); void(AbstractTexture::*getLevelParameterivImplementation)(GLenum, GLint, GLenum, GLint*);
#endif #endif
void(AbstractTexture::*mipmapImplementation)(); void(AbstractTexture::*mipmapImplementation)();

8
src/Magnum/Test/CubeMapTextureGLTest.cpp

@ -264,8 +264,12 @@ void CubeMapTextureGLTest::storage() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */ #ifndef MAGNUM_TARGET_GLES2
#ifndef MAGNUM_TARGET_GLES #ifdef MAGNUM_TARGET_GLES
if(!Context::current()->isVersionSupported(Version::GLES310))
CORRADE_SKIP("OpenGL ES 3.1 not supported, skipping image size testing");
#endif
CORRADE_COMPARE(texture.imageSize(CubeMapTexture::Coordinate::PositiveX, 0), Vector2i(32)); CORRADE_COMPARE(texture.imageSize(CubeMapTexture::Coordinate::PositiveX, 0), Vector2i(32));
CORRADE_COMPARE(texture.imageSize(CubeMapTexture::Coordinate::NegativeX, 0), Vector2i(32)); CORRADE_COMPARE(texture.imageSize(CubeMapTexture::Coordinate::NegativeX, 0), Vector2i(32));
CORRADE_COMPARE(texture.imageSize(CubeMapTexture::Coordinate::PositiveY, 0), Vector2i(32)); CORRADE_COMPARE(texture.imageSize(CubeMapTexture::Coordinate::PositiveY, 0), Vector2i(32));

8
src/Magnum/Test/TextureArrayGLTest.cpp

@ -526,8 +526,12 @@ void TextureArrayGLTest::storage2D() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */ #ifndef MAGNUM_TARGET_GLES2
#ifndef MAGNUM_TARGET_GLES #ifdef MAGNUM_TARGET_GLES
if(!Context::current()->isVersionSupported(Version::GLES310))
CORRADE_SKIP("OpenGL ES 3.1 not supported, skipping image size testing");
#endif
CORRADE_COMPARE(texture.imageSize(0), Vector3i(32, 32, 32)); CORRADE_COMPARE(texture.imageSize(0), Vector3i(32, 32, 32));
CORRADE_COMPARE(texture.imageSize(1), Vector3i(16, 16, 32)); CORRADE_COMPARE(texture.imageSize(1), Vector3i(16, 16, 32));
CORRADE_COMPARE(texture.imageSize(2), Vector3i( 8, 8, 32)); CORRADE_COMPARE(texture.imageSize(2), Vector3i( 8, 8, 32));

16
src/Magnum/Test/TextureGLTest.cpp

@ -683,8 +683,12 @@ void TextureGLTest::storage2D() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */ #ifndef MAGNUM_TARGET_GLES2
#ifndef MAGNUM_TARGET_GLES #ifdef MAGNUM_TARGET_GLES
if(!Context::current()->isVersionSupported(Version::GLES310))
CORRADE_SKIP("OpenGL ES 3.1 not supported, skipping image size testing.");
#endif
CORRADE_COMPARE(texture.imageSize(0), Vector2i(32)); CORRADE_COMPARE(texture.imageSize(0), Vector2i(32));
CORRADE_COMPARE(texture.imageSize(1), Vector2i(16)); CORRADE_COMPARE(texture.imageSize(1), Vector2i(16));
CORRADE_COMPARE(texture.imageSize(2), Vector2i( 8)); CORRADE_COMPARE(texture.imageSize(2), Vector2i( 8));
@ -707,8 +711,12 @@ void TextureGLTest::storage3D() {
MAGNUM_VERIFY_NO_ERROR(); MAGNUM_VERIFY_NO_ERROR();
/** @todo How to test this on ES? */ #ifndef MAGNUM_TARGET_GLES2
#ifndef MAGNUM_TARGET_GLES #ifdef MAGNUM_TARGET_GLES
if(!Context::current()->isVersionSupported(Version::GLES310))
CORRADE_SKIP("OpenGL ES 3.1 not supported, skipping image size testing.");
#endif
CORRADE_COMPARE(texture.imageSize(0), Vector3i(32)); CORRADE_COMPARE(texture.imageSize(0), Vector3i(32));
CORRADE_COMPARE(texture.imageSize(1), Vector3i(16)); CORRADE_COMPARE(texture.imageSize(1), Vector3i(16));
CORRADE_COMPARE(texture.imageSize(2), Vector3i( 8)); CORRADE_COMPARE(texture.imageSize(2), Vector3i( 8));

5
src/Magnum/Texture.h

@ -185,7 +185,7 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
constexpr CORRADE_DEPRECATED("use dedicated Texture, TextureArray, MultisampleTexture, RectangleTexture classes instead") Target target() const { return static_cast<Target>(_target); } constexpr CORRADE_DEPRECATED("use dedicated Texture, TextureArray, MultisampleTexture, RectangleTexture classes instead") Target target() const { return static_cast<Target>(_target); }
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES2
/** /**
* @brief %Image size in given mip level * @brief %Image size in given mip level
* *
@ -196,7 +196,8 @@ template<UnsignedInt dimensions> class Texture: public AbstractTexture {
* @fn_gl{GetTexLevelParameter} or @fn_gl_extension{GetTextureLevelParameter,EXT,direct_state_access} * @fn_gl{GetTexLevelParameter} or @fn_gl_extension{GetTextureLevelParameter,EXT,direct_state_access}
* with @def_gl{TEXTURE_WIDTH}, @def_gl{TEXTURE_HEIGHT} or * with @def_gl{TEXTURE_WIDTH}, @def_gl{TEXTURE_HEIGHT} or
* @def_gl{TEXTURE_DEPTH} * @def_gl{TEXTURE_DEPTH}
* @requires_gl %Texture image queries are not available in OpenGL ES. * @requires_gles31 %Texture image size queries are not available in
* OpenGL ES 3.0 and older.
*/ */
VectorTypeFor<dimensions, Int> imageSize(Int level) { VectorTypeFor<dimensions, Int> imageSize(Int level) {
return DataHelper<dimensions>::imageSize(*this, _target, level); return DataHelper<dimensions>::imageSize(*this, _target, level);

2
src/Magnum/TextureArray.h

@ -249,7 +249,7 @@ template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
} }
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES2
/** @copydoc Texture::imageSize() */ /** @copydoc Texture::imageSize() */
VectorTypeFor<dimensions+1, Int> imageSize(Int level) { VectorTypeFor<dimensions+1, Int> imageSize(Int level) {
return DataHelper<dimensions+1>::imageSize(*this, _target, level); return DataHelper<dimensions+1>::imageSize(*this, _target, level);

Loading…
Cancel
Save