Browse Source

GL: make the Array GL::samplerWrapping() work and test it.

Also not sure what happened there.
pull/297/head
Vladimír Vondruš 8 years ago
parent
commit
cd7f67e5c9
  1. 5
      src/Magnum/GL/Sampler.h
  2. 15
      src/Magnum/GL/Test/SamplerTest.cpp

5
src/Magnum/GL/Sampler.h

@ -29,6 +29,7 @@
* @brief Class @ref Magnum::GL::Sampler, enum @ref Magnum::GL::SamplerFilter, @ref Magnum::GL::SamplerMipmap, @ref Magnum::GL::SamplerWrapping, @ref Magnum::GL::SamplerCompareMode, @ref Magnum::GL::SamplerCompareFunction, @ref Magnum::GL::SamplerDepthStencilMode, function @ref Magnum::GL::samplerFilter(), @ref Magnum::GL::samplerMipmap(), @ref Magnum::GL::hasSamplerWrapping(), @ref Magnum::GL::samplerWrapping() * @brief Class @ref Magnum::GL::Sampler, enum @ref Magnum::GL::SamplerFilter, @ref Magnum::GL::SamplerMipmap, @ref Magnum::GL::SamplerWrapping, @ref Magnum::GL::SamplerCompareMode, @ref Magnum::GL::SamplerCompareFunction, @ref Magnum::GL::SamplerDepthStencilMode, function @ref Magnum::GL::samplerFilter(), @ref Magnum::GL::samplerMipmap(), @ref Magnum::GL::hasSamplerWrapping(), @ref Magnum::GL::samplerWrapping()
*/ */
#include "Magnum/Array.h"
#include "Magnum/Magnum.h" #include "Magnum/Magnum.h"
#include "Magnum/GL/OpenGL.h" #include "Magnum/GL/OpenGL.h"
#include "Magnum/GL/visibility.h" #include "Magnum/GL/visibility.h"
@ -189,9 +190,9 @@ format, @cpp true @ce otherwise. The @p filter value is expected to be valid.
extension. Such check is outside of the scope of this function and you are extension. Such check is outside of the scope of this function and you are
expected to verify extension availability before using such format. expected to verify extension availability before using such format.
@see @ref samplerFilter(), @ref samplerMipmap() @see @see @ref samplerWrapping(), @ref samplerFilter(), @ref samplerMipmap()
*/ */
MAGNUM_GL_EXPORT bool hasSamplerWrapping(Magnum::SamplerWrapping wrappomg); MAGNUM_GL_EXPORT bool hasSamplerWrapping(Magnum::SamplerWrapping wrapping);
/** /**
@brief Convert generic sampler filter mode to OpenGL filter mode @brief Convert generic sampler filter mode to OpenGL filter mode

15
src/Magnum/GL/Test/SamplerTest.cpp

@ -39,6 +39,7 @@ struct SamplerTest: TestSuite::Tester {
void mapMipmap(); void mapMipmap();
void mapMipmapInvalid(); void mapMipmapInvalid();
void mapWrapping(); void mapWrapping();
void mapWrappingArray();
void mapWrappingInvalid(); void mapWrappingInvalid();
void mapWrappingUnsupported(); void mapWrappingUnsupported();
@ -60,6 +61,7 @@ SamplerTest::SamplerTest() {
&SamplerTest::mapMipmap, &SamplerTest::mapMipmap,
&SamplerTest::mapMipmapInvalid, &SamplerTest::mapMipmapInvalid,
&SamplerTest::mapWrapping, &SamplerTest::mapWrapping,
&SamplerTest::mapWrappingArray,
&SamplerTest::mapWrappingInvalid, &SamplerTest::mapWrappingInvalid,
&SamplerTest::mapWrappingUnsupported, &SamplerTest::mapWrappingUnsupported,
@ -126,6 +128,10 @@ void SamplerTest::mapWrapping() {
#endif #endif
} }
void SamplerTest::mapWrappingArray() {
CORRADE_COMPARE(samplerWrapping<2>({Magnum::SamplerWrapping::Repeat, Magnum::SamplerWrapping::ClampToEdge}), (Array2D<SamplerWrapping>{SamplerWrapping::Repeat, SamplerWrapping::ClampToEdge}));
}
void SamplerTest::mapWrappingInvalid() { void SamplerTest::mapWrappingInvalid() {
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -141,10 +147,13 @@ void SamplerTest::mapWrappingUnsupported() {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
CORRADE_SKIP("All pixel formats are supported on desktop"); CORRADE_SKIP("All pixel formats are supported on desktop");
#else #else
std::ostringstream out; CORRADE_VERIFY(!hasSamplerWrapping(Magnum::SamplerWrapping::MirrorClampToEdge));
Error redirectError{&out};
samplerWrapping(Magnum::SamplerWrapping::MirrorClampToEdge); std::ostringstream out;
{
Error redirectError{&out};
samplerWrapping(Magnum::SamplerWrapping::MirrorClampToEdge);
}
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out.str(),
"GL::samplerWrapping(): wrapping SamplerWrapping::MirrorClampToEdge is not supported on this target\n"); "GL::samplerWrapping(): wrapping SamplerWrapping::MirrorClampToEdge is not supported on this target\n");
#endif #endif

Loading…
Cancel
Save