Browse Source

Platform: add default argument to createContext().

Somebody would just want to defer context creation after parsing
arguments or doing some validations without any particular setup, thus
having to write even the {} is annoying.
pull/34/head
Vladimír Vondruš 13 years ago
parent
commit
5c0747359a
  1. 2
      src/Platform/AbstractXApplication.cpp
  2. 6
      src/Platform/AbstractXApplication.h
  3. 4
      src/Platform/GlutApplication.cpp
  4. 6
      src/Platform/GlutApplication.h
  5. 4
      src/Platform/NaClApplication.cpp
  6. 6
      src/Platform/NaClApplication.h
  7. 4
      src/Platform/Sdl2Application.cpp
  8. 6
      src/Platform/Sdl2Application.h
  9. 4
      src/Platform/WindowlessGlxApplication.cpp
  10. 6
      src/Platform/WindowlessGlxApplication.h
  11. 4
      src/Platform/WindowlessNaClApplication.cpp
  12. 6
      src/Platform/WindowlessNaClApplication.h
  13. 2
      src/Platform/magnum-info.cpp
  14. 2
      src/Text/fontconverter.cpp
  15. 2
      src/TextureTools/distancefieldconverter.cpp

2
src/Platform/AbstractXApplication.cpp

@ -44,6 +44,8 @@ AbstractXApplication::AbstractXApplication(Implementation::AbstractContextHandle
AbstractXApplication::AbstractXApplication(Implementation::AbstractContextHandler<Display*, VisualID, Window>* contextHandler, const Arguments&, std::nullptr_t): contextHandler(contextHandler), c(nullptr), flags(Flag::Redraw) {}
void AbstractXApplication::createContext() { createContext({}); }
void AbstractXApplication::createContext(const Configuration& configuration) {
if(!tryCreateContext(configuration)) std::exit(1);
}

6
src/Platform/AbstractXApplication.h

@ -88,7 +88,13 @@ class AbstractXApplication {
~AbstractXApplication();
/** @copydoc Sdl2Application::createContext() */
#ifdef DOXYGEN_GENERATING_OUTPUT
void createContext(const Configuration& configuration = Configuration());
#else
/* To avoid "invalid use of incomplete type" */
void createContext(const Configuration& configuration);
void createContext();
#endif
/** @copydoc Sdl2Application::tryCreateContext() */
bool tryCreateContext(const Configuration& configuration);

4
src/Platform/GlutApplication.cpp

@ -42,7 +42,7 @@ GlutApplication::GlutApplication(const Arguments& arguments, const Configuration
#ifndef DOXYGEN_GENERATING_OUTPUT
GlutApplication::GlutApplication(const Arguments& arguments): c(nullptr) {
initialize(arguments.argc, arguments.argv);
createContext({});
createContext();
}
#endif
@ -59,6 +59,8 @@ void GlutApplication::initialize(int& argc, char** argv) {
glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION);
}
void GlutApplication::createContext() { createContext({}); }
void GlutApplication::createContext(const Configuration& configuration) {
if(!tryCreateContext(configuration)) std::exit(1);
}

6
src/Platform/GlutApplication.h

@ -114,7 +114,13 @@ class GlutApplication {
~GlutApplication();
/** @copydoc Sdl2Application::createContext() */
#ifdef DOXYGEN_GENERATING_OUTPUT
void createContext(const Configuration& configuration = Configuration());
#else
/* To avoid "invalid use of incomplete type" */
void createContext(const Configuration& configuration);
void createContext();
#endif
/** @copydoc Sdl2Application::tryCreateContext() */
bool tryCreateContext(const Configuration& configuration);

4
src/Platform/NaClApplication.cpp

@ -60,7 +60,7 @@ NaClApplication::NaClApplication(const Arguments& arguments, const Configuration
#ifndef DOXYGEN_GENERATING_OUTPUT
NaClApplication::NaClApplication(const Arguments& arguments): Instance(arguments), Graphics3DClient(this), MouseLock(this), c(nullptr) {
debugOutput = new ConsoleDebugOutput(this);
createContext({});
createContext();
}
#endif
@ -68,6 +68,8 @@ NaClApplication::NaClApplication(const Arguments& arguments, std::nullptr_t): In
debugOutput = new ConsoleDebugOutput(this);
}
void NaClApplication::createContext() { createContext({}); }
void NaClApplication::createContext(const Configuration& configuration) {
if(!tryCreateContext(configuration)) std::exit(1);
}

6
src/Platform/NaClApplication.h

@ -179,7 +179,13 @@ class NaClApplication: public pp::Instance, public pp::Graphics3DClient, public
~NaClApplication();
/** @copydoc Sdl2Application::createContext() */
#ifdef DOXYGEN_GENERATING_OUTPUT
void createContext(const Configuration& configuration = Configuration());
#else
/* To avoid "invalid use of incomplete type" */
void createContext(const Configuration& configuration);
void createContext();
#endif
/** @copydoc Sdl2Application::tryCreateContext() */
bool tryCreateContext(const Configuration& configuration);

4
src/Platform/Sdl2Application.cpp

@ -68,7 +68,7 @@ Sdl2Application::Sdl2Application(const Arguments&, const Configuration& configur
#ifndef DOXYGEN_GENERATING_OUTPUT
Sdl2Application::Sdl2Application(const Arguments&): context(nullptr), flags(Flag::Redraw) {
initialize();
createContext({});
createContext();
}
#endif
@ -88,6 +88,8 @@ void Sdl2Application::initialize() {
}
}
void Sdl2Application::createContext() { createContext({}); }
void Sdl2Application::createContext(const Configuration& configuration) {
if(!tryCreateContext(configuration)) std::exit(1);
}

6
src/Platform/Sdl2Application.h

@ -182,7 +182,13 @@ class Sdl2Application {
* constructor itself. The program exits if the context cannot be
* created, see @ref tryCreateContext() for an alternative.
*/
#ifdef DOXYGEN_GENERATING_OUTPUT
void createContext(const Configuration& configuration = Configuration());
#else
/* To avoid "invalid use of incomplete type" */
void createContext(const Configuration& configuration);
void createContext();
#endif
/**
* @brief Try to create context with given configuration

4
src/Platform/WindowlessGlxApplication.cpp

@ -41,12 +41,14 @@ WindowlessGlxApplication::WindowlessGlxApplication(const Arguments&, const Confi
#ifndef DOXYGEN_GENERATING_OUTPUT
WindowlessGlxApplication::WindowlessGlxApplication(const Arguments&): c(nullptr) {
createContext({});
createContext();
}
#endif
WindowlessGlxApplication::WindowlessGlxApplication(const Arguments&, std::nullptr_t): c(nullptr) {}
void WindowlessGlxApplication::createContext() { createContext({}); }
void WindowlessGlxApplication::createContext(const Configuration& configuration) {
if(!tryCreateContext(configuration)) std::exit(1);
}

6
src/Platform/WindowlessGlxApplication.h

@ -107,7 +107,13 @@ class WindowlessGlxApplication {
~WindowlessGlxApplication();
/** @copydoc Sdl2Application::createContext() */
#ifdef DOXYGEN_GENERATING_OUTPUT
void createContext(const Configuration& configuration = Configuration());
#else
/* To avoid "invalid use of incomplete type" */
void createContext(const Configuration& configuration);
void createContext();
#endif
/** @copydoc Sdl2Application::tryCreateContext() */
bool tryCreateContext(const Configuration& configuration);

4
src/Platform/WindowlessNaClApplication.cpp

@ -59,7 +59,7 @@ WindowlessNaClApplication::WindowlessNaClApplication(const Arguments& arguments,
#ifndef DOXYGEN_GENERATING_OUTPUT
WindowlessNaClApplication::WindowlessNaClApplication(const Arguments& arguments): Instance(arguments), Graphics3DClient(this), c(nullptr) {
debugOutput = new ConsoleDebugOutput(this);
createContext({});
createContext();
}
#endif
@ -67,6 +67,8 @@ WindowlessNaClApplication::WindowlessNaClApplication(const Arguments& arguments,
debugOutput = new ConsoleDebugOutput(this);
}
void WindowlessNaClApplication::createContext() { createContext({}); }
void WindowlessNaClApplication::createContext(const Configuration& configuration) {
if(!tryCreateContext(configuration)) std::exit(1);
}

6
src/Platform/WindowlessNaClApplication.h

@ -123,7 +123,13 @@ class WindowlessNaClApplication: public pp::Instance, public pp::Graphics3DClien
~WindowlessNaClApplication();
/** @copydoc Sdl2Application::createContext() */
#ifdef DOXYGEN_GENERATING_OUTPUT
void createContext(const Configuration& configuration = Configuration());
#else
/* To avoid "invalid use of incomplete type" */
void createContext(const Configuration& configuration);
void createContext();
#endif
/** @copydoc Sdl2Application::tryCreateContext() */
bool tryCreateContext(const Configuration& configuration);

2
src/Platform/magnum-info.cpp

@ -70,7 +70,7 @@ MagnumInfo::MagnumInfo(const Arguments& arguments): Platform::WindowlessApplicat
/* Create context after parsing arguments, so the help can be displayed
without creating context */
createContext({});
createContext();
Context* c = Context::current();
/* Pass debug output as messages to JavaScript */

2
src/Text/fontconverter.cpp

@ -62,7 +62,7 @@ FontConverter::FontConverter(const Arguments& arguments): Platform::WindowlessAp
.setHelp("Converts font to raster one of given atlas size.")
.parse(arguments.argc, arguments.argv);
createContext({});
createContext();
}
int FontConverter::exec() {

2
src/TextureTools/distancefieldconverter.cpp

@ -61,7 +61,7 @@ DistanceFieldConverter::DistanceFieldConverter(const Arguments& arguments): Wind
.setHelp("Converts black&white image to distance-field representation.")
.parse(arguments.argc, arguments.argv);
createContext({});
createContext();
}
int DistanceFieldConverter::exec() {

Loading…
Cancel
Save