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 =
# 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
......
......@@ -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
......
......@@ -124,6 +124,7 @@ void WindowManager::eventLoop()
// be sure there's at least one observer!
assert(eventObservers.size() > 0);
// 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);
......
......@@ -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;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment