Browse Source

Support OpenGL tests also on Windows and OS X.

I wanted to preserve the parameter-less constructor of tests, but WINAPI
requires fairly ugly entagled set of functions, passing HWND around,
which required storing it in a global var and hoping it is properly
initialized when querying it for it to be passed to application
constructor.

When this was done, it was now fairly easy to support passing also
argv/argc to application constructor, which in the future will enable
selective disabling of extensions for even better test coverage.

This however needed slightly different main() function and thus we now
have MAGNUM_GL_TEST_MAIN() instead of CORRADE_TEST_MAIN(). Using the
latter will result in an assert inside std::optional.
pull/107/head
Vladimír Vondruš 11 years ago
parent
commit
88f0415290
  1. 8
      CMakeLists.txt
  2. 2
      src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp
  3. 2
      src/Magnum/Shaders/Test/FlatGLTest.cpp
  4. 2
      src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp
  5. 2
      src/Magnum/Shaders/Test/PhongGLTest.cpp
  6. 2
      src/Magnum/Shaders/Test/VectorGLTest.cpp
  7. 2
      src/Magnum/Shaders/Test/VertexColorGLTest.cpp
  8. 2
      src/Magnum/Test/AbstractObjectGLTest.cpp
  9. 53
      src/Magnum/Test/AbstractOpenGLTester.h
  10. 2
      src/Magnum/Test/AbstractQueryGLTest.cpp
  11. 2
      src/Magnum/Test/AbstractShaderProgramGLTest.cpp
  12. 2
      src/Magnum/Test/AbstractTextureGLTest.cpp
  13. 2
      src/Magnum/Test/BufferGLTest.cpp
  14. 2
      src/Magnum/Test/BufferImageGLTest.cpp
  15. 2
      src/Magnum/Test/BufferTextureGLTest.cpp
  16. 2
      src/Magnum/Test/ContextGLTest.cpp
  17. 2
      src/Magnum/Test/CubeMapTextureArrayGLTest.cpp
  18. 2
      src/Magnum/Test/CubeMapTextureGLTest.cpp
  19. 2
      src/Magnum/Test/DebugOutputGLTest.cpp
  20. 2
      src/Magnum/Test/FramebufferGLTest.cpp
  21. 2
      src/Magnum/Test/MeshGLTest.cpp
  22. 2
      src/Magnum/Test/MultisampleTextureGLTest.cpp
  23. 2
      src/Magnum/Test/PrimitiveQueryGLTest.cpp
  24. 2
      src/Magnum/Test/RectangleTextureGLTest.cpp
  25. 2
      src/Magnum/Test/RenderbufferGLTest.cpp
  26. 2
      src/Magnum/Test/SampleQueryGLTest.cpp
  27. 2
      src/Magnum/Test/ShaderGLTest.cpp
  28. 2
      src/Magnum/Test/TextureArrayGLTest.cpp
  29. 2
      src/Magnum/Test/TextureGLTest.cpp
  30. 2
      src/Magnum/Test/TimeQueryGLTest.cpp
  31. 2
      src/Magnum/Test/TransformFeedbackGLTest.cpp
  32. 2
      src/Magnum/Text/Test/GlyphCacheGLTest.cpp
  33. 2
      src/Magnum/Text/Test/RendererGLTest.cpp
  34. 2
      src/MagnumPlugins/MagnumFont/Test/MagnumFontGLTest.cpp
  35. 2
      src/MagnumPlugins/MagnumFontConverter/Test/MagnumFontConverterGLTest.cpp

8
CMakeLists.txt

@ -176,9 +176,15 @@ if(TARGET_DESKTOP_GLES)
endif()
if(BUILD_GL_TESTS)
if(UNIX AND (NOT MAGNUM_TARGET_GLES OR MAGNUM_TARGET_DESKTOP_GLES))
if(CORRADE_TARGET_APPLE)
set(WITH_WINDOWLESSCGLAPPLICATION ON)
set(GL_TEST_LIBRARIES Magnum MagnumWindowlessCglApplication)
elseif(CORRADE_TARGET_UNIX AND (NOT MAGNUM_TARGET_GLES OR MAGNUM_TARGET_DESKTOP_GLES))
set(WITH_WINDOWLESSGLXAPPLICATION ON)
set(GL_TEST_LIBRARIES Magnum MagnumWindowlessGlxApplication)
elseif(CORRADE_TARGET_WINDOWS)
set(WITH_WINDOWLESSWGLAPPLICATION ON)
set(GL_TEST_LIBRARIES Magnum MagnumWindowlessWglApplication)
else()
message(FATAL_ERROR "Cannot run tests for OpenGL code on this platform. Set BUILD_GL_TESTS to OFF to skip building them.")
endif()

2
src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp

@ -52,4 +52,4 @@ void DistanceFieldVectorGLTest::compile3D() {
}}}
CORRADE_TEST_MAIN(Magnum::Shaders::Test::DistanceFieldVectorGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Shaders::Test::DistanceFieldVectorGLTest)

2
src/Magnum/Shaders/Test/FlatGLTest.cpp

@ -66,4 +66,4 @@ void FlatGLTest::compile3DTextured() {
}}}
CORRADE_TEST_MAIN(Magnum::Shaders::Test::FlatGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Shaders::Test::FlatGLTest)

2
src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp

@ -68,4 +68,4 @@ void MeshVisualizerGLTest::compileWireframeNoGeometryShader() {
}}}
CORRADE_TEST_MAIN(Magnum::Shaders::Test::MeshVisualizerGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Shaders::Test::MeshVisualizerGLTest)

2
src/Magnum/Shaders/Test/PhongGLTest.cpp

@ -94,4 +94,4 @@ void PhongGLTest::compileAmbientDiffuseSpecularTexture() {
}}}
CORRADE_TEST_MAIN(Magnum::Shaders::Test::PhongGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Shaders::Test::PhongGLTest)

2
src/Magnum/Shaders/Test/VectorGLTest.cpp

@ -52,4 +52,4 @@ void VectorGLTest::compile3D() {
}}}
CORRADE_TEST_MAIN(Magnum::Shaders::Test::VectorGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Shaders::Test::VectorGLTest)

2
src/Magnum/Shaders/Test/VertexColorGLTest.cpp

@ -52,4 +52,4 @@ void VertexColorGLTest::compile3D() {
}}}
CORRADE_TEST_MAIN(Magnum::Shaders::Test::VertexColorGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Shaders::Test::VertexColorGLTest)

2
src/Magnum/Test/AbstractObjectGLTest.cpp

@ -52,4 +52,4 @@ void AbstractObjectGLTest::labelNoOp() {
}}
CORRADE_TEST_MAIN(Magnum::Test::AbstractObjectGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Test::AbstractObjectGLTest)

53
src/Magnum/Test/AbstractOpenGLTester.h

@ -32,26 +32,33 @@
#include "Magnum/DebugOutput.h"
#include "Magnum/Renderer.h"
#if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_DESKTOP_GLES)
#if defined(CORRADE_TARGET_APPLE)
#include "Magnum/Platform/WindowlessCglApplication.h"
#elif defined(CORRADE_TARGET_UNIX) && (!defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_DESKTOP_GLES))
#include "Magnum/Platform/WindowlessGlxApplication.h"
#elif defined(CORRADE_TARGET_WINDOWS)
#include "Magnum/Platform/WindowlessWglApplication.h"
#else
#error cannot run OpenGL tests on this platform
#endif
namespace Magnum { namespace Test {
class AbstractOpenGLTester: public TestSuite::Tester, public Platform::WindowlessApplication {
class AbstractOpenGLTester: public TestSuite::Tester {
public:
explicit AbstractOpenGLTester();
using TestSuite::Tester::exec;
int exec() override final { return TestSuite::Tester::exec(); }
/* Private use only */
static std::optional<Platform::WindowlessApplication::Arguments> _windowlessApplicationArguments;
private:
static int _zero;
struct WindowlessApplication: Platform::WindowlessApplication {
explicit WindowlessApplication(const Arguments& arguments): Platform::WindowlessApplication{arguments} {}
int exec() override final { return 0; }
} _windowlessApplication;
};
AbstractOpenGLTester::AbstractOpenGLTester(): Platform::WindowlessApplication({_zero, nullptr}) {
AbstractOpenGLTester::AbstractOpenGLTester(): _windowlessApplication{*_windowlessApplicationArguments} {
if(Context::current()->isExtensionSupported<Extensions::GL::KHR::debug>()) {
Renderer::enable(Renderer::Feature::DebugOutput);
Renderer::enable(Renderer::Feature::DebugOutputSynchronous);
@ -62,10 +69,42 @@ AbstractOpenGLTester::AbstractOpenGLTester(): Platform::WindowlessApplication({_
}
}
int AbstractOpenGLTester::_zero = 0;
std::optional<Platform::WindowlessApplication::Arguments> AbstractOpenGLTester::_windowlessApplicationArguments;
#define MAGNUM_VERIFY_NO_ERROR() CORRADE_COMPARE(Magnum::Renderer::error(), Magnum::Renderer::Error::NoError)
#ifndef CORRADE_TARGET_WINDOWS
#define MAGNUM_GL_TEST_MAIN(Class) \
int main(int argc, char** argv) { \
Magnum::Test::AbstractOpenGLTester::_windowlessApplicationArguments.emplace(argc, argv); \
Class t; \
t.registerTest(__FILE__, #Class); \
return t.exec(); \
}
#else
#define MAGNUM_GL_TEST_MAIN(Class) \
LRESULT CALLBACK windowProcedure(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); \
LRESULT CALLBACK windowProcedure(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { \
int ret = 0; \
switch(message) { \
case WM_CREATE: \
{ \
Magnum::Test::AbstractOpenGLTester::_windowlessApplicationArguments->window = hWnd; \
Class t; \
t.registerTest(__FILE__, #Class); \
PostQuitMessage(ret = t.exec()); \
} \
break; \
default: return DefWindowProc(hWnd, message, wParam, lParam); \
} \
return ret; \
} \
int main(int argc, char** argv) { \
Magnum::Test::AbstractOpenGLTester::_windowlessApplicationArguments.emplace(argc, argv, nullptr); \
return Magnum::Platform::WindowlessWglApplication::create(windowProcedure); \
}
#endif
}}
#endif

2
src/Magnum/Test/AbstractQueryGLTest.cpp

@ -143,4 +143,4 @@ void AbstractQueryGLTest::label() {
}}
CORRADE_TEST_MAIN(Magnum::Test::AbstractQueryGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Test::AbstractQueryGLTest)

2
src/Magnum/Test/AbstractShaderProgramGLTest.cpp

@ -383,4 +383,4 @@ void AbstractShaderProgramGLTest::uniformArray() {
}}
CORRADE_TEST_MAIN(Magnum::Test::AbstractShaderProgramGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Test::AbstractShaderProgramGLTest)

2
src/Magnum/Test/AbstractTextureGLTest.cpp

@ -105,4 +105,4 @@ void AbstractTextureGLTest::label() {
}}
CORRADE_TEST_MAIN(Magnum::Test::AbstractTextureGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Test::AbstractTextureGLTest)

2
src/Magnum/Test/BufferGLTest.cpp

@ -438,4 +438,4 @@ void BufferGLTest::invalidate() {
}}
CORRADE_TEST_MAIN(Magnum::Test::BufferGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Test::BufferGLTest)

2
src/Magnum/Test/BufferImageGLTest.cpp

@ -138,4 +138,4 @@ void BufferImageGLTest::setData() {
}}
CORRADE_TEST_MAIN(Magnum::Test::BufferImageGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Test::BufferImageGLTest)

2
src/Magnum/Test/BufferTextureGLTest.cpp

@ -147,4 +147,4 @@ void BufferTextureGLTest::setBufferOffset() {
}}
CORRADE_TEST_MAIN(Magnum::Test::BufferTextureGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Test::BufferTextureGLTest)

2
src/Magnum/Test/ContextGLTest.cpp

@ -109,4 +109,4 @@ void ContextGLTest::isExtensionDisabled() {
}}
CORRADE_TEST_MAIN(Magnum::Test::ContextGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Test::ContextGLTest)

2
src/Magnum/Test/CubeMapTextureArrayGLTest.cpp

@ -486,4 +486,4 @@ void CubeMapTextureArrayGLTest::invalidateSubImage() {
}}
CORRADE_TEST_MAIN(Magnum::Test::CubeMapTextureArrayGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Test::CubeMapTextureArrayGLTest)

2
src/Magnum/Test/CubeMapTextureGLTest.cpp

@ -591,4 +591,4 @@ void CubeMapTextureGLTest::invalidateSubImage() {
}}
CORRADE_TEST_MAIN(Magnum::Test::CubeMapTextureGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Test::CubeMapTextureGLTest)

2
src/Magnum/Test/DebugOutputGLTest.cpp

@ -175,4 +175,4 @@ void DebugOutputGLTest::groupFallback() {
}}
CORRADE_TEST_MAIN(Magnum::Test::DebugOutputGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Test::DebugOutputGLTest)

2
src/Magnum/Test/FramebufferGLTest.cpp

@ -988,4 +988,4 @@ void FramebufferGLTest::blit() {
}}
CORRADE_TEST_MAIN(Magnum::Test::FramebufferGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Test::FramebufferGLTest)

2
src/Magnum/Test/MeshGLTest.cpp

@ -1862,4 +1862,4 @@ void MeshGLTest::multiDrawBaseVertex() {
}}
CORRADE_TEST_MAIN(Magnum::Test::MeshGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Test::MeshGLTest)

2
src/Magnum/Test/MultisampleTextureGLTest.cpp

@ -323,4 +323,4 @@ void MultisampleTextureGLTest::invalidateSubImage2DArray() {
}}
CORRADE_TEST_MAIN(Magnum::Test::MultisampleTextureGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Test::MultisampleTextureGLTest)

2
src/Magnum/Test/PrimitiveQueryGLTest.cpp

@ -192,4 +192,4 @@ void PrimitiveQueryGLTest::transformFeedbackPrimitivesWritten() {
}}
CORRADE_TEST_MAIN(Magnum::Test::PrimitiveQueryGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Test::PrimitiveQueryGLTest)

2
src/Magnum/Test/RectangleTextureGLTest.cpp

@ -394,4 +394,4 @@ void RectangleTextureGLTest::invalidateSubImage() {
}}
CORRADE_TEST_MAIN(Magnum::Test::RectangleTextureGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Test::RectangleTextureGLTest)

2
src/Magnum/Test/RenderbufferGLTest.cpp

@ -186,4 +186,4 @@ void RenderbufferGLTest::setStorageMultisample() {
}}
CORRADE_TEST_MAIN(Magnum::Test::RenderbufferGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Test::RenderbufferGLTest)

2
src/Magnum/Test/SampleQueryGLTest.cpp

@ -241,4 +241,4 @@ void SampleQueryGLTest::conditionalRender() {
}}
CORRADE_TEST_MAIN(Magnum::Test::SampleQueryGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Test::SampleQueryGLTest)

2
src/Magnum/Test/ShaderGLTest.cpp

@ -225,4 +225,4 @@ void ShaderGLTest::compile() {
}}
CORRADE_TEST_MAIN(Magnum::Test::ShaderGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Test::ShaderGLTest)

2
src/Magnum/Test/TextureArrayGLTest.cpp

@ -1047,4 +1047,4 @@ void TextureArrayGLTest::invalidateSubImage2D() {
}}
CORRADE_TEST_MAIN(Magnum::Test::TextureArrayGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Test::TextureArrayGLTest)

2
src/Magnum/Test/TextureGLTest.cpp

@ -1396,4 +1396,4 @@ void TextureGLTest::invalidateSubImage3D() {
}}
CORRADE_TEST_MAIN(Magnum::Test::TextureGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Test::TextureGLTest)

2
src/Magnum/Test/TimeQueryGLTest.cpp

@ -132,4 +132,4 @@ void TimeQueryGLTest::queryTimestamp() {
}}
CORRADE_TEST_MAIN(Magnum::Test::TimeQueryGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Test::TimeQueryGLTest)

2
src/Magnum/Test/TransformFeedbackGLTest.cpp

@ -456,4 +456,4 @@ void TransformFeedbackGLTest::interleaved() {
}}
CORRADE_TEST_MAIN(Magnum::Test::TransformFeedbackGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Test::TransformFeedbackGLTest)

2
src/Magnum/Text/Test/GlyphCacheGLTest.cpp

@ -93,4 +93,4 @@ void GlyphCacheGLTest::reserve() {
}}}
CORRADE_TEST_MAIN(Magnum::Text::Test::GlyphCacheGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Text::Test::GlyphCacheGLTest)

2
src/Magnum/Text/Test/RendererGLTest.cpp

@ -430,4 +430,4 @@ void RendererGLTest::multiline() {
}}}
CORRADE_TEST_MAIN(Magnum::Text::Test::RendererGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Text::Test::RendererGLTest)

2
src/MagnumPlugins/MagnumFont/Test/MagnumFontGLTest.cpp

@ -106,4 +106,4 @@ void MagnumFontGLTest::createGlyphCache() {
}}}
CORRADE_TEST_MAIN(Magnum::Text::Test::MagnumFontGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Text::Test::MagnumFontGLTest)

2
src/MagnumPlugins/MagnumFontConverter/Test/MagnumFontConverterGLTest.cpp

@ -123,4 +123,4 @@ void MagnumFontConverterGLTest::exportFont() {
}}}
CORRADE_TEST_MAIN(Magnum::Text::Test::MagnumFontConverterGLTest)
MAGNUM_GL_TEST_MAIN(Magnum::Text::Test::MagnumFontConverterGLTest)

Loading…
Cancel
Save