diff --git a/src/Magnum/GL/Test/GlobalStateAcrossLibrariesGLTest.cpp b/src/Magnum/GL/Test/GlobalStateAcrossLibrariesGLTest.cpp index faa32bd81..18899d583 100644 --- a/src/Magnum/GL/Test/GlobalStateAcrossLibrariesGLTest.cpp +++ b/src/Magnum/GL/Test/GlobalStateAcrossLibrariesGLTest.cpp @@ -33,14 +33,16 @@ namespace Magnum { namespace GL { namespace Test { namespace { struct GlobalStateAcrossLibrariesGLTest: OpenGLTester { explicit GlobalStateAcrossLibrariesGLTest(); - void test(); + void magnumContext(); + void functionPointers(); }; GlobalStateAcrossLibrariesGLTest::GlobalStateAcrossLibrariesGLTest() { - addTests({&GlobalStateAcrossLibrariesGLTest::test}); + addTests({&GlobalStateAcrossLibrariesGLTest::magnumContext, + &GlobalStateAcrossLibrariesGLTest::functionPointers}); } -void GlobalStateAcrossLibrariesGLTest::test() { +void GlobalStateAcrossLibrariesGLTest::magnumContext() { #if defined(MAGNUM_BUILD_STATIC_UNIQUE_GLOBALS) && !defined(MAGNUM_BUILD_STATIC) CORRADE_VERIFY(!"MAGNUM_BUILD_STATIC_UNIQUE_GLOBALS enabled but MAGNUM_BUILD_STATIC not"); #endif @@ -55,6 +57,27 @@ void GlobalStateAcrossLibrariesGLTest::test() { } } +void GlobalStateAcrossLibrariesGLTest::functionPointers() { + #if defined(MAGNUM_BUILD_STATIC_UNIQUE_GLOBALS) && !defined(MAGNUM_BUILD_STATIC) + CORRADE_VERIFY(!"MAGNUM_BUILD_STATIC_UNIQUE_GLOBALS enabled but MAGNUM_BUILD_STATIC not"); + #endif + + CORRADE_VERIFY(glCreateProgram); + + { + #ifndef MAGNUM_BUILD_STATIC_UNIQUE_GLOBALS + CORRADE_EXPECT_FAIL("MAGNUM_BUILD_STATIC_UNIQUE_GLOBALS not enabled."); + #endif + /* Annotating the flextGL global with __attribute__((weak)) makes + static builds crash on startup due to a null function pointer call. + This is because even the GL 1.0 / 1.1 function pointers are accessed + through this struct and somehow the weak symbol makes the struct all + nulls. Not sure how to proceed. */ + CORRADE_EXPECT_FAIL("Deduplication of global GL function pointers across shared libraries isn't implemented yet."); + CORRADE_COMPARE(createProgramInALibrary(), reinterpret_cast(glCreateProgram)); + } +} + }}}} CORRADE_TEST_MAIN(Magnum::GL::Test::GlobalStateAcrossLibrariesGLTest) diff --git a/src/Magnum/GL/Test/GlobalStateAcrossLibrariesLibrary.cpp b/src/Magnum/GL/Test/GlobalStateAcrossLibrariesLibrary.cpp index 9f102c33c..2afb6a0d9 100644 --- a/src/Magnum/GL/Test/GlobalStateAcrossLibrariesLibrary.cpp +++ b/src/Magnum/GL/Test/GlobalStateAcrossLibrariesLibrary.cpp @@ -34,4 +34,8 @@ GL::Context* currentContextInALibrary() { return &GL::Context::current(); } +void* createProgramInALibrary() { + return reinterpret_cast(glCreateProgram); +} + }}} diff --git a/src/Magnum/GL/Test/GlobalStateAcrossLibrariesLibrary.h b/src/Magnum/GL/Test/GlobalStateAcrossLibrariesLibrary.h index aa4afda1a..a6ee82369 100644 --- a/src/Magnum/GL/Test/GlobalStateAcrossLibrariesLibrary.h +++ b/src/Magnum/GL/Test/GlobalStateAcrossLibrariesLibrary.h @@ -38,6 +38,7 @@ namespace Magnum { namespace GL { namespace Test { MAGNUM_GLOBALSTATEACROSSLIBRARIESLIBRARY_EXPORT GL::Context* currentContextInALibrary(); +MAGNUM_GLOBALSTATEACROSSLIBRARIESLIBRARY_EXPORT void* createProgramInALibrary(); }}}