StelLoadingBar.cpp   StelLoadingBar.cpp 
skipping to change at line 23 skipping to change at line 23
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelLoadingBar.hpp" #include "StelLoadingBar.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelTextureMgr.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelPainter.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "renderer/StelRenderer.hpp"
#include <QDebug> #include <QDebug>
#include <QtOpenGL>
StelLoadingBar::StelLoadingBar(const QString& splashTex, StelLoadingBar::StelLoadingBar(const QString& splashTex,
const QString& extraTextString, float extraTextSize, const QString& extraTextString, float extraTextSize,
float extraTextPosx, float extraTextPosy, int aWidth, int aHeight) : float extraTextPosx, float extraTextPosy, int aWidth, int aHeight)
width(aWidth), height(aHeight), extraText(extraTextString), sPainter : width(aWidth)
(NULL) , height(aHeight)
, splash(NULL)
, extraText(extraTextString)
, splashName(splashTex)
, viewportXywh(StelApp::getInstance().getCore()->getProjection2d()->
getViewportXywh())
{ {
extraTextFont.setPixelSize(extraTextSize); extraTextFont.setPixelSize(extraTextSize);
sPainter = new StelPainter(StelApp::getInstance().getCore()->getProj splashx = viewportXywh[0] + (viewportXywh[2] - width)/2;
ection2d()); splashy = viewportXywh[1] + (viewportXywh[3] - height)/2;
int screenw = sPainter->getProjector()->getViewportWidth();
int screenh = sPainter->getProjector()->getViewportHeight();
splashx = sPainter->getProjector()->getViewportPosX() + (screenw - w
idth)/2;
splashy = sPainter->getProjector()->getViewportPosY() + (screenh - h
eight)/2;
if (!splashTex.isEmpty())
splash = StelApp::getInstance().getTextureManager().createTe
xture(splashTex);
extraTextPos.set(extraTextPosx, extraTextPosy); extraTextPos.set(extraTextPosx, extraTextPosy);
} }
StelLoadingBar::~StelLoadingBar() StelLoadingBar::~StelLoadingBar()
{ {
delete sPainter; if(NULL != splash) {delete splash;}
} }
void StelLoadingBar::draw() void StelLoadingBar::draw(StelRenderer* renderer)
{ {
sPainter->setColor(1.f, 1.f, 1.f); if(NULL == splash)
sPainter->enableTexture2d(true);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Draw the splash screen if available
if (splash)
{ {
splash->bind(); splash = renderer->createTexture(splashName);
sPainter->drawRect2d(splashx, splashy, width, height);
} }
sPainter->setFont(extraTextFont); // Background.
sPainter->drawText(splashx + extraTextPos[0], splashy + extraTextPos renderer->setGlobalColor(0.0f, 0.0f, 0.0f);
[1]-sPainter->getFontMetrics().height()-1, extraText); renderer->drawRect(viewportXywh[0], viewportXywh[1], viewportXywh[2]
StelPainter::swapBuffer(); // And swap the buffers , viewportXywh[3]);
renderer->setGlobalColor(1.0f, 1.0f, 1.0f);
renderer->setBlendMode(BlendMode_Alpha);
// Draw the splash screen.
splash->bind();
renderer->drawTexturedRect(splashx, splashy, width, height);
renderer->setFont(extraTextFont);
const QFontMetrics fontMetrics(extraTextFont);
renderer->drawText(TextParams(splashx + extraTextPos[0],
splashy + extraTextPos[1] - fontMetric
s.height() - 1,
extraText));
renderer->swapBuffers();
} }
 End of changes. 11 change blocks. 
32 lines changed or deleted 35 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/