Browse Source

GL: add a test for global function pointers across libraries as well.

Fails. The huge change just before should have made the fix possible,
but apparently it's not so simple. Nothing is ever simple. Sigh.
pull/442/head
Vladimír Vondruš 6 years ago
parent
commit
3942dff532
  1. 29
      src/Magnum/GL/Test/GlobalStateAcrossLibrariesGLTest.cpp
  2. 4
      src/Magnum/GL/Test/GlobalStateAcrossLibrariesLibrary.cpp
  3. 1
      src/Magnum/GL/Test/GlobalStateAcrossLibrariesLibrary.h

29
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<void*>(glCreateProgram));
}
}
}}}}
CORRADE_TEST_MAIN(Magnum::GL::Test::GlobalStateAcrossLibrariesGLTest)

4
src/Magnum/GL/Test/GlobalStateAcrossLibrariesLibrary.cpp

@ -34,4 +34,8 @@ GL::Context* currentContextInALibrary() {
return &GL::Context::current();
}
void* createProgramInALibrary() {
return reinterpret_cast<void*>(glCreateProgram);
}
}}}

1
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();
}}}

Loading…
Cancel
Save