diff --git a/doc/portability.dox b/doc/portability.dox index 113177123..ff79d2ec9 100644 --- a/doc/portability.dox +++ b/doc/portability.dox @@ -164,9 +164,12 @@ mouse movement events etc. In most cases the entry point is classic `main()` function, but some platforms (e.g. Native Client) have different requirements. To make things easier, entry -points are handled using macros, which take care of the rest. Each application -has its own specific macro and if no other application header is included, the -macro is also aliased to MAGNUM_APPLICATION_MAIN() to save you typing. +points are handled using macros, which take care of the rest. + +If only one `*Application` or `*WindowlessApplication` header is included, the +application class is aliased to `Platform::Application` or `Platform::WindowlessApplication` +and the macro is aliased to `MAGNUM_APPLICATION_MAIN()` or `MAGNUM_WINDOWLESSAPPLICATION_MAIN()` +to simplify porting. Example application, which targets both embedded Linux (using plain X and EGL) and desktop (using SDL2 toolkit). Thanks to static polymorphism most of the @@ -179,15 +182,9 @@ particular *Event class implementations: #include #endif -#ifndef MAGNUM_TARGET_GLES -typedef Platform::Sdl2Application ApplicationBase; -#else -typedef Platform::XEglApplication ApplicationBase; -#endif - -class MyApplication: public ApplicationBase { +class MyApplication: public Platform::Application { public: - MyApplication(int& argc, char** argv): ApplicationBase(argc, argv, "My Application") { + MyApplication(int& argc, char** argv): Platform::Application(argc, argv, "My Application") { // ... } diff --git a/src/Platform/GlutApplication.h b/src/Platform/GlutApplication.h index 2dd33de0c..ccf90113a 100644 --- a/src/Platform/GlutApplication.h +++ b/src/Platform/GlutApplication.h @@ -60,6 +60,10 @@ class MyApplication: public Magnum::Platform::GlutApplication { }; MAGNUM_GLUTAPPLICATION_MAIN(MyApplication) @endcode + +If no other application header is included this class is also aliased to +`Platform::Application` and the macro is aliased to `MAGNUM_APPLICATION_MAIN()` +to simplify porting. */ class GlutApplication { public: @@ -386,6 +390,7 @@ When no other application header is included this macro is also aliased to #ifndef DOXYGEN_GENERATING_OUTPUT #ifndef MAGNUM_APPLICATION_MAIN +typedef GlutApplication Application; #define MAGNUM_APPLICATION_MAIN(className) MAGNUM_GLUTAPPLICATION_MAIN(className) #else #undef MAGNUM_APPLICATION_MAIN diff --git a/src/Platform/GlxApplication.h b/src/Platform/GlxApplication.h index 5fb0b4f88..e5f8f470b 100644 --- a/src/Platform/GlxApplication.h +++ b/src/Platform/GlxApplication.h @@ -50,6 +50,10 @@ class MyApplication: public Magnum::Platform::GlxApplication { }; MAGNUM_GLXAPPLICATION_MAIN(MyApplication) @endcode + +If no other application header is included this class is also aliased to +`Platform::Application` and the macro is aliased to `MAGNUM_APPLICATION_MAIN()` +to simplify porting. */ class GlxApplication: public AbstractXApplication { public: @@ -87,6 +91,7 @@ When no other application header is included this macro is also aliased to #ifndef DOXYGEN_GENERATING_OUTPUT #ifndef MAGNUM_APPLICATION_MAIN +typedef GlxApplication Application; #define MAGNUM_APPLICATION_MAIN(className) MAGNUM_GLXAPPLICATION_MAIN(className) #else #undef MAGNUM_APPLICATION_MAIN diff --git a/src/Platform/NaClApplication.h b/src/Platform/NaClApplication.h index da9c6a497..7ba5aa39d 100644 --- a/src/Platform/NaClApplication.h +++ b/src/Platform/NaClApplication.h @@ -67,6 +67,10 @@ class MyApplication: public Magnum::Platform::Sdl2Application { }; MAGNUM_NACLAPPLICATION_MAIN(MyApplication) @endcode + +If no other application header is included this class is also aliased to +`Platform::Application` and the macro is aliased to `MAGNUM_APPLICATION_MAIN()` +to simplify porting. */ class NaClApplication: public pp::Instance, public pp::Graphics3DClient, public pp::MouseLock { public: @@ -483,6 +487,7 @@ When no other application header is included this macro is also aliased to #ifndef DOXYGEN_GENERATING_OUTPUT #ifndef MAGNUM_APPLICATION_MAIN +typedef NaClApplication Application; #define MAGNUM_APPLICATION_MAIN(className) MAGNUM_NACLAPPLICATION_MAIN(className) #else #undef MAGNUM_APPLICATION_MAIN diff --git a/src/Platform/Sdl2Application.h b/src/Platform/Sdl2Application.h index e7c69601b..356b5109d 100644 --- a/src/Platform/Sdl2Application.h +++ b/src/Platform/Sdl2Application.h @@ -62,6 +62,10 @@ class MyApplication: public Magnum::Platform::Sdl2Application { }; MAGNUM_SDL2APPLICATION_MAIN(MyApplication) @endcode + +If no other application header is included this class is also aliased to +`Platform::Application` and the macro is aliased to `MAGNUM_APPLICATION_MAIN()` +to simplify porting. */ class Sdl2Application { public: @@ -435,6 +439,7 @@ When no other application header is included this macro is also aliased to #ifndef DOXYGEN_GENERATING_OUTPUT #ifndef MAGNUM_APPLICATION_MAIN +typedef Sdl2Application Application; #define MAGNUM_APPLICATION_MAIN(className) MAGNUM_SDL2APPLICATION_MAIN(className) #else #undef MAGNUM_APPLICATION_MAIN diff --git a/src/Platform/WindowlessGlxApplication.h b/src/Platform/WindowlessGlxApplication.h index 8a34e1f91..b3b86ddea 100644 --- a/src/Platform/WindowlessGlxApplication.h +++ b/src/Platform/WindowlessGlxApplication.h @@ -55,6 +55,10 @@ class MyApplication: public Magnum::Platform::WindowlessGlxApplication { }; MAGNUM_WINDOWLESSGLXAPPLICATION_MAIN(MyApplication) @endcode + +If no other application header is included this class is also aliased to +`Platform::WindowlessApplication` and the macro is aliased to +`MAGNUM_WINDOWLESSAPPLICATION_MAIN()` to simplify porting. */ class WindowlessGlxApplication { public: @@ -107,6 +111,7 @@ aliased to `MAGNUM_WINDOWLESSAPPLICATION_MAIN()`. #ifndef DOXYGEN_GENERATING_OUTPUT #ifndef MAGNUM_WINDOWLESSAPPLICATION_MAIN +typedef WindowlessGlxApplication WindowlessApplication; #define MAGNUM_WINDOWLESSAPPLICATION_MAIN(className) MAGNUM_WINDOWLESSGLXAPPLICATION_MAIN(className) #else #undef MAGNUM_WINDOWLESSAPPLICATION_MAIN diff --git a/src/Platform/XEglApplication.h b/src/Platform/XEglApplication.h index 3a0e71703..65cc2d5ae 100644 --- a/src/Platform/XEglApplication.h +++ b/src/Platform/XEglApplication.h @@ -50,6 +50,10 @@ class MyApplication: public Magnum::Platform::XEglApplication { }; MAGNUM_XEGLAPPLICATION_MAIN(MyApplication) @endcode + +If no other application header is included this class is also aliased to +`Platform::Application` and the macro is aliased to `MAGNUM_APPLICATION_MAIN()` +to simplify porting. */ class XEglApplication: public AbstractXApplication { public: @@ -87,6 +91,7 @@ When no other application header is included this macro is also aliased to #ifndef DOXYGEN_GENERATING_OUTPUT #ifndef MAGNUM_APPLICATION_MAIN +typedef XEglApplication Application; #define MAGNUM_APPLICATION_MAIN(className) MAGNUM_XEGLAPPLICATION_MAIN(className) #else #undef MAGNUM_APPLICATION_MAIN