Browse Source

GL: be nice and show a message for this assertion.

pull/651/merge
Vladimír Vondruš 1 year ago
parent
commit
c46c7f58fb
  1. 2
      src/Magnum/GL/PixelFormat.cpp
  2. 7
      src/Magnum/GL/Test/PixelFormatTest.cpp

2
src/Magnum/GL/PixelFormat.cpp

@ -266,7 +266,7 @@ UnsignedInt pixelFormatSize(const PixelFormat format, const PixelType type) {
#pragma GCC diagnostic pop
#endif
CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
CORRADE_ASSERT_UNREACHABLE("GL::pixelFormatSize(): unknown" << format << "or" << type, {});
}
Containers::Optional<Magnum::PixelFormat> genericPixelFormat(const PixelFormat format, PixelType type) {

7
src/Magnum/GL/Test/PixelFormatTest.cpp

@ -27,6 +27,7 @@
#include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/String.h>
#include <Corrade/TestSuite/Tester.h>
#include <Corrade/TestSuite/Compare/String.h>
#include "Magnum/PixelFormat.h"
#include "Magnum/GL/PixelFormat.h"
@ -444,8 +445,12 @@ void PixelFormatTest::sizeInvalid() {
Containers::String out;
Error redirectError{&out};
pixelFormatSize(PixelFormat(0xdeadbeef), PixelType(0xbadcafe));
pixelFormatSize(PixelFormat::DepthStencil, PixelType::Float);
CORRADE_COMPARE(out, "GL::pixelFormatSize(): invalid GL::PixelType::Float specified for GL::PixelFormat::DepthStencil\n");
CORRADE_COMPARE_AS(out,
"GL::pixelFormatSize(): unknown GL::PixelFormat(0xdeadbeef) or GL::PixelType(0xbadcafe)\n"
"GL::pixelFormatSize(): invalid GL::PixelType::Float specified for GL::PixelFormat::DepthStencil\n",
TestSuite::Compare::String);
}
void PixelFormatTest::mapCompressedFormatTextureFormat() {

Loading…
Cancel
Save