Browse Source

GL: make it possible to pass a pre-filled Utility::Arguments to Context.

For example to support additional app-specific configuration.
pull/249/merge
Vladimír Vondruš 8 years ago
parent
commit
81aa98dbee
  1. 6
      src/Magnum/GL/Context.cpp
  2. 2
      src/Magnum/GL/Context.h
  3. 12
      src/Magnum/Platform/GLContext.h

6
src/Magnum/GL/Context.cpp

@ -449,9 +449,11 @@ Context& Context::current() {
return *currentContext; 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 */ /* Parse arguments */
Utility::Arguments args{"magnum"}; CORRADE_INTERNAL_ASSERT(args.prefix() == "magnum");
args.addOption("disable-workarounds") 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") .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") .addOption("disable-extensions").setHelp("disable-extensions", "OpenGL extensions to disable", "LIST")

2
src/Magnum/GL/Context.h

@ -638,6 +638,8 @@ class MAGNUM_GL_EXPORT Context {
#endif #endif
explicit Context(NoCreateT, Int argc, const char** argv, void functionLoader()); 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(); bool tryCreate();
void create(); void create();

12
src/Magnum/Platform/GLContext.h

@ -108,6 +108,18 @@ class GLContext: public GL::Context {
/** @overload */ /** @overload */
explicit GLContext(NoCreateT, Int argc, std::nullptr_t argv): GLContext{NoCreate, argc, static_cast<const char**>(argv)} {} explicit GLContext(NoCreateT, Int argc, std::nullptr_t argv): GLContext{NoCreate, argc, static_cast<const char**>(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<const char**>(argv)} {}
explicit GLContext(NoCreateT, Utility::Arguments& args, Int argc, std::nullptr_t argv): GLContext{NoCreate, args, argc, static_cast<const char**>(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 * @brief Construct the class without doing complete setup
* *

Loading…
Cancel
Save