Browse Source

Platform: added Application and WindowlessApplication aliases.

If only one *Application or Windowless*Application header is included,
the class is aliased to Application or WindowlessApplication to simplify
porting.
pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
2c8a4c306c
  1. 19
      doc/portability.dox
  2. 5
      src/Platform/GlutApplication.h
  3. 5
      src/Platform/GlxApplication.h
  4. 5
      src/Platform/NaClApplication.h
  5. 5
      src/Platform/Sdl2Application.h
  6. 5
      src/Platform/WindowlessGlxApplication.h
  7. 5
      src/Platform/XEglApplication.h

19
doc/portability.dox

@ -164,9 +164,12 @@ mouse movement events etc.
In most cases the entry point is classic `main()` function, but some platforms 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 (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 points are handled using macros, which take care of the rest.
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. 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) Example application, which targets both embedded Linux (using plain X and EGL)
and desktop (using SDL2 toolkit). Thanks to static polymorphism most of the and desktop (using SDL2 toolkit). Thanks to static polymorphism most of the
@ -179,15 +182,9 @@ particular *Event class implementations:
#include <Platform/XEglApplication.h> #include <Platform/XEglApplication.h>
#endif #endif
#ifndef MAGNUM_TARGET_GLES class MyApplication: public Platform::Application {
typedef Platform::Sdl2Application ApplicationBase;
#else
typedef Platform::XEglApplication ApplicationBase;
#endif
class MyApplication: public ApplicationBase {
public: public:
MyApplication(int& argc, char** argv): ApplicationBase(argc, argv, "My Application") { MyApplication(int& argc, char** argv): Platform::Application(argc, argv, "My Application") {
// ... // ...
} }

5
src/Platform/GlutApplication.h

@ -60,6 +60,10 @@ class MyApplication: public Magnum::Platform::GlutApplication {
}; };
MAGNUM_GLUTAPPLICATION_MAIN(MyApplication) MAGNUM_GLUTAPPLICATION_MAIN(MyApplication)
@endcode @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 { class GlutApplication {
public: public:
@ -386,6 +390,7 @@ When no other application header is included this macro is also aliased to
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef MAGNUM_APPLICATION_MAIN #ifndef MAGNUM_APPLICATION_MAIN
typedef GlutApplication Application;
#define MAGNUM_APPLICATION_MAIN(className) MAGNUM_GLUTAPPLICATION_MAIN(className) #define MAGNUM_APPLICATION_MAIN(className) MAGNUM_GLUTAPPLICATION_MAIN(className)
#else #else
#undef MAGNUM_APPLICATION_MAIN #undef MAGNUM_APPLICATION_MAIN

5
src/Platform/GlxApplication.h

@ -50,6 +50,10 @@ class MyApplication: public Magnum::Platform::GlxApplication {
}; };
MAGNUM_GLXAPPLICATION_MAIN(MyApplication) MAGNUM_GLXAPPLICATION_MAIN(MyApplication)
@endcode @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 { class GlxApplication: public AbstractXApplication {
public: public:
@ -87,6 +91,7 @@ When no other application header is included this macro is also aliased to
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef MAGNUM_APPLICATION_MAIN #ifndef MAGNUM_APPLICATION_MAIN
typedef GlxApplication Application;
#define MAGNUM_APPLICATION_MAIN(className) MAGNUM_GLXAPPLICATION_MAIN(className) #define MAGNUM_APPLICATION_MAIN(className) MAGNUM_GLXAPPLICATION_MAIN(className)
#else #else
#undef MAGNUM_APPLICATION_MAIN #undef MAGNUM_APPLICATION_MAIN

5
src/Platform/NaClApplication.h

@ -67,6 +67,10 @@ class MyApplication: public Magnum::Platform::Sdl2Application {
}; };
MAGNUM_NACLAPPLICATION_MAIN(MyApplication) MAGNUM_NACLAPPLICATION_MAIN(MyApplication)
@endcode @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 { class NaClApplication: public pp::Instance, public pp::Graphics3DClient, public pp::MouseLock {
public: public:
@ -483,6 +487,7 @@ When no other application header is included this macro is also aliased to
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef MAGNUM_APPLICATION_MAIN #ifndef MAGNUM_APPLICATION_MAIN
typedef NaClApplication Application;
#define MAGNUM_APPLICATION_MAIN(className) MAGNUM_NACLAPPLICATION_MAIN(className) #define MAGNUM_APPLICATION_MAIN(className) MAGNUM_NACLAPPLICATION_MAIN(className)
#else #else
#undef MAGNUM_APPLICATION_MAIN #undef MAGNUM_APPLICATION_MAIN

5
src/Platform/Sdl2Application.h

@ -62,6 +62,10 @@ class MyApplication: public Magnum::Platform::Sdl2Application {
}; };
MAGNUM_SDL2APPLICATION_MAIN(MyApplication) MAGNUM_SDL2APPLICATION_MAIN(MyApplication)
@endcode @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 { class Sdl2Application {
public: public:
@ -435,6 +439,7 @@ When no other application header is included this macro is also aliased to
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef MAGNUM_APPLICATION_MAIN #ifndef MAGNUM_APPLICATION_MAIN
typedef Sdl2Application Application;
#define MAGNUM_APPLICATION_MAIN(className) MAGNUM_SDL2APPLICATION_MAIN(className) #define MAGNUM_APPLICATION_MAIN(className) MAGNUM_SDL2APPLICATION_MAIN(className)
#else #else
#undef MAGNUM_APPLICATION_MAIN #undef MAGNUM_APPLICATION_MAIN

5
src/Platform/WindowlessGlxApplication.h

@ -55,6 +55,10 @@ class MyApplication: public Magnum::Platform::WindowlessGlxApplication {
}; };
MAGNUM_WINDOWLESSGLXAPPLICATION_MAIN(MyApplication) MAGNUM_WINDOWLESSGLXAPPLICATION_MAIN(MyApplication)
@endcode @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 { class WindowlessGlxApplication {
public: public:
@ -107,6 +111,7 @@ aliased to `MAGNUM_WINDOWLESSAPPLICATION_MAIN()`.
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef MAGNUM_WINDOWLESSAPPLICATION_MAIN #ifndef MAGNUM_WINDOWLESSAPPLICATION_MAIN
typedef WindowlessGlxApplication WindowlessApplication;
#define MAGNUM_WINDOWLESSAPPLICATION_MAIN(className) MAGNUM_WINDOWLESSGLXAPPLICATION_MAIN(className) #define MAGNUM_WINDOWLESSAPPLICATION_MAIN(className) MAGNUM_WINDOWLESSGLXAPPLICATION_MAIN(className)
#else #else
#undef MAGNUM_WINDOWLESSAPPLICATION_MAIN #undef MAGNUM_WINDOWLESSAPPLICATION_MAIN

5
src/Platform/XEglApplication.h

@ -50,6 +50,10 @@ class MyApplication: public Magnum::Platform::XEglApplication {
}; };
MAGNUM_XEGLAPPLICATION_MAIN(MyApplication) MAGNUM_XEGLAPPLICATION_MAIN(MyApplication)
@endcode @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 { class XEglApplication: public AbstractXApplication {
public: public:
@ -87,6 +91,7 @@ When no other application header is included this macro is also aliased to
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef MAGNUM_APPLICATION_MAIN #ifndef MAGNUM_APPLICATION_MAIN
typedef XEglApplication Application;
#define MAGNUM_APPLICATION_MAIN(className) MAGNUM_XEGLAPPLICATION_MAIN(className) #define MAGNUM_APPLICATION_MAIN(className) MAGNUM_XEGLAPPLICATION_MAIN(className)
#else #else
#undef MAGNUM_APPLICATION_MAIN #undef MAGNUM_APPLICATION_MAIN

Loading…
Cancel
Save