Browse Source

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).
pull/7/head
Vladimír Vondruš 14 years ago
parent
commit
9cf48eee56
  1. 52
      src/Platform/AbstractApplication.h
  2. 9
      src/Platform/AbstractXApplication.h
  3. 1
      src/Platform/CMakeLists.txt
  4. 26
      src/Platform/GlutApplication.h
  5. 15
      src/Platform/GlxApplication.h
  6. 26
      src/Platform/Sdl2Application.h
  7. 15
      src/Platform/XEglApplication.h

52
src/Platform/AbstractApplication.h

@ -1,52 +0,0 @@
#ifndef Magnum_Platform_AbstractApplication_h
#define Magnum_Platform_AbstractApplication_h
/*
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz>
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

9
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; }

1
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)

26
src/Platform/GlutApplication.h

@ -26,8 +26,6 @@
#include <GL/freeglut.h>
#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<GLsizei>& size = Math::Vector2<GLsizei>(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;
}

15
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:

26
src/Platform/Sdl2Application.h

@ -26,8 +26,6 @@
#include <SDL2/SDL_scancode.h>
#include <Corrade/Containers/EnumSet.h>
#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 */

15
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:

Loading…
Cancel
Save