diff --git a/src/Platform/AbstractXApplication.h b/src/Platform/AbstractXApplication.h index 0cc4c3e3e..3dc104f17 100644 --- a/src/Platform/AbstractXApplication.h +++ b/src/Platform/AbstractXApplication.h @@ -296,6 +296,34 @@ class AbstractXApplication { Flags flags; }; +/** @hideinitializer +@param className Class name + +Can be used 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 + CORRADE_ENUMSET_OPERATORS(AbstractXApplication::Modifiers) CORRADE_ENUMSET_OPERATORS(AbstractXApplication::Flags) diff --git a/src/Platform/GlutApplication.h b/src/Platform/GlutApplication.h index aa30a55f3..caf34fb17 100644 --- a/src/Platform/GlutApplication.h +++ b/src/Platform/GlutApplication.h @@ -43,16 +43,13 @@ support for changing cursor and mouse tracking and warping. @section GlutApplication-usage Usage 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()`, for -example: +draw on the screen. The subclass can be then used directly in `main()` - see +convenience macro MAGNUM_GLUTAPPLICATION_MAIN(). @code class MyApplication: public Magnum::Platform::GlutApplication { // implement required methods... }; -int main(int argc, char** argv) { - MyApplication c(argc, argv); - return c.exec(); -} +MAGNUM_GLUTAPPLICATION_MAIN(MyApplication) @endcode */ class GlutApplication { @@ -269,6 +266,34 @@ class GlutApplication { Context* c; }; +/** @hideinitializer +@param className Class name + +Can be used 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_GLUTAPPLICATION_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_GLUTAPPLICATION_MAIN(className) +#else +#undef MAGNUM_APPLICATION_MAIN +#endif +#endif + /* Implementations for inline functions with unused parameters */ inline void GlutApplication::keyPressEvent(Key, const Math::Vector2&) {} inline void GlutApplication::mousePressEvent(MouseButton, const Math::Vector2&) {} diff --git a/src/Platform/GlxApplication.h b/src/Platform/GlxApplication.h index 95535cce0..f17d683be 100644 --- a/src/Platform/GlxApplication.h +++ b/src/Platform/GlxApplication.h @@ -32,16 +32,13 @@ Uses GlxContextHandler. @section GlxApplication-usage Usage 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()`, for -example: +draw on the screen. The subclass can be then used directly in `main()` - see +convenience macro MAGNUM_XAPPLICATION_MAIN(). @code class MyApplication: public Magnum::Platform::GlxApplication { // implement required methods... }; -int main(int argc, char** argv) { - MyApplication c(argc, argv); - return c.exec(); -} +MAGNUM_XAPPLICATION_MAIN(MyApplication) @endcode */ class GlxApplication: public AbstractXApplication { diff --git a/src/Platform/NaClApplication.h b/src/Platform/NaClApplication.h index bb0ecd3e0..246b989f0 100644 --- a/src/Platform/NaClApplication.h +++ b/src/Platform/NaClApplication.h @@ -160,7 +160,9 @@ namespace Implementation { @brief Entry point for NaCl application @param application Application class name -See NaClApplication for more information. +See NaClApplication and @ref portability-applications for more information. +When no other application header is included this macro is also aliased to +`MAGNUM_APPLICATION_MAIN()`. */ /* look at that insane placement of __attribute__. WTF. */ #define MAGNUM_NACLAPPLICATION_MAIN(application) \ @@ -170,6 +172,14 @@ See NaClApplication for more information. } \ } +#ifndef DOXYGEN_GENERATING_OUTPUT +#ifndef MAGNUM_APPLICATION_MAIN +#define MAGNUM_APPLICATION_MAIN(className) MAGNUM_NACLAPPLICATION_MAIN(className) +#else +#undef MAGNUM_APPLICATION_MAIN +#endif +#endif + }} #endif diff --git a/src/Platform/Sdl2Application.h b/src/Platform/Sdl2Application.h index 033fc804f..1304d16b1 100644 --- a/src/Platform/Sdl2Application.h +++ b/src/Platform/Sdl2Application.h @@ -42,16 +42,13 @@ Supports keyboard and mouse handling. @section Sdl2Application-usage Usage 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()`, for -example: +draw on the screen. The subclass can be then used directly in `main()` - see +convenience macro MAGNUM_SDL2APPLICATION_MAIN(). @code class MyApplication: public Magnum::Platform::Sdl2Application { // implement required methods... }; -int main(int argc, char** argv) { - MyApplication c(argc, argv); - return c.exec(); -} +MAGNUM_SDL2APPLICATION_MAIN(MyApplication) @endcode */ class Sdl2Application { @@ -217,6 +214,34 @@ class Sdl2Application { bool _redraw; }; +/** @hideinitializer +@param className Class name + +Can be used 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_SDL2APPLICATION_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_SDL2APPLICATION_MAIN(className) +#else +#undef MAGNUM_APPLICATION_MAIN +#endif +#endif + CORRADE_ENUMSET_OPERATORS(Sdl2Application::Modifiers) /* Implementations for inline functions with unused parameters */ diff --git a/src/Platform/XEglApplication.h b/src/Platform/XEglApplication.h index 490b16353..7fdcfe1f4 100644 --- a/src/Platform/XEglApplication.h +++ b/src/Platform/XEglApplication.h @@ -32,16 +32,13 @@ Uses EglContextHandler. @section XEglApplication-usage Usage 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()`, for -example: +draw on the screen. The subclass can be then used directly in `main()` - see +convenience macro MAGNUM_XAPPLICATION_MAIN(). @code class MyApplication: public Magnum::Platform::XEglApplication { // implement required methods... }; -int main(int argc, char** argv) { - MyApplication c(argc, argv); - return c.exec(); -} +MAGNUM_XAPPLICATION_MAIN(MyApplication) @endcode */ class XEglApplication: public AbstractXApplication {