From 9cf48eee56a15674dc396882818db500d4dab850 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 10 Nov 2012 22:44:42 +0100 Subject: [PATCH] Platform: removed unneeded AbstractApplication base. It's really not needed to have useless class defining only one function (which wouldn't be used everywhere anyway). --- src/Platform/AbstractApplication.h | 52 ----------------------------- src/Platform/AbstractXApplication.h | 9 +++-- src/Platform/CMakeLists.txt | 1 - src/Platform/GlutApplication.h | 26 +++++++++++---- src/Platform/GlxApplication.h | 15 +++++++++ src/Platform/Sdl2Application.h | 26 +++++++++++---- src/Platform/XEglApplication.h | 15 +++++++++ 7 files changed, 76 insertions(+), 68 deletions(-) delete mode 100644 src/Platform/AbstractApplication.h diff --git a/src/Platform/AbstractApplication.h b/src/Platform/AbstractApplication.h deleted file mode 100644 index 5a5025818..000000000 --- a/src/Platform/AbstractApplication.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef Magnum_Platform_AbstractApplication_h -#define Magnum_Platform_AbstractApplication_h -/* - Copyright © 2010, 2011, 2012 Vladimír Vondruš - - This file is part of Magnum. - - Magnum is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 3 - only, as published by the Free Software Foundation. - - Magnum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License version 3 for more details. -*/ - -/** @file - * @brief Class Magnum::Platform::AbstractApplication - */ - -namespace Magnum { namespace Platform { - -/** -@brief Base class for applications - -See subclasses documentation for more information. Subclasses are meant to be -used directly in `main()`, for example: -@code -class MyContext: public Magnum::Platform::GlutApplication { - // implement required methods... -}; -int main(int argc, char** argv) { - MyContext c(argc, argv); - return c.exec(); -} -@endcode -*/ -class AbstractApplication { - public: - virtual inline ~AbstractApplication() {} - - /** - * @brief Execute main loop - * @return Value for returning from `main()`. - */ - virtual int exec() = 0; -}; - -}} - -#endif diff --git a/src/Platform/AbstractXApplication.h b/src/Platform/AbstractXApplication.h index d6531c119..0cc4c3e3e 100644 --- a/src/Platform/AbstractXApplication.h +++ b/src/Platform/AbstractXApplication.h @@ -30,7 +30,6 @@ #undef Always #include "Math/Vector2.h" -#include "AbstractApplication.h" #include "AbstractContextHandler.h" #include "magnumCompatibility.h" @@ -48,7 +47,7 @@ Supports keyboard and mouse handling. @note Not meant to be used directly, see subclasses. */ -class AbstractXApplication: public AbstractApplication { +class AbstractXApplication { public: /** * @brief Constructor @@ -69,7 +68,11 @@ class AbstractXApplication: public AbstractApplication { */ virtual ~AbstractXApplication() = 0; - int exec() override; + /** + * @brief Execute main loop + * @return Value for returning from `main()`. + */ + int exec(); /** @brief Exit application main loop */ inline void exit() { flags |= Flag::Exit; } diff --git a/src/Platform/CMakeLists.txt b/src/Platform/CMakeLists.txt index 9099367f2..abfa827a6 100644 --- a/src/Platform/CMakeLists.txt +++ b/src/Platform/CMakeLists.txt @@ -3,7 +3,6 @@ add_library(MagnumPlatformExtensionWrangler OBJECT ExtensionWrangler.cpp) set(MagnumPlatform_HEADERS AbstractContextHandler.h - AbstractApplication.h ExtensionWrangler.h) install(FILES ${MagnumPlatform_HEADERS} DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Platform) diff --git a/src/Platform/GlutApplication.h b/src/Platform/GlutApplication.h index 07ae26987..aa30a55f3 100644 --- a/src/Platform/GlutApplication.h +++ b/src/Platform/GlutApplication.h @@ -26,8 +26,6 @@ #include -#include "AbstractApplication.h" - #include "magnumCompatibility.h" namespace Magnum { @@ -42,10 +40,22 @@ namespace Platform { Supports keyboard handling for limited subset of keys, mouse handling with 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. +draw on the screen. The subclass can be then used directly in `main()`, for +example: +@code +class MyApplication: public Magnum::Platform::GlutApplication { + // implement required methods... +}; +int main(int argc, char** argv) { + MyApplication c(argc, argv); + return c.exec(); +} +@endcode */ -class GlutApplication: public AbstractApplication { +class GlutApplication { public: /** * @brief Constructor @@ -58,9 +68,13 @@ class GlutApplication: public AbstractApplication { */ GlutApplication(int& argc, char** argv, const std::string& title = "Magnum GLUT application", const Math::Vector2& size = Math::Vector2(800, 600)); - ~GlutApplication(); + virtual ~GlutApplication(); - inline int exec() override { + /** + * @brief Execute main loop + * @return Value for returning from `main()`. + */ + inline int exec() { glutMainLoop(); return 0; } diff --git a/src/Platform/GlxApplication.h b/src/Platform/GlxApplication.h index 90b15ad44..95535cce0 100644 --- a/src/Platform/GlxApplication.h +++ b/src/Platform/GlxApplication.h @@ -28,6 +28,21 @@ namespace Magnum { namespace Platform { @brief GLX application 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: +@code +class MyApplication: public Magnum::Platform::GlxApplication { + // implement required methods... +}; +int main(int argc, char** argv) { + MyApplication c(argc, argv); + return c.exec(); +} +@endcode */ class GlxApplication: public AbstractXApplication { public: diff --git a/src/Platform/Sdl2Application.h b/src/Platform/Sdl2Application.h index 0ce360313..033fc804f 100644 --- a/src/Platform/Sdl2Application.h +++ b/src/Platform/Sdl2Application.h @@ -26,8 +26,6 @@ #include #include -#include "AbstractApplication.h" - #include "magnumCompatibility.h" namespace Magnum { @@ -41,10 +39,22 @@ namespace Platform { 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. +draw on the screen. The subclass can be then used directly in `main()`, for +example: +@code +class MyApplication: public Magnum::Platform::Sdl2Application { + // implement required methods... +}; +int main(int argc, char** argv) { + MyApplication c(argc, argv); + return c.exec(); +} +@endcode */ -class Sdl2Application: public AbstractApplication { +class Sdl2Application { public: /** * @brief Constructor @@ -63,9 +73,13 @@ class Sdl2Application: public AbstractApplication { * * Deletes context and destroys the window. */ - ~Sdl2Application(); + virtual ~Sdl2Application(); - int exec() override; + /** + * @brief Execute main loop + * @return Value for returning from `main()`. + */ + int exec(); /** @{ @name Drawing functions */ diff --git a/src/Platform/XEglApplication.h b/src/Platform/XEglApplication.h index 0478b0921..490b16353 100644 --- a/src/Platform/XEglApplication.h +++ b/src/Platform/XEglApplication.h @@ -28,6 +28,21 @@ namespace Magnum { namespace Platform { @brief X/EGL application 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: +@code +class MyApplication: public Magnum::Platform::XEglApplication { + // implement required methods... +}; +int main(int argc, char** argv) { + MyApplication c(argc, argv); + return c.exec(); +} +@endcode */ class XEglApplication: public AbstractXApplication { public: