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

Refactored the main rendering engine

* Now there's a generic Einstein@Home and a science run specific part
* Search information retieval and rendering moved into subclass
* Renamed a few things as they're now true members
* Moved a few things from private to protected (obviously)
parent 97a1dc47
No related branches found
No related tags found
No related merge requests found
...@@ -28,6 +28,14 @@ Starsphere::Starsphere() : AbstractGraphicsEngine() ...@@ -28,6 +28,14 @@ Starsphere::Starsphere() : AbstractGraphicsEngine()
rotation_speed = 180.0; rotation_speed = 180.0;
m_RefreshSearchMarker = true; m_RefreshSearchMarker = true;
m_XStartPosLeft = 0.008;
m_YStartPosTop = 0.975;
m_FontScaleLarge = 0.0225;
m_FontScaleMedium = 0.0131;
m_FontScaleSmall = 0.0131;
m_YOffsetLarge = 0.015;
m_YOffsetMedium = 0.015;
} }
Starsphere::~Starsphere() Starsphere::~Starsphere()
...@@ -506,6 +514,9 @@ void Starsphere::resize(const int width, const int height) ...@@ -506,6 +514,9 @@ void Starsphere::resize(const int width, const int height)
*/ */
void Starsphere::initialize(const int width, const int height, const Resource *font) void Starsphere::initialize(const int width, const int height, const Resource *font)
{ {
// Initialize the BOINC client adapter
m_BoincAdapter.initialize("EinsteinHS");
// setup initial dimensions // setup initial dimensions
resize(width, height); resize(width, height);
...@@ -688,17 +699,6 @@ void Starsphere::render(const double timeOfDay) ...@@ -688,17 +699,6 @@ void Starsphere::render(const double timeOfDay)
// draw 2D vectorized HUD // draw 2D vectorized HUD
if(isFeature(LOGO) || isFeature(SEARCHINFO)) { if(isFeature(LOGO) || isFeature(SEARCHINFO)) {
static const GLfloat xStartPosLeft = 0.008;
const GLfloat xStartPosRight = 1 * aspect - 0.145;
static const GLfloat yStartPosTop = 0.975;
static const GLfloat yStartPosBottom = 0.07;
static const GLfloat fontScaleLarge = 0.0225;
static const GLfloat fontScaleMedium = 0.0131;
static const GLfloat fontScaleSmall = 0.0131;
// static const GLfloat yOffset = (font->Ascender() + font->Descender());
static const GLfloat yOffsetLarge = 0.015;
static const GLfloat yOffsetMedium = 0.015;
// disable depth testing since we're in 2D mode // disable depth testing since we're in 2D mode
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
...@@ -718,7 +718,7 @@ void Starsphere::render(const double timeOfDay) ...@@ -718,7 +718,7 @@ void Starsphere::render(const double timeOfDay)
glPushMatrix(); glPushMatrix();
glColor3f(1.0, 1.0, 0.0); glColor3f(1.0, 1.0, 0.0);
glTranslatef(xStartPosLeft, yStartPosTop, 0); glTranslatef(m_XStartPosLeft, m_YStartPosTop, 0);
// glScalef(fontScaleLarge, fontScaleLarge, 1.0); // glScalef(fontScaleLarge, fontScaleLarge, 1.0);
glScalef(0.001, 0.001, 1.0); glScalef(0.001, 0.001, 1.0);
// m_PolygonFont->Render("Einstein@Home"); // m_PolygonFont->Render("Einstein@Home");
...@@ -730,74 +730,15 @@ void Starsphere::render(const double timeOfDay) ...@@ -730,74 +730,15 @@ void Starsphere::render(const double timeOfDay)
glLoadIdentity(); glLoadIdentity();
glColor4f(1.0, 1.0, 1.0, 0.5); glColor4f(1.0, 1.0, 1.0, 0.5);
glTranslatef(xStartPosLeft, yStartPosTop - yOffsetLarge, 0); glTranslatef(m_XStartPosLeft, m_YStartPosTop - m_YOffsetLarge, 0);
glScalef(fontScaleMedium, fontScaleMedium, 1.0); glScalef(m_FontScaleMedium, m_FontScaleMedium, 1.0);
m_PolygonFont->Render("World Year of Physics 2005"); m_PolygonFont->Render("World Year of Physics 2005");
glPopMatrix(); glPopMatrix();
} }
if (isFeature(SEARCHINFO)) {
// left info block
glPushMatrix();
glColor3f(1.0, 1.0, 0.0);
glTranslatef(xStartPosLeft, yStartPosBottom, 0);
glScalef(fontScaleMedium, fontScaleMedium, 1.0);
m_PolygonFont->Render("BOINC Statistics");
glLoadIdentity();
glColor4f(1.0, 1.0, 1.0, 0.5);
glTranslatef(xStartPosLeft, yStartPosBottom - yOffsetMedium, 0);
glScalef(fontScaleSmall, fontScaleSmall, 1.0);
m_PolygonFont->Render(m_UserName.c_str());
glLoadIdentity();
glTranslatef(xStartPosLeft, yStartPosBottom - 2*yOffsetMedium, 0);
glScalef(fontScaleSmall, fontScaleSmall, 1.0);
m_PolygonFont->Render(m_TeamName.c_str());
glLoadIdentity();
glTranslatef(xStartPosLeft, yStartPosBottom - 3*yOffsetMedium, 0);
glScalef(fontScaleSmall, fontScaleSmall, 1.0);
m_PolygonFont->Render(m_UserCredit.c_str());
glLoadIdentity();
glTranslatef(xStartPosLeft, yStartPosBottom - 4*yOffsetMedium, 0);
glScalef(fontScaleSmall, fontScaleSmall, 1.0);
m_PolygonFont->Render(m_UserRACredit.c_str());
glPopMatrix();
// right info block
glPushMatrix();
glColor3f(1.0, 1.0, 0.0);
glTranslatef(xStartPosRight, yStartPosBottom, 0);
glScalef(fontScaleMedium, fontScaleMedium, 1.0);
m_PolygonFont->Render("Search Information");
glLoadIdentity();
glColor4f(1.0, 1.0, 1.0, 0.5);
glTranslatef(xStartPosRight, yStartPosBottom - yOffsetMedium, 0);
glScalef(fontScaleSmall, fontScaleSmall, 1.0);
m_PolygonFont->Render(m_WUSkyPosRightAscension.c_str());
glLoadIdentity();
glTranslatef(xStartPosRight, yStartPosBottom - 2*yOffsetMedium, 0);
glScalef(fontScaleSmall, fontScaleSmall, 1.0);
m_PolygonFont->Render(m_WUSkyPosDeclination.c_str());
glLoadIdentity();
glTranslatef(xStartPosRight, yStartPosBottom - 3*yOffsetMedium, 0);
glScalef(fontScaleSmall, fontScaleSmall, 1.0);
m_PolygonFont->Render(m_WUPercentDone.c_str());
glLoadIdentity(); if (isFeature(SEARCHINFO)) {
glTranslatef(xStartPosRight, yStartPosBottom - 4*yOffsetMedium, 0); renderSearchInformation();
glScalef(fontScaleSmall, fontScaleSmall, 1.0);
m_PolygonFont->Render(m_WUCPUTime.c_str());
glPopMatrix();
} }
// restore original state // restore original state
...@@ -940,38 +881,4 @@ void Starsphere::refreshBOINCInformation() ...@@ -940,38 +881,4 @@ void Starsphere::refreshBOINCInformation()
buffer << "Project RAC: " << fixed << m_BoincAdapter.userRACredit() << ends; buffer << "Project RAC: " << fixed << m_BoincAdapter.userRACredit() << ends;
m_UserRACredit = buffer.str(); m_UserRACredit = buffer.str();
buffer.str(""); buffer.str("");
// store content required for our HUD (search info)
if(m_CurrentRightAscension != m_BoincAdapter.wuSkyPosRightAscension()) {
// we've got a new position, update search marker and HUD
m_CurrentRightAscension = m_BoincAdapter.wuSkyPosRightAscension();
m_RefreshSearchMarker = true;
buffer << "Ascension: " << fixed << m_CurrentRightAscension * 360/PI2 << " deg" << ends;
m_WUSkyPosRightAscension = buffer.str();
buffer.str("");
}
if(m_CurrentDeclination != m_BoincAdapter.wuSkyPosDeclination()) {
// we've got a new position, update search marker and HUD
m_CurrentDeclination = m_BoincAdapter.wuSkyPosDeclination();
m_RefreshSearchMarker = true;
buffer << "Declination: " << fixed << m_CurrentDeclination * 360/PI2 << " deg" << ends;
m_WUSkyPosDeclination = buffer.str();
buffer.str("");
}
buffer << "Completed: " << fixed << m_BoincAdapter.wuFractionDone() * 100 << " %" << ends;
m_WUPercentDone = buffer.str();
buffer.str("");
const double cputime = m_BoincAdapter.wuCPUTime();
const int hrs = cputime / 3600;
const int min = (cputime - hrs*3600) / 60;
const int sec = cputime - (hrs*3600 + min*60);
buffer << "CPU Time: " << right << setw(2) << hrs << ":"
<< right << setw(2) << min << ":"
<< right << setw(2) << sec << ends;
m_WUCPUTime = buffer.str();
} }
...@@ -38,7 +38,6 @@ using namespace std; ...@@ -38,7 +38,6 @@ using namespace std;
class Starsphere : public AbstractGraphicsEngine class Starsphere : public AbstractGraphicsEngine
{ {
public: public:
Starsphere();
virtual ~Starsphere(); virtual ~Starsphere();
// core methods // core methods
...@@ -52,7 +51,39 @@ public: ...@@ -52,7 +51,39 @@ public:
void keyboardPressEvent(const int keyPressed); void keyboardPressEvent(const int keyPressed);
// update HUD content // update HUD content
void refreshBOINCInformation(); virtual void refreshBOINCInformation();
protected:
/// Contructor (protected since this an abstract class)
Starsphere();
// resource handling
FTFont *m_PolygonFont;
OGLFT::TranslucentTexture* face;
// Graphics state info:
float aspect;
// HUD text rendering config (maybe overridden in subclasses)
GLfloat m_XStartPosLeft;
GLfloat m_YStartPosTop;
GLfloat m_FontScaleLarge;
GLfloat m_FontScaleMedium;
GLfloat m_FontScaleSmall;
GLfloat m_YOffsetLarge;
GLfloat m_YOffsetMedium;
// local HUD contents
string m_UserName;
string m_TeamName;
string m_UserCredit;
string m_UserRACredit;
// search marker info
double m_CurrentRightAscension;
double m_CurrentDeclination;
bool m_RefreshSearchMarker;
private: private:
void make_stars(); void make_stars();
...@@ -98,11 +129,11 @@ private: ...@@ -98,11 +129,11 @@ private:
GLfloat rotation_offset; // so that we can rotate sphere GLfloat rotation_offset; // so that we can rotate sphere
GLfloat rotation_speed; // degrees per minute GLfloat rotation_speed; // degrees per minute
// Graphics state info:
float aspect;
//------------ new clean members ----- //------------ new clean members -----
// application specific rendering
virtual void renderSearchInformation() = 0;
// view control // view control
void rotateSphere(const int relativeRotation, const int relativeElevation); void rotateSphere(const int relativeRotation, const int relativeElevation);
void zoomSphere(const int relativeZoom); void zoomSphere(const int relativeZoom);
...@@ -125,25 +156,6 @@ private: ...@@ -125,25 +156,6 @@ private:
MARKER = 1024 MARKER = 1024
}; };
// resource handling
FTFont *m_PolygonFont;
OGLFT::TranslucentTexture* face;
// local HUD contents
string m_UserName;
string m_TeamName;
string m_UserCredit;
string m_UserRACredit;
string m_WUSkyPosRightAscension;
string m_WUSkyPosDeclination;
string m_WUPercentDone;
string m_WUCPUTime;
// search marker info
double m_CurrentRightAscension;
double m_CurrentDeclination;
bool m_RefreshSearchMarker;
// observatory movement // observatory movement
// (in seconds since 1970 with usec precision) // (in seconds since 1970 with usec precision)
double m_ObservatoryDrawTimeLocal; double m_ObservatoryDrawTimeLocal;
......
#include "StarsphereS5R3.h"
StarsphereS5R3::StarsphereS5R3() : m_EinsteinAdapter(&m_BoincAdapter)
{
m_YStartPosBottom = 0.07;
}
StarsphereS5R3::~StarsphereS5R3()
{
}
void StarsphereS5R3::refreshBOINCInformation()
{
Starsphere::refreshBOINCInformation();
// prepare conversion buffer
stringstream buffer;
buffer.precision(2);
buffer.setf(ios::fixed, ios::floatfield);
buffer.fill('0');
buffer.setf(ios::right, ios::adjustfield);
// store content required for our HUD (search info)
if(m_CurrentRightAscension != m_EinsteinAdapter.wuSkyPosRightAscension()) {
// we've got a new position, update search marker and HUD
m_CurrentRightAscension = m_EinsteinAdapter.wuSkyPosRightAscension();
m_RefreshSearchMarker = true;
buffer << "Ascension: " << fixed << m_CurrentRightAscension * 360/PI2 << " deg" << ends;
m_WUSkyPosRightAscension = buffer.str();
buffer.str("");
}
if(m_CurrentDeclination != m_EinsteinAdapter.wuSkyPosDeclination()) {
// we've got a new position, update search marker and HUD
m_CurrentDeclination = m_EinsteinAdapter.wuSkyPosDeclination();
m_RefreshSearchMarker = true;
buffer << "Declination: " << fixed << m_CurrentDeclination * 360/PI2 << " deg" << ends;
m_WUSkyPosDeclination = buffer.str();
buffer.str("");
}
buffer << "Completed: " << fixed << m_EinsteinAdapter.wuFractionDone() * 100 << " %" << ends;
m_WUPercentDone = buffer.str();
buffer.str("");
const double cputime = m_EinsteinAdapter.wuCPUTime();
const int hrs = cputime / 3600;
const int min = (cputime - hrs*3600) / 60;
const int sec = cputime - (hrs*3600 + min*60);
buffer << "CPU Time: " << right << setw(2) << hrs << ":"
<< right << setw(2) << min << ":"
<< right << setw(2) << sec << ends;
m_WUCPUTime = buffer.str();
}
void StarsphereS5R3::renderSearchInformation()
{
m_XStartPosRight = 1 * aspect - 0.145;
// left info block
glPushMatrix();
glColor3f(1.0, 1.0, 0.0);
glTranslatef(m_XStartPosLeft, m_YStartPosBottom, 0);
glScalef(m_FontScaleMedium, m_FontScaleMedium, 1.0);
m_PolygonFont->Render("BOINC Statistics");
glLoadIdentity();
glColor4f(1.0, 1.0, 1.0, 0.5);
glTranslatef(m_XStartPosLeft, m_YStartPosBottom - m_YOffsetMedium, 0);
glScalef(m_FontScaleSmall, m_FontScaleSmall, 1.0);
m_PolygonFont->Render(m_UserName.c_str());
glLoadIdentity();
glTranslatef(m_XStartPosLeft, m_YStartPosBottom - 2*m_YOffsetMedium, 0);
glScalef(m_FontScaleSmall, m_FontScaleSmall, 1.0);
m_PolygonFont->Render(m_TeamName.c_str());
glLoadIdentity();
glTranslatef(m_XStartPosLeft, m_YStartPosBottom - 3*m_YOffsetMedium, 0);
glScalef(m_FontScaleSmall, m_FontScaleSmall, 1.0);
m_PolygonFont->Render(m_UserCredit.c_str());
glLoadIdentity();
glTranslatef(m_XStartPosLeft, m_YStartPosBottom - 4*m_YOffsetMedium, 0);
glScalef(m_FontScaleSmall, m_FontScaleSmall, 1.0);
m_PolygonFont->Render(m_UserRACredit.c_str());
glPopMatrix();
// right info block
glPushMatrix();
glColor3f(1.0, 1.0, 0.0);
glTranslatef(m_XStartPosRight, m_YStartPosBottom, 0);
glScalef(m_FontScaleMedium, m_FontScaleMedium, 1.0);
m_PolygonFont->Render("Search Information");
glLoadIdentity();
glColor4f(1.0, 1.0, 1.0, 0.5);
glTranslatef(m_XStartPosRight, m_YStartPosBottom - m_YOffsetMedium, 0);
glScalef(m_FontScaleSmall, m_FontScaleSmall, 1.0);
m_PolygonFont->Render(m_WUSkyPosRightAscension.c_str());
glLoadIdentity();
glTranslatef(m_XStartPosRight, m_YStartPosBottom - 2*m_YOffsetMedium, 0);
glScalef(m_FontScaleSmall, m_FontScaleSmall, 1.0);
m_PolygonFont->Render(m_WUSkyPosDeclination.c_str());
glLoadIdentity();
glTranslatef(m_XStartPosRight, m_YStartPosBottom - 3*m_YOffsetMedium, 0);
glScalef(m_FontScaleSmall, m_FontScaleSmall, 1.0);
m_PolygonFont->Render(m_WUPercentDone.c_str());
glLoadIdentity();
glTranslatef(m_XStartPosRight, m_YStartPosBottom - 4*m_YOffsetMedium, 0);
glScalef(m_FontScaleSmall, m_FontScaleSmall, 1.0);
m_PolygonFont->Render(m_WUCPUTime.c_str());
glPopMatrix();
}
#ifndef STARSPHERES5R3_H_
#define STARSPHERES5R3_H_
#include <sstream>
#include "Starsphere.h"
#include "EinsteinS5R3Adapter.h"
using namespace std;
class StarsphereS5R3 : public Starsphere
{
public:
StarsphereS5R3();
virtual ~StarsphereS5R3();
void refreshBOINCInformation();
private:
void renderSearchInformation();
EinsteinS5R3Adapter m_EinsteinAdapter;
string m_WUSkyPosRightAscension;
string m_WUSkyPosDeclination;
string m_WUPercentDone;
string m_WUCPUTime;
GLfloat m_XStartPosRight;
GLfloat m_YStartPosBottom;
};
#endif /*STARSPHERES5R3_H_*/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment