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

Fixing windoze window issue (move/resize)

* Windoze "resets" the OpenGL context when SetVideoMode is called - ergo, we need to reinitialize the context
* Added a switch (recycle) to initialize() to distinguish between one-off and recurring actions
parent b6878226
No related branches found
No related tags found
No related merge requests found
......@@ -28,8 +28,9 @@ public:
* \param width The current width of the display surface
* \param height The current height of the display surface
* \param font A pointer to a Resource object containing TTF font faces for text rendering
* \param recycle This flag indicates whether we initialize (FALSE) or reinitialize (TRUE) the context
*/
virtual void initialize(const int width, const int height, const Resource *font) = 0;
virtual void initialize(const int width, const int height, const Resource *font, const bool recycle = false) = 0;
/**
* \brief This method is called when the windowing system encounters a window resize event
......
......@@ -542,14 +542,14 @@ void Starsphere::resize(const int width, const int height)
/**
* What to do when graphics are "initialized".
*/
void Starsphere::initialize(const int width, const int height, const Resource *font)
void Starsphere::initialize(const int width, const int height, const Resource *font, const bool recycle)
{
// check whether we initialize the first time or have to recycle (required for windoze)
if(!recycle) {
// Initialize the BOINC client adapter
m_BoincAdapter.initialize("EinsteinHS");
// setup initial dimensions
resize(width, height);
// create large font instances using font resource (base address + size)
m_FontLogo1 = new OGLFT::TranslucentTexture(&font->data()->at(0), font->data()->size(), 24, 72 );
if ( m_FontLogo1 == 0 || !m_FontLogo1->isValid() ) {
......@@ -582,16 +582,30 @@ void Starsphere::initialize(const int width, const int height, const Resource *f
}
m_FontText->setForegroundColor(0.75, 0.75, 0.75, 1.0);
// inital HUD offset setup
m_XStartPosLeft = 5;
m_YOffsetLarge = 18;
setFeature(STARS, true);
setFeature(CONSTELLATIONS, true);
setFeature(PULSARS, true);
setFeature(OBSERVATORIES, true);
setFeature(SNRS, true);
setFeature(GLOBE, true);
setFeature(SEARCHINFO, true);
setFeature(LOGO, true);
setFeature(MARKER, true);
}
// setup initial dimensions
resize(width, height);
// more font setup and optimizations
glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
#if defined( GL_RASTER_POSITION_UNCLIPPED_IBM )
glEnable( GL_RASTER_POSITION_UNCLIPPED_IBM );
#endif
// inital HUD offset setup
m_XStartPosLeft = 5;
m_YOffsetLarge = 18;
// Drawing setup:
glClearColor(0.0, 0.0, 0.0, 0.0); // background is black
glEnable(GL_CULL_FACE);
......@@ -632,16 +646,6 @@ void Starsphere::initialize(const int width, const int height, const Resource *f
make_globe();
make_obs();
setFeature(STARS, true);
setFeature(CONSTELLATIONS, true);
setFeature(PULSARS, true);
setFeature(OBSERVATORIES, true);
setFeature(SNRS, true);
setFeature(GLOBE, true);
setFeature(SEARCHINFO, true);
setFeature(LOGO, true);
setFeature(MARKER, true);
glDisable(GL_CLIP_PLANE0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glFlush();
......
......@@ -71,8 +71,9 @@ public:
* \param width The current width of the display surface
* \param height The current height of the display surface
* \param font A pointer to a Resource object containing TTF font faces for text rendering
* \param recycle This flag indicates whether we initialize (FALSE) or reinitialize (TRUE) the context
*/
virtual void initialize(const int width, const int height, const Resource *font);
virtual void initialize(const int width, const int height, const Resource *font, const bool recycle = false);
/**
* \brief This method is called when the windowing system encounters a window resize event
......
......@@ -8,9 +8,12 @@ StarsphereS5R3::~StarsphereS5R3()
{
}
void StarsphereS5R3::initialize(const int width, const int height, const Resource *font)
void StarsphereS5R3::initialize(const int width, const int height, const Resource *font, const bool recycle)
{
Starsphere::initialize(width, height, font);
Starsphere::initialize(width, height, font, recycle);
// check whether we initialize the first time or have to recycle (required for windoze)
if(!recycle) {
// adjust HUD config
m_YOffsetMedium = 15;
......@@ -21,6 +24,7 @@ void StarsphereS5R3::initialize(const int width, const int height, const Resourc
m_Y3StartPosBottom = m_Y2StartPosBottom - m_YOffsetMedium;
m_Y4StartPosBottom = m_Y3StartPosBottom - m_YOffsetMedium;
}
}
void StarsphereS5R3::resize(const int width, const int height)
{
......@@ -68,6 +72,7 @@ void StarsphereS5R3::refreshBOINCInformation()
m_WUPercentDone = buffer.str();
buffer.str("");
/// \todo Show accumulated time (init_data time + shmem time)
const double cputime = m_EinsteinAdapter.wuCPUTime();
const int hrs = cputime / 3600;
const int min = (cputime - hrs*3600) / 60;
......
......@@ -40,8 +40,9 @@ public:
* \param width The current width of the display surface
* \param height The current height of the display surface
* \param font A pointer to a Resource object containing TTF font faces for text rendering
* \param recycle This flag indicates whether we initialize (FALSE) or reinitialize (TRUE) the context
*/
void initialize(const int width, const int height, const Resource *font);
virtual void initialize(const int width, const int height, const Resource *font, const bool recycle = false);
/**
* \brief This method is called when the windowing system encounters a window resize event
......
......@@ -208,7 +208,8 @@ void WindowManager::eventLoop()
m_VideoModeFlags);
// notify our observers (currently exactly one)
eventObservers.front()->resize(m_CurrentWidth, m_CurrentHeight);
// (windoze needs to be reinitialized instead of just resized, oh well)
eventObservers.front()->initialize(m_CurrentWidth, m_CurrentHeight, 0, true);
}
else if (event.type == SDL_QUIT ||
(event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment