Skip to content
Snippets Groups Projects
Select Git revision
  • master default
  • mingw_gcc44
  • release_ABP1_012
  • release_ABP1_008
  • release_ABP1_006
  • release_ABP1_007
  • release_ABP1_005
  • release_ABP1_004
  • release_ABP1_003
  • pre_release_0.15
  • release_ABP1_001
  • release_ABP1_002
  • pre_release_0.13
  • pre_release_0.14
  • pre_release_0.11
  • pre_release_0.12
  • pre_release_0.10
  • pre_release_0.09
  • pre_release_0.08
19 results

StarsphereS5R3.cpp

Blame
  • Forked from einsteinathome / graphicsframework
    247 commits behind the upstream repository.
    • Oliver Bock's avatar
      f327579e
      Fixed BOINC information update · f327579e
      Oliver Bock authored
      * The interface declared in AbstractGraphicsEngine is now implemented in the most specialized class only (to make sure it's called, down the inheritance hierarchy)
      * The abstract or generelized classes (up the hierarchy) got local implementation (protected) which are called by their respective children.
      * Fixed a bug in the old starsphere code. Search marker rendering deleted to much (memory corruption)! Does OpenGL do any boundary checking?
      f327579e
      History
      Fixed BOINC information update
      Oliver Bock authored
      * The interface declared in AbstractGraphicsEngine is now implemented in the most specialized class only (to make sure it's called, down the inheritance hierarchy)
      * The abstract or generelized classes (up the hierarchy) got local implementation (protected) which are called by their respective children.
      * Fixed a bug in the old starsphere code. Search marker rendering deleted to much (memory corruption)! Does OpenGL do any boundary checking?
    StarsphereS5R3.cpp 3.36 KiB
    #include "StarsphereS5R3.h"
    
    StarsphereS5R3::StarsphereS5R3() : Starsphere(), m_EinsteinAdapter(&m_BoincAdapter)
    {
    }
    
    StarsphereS5R3::~StarsphereS5R3()
    {
    }
    
    void StarsphereS5R3::initialize(const int width, const int height, const Resource *font)
    {
    	Starsphere::initialize(width, height, font);
    	
    	// adjust HUD config
    	m_YOffsetMedium = 15;
    	m_XStartPosRight = width - 125;
    	m_YStartPosBottom = 70;	
    	m_Y1StartPosBottom = m_YStartPosBottom  - m_YOffsetMedium;
    	m_Y2StartPosBottom = m_Y1StartPosBottom - m_YOffsetMedium;
    	m_Y3StartPosBottom = m_Y2StartPosBottom - m_YOffsetMedium;
    	m_Y4StartPosBottom = m_Y3StartPosBottom - m_YOffsetMedium;
    }
    
    void StarsphereS5R3::resize(const int width, const int height)
    {
    	Starsphere::resize(width, height);
    	
    	// adjust HUD config
    	m_XStartPosRight = width - 125;
    }
    
    void StarsphereS5R3::refreshBOINCInformation()
    {
    	// call base class implementation
    	Starsphere::refreshLocalBOINCInformation();
    	
    	// update local/specific content
    	m_EinsteinAdapter.refresh();
    	
    	// 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()
    {
    		// left info block      
    		m_FontHeader->draw(m_XStartPosLeft, m_YStartPosBottom, "BOINC Statistics");
    		m_FontText->draw(m_XStartPosLeft, m_Y1StartPosBottom, m_UserName.c_str());
    		m_FontText->draw(m_XStartPosLeft, m_Y2StartPosBottom, m_TeamName.c_str());
    		m_FontText->draw(m_XStartPosLeft, m_Y3StartPosBottom, m_UserCredit.c_str());
    		m_FontText->draw(m_XStartPosLeft, m_Y4StartPosBottom, m_UserRACredit.c_str());
    		
    		// right info block
    		m_FontHeader->draw(m_XStartPosRight, m_YStartPosBottom, "Search Information");
    		m_FontText->draw(m_XStartPosRight, m_Y1StartPosBottom, m_WUSkyPosRightAscension.c_str());
    		m_FontText->draw(m_XStartPosRight, m_Y2StartPosBottom, m_WUSkyPosDeclination.c_str());
    		m_FontText->draw(m_XStartPosRight, m_Y3StartPosBottom, m_WUPercentDone.c_str());
    		m_FontText->draw(m_XStartPosRight, m_Y4StartPosBottom, m_WUCPUTime.c_str());
    }