Skip to content
Snippets Groups Projects
Commit c34da1d2 authored by Oliver Bock's avatar Oliver Bock
Browse files

More doxygenized code (also fixed Doxyfile to not include parent directory)

parent e7315b44
No related branches found
No related tags found
No related merge requests found
...@@ -477,7 +477,7 @@ WARN_LOGFILE = ...@@ -477,7 +477,7 @@ WARN_LOGFILE =
# directories like "/usr/src/myproject". Separate the files or directories # directories like "/usr/src/myproject". Separate the files or directories
# with spaces. # with spaces.
INPUT = ../ INPUT = ./
# This tag can be used to specify the character encoding of the source files that # 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 # doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default
......
...@@ -28,7 +28,7 @@ public: ...@@ -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 * 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 * that you use only sensible combinations of \c engine and \c application (you
......
...@@ -124,6 +124,7 @@ void WindowManager::eventLoop() ...@@ -124,6 +124,7 @@ void WindowManager::eventLoop()
// be sure there's at least one observer! // be sure there's at least one observer!
assert(eventObservers.size() > 0); assert(eventObservers.size() > 0);
// TODO: make interval setting available to the outside
// set two main timers (interval in ms) // set two main timers (interval in ms)
SDL_AddTimer(40, &timerCallbackRenderEvent, NULL); SDL_AddTimer(40, &timerCallbackRenderEvent, NULL);
SDL_AddTimer(1000, &timerCallbackBOINCUpdateEvent, NULL); SDL_AddTimer(1000, &timerCallbackBOINCUpdateEvent, NULL);
......
...@@ -14,48 +14,202 @@ ...@@ -14,48 +14,202 @@
using namespace std; 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 class WindowManager
{ {
public: public:
/// Default constructor
WindowManager(); WindowManager();
/// Destructor
virtual ~WindowManager(); 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); 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); 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); 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(); void eventLoop();
/**
* \brief Retrieve the current main window's width
*
* \return The current window width
*/
int windowWidth() const; int windowWidth() const;
/**
* \brief Retrieve the current main window's height
*
* \return The current window height
*/
int windowHeight() const; 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; 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; 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(); void toggleFullscreen();
private: 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); 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); static Uint32 timerCallbackBOINCUpdateEvent(Uint32 interval, void *param);
/// The current width of the host's desktop
int m_DesktopWidth; int m_DesktopWidth;
/// The current height of the host's desktop
int m_DesktopHeight; int m_DesktopHeight;
/// The current bits per pixel value of the host's desktop
int m_DesktopBitsPerPixel; int m_DesktopBitsPerPixel;
/// The current width of the application window (windowed and/or fullscreen)
int m_CurrentWidth; int m_CurrentWidth;
/// The current height of the application window (windowed and/or fullscreen)
int m_CurrentHeight; int m_CurrentHeight;
/// The width of the application window (windowed mode only)
int m_WindowedWidth; int m_WindowedWidth;
/// The height of the application window (windowed mode only)
int m_WindowedHeight; int m_WindowedHeight;
/// The current video mode flags
Uint32 m_VideoModeFlags; Uint32 m_VideoModeFlags;
/// Indicator for fullscreen mode availability
bool m_FullscreenModeAvailable; bool m_FullscreenModeAvailable;
/// Indicator for desired window mode availability (resolution, color depth, features)
bool m_WindowedModeAvailable; bool m_WindowedModeAvailable;
/// The SDL display surface handle
SDL_Surface *m_DisplaySurface; SDL_Surface *m_DisplaySurface;
/**
* \brief The known event codes handled by %eventLoop()
*
* \see eventLoop()
* \see timerCallbackRenderEvent()
* \see timerCallbackBOINCUpdateEvent()
*/
enum EventCodes { enum EventCodes {
RenderEvent, RenderEvent,
BOINCUpdateEvent BOINCUpdateEvent
}; };
/// The event observer registry
list<AbstractGraphicsEngine *> eventObservers; list<AbstractGraphicsEngine *> eventObservers;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment