Browse Source

Platform: make virtual functions private, rendering protected, other public.

* The default (empty) implementation of virtuals shouldn't be called,
   thus this effectively protects the user from doing it.
 * Only the application itself knows best when and how to call
   rendering-related functions such as swapBuffers() and redraw(), thus
   they are protected.
 * Functions for setting up fullscreen or hiding the mouse may be called
   from user code outside the application, thus they are kept public.
pull/34/head
Vladimír Vondruš 13 years ago
parent
commit
f0eaf04e36
  1. 19
      src/Platform/AbstractXApplication.h
  2. 23
      src/Platform/GlutApplication.h
  3. 47
      src/Platform/NaClApplication.h
  4. 5
      src/Platform/ScreenedApplication.h
  5. 45
      src/Platform/Sdl2Application.h

19
src/Platform/AbstractXApplication.h

@ -111,13 +111,7 @@ class AbstractXApplication {
/** @copydoc Sdl2Application::tryCreateContext() */
bool tryCreateContext(const Configuration& configuration);
/** @{ @name Drawing functions */
/** @copydoc Sdl2Application::viewportEvent() */
virtual void viewportEvent(const Vector2i& size) = 0;
/** @copydoc Sdl2Application::drawEvent() */
virtual void drawEvent() = 0;
/** @{ @name Screen handling */
/** @copydoc Sdl2Application::swapBuffers() */
void swapBuffers();
@ -125,6 +119,17 @@ class AbstractXApplication {
/** @copydoc Sdl2Application::redraw() */
void redraw() { flags |= Flag::Redraw; }
#ifdef DOXYGEN_GENERATING_OUTPUT
protected:
#else
private:
#endif
/** @copydoc Sdl2Application::viewportEvent() */
virtual void viewportEvent(const Vector2i& size) = 0;
/** @copydoc Sdl2Application::drawEvent() */
virtual void drawEvent() = 0;
/*@}*/
/** @{ @name Keyboard handling */

23
src/Platform/GlutApplication.h

@ -137,13 +137,7 @@ class GlutApplication {
/** @copydoc Sdl2Application::tryCreateContext() */
bool tryCreateContext(const Configuration& configuration);
/** @{ @name Drawing functions */
/** @copydoc Sdl2Application::viewportEvent() */
virtual void viewportEvent(const Vector2i& size) = 0;
/** @copydoc Sdl2Application::drawEvent() */
virtual void drawEvent() = 0;
/** @{ @name Screen handling */
/** @copydoc Sdl2Application::swapBuffers() */
void swapBuffers() { glutSwapBuffers(); }
@ -151,6 +145,17 @@ class GlutApplication {
/** @copydoc Sdl2Application::redraw() */
void redraw() { glutPostRedisplay(); }
#ifdef DOXYGEN_GENERATING_OUTPUT
protected:
#else
private:
#endif
/** @copydoc Sdl2Application::viewportEvent() */
virtual void viewportEvent(const Vector2i& size) = 0;
/** @copydoc Sdl2Application::drawEvent() */
virtual void drawEvent() = 0;
/*@}*/
/** @{ @name Keyboard handling */
@ -201,7 +206,11 @@ class GlutApplication {
glutWarpPointer(position.x(), position.y());
}
#ifdef DOXYGEN_GENERATING_OUTPUT
protected:
#else
private:
#endif
/** @copydoc Sdl2Application::mousePressEvent() */
virtual void mousePressEvent(MouseEvent& event);

47
src/Platform/NaClApplication.h

@ -172,19 +172,6 @@ class NaClApplication: public pp::Instance, public pp::Graphics3DClient, public
/** @brief Moving is not allowed */
NaClApplication& operator=(NaClApplication&&) = delete;
/** @brief Whether the application runs fullscreen */
bool isFullscreen();
/**
* @brief Set fullscreen
* @return `False` if switch to opposite mode is in progress or if the
* switch is not possible, `true` otherwise.
*
* The switch is done asynchronously, during the switch no event
* processing is done.
*/
bool setFullscreen(bool enabled);
protected:
/* Nobody will need to have (and delete) NaClApplication*, thus this is
faster than public pure virtual destructor */
@ -202,20 +189,40 @@ class NaClApplication: public pp::Instance, public pp::Graphics3DClient, public
/** @copydoc Sdl2Application::tryCreateContext() */
bool tryCreateContext(const Configuration& configuration);
/** @{ @name Drawing functions */
/** @{ @name Screen handling */
/** @copydoc Sdl2Application::viewportEvent() */
virtual void viewportEvent(const Vector2i& size) = 0;
public:
/** @brief Whether the application runs fullscreen */
bool isFullscreen();
/** @copydoc Sdl2Application::drawEvent() */
virtual void drawEvent() = 0;
/**
* @brief Set fullscreen
* @return `False` if switch to opposite mode is in progress or if the
* switch is not possible, `true` otherwise.
*
* The switch is done asynchronously, during the switch no event
* processing is done.
*/
bool setFullscreen(bool enabled);
protected:
/** @copydoc Sdl2Application::swapBuffers() */
void swapBuffers();
/** @copydoc Sdl2Application::redraw() */
void redraw() { flags |= Flag::Redraw; }
#ifdef DOXYGEN_GENERATING_OUTPUT
protected:
#else
private:
#endif
/** @copydoc Sdl2Application::viewportEvent() */
virtual void viewportEvent(const Vector2i& size) = 0;
/** @copydoc Sdl2Application::drawEvent() */
virtual void drawEvent() = 0;
/*@}*/
/** @{ @name Keyboard handling */
@ -255,7 +262,11 @@ class NaClApplication: public pp::Instance, public pp::Graphics3DClient, public
*/
void setMouseLocked(bool enabled);
#ifdef DOXYGEN_GENERATING_OUTPUT
protected:
#else
private:
#endif
/**
* @brief Mouse press event
*

5
src/Platform/ScreenedApplication.h

@ -161,6 +161,11 @@ template<class Application> class BasicScreenedApplication: public Application,
this is faster than public pure virtual destructor */
~BasicScreenedApplication();
#ifdef DOXYGEN_GENERATING_OUTPUT
protected:
#else
private:
#endif
/**
* @brief Global viewport event
*

45
src/Platform/Sdl2Application.h

@ -210,8 +210,28 @@ class Sdl2Application {
*/
bool tryCreateContext(const Configuration& configuration);
/** @{ @name Drawing functions */
/** @{ @name Screen handling */
/**
* @brief Swap buffers
*
* Paints currently rendered framebuffer on screen.
*/
void swapBuffers();
/**
* @brief Redraw immediately
*
* Marks the window for redrawing, resulting in call to @ref drawEvent()
* in the next iteration.
*/
void redraw() { flags |= Flag::Redraw; }
#ifdef DOXYGEN_GENERATING_OUTPUT
protected:
#else
private:
#endif
/**
* @brief Viewport event
*
@ -236,21 +256,6 @@ class Sdl2Application {
*/
virtual void drawEvent() = 0;
/**
* @brief Swap buffers
*
* Paints currently rendered framebuffer on screen.
*/
void swapBuffers();
/**
* @brief Redraw immediately
*
* Marks the window for redrawing, resulting in call to @ref drawEvent()
* in the next iteration.
*/
void redraw() { flags |= Flag::Redraw; }
/*@}*/
/** @{ @name Keyboard handling */
@ -281,12 +286,16 @@ class Sdl2Application {
* @brief Enable or disable mouse locking
*
* When mouse is locked, the cursor is hidden and only
* MouseMoveEvent::relativePosition() is changing, absolute position
* stays the same.
* @ref MouseMoveEvent::relativePosition() is changing, absolute
* position stays the same.
*/
void setMouseLocked(bool enabled);
#ifdef DOXYGEN_GENERATING_OUTPUT
protected:
#else
private:
#endif
/**
* @brief Mouse press event
*

Loading…
Cancel
Save