From 508dd4d94d823659c49f6a6fb77918df33ae7dfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 20 Mar 2013 14:55:59 +0100 Subject: [PATCH] Platform: have special MAGNUM_*APPLICATION_MAIN() for each class. --- src/Platform/AbstractXApplication.h | 30 ------------------------- src/Platform/GlxApplication.h | 34 +++++++++++++++++++++++++++-- src/Platform/XEglApplication.h | 34 +++++++++++++++++++++++++++-- 3 files changed, 64 insertions(+), 34 deletions(-) diff --git a/src/Platform/AbstractXApplication.h b/src/Platform/AbstractXApplication.h index 415105fa1..04fdad3c6 100644 --- a/src/Platform/AbstractXApplication.h +++ b/src/Platform/AbstractXApplication.h @@ -370,36 +370,6 @@ class AbstractXApplication::MouseMoveEvent: public AbstractXApplication::InputEv const Vector2i _position; }; -/** @hideinitializer -@brief Entry point for X11-based applications -@param className Class name - -Can be used with AbstractXApplication subclasses as equivalent to the -following code to achieve better portability, see @ref portability-applications -for more information. -@code -int main(int argc, char** argv) { - className app(argc, argv); - return app.exec(); -} -@endcode -When no other application header is included this macro is also aliased to -`MAGNUM_APPLICATION_MAIN()`. -*/ -#define MAGNUM_XAPPLICATION_MAIN(className) \ - int main(int argc, char** argv) { \ - className app(argc, argv); \ - return app.exec(); \ - } - -#ifndef DOXYGEN_GENERATING_OUTPUT -#ifndef MAGNUM_APPLICATION_MAIN -#define MAGNUM_APPLICATION_MAIN(className) MAGNUM_XAPPLICATION_MAIN(className) -#else -#undef MAGNUM_APPLICATION_MAIN -#endif -#endif - /* Implementations for inline functions with unused parameters */ inline void AbstractXApplication::keyPressEvent(KeyEvent&) {} inline void AbstractXApplication::keyReleaseEvent(KeyEvent&) {} diff --git a/src/Platform/GlxApplication.h b/src/Platform/GlxApplication.h index 1f1f4ea5f..5fb0b4f88 100644 --- a/src/Platform/GlxApplication.h +++ b/src/Platform/GlxApplication.h @@ -43,12 +43,12 @@ targetting OpenGL ES. Uses GlxContextHandler. You need to implement at least drawEvent() and viewportEvent() to be able to draw on the screen. The subclass can be then used directly in `main()` - see -convenience macro MAGNUM_XAPPLICATION_MAIN(). +convenience macro MAGNUM_GLXAPPLICATION_MAIN(). @code class MyApplication: public Magnum::Platform::GlxApplication { // implement required methods... }; -MAGNUM_XAPPLICATION_MAIN(MyApplication) +MAGNUM_GLXAPPLICATION_MAIN(MyApplication) @endcode */ class GlxApplication: public AbstractXApplication { @@ -63,6 +63,36 @@ class GlxApplication: public AbstractXApplication { inline explicit GlxApplication(int& argc, char** argv, const std::string& title = "Magnum GLX application", const Vector2i& size = Vector2i(800, 600)): AbstractXApplication(new GlxContextHandler, argc, argv, title, size) {} }; +/** @hideinitializer +@brief Entry point for GLX-based applications +@param className Class name + +Can be used with GlxApplication subclasses as equivalent to the following code +to achieve better portability, see @ref portability-applications for more +information. +@code +int main(int argc, char** argv) { + className app(argc, argv); + return app.exec(); +} +@endcode +When no other application header is included this macro is also aliased to +`MAGNUM_APPLICATION_MAIN()`. +*/ +#define MAGNUM_GLXAPPLICATION_MAIN(className) \ + int main(int argc, char** argv) { \ + className app(argc, argv); \ + return app.exec(); \ + } + +#ifndef DOXYGEN_GENERATING_OUTPUT +#ifndef MAGNUM_APPLICATION_MAIN +#define MAGNUM_APPLICATION_MAIN(className) MAGNUM_GLXAPPLICATION_MAIN(className) +#else +#undef MAGNUM_APPLICATION_MAIN +#endif +#endif + }} #endif diff --git a/src/Platform/XEglApplication.h b/src/Platform/XEglApplication.h index b37ac0328..3a0e71703 100644 --- a/src/Platform/XEglApplication.h +++ b/src/Platform/XEglApplication.h @@ -43,12 +43,12 @@ EglContextHandler. You need to implement at least drawEvent() and viewportEvent() to be able to draw on the screen. The subclass can be then used directly in `main()` - see -convenience macro MAGNUM_XAPPLICATION_MAIN(). +convenience macro MAGNUM_XEGLAPPLICATION_MAIN(). @code class MyApplication: public Magnum::Platform::XEglApplication { // implement required methods... }; -MAGNUM_XAPPLICATION_MAIN(MyApplication) +MAGNUM_XEGLAPPLICATION_MAIN(MyApplication) @endcode */ class XEglApplication: public AbstractXApplication { @@ -63,6 +63,36 @@ class XEglApplication: public AbstractXApplication { inline explicit XEglApplication(int& argc, char** argv, const std::string& title = "Magnum X/EGL application", const Vector2i& size = Vector2i(800, 600)): AbstractXApplication(new EglContextHandler, argc, argv, title, size) {} }; +/** @hideinitializer +@brief Entry point for X/EGL-based applications +@param className Class name + +Can be used with XEglApplication subclasses as equivalent to the following code +to achieve better portability, see @ref portability-applications for more +information. +@code +int main(int argc, char** argv) { + className app(argc, argv); + return app.exec(); +} +@endcode +When no other application header is included this macro is also aliased to +`MAGNUM_APPLICATION_MAIN()`. +*/ +#define MAGNUM_XEGLAPPLICATION_MAIN(className) \ + int main(int argc, char** argv) { \ + className app(argc, argv); \ + return app.exec(); \ + } + +#ifndef DOXYGEN_GENERATING_OUTPUT +#ifndef MAGNUM_APPLICATION_MAIN +#define MAGNUM_APPLICATION_MAIN(className) MAGNUM_XEGLAPPLICATION_MAIN(className) +#else +#undef MAGNUM_APPLICATION_MAIN +#endif +#endif + }} #endif