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

Restructured project preferences handling

* Removed recently added BOINC stuff from AbstractGraphicsEngine
* WindowManager now got his "own" instance of BOINCClientAdapter
* WindowManager's (default) parameters are overridden if project preferences are set by the user!
* Also: removed trailing whitespaces (Ganymede's new editor shines)
parent c041215f
No related branches found
No related tags found
No related merge requests found
......@@ -22,43 +22,12 @@
AbstractGraphicsEngine::AbstractGraphicsEngine() : m_BoincAdapter()
{
m_InitialBOINCRefreshDone = false;
}
AbstractGraphicsEngine::~AbstractGraphicsEngine()
{
}
int AbstractGraphicsEngine::initialWindowWidth()
{
if(!m_InitialBOINCRefreshDone) {
m_BoincAdapter.refresh();
m_InitialBOINCRefreshDone = true;
}
return m_BoincAdapter.graphicsWindowWidth();
}
int AbstractGraphicsEngine::initialWindowHeight()
{
if(!m_InitialBOINCRefreshDone) {
m_BoincAdapter.refresh();
m_InitialBOINCRefreshDone = true;
}
return m_BoincAdapter.graphicsWindowHeight();
}
int AbstractGraphicsEngine::frameRate()
{
if(!m_InitialBOINCRefreshDone) {
m_BoincAdapter.refresh();
m_InitialBOINCRefreshDone = true;
}
return m_BoincAdapter.graphicsFrameRate();
}
void AbstractGraphicsEngine::refreshLocalBOINCInformation()
{
m_BoincAdapter.refresh();
......
......@@ -167,33 +167,6 @@ public:
*/
virtual void refreshBOINCInformation() = 0;
/**
* \brief Retrieves the initial window width (horizontal resolution) when running in windowed mode
*
* \return The initial window width to be used
*
* \see BOINCClientAdapter::graphicsWindowWidth()
*/
int initialWindowWidth();
/**
* \brief Retrieves the initial window width (vertical resolution) when running in windowed mode
*
* \return The initial window height to be used
*
* \see BOINCClientAdapter::graphicsWindowHeight()
*/
int initialWindowHeight();
/**
* \brief Retrieves the frame rate at which the graphics engine should be invoked for rendering
*
* \return The frame rate to be used for rendering
*
* \see BOINCClientAdapter::graphicsFrameRate()
*/
int frameRate();
protected:
/**
* \brief Default constructor
......@@ -213,10 +186,6 @@ protected:
/// BOINC client adapter instance for information retrieval
BOINCClientAdapter m_BoincAdapter;
private:
/// Indicator showing the initial BOINC adapter refresh status
bool m_InitialBOINCRefreshDone;
};
/**
......
......@@ -23,10 +23,12 @@
WindowManager::WindowManager()
{
m_ScreensaverMode = false;
m_BoincAdapter = new BOINCClientAdapter();
}
WindowManager::~WindowManager()
{
delete m_BoincAdapter;
}
bool WindowManager::initialize(const int width, const int height, const int frameRate)
......@@ -53,10 +55,16 @@ bool WindowManager::initialize(const int width, const int height, const int fram
m_DesktopBitsPerPixel = videoInfo->vfmt->BitsPerPixel;
}
// set initial non-fullscreen resolution as well as the render interval
m_WindowedWidth = width;
m_WindowedHeight = height;
m_RenderEventInterval = 1000.0f / frameRate;
// get initial non-fullscreen resolution and frame rate from project preferences
m_BoincAdapter->initialize("");
int preferredWidth = m_BoincAdapter->graphicsWindowWidth();
int preferredHeight = m_BoincAdapter->graphicsWindowHeight();
int preferredFrameRate = m_BoincAdapter->graphicsFrameRate();
// override optional default values if preferred values are set
m_WindowedWidth = preferredWidth != 0 ? preferredWidth : width;
m_WindowedHeight = preferredHeight != 0 ? preferredHeight : height;
m_RenderEventInterval = 1000.0f / (preferredFrameRate != 0 ? preferredFrameRate : frameRate);
/*
* SDL_ASYNCBLIT - Surface benutzt asynchrone Blits, wenn möglich
......
......@@ -31,6 +31,7 @@
#include <util.h>
#include "AbstractGraphicsEngine.h"
#include "BOINCClientAdapter.h"
using namespace std;
......@@ -66,7 +67,10 @@ public:
* \brief Initializes the %WindowManager
*
* Call this method first (after instantiation) to prepare the
* main application window as well as the OpenGL context.
* main application window as well as the OpenGL context. Please
* note that the optional parameters \c width, \c height and \c
* frameRate are overridden by the values set by the user in the
* project preferences!
*
* \param width The optional initial width of the main window
* \param height The optional initial height of the main window
......@@ -197,6 +201,9 @@ private:
*/
static Uint32 timerCallbackBOINCUpdateEvent(Uint32 interval, void *param);
/// Local BOINC adapter instance to read project preferences
BOINCClientAdapter *m_BoincAdapter;
/// The render event interval (in ms) for invoking the render event observer
float m_RenderEventInterval;
......
......@@ -42,10 +42,7 @@ int main(int argc, char **argv)
}
// initialize window manager
if(!window.initialize(graphics->initialWindowWidth(),
graphics->initialWindowHeight(),
graphics->frameRate())) {
if(!window.initialize()) {
cerr << "Window manager could not be initialized!" << endl;
delete graphics;
exit(1);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment