diff --git a/Doxyfile b/Doxyfile index 7f083be2bcb35d42f56f93d73aea32f348361387..01ac784f266a9af5c8bb66bb9167dc0f92b080ce 100644 --- a/Doxyfile +++ b/Doxyfile @@ -477,7 +477,7 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = ../ +INPUT = ./ # This tag can be used to specify the character encoding of the source files that # doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default diff --git a/GraphicsEngineFactory.h b/GraphicsEngineFactory.h index 9e289a0da4c1c5b873b0394b53f8df1a16e99c6a..550f27024cffd1fea9dfaeb5c93435e7920d7246 100644 --- a/GraphicsEngineFactory.h +++ b/GraphicsEngineFactory.h @@ -28,7 +28,7 @@ public: }; /** - * \brief Instaniates a new graphics engine + * \brief Instantiates a new graphics engine * * Use this method to create a new grahics engine instance. However, please make * that you use only sensible combinations of \c engine and \c application (you diff --git a/WindowManager.cpp b/WindowManager.cpp index 06dd790ba197c4b7a70a7220059bfc709f4064bf..bd4206fb4d6f6547daeb3b64f894c8a607de2e7c 100644 --- a/WindowManager.cpp +++ b/WindowManager.cpp @@ -124,7 +124,8 @@ void WindowManager::eventLoop() // be sure there's at least one observer! assert(eventObservers.size() > 0); - // set two main timers (interval in ms) + // TODO: make interval setting available to the outside + // set two main timers (interval in ms) SDL_AddTimer(40, &timerCallbackRenderEvent, NULL); SDL_AddTimer(1000, &timerCallbackBOINCUpdateEvent, NULL); diff --git a/WindowManager.h b/WindowManager.h index 2daa714e9391a733303e4074da79699fc8f4cc6d..4ce20d6db4633ebe34076e2b62ff5219cc1bac40 100644 --- a/WindowManager.h +++ b/WindowManager.h @@ -14,48 +14,202 @@ using namespace std; +/** + * \brief This class is responsible for the application's window and event management. + * + * %WindowManager provides an initialized OpenGL context needed by any given + * \ref AbstractGraphicsEngine. In addition to that it serves as the main event + * controller. That means it handles all window and user input events and propagates + * them to all registered observers (of type \ref AbstractGraphicsEngine). This also + * includes all timer events required for rendering and information retrieval control. + * + * \author Oliver Bock\n + * Max-Planck-Institute for Gravitational Physics\n + * Hannover, Germany + */ class WindowManager { public: + + /// Default constructor WindowManager(); + + /// Destructor virtual ~WindowManager(); + /** + * \brief Initializes the %WindowManager + * + * Call this method first (after instantiation) to prepare the + * main application window as well as the OpenGL context. + * + * \param width The optional initial width of the main window + * \param height The optional initial height of the main window + * + * \return TRUE if successfull, otherwise FALSE + */ bool initialize(const int width = 1024, const int height = 768); + + /** + * \brief Registeres a new event observer + * + * All registered observers are notified in case one of the events + * specified in \ref EventCodes occurrs. + * + * \param engine The pointer to the \ref AbstractGraphicsEngine instance to register + * + * \see AbstractGraphicsEngine::mouseButtonEvent() + * \see AbstractGraphicsEngine::mouseMoveEvent() + * \see AbstractGraphicsEngine::keyboardPressEvent() + */ void registerEventObserver(AbstractGraphicsEngine *engine); + + /** + * \brief Unregisteres a new event observer + * + * \param engine The pointer to the \ref AbstractGraphicsEngine instance to unregister + */ void unregisterEventObserver(AbstractGraphicsEngine *engine); + + /** + * \brief The main event loop + * + * Call this method to enter the main window's event loop. All subsequent application + * control is defined here. The method returns when the window is closed or destroyed. + */ void eventLoop(); + /** + * \brief Retrieve the current main window's width + * + * \return The current window width + */ int windowWidth() const; + + /** + * \brief Retrieve the current main window's height + * + * \return The current window height + */ int windowHeight() const; + /** + * \brief Set the main window's caption + * + * \param caption The new caption of the main window + */ void setWindowCaption(const string caption) const; + + /** + * \brief Set the main window's icon + * + * \param filename The new icon's filename + */ void setWindowIcon(const string filename) const; + + /** + * \brief Toggles the fullscreen state of the main window + * + * Note: the initial state is windowed (not fullscreen). + * + */ void toggleFullscreen(); private: - // FIXME: work around static, otherwise event conflict when more than one instance + /** + * \brief Timer callback to trigger render events + * + * This callback is used by a SDL timer registered in \ref eventLoop(). + * It creates a \ref RenderEvent which is handled by eventLoop(). + * In order to use a constant timer interval, \c interval is + * returned as it was passed. + * + * \param interval The current timer interval + * \param param The user supplied parameter of the timer event + * + * \return The timer interval to be used for the following events + * + * \see eventLoop() + * \see EventCodes + * + * \todo Work around static callback, otherwise we might get event conflicts + * when more than one instance. Maybe we should use a singleton here anyway... + */ static Uint32 timerCallbackRenderEvent(Uint32 interval, void *param); + + /** + * \brief Timer callback to trigger BOINC update events + * + * This callback is used by a SDL timer registered in \ref eventLoop(). + * It creates a \ref BOINCUpdateEvent which is handled by eventLoop(). + * In order to use a constant timer interval, \c interval is + * returned as it was passed. + * + * Note: it might seem a bit strange to trigger the BOINC updates here but it's + * here where \b all event controlling and propagation takes place. BOINCClientAdapter + * for example is meant to be used \b by an instance receiving this event, not + * actually handling it itself. Thus AbstractGraphicsEngine handles this event + * and \b uses its BOINC adapter accordingly. + * + * \param interval The current timer interval + * \param param The user supplied parameter of the timer event + * + * \return The timer interval to be used for the following events + * + * \see eventLoop() + * \see EventCodes + * + * \todo Work around static callback, otherwise we might get event conflicts + * when more than one instance. Maybe we should use a singleton here anyway... + */ static Uint32 timerCallbackBOINCUpdateEvent(Uint32 interval, void *param); + /// The current width of the host's desktop int m_DesktopWidth; + + /// The current height of the host's desktop int m_DesktopHeight; + + /// The current bits per pixel value of the host's desktop int m_DesktopBitsPerPixel; + + /// The current width of the application window (windowed and/or fullscreen) int m_CurrentWidth; + + /// The current height of the application window (windowed and/or fullscreen) int m_CurrentHeight; + + /// The width of the application window (windowed mode only) int m_WindowedWidth; + + /// The height of the application window (windowed mode only) int m_WindowedHeight; + + /// The current video mode flags Uint32 m_VideoModeFlags; + /// Indicator for fullscreen mode availability bool m_FullscreenModeAvailable; + + /// Indicator for desired window mode availability (resolution, color depth, features) bool m_WindowedModeAvailable; + /// The SDL display surface handle SDL_Surface *m_DisplaySurface; + /** + * \brief The known event codes handled by %eventLoop() + * + * \see eventLoop() + * \see timerCallbackRenderEvent() + * \see timerCallbackBOINCUpdateEvent() + */ enum EventCodes { RenderEvent, BOINCUpdateEvent }; + /// The event observer registry list<AbstractGraphicsEngine *> eventObservers; };