Browse Source

Platform: have special MAGNUM_*APPLICATION_MAIN() for each class.

pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
508dd4d94d
  1. 30
      src/Platform/AbstractXApplication.h
  2. 34
      src/Platform/GlxApplication.h
  3. 34
      src/Platform/XEglApplication.h

30
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&) {}

34
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

34
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

Loading…
Cancel
Save