diff --git a/src/Magnum/GL/Context.cpp b/src/Magnum/GL/Context.cpp index 33fd62060..a36f3ff43 100644 --- a/src/Magnum/GL/Context.cpp +++ b/src/Magnum/GL/Context.cpp @@ -449,9 +449,11 @@ Context& Context::current() { return *currentContext; } -Context::Context(NoCreateT, Int argc, const char** argv, void functionLoader()): _functionLoader{functionLoader}, _version{Version::None} { +Context::Context(NoCreateT, Int argc, const char** argv, void functionLoader()): Context{NoCreate, Utility::Arguments{"magnum"}, argc, argv, functionLoader} {} + +Context::Context(NoCreateT, Utility::Arguments& args, Int argc, const char** argv, void functionLoader()): _functionLoader{functionLoader}, _version{Version::None} { /* Parse arguments */ - Utility::Arguments args{"magnum"}; + CORRADE_INTERNAL_ASSERT(args.prefix() == "magnum"); args.addOption("disable-workarounds") .setHelp("disable-workarounds", "driver workarounds to disable\n (see http://doc.magnum.graphics/magnum/opengl-workarounds.html for detailed info)", "LIST") .addOption("disable-extensions").setHelp("disable-extensions", "OpenGL extensions to disable", "LIST") diff --git a/src/Magnum/GL/Context.h b/src/Magnum/GL/Context.h index cde0b36c7..bedede7c6 100644 --- a/src/Magnum/GL/Context.h +++ b/src/Magnum/GL/Context.h @@ -638,6 +638,8 @@ class MAGNUM_GL_EXPORT Context { #endif explicit Context(NoCreateT, Int argc, const char** argv, void functionLoader()); + explicit Context(NoCreateT, Utility::Arguments&& args, Int argc, const char** argv, void functionLoader()): Context{NoCreate, args, argc, argv, functionLoader} {} + explicit Context(NoCreateT, Utility::Arguments& args, Int argc, const char** argv, void functionLoader()); bool tryCreate(); void create(); diff --git a/src/Magnum/Platform/GLContext.h b/src/Magnum/Platform/GLContext.h index 41eed2528..aa750bb8c 100644 --- a/src/Magnum/Platform/GLContext.h +++ b/src/Magnum/Platform/GLContext.h @@ -108,6 +108,18 @@ class GLContext: public GL::Context { /** @overload */ explicit GLContext(NoCreateT, Int argc, std::nullptr_t argv): GLContext{NoCreate, argc, static_cast(argv)} {} + #ifndef DOXYGEN_GENERATING_OUTPUT + /* Used privately to inject additional command-line arguments */ + explicit GLContext(NoCreateT, Utility::Arguments& args, Int argc, char** argv): GLContext{NoCreate, args, argc, const_cast(argv)} {} + explicit GLContext(NoCreateT, Utility::Arguments& args, Int argc, std::nullptr_t argv): GLContext{NoCreate, args, argc, static_cast(argv)} {} + explicit GLContext(NoCreateT, Utility::Arguments& args, Int argc, const char** argv): + #ifndef CORRADE_TARGET_EMSCRIPTEN + GL::Context{NoCreate, args, argc, argv, flextGLInit} {} + #else + GL::Context{NoCreate, args, argc, argv, nullptr} {} + #endif + #endif + /** * @brief Construct the class without doing complete setup *