StelMainView.cpp   StelMainView.cpp 
skipping to change at line 36 skipping to change at line 36
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include "StelGuiBase.hpp" #include "StelGuiBase.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelActionMgr.hpp" #include "StelActionMgr.hpp"
#include "StelOpenGL.hpp" #include "StelOpenGL.hpp"
#include <QDeclarativeItem> #include <QDeclarativeItem>
#include <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
#if STEL_USE_NEW_OPENGL_WIDGETS
#include <QOpenGLWidget>
#else
#include <QGLWidget> #include <QGLWidget>
#endif
#include <QGuiApplication> #include <QGuiApplication>
#include <QFileInfo> #include <QFileInfo>
#include <QIcon> #include <QIcon>
#include <QMoveEvent> #include <QMoveEvent>
#include <QPluginLoader> #include <QPluginLoader>
#include <QScreen> #include <QScreen>
#include <QSettings> #include <QSettings>
#include <QtPlugin> #include <QtPlugin>
#include <QThread> #include <QThread>
#include <QTimer> #include <QTimer>
#include <QWidget> #include <QWidget>
#include <QWindow> #include <QWindow>
#include <QMessageBox>
#include <QDeclarativeContext> #include <QDeclarativeContext>
#include <QPinchGesture> #ifdef Q_OS_WIN
#include <QPinchGesture>
#endif
#include <QOpenGLShader> #include <QOpenGLShader>
#include <QOpenGLShaderProgram> #include <QOpenGLShaderProgram>
#include <clocale> #include <clocale>
// Initialize static variables // Initialize static variables
StelMainView* StelMainView::singleton = NULL; StelMainView* StelMainView::singleton = NULL;
//! Render Stellarium sky. //! Render Stellarium sky.
class StelSkyItem : public QDeclarativeItem class StelSkyItem : public QDeclarativeItem
skipping to change at line 72 skipping to change at line 79
public: public:
StelSkyItem(QDeclarativeItem* parent = NULL); StelSkyItem(QDeclarativeItem* parent = NULL);
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option , QWidget* widget = 0); void paint(QPainter* painter, const QStyleOptionGraphicsItem* option , QWidget* widget = 0);
protected: protected:
void mousePressEvent(QGraphicsSceneMouseEvent* event); void mousePressEvent(QGraphicsSceneMouseEvent* event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent* event); void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
void mouseMoveEvent(QGraphicsSceneMouseEvent* event); void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
void wheelEvent(QGraphicsSceneWheelEvent *event); void wheelEvent(QGraphicsSceneWheelEvent *event);
void keyPressEvent(QKeyEvent *event); void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event); void keyReleaseEvent(QKeyEvent *event);
#ifdef Q_OS_WIN
bool event(QEvent * e); bool event(QEvent * e);
#endif
private: private:
double previousPaintTime; double previousPaintTime;
void onSizeChanged(); void onSizeChanged();
#ifdef Q_OS_WIN
void pinchTriggered(QPinchGesture *gesture); void pinchTriggered(QPinchGesture *gesture);
bool gestureEvent(QGestureEvent *event); bool gestureEvent(QGestureEvent *event);
#endif
}; };
//! Initialize and render Stellarium gui. //! Initialize and render Stellarium gui.
class StelGuiItem : public QDeclarativeItem class StelGuiItem : public QDeclarativeItem
{ {
public: public:
StelGuiItem(QDeclarativeItem* parent = NULL); StelGuiItem(QDeclarativeItem* parent = NULL);
private: private:
QGraphicsWidget *widget; QGraphicsWidget *widget;
void onSizeChanged(); void onSizeChanged();
}; };
StelSkyItem::StelSkyItem(QDeclarativeItem* parent) StelSkyItem::StelSkyItem(QDeclarativeItem* parent)
{ {
Q_UNUSED(parent); Q_UNUSED(parent);
setObjectName("SkyItem"); setObjectName("SkyItem");
setFlag(QGraphicsItem::ItemHasNoContents, false); setFlag(QGraphicsItem::ItemHasNoContents, false);
setAcceptHoverEvents(true); setAcceptHoverEvents(true);
#ifdef Q_OS_WIN
setAcceptTouchEvents(true); setAcceptTouchEvents(true);
grabGesture(Qt::PinchGesture); grabGesture(Qt::PinchGesture);
#endif
setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton | Qt::Middl eButton); setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton | Qt::Middl eButton);
connect(this, &StelSkyItem::widthChanged, this, &StelSkyItem::onSize Changed); connect(this, &StelSkyItem::widthChanged, this, &StelSkyItem::onSize Changed);
connect(this, &StelSkyItem::heightChanged, this, &StelSkyItem::onSiz eChanged); connect(this, &StelSkyItem::heightChanged, this, &StelSkyItem::onSiz eChanged);
previousPaintTime = StelApp::getTotalRunTime(); previousPaintTime = StelApp::getTotalRunTime();
StelMainView::getInstance().skyItem = this; StelMainView::getInstance().skyItem = this;
setFocus(true); setFocus(true);
} }
void StelSkyItem::onSizeChanged() void StelSkyItem::onSizeChanged()
{ {
skipping to change at line 162 skipping to change at line 175
} }
void StelSkyItem::wheelEvent(QGraphicsSceneWheelEvent *event) void StelSkyItem::wheelEvent(QGraphicsSceneWheelEvent *event)
{ {
QPointF pos = event->scenePos(); QPointF pos = event->scenePos();
pos.setY(height() - 1 - pos.y()); pos.setY(height() - 1 - pos.y());
QWheelEvent newEvent(QPoint(pos.x(),pos.y()), event->delta(), event- >buttons(), event->modifiers(), event->orientation()); QWheelEvent newEvent(QPoint(pos.x(),pos.y()), event->delta(), event- >buttons(), event->modifiers(), event->orientation());
StelApp::getInstance().handleWheel(&newEvent); StelApp::getInstance().handleWheel(&newEvent);
} }
#ifdef Q_OS_WIN
bool StelSkyItem::event(QEvent * e) bool StelSkyItem::event(QEvent * e)
{ {
switch (e->type()){ switch (e->type()){
case QEvent::TouchBegin: case QEvent::TouchBegin:
case QEvent::TouchUpdate: case QEvent::TouchUpdate:
case QEvent::TouchEnd: case QEvent::TouchEnd:
{ {
QTouchEvent *touchEvent = static_cast<QTouchEvent *>(e); QTouchEvent *touchEvent = static_cast<QTouchEvent *>(e);
QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->tou chPoints(); QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->tou chPoints();
skipping to change at line 208 skipping to change at line 222
{ {
QPinchGesture::ChangeFlags changeFlags = gesture->changeFlags(); QPinchGesture::ChangeFlags changeFlags = gesture->changeFlags();
if (changeFlags & QPinchGesture::ScaleFactorChanged) { if (changeFlags & QPinchGesture::ScaleFactorChanged) {
qreal zoom = gesture->scaleFactor(); qreal zoom = gesture->scaleFactor();
if (zoom < 2 && zoom > 0.5){ if (zoom < 2 && zoom > 0.5){
StelApp::getInstance().handlePinch(zoom, true); StelApp::getInstance().handlePinch(zoom, true);
} }
} }
} }
#endif
void StelSkyItem::keyPressEvent(QKeyEvent* event) void StelSkyItem::keyPressEvent(QKeyEvent* event)
{ {
StelApp::getInstance().handleKeys(event); StelApp::getInstance().handleKeys(event);
} }
void StelSkyItem::keyReleaseEvent(QKeyEvent* event) void StelSkyItem::keyReleaseEvent(QKeyEvent* event)
{ {
StelApp::getInstance().handleKeys(event); StelApp::getInstance().handleKeys(event);
} }
skipping to change at line 230 skipping to change at line 245
{ {
connect(this, &StelGuiItem::widthChanged, this, &StelGuiItem::onSize Changed); connect(this, &StelGuiItem::widthChanged, this, &StelGuiItem::onSize Changed);
connect(this, &StelGuiItem::heightChanged, this, &StelGuiItem::onSiz eChanged); connect(this, &StelGuiItem::heightChanged, this, &StelGuiItem::onSiz eChanged);
widget = new QGraphicsWidget(this); widget = new QGraphicsWidget(this);
StelMainView::getInstance().guiWidget = widget; StelMainView::getInstance().guiWidget = widget;
StelApp::getInstance().getGui()->init(widget); StelApp::getInstance().getGui()->init(widget);
} }
void StelGuiItem::onSizeChanged() void StelGuiItem::onSizeChanged()
{ {
// I whish I could find a way to let Qt automatically resize the wid get // I wish I could find a way to let Qt automatically resize the widget
// when the QDeclarativeItem size changes. // when the QDeclarativeItem size changes.
widget->setGeometry(0, 0, width(), height()); widget->setGeometry(0, 0, width(), height());
StelApp::getInstance().getGui()->forceRefreshGui(); StelApp::getInstance().getGui()->forceRefreshGui();
} }
#if STEL_USE_NEW_OPENGL_WIDGETS
class StelQOpenGLWidget : public QOpenGLWidget
{
public:
StelQOpenGLWidget(QWidget* parent) : QOpenGLWidget(parent)
{
// TODO: Unclear if tese attributes make sense?
setAttribute(Qt::WA_PaintOnScreen);
setAttribute(Qt::WA_NoSystemBackground);
setAttribute(Qt::WA_OpaquePaintEvent);
}
protected:
virtual void initializeGL()
{
qDebug() << "It appears this was never called?";
qDebug() << "OpenGL supported version: " << QString((char*)glGetStri
ng(GL_VERSION));
QOpenGLWidget::initializeGL();
this->makeCurrent(); // Do we need this?
// GZ I have no idea how to proceed, sorry.
QSurfaceFormat format=this->format();
qDebug() << "Current Format: " << this->format();
// TODO: Test something? The old tests may be obsolete as all OpenGL
2 formats/contexts have these?
}
virtual void paintGL()
{
// TODO: what shall this do exactly?
}
virtual void resizeGL()
{
// TODO: what shall this do exactly?
}
};
#else
class StelQGLWidget : public QGLWidget class StelQGLWidget : public QGLWidget
{ {
public: public:
StelQGLWidget(QGLContext* ctx, QWidget* parent) : QGLWidget(ctx, par ent) StelQGLWidget(QGLContext* ctx, QWidget* parent) : QGLWidget(ctx, par ent)
{ {
setAttribute(Qt::WA_PaintOnScreen); setAttribute(Qt::WA_PaintOnScreen);
setAttribute(Qt::WA_NoSystemBackground); setAttribute(Qt::WA_NoSystemBackground);
setAttribute(Qt::WA_OpaquePaintEvent); setAttribute(Qt::WA_OpaquePaintEvent);
} }
skipping to change at line 265 skipping to change at line 318
qDebug() << "Current Context: " << this->format(); qDebug() << "Current Context: " << this->format();
if (!format().stencil()) if (!format().stencil())
qWarning("Could not get stencil buffer; results will be suboptimal"); qWarning("Could not get stencil buffer; results will be suboptimal");
if (!format().depth()) if (!format().depth())
qWarning("Could not get depth buffer; results will b e suboptimal"); qWarning("Could not get depth buffer; results will b e suboptimal");
if (!format().doubleBuffer()) if (!format().doubleBuffer())
qWarning("Could not get double buffer; results will be suboptimal"); qWarning("Could not get double buffer; results will be suboptimal");
} }
}; };
#endif
StelMainView::StelMainView(QWidget* parent) StelMainView::StelMainView(QWidget* parent)
: QDeclarativeView(parent), gui(NULL), : QDeclarativeView(parent), gui(NULL),
flagInvertScreenShotColors(false), flagInvertScreenShotColors(false),
screenShotPrefix("stellarium-"), screenShotPrefix("stellarium-"),
screenShotDir(""), screenShotDir(""),
cursorTimeout(-1.f), flagCursorTimeout(false), minFpsTimer(NULL), maxfps(10000.f) cursorTimeout(-1.f), flagCursorTimeout(false), minFpsTimer(NULL), maxfps(10000.f)
{ {
StelApp::initStatic(); StelApp::initStatic();
skipping to change at line 293 skipping to change at line 347
// Allows for precise FPS control // Allows for precise FPS control
setViewportUpdateMode(QGraphicsView::NoViewportUpdate); setViewportUpdateMode(QGraphicsView::NoViewportUpdate);
setFrameShape(QFrame::NoFrame); setFrameShape(QFrame::NoFrame);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setFocusPolicy(Qt::StrongFocus); setFocusPolicy(Qt::StrongFocus);
connect(this, SIGNAL(screenshotRequested()), this, SLOT(doScreenshot ())); connect(this, SIGNAL(screenshotRequested()), this, SLOT(doScreenshot ()));
lastEventTimeSec = 0; lastEventTimeSec = 0;
#if STEL_USE_NEW_OPENGL_WIDGETS
// Primary test for OpenGL existence
if (QSurfaceFormat::defaultFormat().majorVersion() < 2)
{
qWarning() << "No OpenGL 2 support on this system. Aborting.
";
QMessageBox::critical(0, "Stellarium", q_("No OpenGL 2 found
on this system. Please upgrade hardware or use MESA or an older version.")
, QMessageBox::Abort, QMessageBox::Abort);
exit(0);
}
//QSurfaceFormat format();
//// TBD: What options shall be default?
//QSurfaceFormat::setDefaultFormat(format);
////QOpenGLContext* context=new QOpenGLContext::create();
glWidget = new StelQOpenGLWidget(this);
//glWidget->setFormat(format);
#else
// Primary test for OpenGL existence
if (QGLFormat::openGLVersionFlags() < QGLFormat::OpenGL_Version_2_1)
{
qWarning() << "No OpenGL 2.1 support on this system. Abortin
g.";
QMessageBox::critical(0, "Stellarium", q_("No OpenGL 2 found
on this system. Please upgrade hardware or use MESA or an older version.")
, QMessageBox::Abort, QMessageBox::Abort);
exit(1);
}
// Create an openGL viewport // Create an openGL viewport
QGLFormat glFormat(QGL::StencilBuffer | QGL::DepthBuffer | QGL::Doub leBuffer); QGLFormat glFormat(QGL::StencilBuffer | QGL::DepthBuffer | QGL::Doub leBuffer);
glWidget = new StelQGLWidget(new QGLContext(glFormat), this); // Even if setting a version here, it is ignored in StelQGLWidget()!
// TBD: Maybe this must make a differentiation between OpenGL and Op
enGL ES!
// glFormat.setVersion(2, 1);
QGLContext* context=new QGLContext(glFormat);
if (context->format() != glFormat)
{
qWarning() << "Cannot provide OpenGL context. Apparently ins
ufficient OpenGL resources on this system.";
QMessageBox::critical(0, "Stellarium", q_("Cannot acquire ne
cessary OpenGL resources."), QMessageBox::Abort, QMessageBox::Abort);
exit(1);
}
glWidget = new StelQGLWidget(context, this);
// This does not return the version number set previously!
// qDebug() << "glWidget.context.format.version, result:" << glWidge
t->context()->format().majorVersion() << "." << glWidget->context()->format
().minorVersion();
#endif
setViewport(glWidget); setViewport(glWidget);
// Workaround (see Bug #940638) Although we have already explicitly set // Workaround (see Bug #940638) Although we have already explicitly set
// LC_NUMERIC to "C" in main.cpp there seems to be a bug in OpenGL w here // LC_NUMERIC to "C" in main.cpp there seems to be a bug in OpenGL w here
// it will silently reset LC_NUMERIC to the value of LC_ALL during O penGL // it will silently reset LC_NUMERIC to the value of LC_ALL during O penGL
// initialization. This has been observed on Ubuntu 11.10 under cert ain // initialization. This has been observed on Ubuntu 11.10 under cert ain
// circumstances, so here we set it again just to be on the safe sid e. // circumstances, so here we set it again just to be on the safe sid e.
setlocale(LC_NUMERIC, "C"); setlocale(LC_NUMERIC, "C");
// End workaround // End workaround
} }
skipping to change at line 333 skipping to change at line 426
{ {
StelGuiPluginInterface* pluginInterface = qobject_cast<StelG uiPluginInterface*>(plugin); StelGuiPluginInterface* pluginInterface = qobject_cast<StelG uiPluginInterface*>(plugin);
if (pluginInterface) if (pluginInterface)
{ {
gui = pluginInterface->getStelGuiBase(); gui = pluginInterface->getStelGuiBase();
} }
break; break;
} }
Q_ASSERT(gui); Q_ASSERT(gui);
#if STEL_USE_NEW_OPENGL_WIDGETS
//glWidget->initializeGL(); // protected...
//Q_ASSERT(glWidget->isValid());
#else
Q_ASSERT(glWidget->isValid()); Q_ASSERT(glWidget->isValid());
glWidget->makeCurrent(); glWidget->makeCurrent();
#endif
// Debug info about supported version of OpenGL and vendor/renderer // Should be check of requirements disabled?
qDebug() << "OpenGL versions supported:" << getSupportedOpenGLVersio if (conf->value("main/check_requirements", true).toBool())
n(); {
qDebug() << "Driver version string:" << QString(reinterpret_cast<con // Find out lots of debug info about supported version of Op
st char*>(glGetString(GL_VERSION))); enGL and vendor/renderer.
qDebug() << "GL vendor is" << QString(reinterpret_cast<const char*>( processOpenGLdiagnosticsAndWarnings(conf, glWidget);
glGetString(GL_VENDOR))); }
qDebug() << "GL renderer is" << QString(reinterpret_cast<const char*
>(glGetString(GL_RENDERER)));
qDebug() << "GL Shading Language version is" << QString(reinterpret_
cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION)));
// Only give extended info if called on command line, for diagnostic
.
if (qApp->property("dump_OpenGL_details").toBool())
dumpOpenGLdiagnostics();
stelApp= new StelApp(); stelApp= new StelApp();
stelApp->setGui(gui); stelApp->setGui(gui);
stelApp->init(conf); stelApp->init(conf);
StelActionMgr *actionMgr = stelApp->getStelActionManager(); StelActionMgr *actionMgr = stelApp->getStelActionManager();
actionMgr->addAction("actionSave_Screenshot_Global", N_("Miscellaneo us"), N_("Save screenshot"), this, "saveScreenShot()", "Ctrl+S"); actionMgr->addAction("actionSave_Screenshot_Global", N_("Miscellaneo us"), N_("Save screenshot"), this, "saveScreenShot()", "Ctrl+S");
actionMgr->addAction("actionSet_Full_Screen_Global", N_("Display Opt ions"), N_("Full-screen mode"), this, "fullScreen", "F11"); actionMgr->addAction("actionSet_Full_Screen_Global", N_("Display Opt ions"), N_("Full-screen mode"), this, "fullScreen", "F11");
StelPainter::initGLShaders(); StelPainter::initGLShaders();
skipping to change at line 398 skipping to change at line 492
flagMaxFpsUpdatePending = false; flagMaxFpsUpdatePending = false;
// XXX: This should be done in StelApp::init(), unfortunately for th e moment we need init the gui before the // XXX: This should be done in StelApp::init(), unfortunately for th e moment we need init the gui before the
// plugins, because the gui create the QActions needed by some plugi ns. // plugins, because the gui create the QActions needed by some plugi ns.
StelApp::getInstance().initPlugIns(); StelApp::getInstance().initPlugIns();
QThread::currentThread()->setPriority(QThread::HighestPriority); QThread::currentThread()->setPriority(QThread::HighestPriority);
startMainLoop(); startMainLoop();
} }
QString StelMainView::getSupportedOpenGLVersion() const // This is a series of various diagnostics based on "bugs" reported for 0.1
{ 3.0 and 0.13.1.
int version = QGLFormat::openGLVersionFlags(); // Almost all can be traced to insufficient driver level.
QStringList ver; // No changes of OpenGL state is done here.
// If problems are detected, warn the user one time, but continue. Warning
panel will be suppressed on next start.
// Work in progress, as long as we get reports about bad systems or until O
penGL startup is finalized and safe.
// Several tests do not apply to MacOS X.
#if STEL_USE_NEW_OPENGL_WIDGETS
void StelMainView::processOpenGLdiagnosticsAndWarnings(QSettings *co
nf, StelQOpenGLWidget* glWidget) const;
#else
void StelMainView::processOpenGLdiagnosticsAndWarnings(QSettings *co
nf, StelQGLWidget* glWidget) const
#endif
{
QOpenGLContext* context=glWidget->context()->contextHandle();
QSurfaceFormat format=context->format();
// These tests are not required on MacOS X
#ifndef Q_OS_MAC
bool openGLerror=false;
if (format.renderableType()==QSurfaceFormat::OpenGL || format.render
ableType()==QSurfaceFormat::OpenGLES)
{
qDebug() << "Detected:" << (format.renderableType()==QSurfac
eFormat::OpenGL ? "OpenGL" : "OpenGL ES" ) << QString("%1.%2").arg(format.
majorVersion()).arg(format.minorVersion());
}
else
{
openGLerror=true;
qDebug() << "Neither OpenGL nor OpenGL ES detected: Unsuppor
ted Format!";
}
#endif
if (version&QGLFormat::OpenGL_Version_1_1) QString glDriver(reinterpret_cast<const char*>(glGetString(GL_VERSIO
ver << "1.1"; N)));
if (version&QGLFormat::OpenGL_Version_1_2) qDebug() << "Driver version string:" << glDriver;
ver << "1.2"; qDebug() << "GL vendor is" << QString(reinterpret_cast<const char*>(
if (version&QGLFormat::OpenGL_Version_1_3) glGetString(GL_VENDOR)));
ver << "1.3"; QString glRenderer(reinterpret_cast<const char*>(glGetString(GL_REND
if (version&QGLFormat::OpenGL_Version_1_4) ERER)));
ver << "1.4"; qDebug() << "GL renderer is" << glRenderer;
if (version&QGLFormat::OpenGL_Version_1_5) bool isMesa=glDriver.contains("Mesa", Qt::CaseInsensitive);
ver << "1.5";
if (version&QGLFormat::OpenGL_Version_2_0) // Minimal required version of OpenGL for Qt5 is 2.1 and OpenGL Shad
ver << "2.0"; ing Language may be 1.20 (or OpenGL ES is 2.0 and GLSL ES is 1.0).
if (version&QGLFormat::OpenGL_Version_2_1) // As of V0.13.0..1, we use GLSL 1.10/GLSL ES 1.00 (implicitly, by o
ver << "2.1"; mitting a #version line), but in case of using ANGLE we need hardware
if (version&QGLFormat::OpenGL_Version_3_0) // detected as providing ps_3_0.
ver << "3.0"; // This means, usually systems with OpenGL3 support reported in the
if (version&QGLFormat::OpenGL_Version_3_1) driver will work, those with reported 2.1 only will almost certainly fail.
ver << "3.1"; // If platform does not even support minimal OpenGL version for Qt5,
if (version&QGLFormat::OpenGL_Version_3_2) then tell the user about troubles and quit from application.
ver << "3.2"; // This test is apparently not applicable on MacOS X due to its beha
if (version&QGLFormat::OpenGL_Version_3_3) ving differently from all other known OSes.
ver << "3.3"; // The correct way to handle driver issues on MacOS X remains howeve
if (version&QGLFormat::OpenGL_Version_4_0) r unclear for now.
ver << "4.0"; #ifndef Q_OS_MAC
if (version&QGLFormat::OpenGL_Version_4_1) if ( openGLerror ||
ver << "4.1"; ((format.renderableType()==QSurfaceFormat::OpenGL ) && (format
if (version&QGLFormat::OpenGL_Version_4_2) .version() < QPair<int, int>(2, 1)) && !isMesa) ||
ver << "4.2"; ((format.renderableType()==QSurfaceFormat::OpenGL ) && (format
if (version&QGLFormat::OpenGL_Version_4_3) .version() < QPair<int, int>(2, 0)) && isMesa) || // Mesa defaults to 2.0
ver << "4.3"; but works!
if (version&QGLFormat::OpenGL_ES_CommonLite_Version_1_0) ((format.renderableType()==QSurfaceFormat::OpenGLES) && (format
ver << "1.0 (ES CL)"; .version() < QPair<int, int>(2, 0))) )
if (version&QGLFormat::OpenGL_ES_CommonLite_Version_1_1) {
ver << "1.1 (ES CL)"; #ifdef Q_OS_WIN
if (version&QGLFormat::OpenGL_ES_Common_Version_1_0) qWarning() << "Oops... Insufficient OpenGL version. Please u
ver << "1.0 (ES C)"; pdate drivers, graphics hardware, or use MESA (or ANGLE) version.";
if (version&QGLFormat::OpenGL_ES_Common_Version_1_1) QMessageBox::critical(0, "Stellarium", q_("Insufficient Open
ver << "1.1 (ES C)"; GL version. Please update drivers, graphics hardware, or use MESA (or ANGLE
if (version&QGLFormat::OpenGL_ES_Version_2_0) ) version."), QMessageBox::Abort, QMessageBox::Abort);
ver << "2.0 (ES)"; #else
qWarning() << "Oops... Insufficient OpenGL version. Please u
pdate drivers, or graphics hardware.";
QMessageBox::critical(0, "Stellarium", q_("Insufficient Open
GL version. Please update drivers, or graphics hardware."), QMessageBox::Ab
ort, QMessageBox::Abort);
#endif
exit(1);
}
#endif
// This call requires OpenGL2+.
QString glslString(reinterpret_cast<const char*>(glGetString(GL_SHAD
ING_LANGUAGE_VERSION)));
qDebug() << "GL Shading Language version is" << glslString;
// Only give extended info if called on command line, for diagnostic
.
if (qApp->property("dump_OpenGL_details").toBool())
dumpOpenGLdiagnostics();
#ifdef Q_OS_WIN
// If we have ANGLE, check esp. for insufficient ps_2 level.
if (glRenderer.startsWith("ANGLE"))
{
QRegExp angleVsPsRegExp(" vs_(\\d)_(\\d) ps_(\\d)_(\\d)");
int angleVSPSpos=angleVsPsRegExp.indexIn(glRenderer);
return ver.join(", "); if (angleVSPSpos >-1)
{
float vsVersion=angleVsPsRegExp.cap(1).toFloat() + 0
.1*angleVsPsRegExp.cap(2).toFloat();
float psVersion=angleVsPsRegExp.cap(3).toFloat() + 0
.1*angleVsPsRegExp.cap(4).toFloat();
qDebug() << "VS Version Number after parsing: " << v
sVersion;
qDebug() << "PS Version Number after parsing: " << p
sVersion;
if ((vsVersion<2.0) || (psVersion<3.0))
{
openGLerror=true;
qDebug() << "This is not enough: we need Dir
ectX9 with vs_2_0 and ps_3_0 or later.";
qDebug() << "You should update graphics driv
ers, graphics hardware, or use the OpenGL-MESA version.";
qDebug() << "Else, please try to use an olde
r version like 0.12.4, and try there with --safe-mode";
if (conf->value("main/ignore_opengl_warning"
, false).toBool())
{
qDebug() << "Config option main/igno
re_opengl_warning found, continuing. Expect problems.";
}
else
{
qDebug() << "You can try to run in a
n unsupported degraded mode by ignoring the warning and continuing.";
qDebug() << "But more than likely pr
oblems will persist.";
QMessageBox::StandardButton answerBu
tton=
QMessageBox::critical(0, "Stellarium
", q_("Your DirectX/OpenGL ES subsystem has problems. See log for details.\
nIgnore and suppress this notice in the future and try to continue in degra
ded mode anyway?"),
QMessageBox::I
gnore|QMessageBox::Abort, QMessageBox::Abort);
if (answerButton == QMessageBox::Abo
rt)
{
qDebug() << "Aborting due to
ANGLE OpenGL ES / DirectX vs or ps version problems.";
exit(1);
}
else
{
qDebug() << "Ignoring all wa
rnings, continuing without further question.";
conf->setValue("main/ignore_
opengl_warning", true);
}
}
}
else
qDebug() << "vs/ps version is fine, we shoul
d not see a graphics problem.";
}
else
{
qDebug() << "Cannot parse ANGLE shader version strin
g. This may indicate future problems.";
qDebug() << "Please send a bug report that includes
this log file and states if Stellarium runs or has problems.";
}
}
#endif
#ifndef Q_OS_MAC
// Do a similar test for MESA: Ensure we have at least Mesa 10, Mesa
9 on FreeBSD (used for hardware-acceleration of AMD IGP) was reported to l
ose the stars.
if (isMesa)
{
QRegExp mesaRegExp("Mesa (\\d+\\.\\d+)"); // we need only ma
jor version. Minor should always be here. Test?
int mesaPos=mesaRegExp.indexIn(glDriver);
if (mesaPos >-1)
{
float mesaVersion=mesaRegExp.cap(1).toFloat();
qDebug() << "MESA Version Number after parsing: " <<
mesaVersion;
if ((mesaVersion<10.0f))
{
openGLerror=true;
qDebug() << "This is not enough: we need Mes
a 10.0 or later.";
qDebug() << "You should update graphics driv
ers or graphics hardware.";
qDebug() << "Else, please try to use an olde
r version like 0.12.4, and try there with --safe-mode";
if (conf->value("main/ignore_opengl_warning"
, false).toBool())
{
qDebug() << "Config option main/igno
re_opengl_warning found, continuing. Expect problems.";
}
else
{
qDebug() << "You can try to run in a
n unsupported degraded mode by ignoring the warning and continuing.";
qDebug() << "But more than likely pr
oblems will persist.";
QMessageBox::StandardButton answerBu
tton=
QMessageBox::critical(0, "Stellarium
", q_("Your OpenGL/Mesa subsystem has problems. See log for details.\nIgnor
e and suppress this notice in the future and try to continue in degraded mo
de anyway?"),
QMessageBox::I
gnore|QMessageBox::Abort, QMessageBox::Abort);
if (answerButton == QMessageBox::Abo
rt)
{
qDebug() << "Aborting due to
OpenGL/Mesa insufficient version problems.";
exit(1);
}
else
{
qDebug() << "Ignoring all wa
rnings, continuing without further question.";
conf->setValue("main/ignore_
opengl_warning", true);
}
}
}
else
qDebug() << "Mesa version is fine, we should
not see a graphics problem.";
}
else
{
qDebug() << "Cannot parse Mesa Driver version string
. This may indicate future problems.";
qDebug() << "Please send a bug report that includes
this log file and states if Stellarium runs or has problems.";
}
}
#endif
// Although our shaders are only GLSL1.10, there are frequent proble
ms with systems just at this level of programmable shaders.
// If GLSL version is less than 1.30 or GLSL ES 1.00, Stellarium usu
ally does run properly on Windows or various Linux flavours.
// Depending on whatever driver/implementation details, Stellarium m
ay crash or show only minor graphical errors.
// On these systems, we show a warning panel that can be suppressed
by a config option which is automatically added on first run.
// Again, based on a sample size of one, Macs have been reported alr
eady to always work in this case.
#ifndef Q_OS_MAC
QRegExp glslRegExp("^(\\d\\.\\d\\d)");
int pos=glslRegExp.indexIn(glslString);
QRegExp glslesRegExp("ES (\\d\\.\\d\\d)");
int posES=glslesRegExp.indexIn(glslString);
if (pos >-1)
{
float glslVersion=glslRegExp.cap(1).toFloat();
qDebug() << "GLSL Version Number after parsing: " << glslVer
sion;
if (glslVersion<1.3f)
{
openGLerror=true;
qDebug() << "This is not enough: we need GLSL1.30 or
later.";
qDebug() << "You should update graphics drivers, gra
phics hardware, or use the MESA version.";
qDebug() << "Else, please try to use an older versio
n like 0.12.4, and try there with --safe-mode";
if (conf->value("main/ignore_opengl_warning", false)
.toBool())
{
qDebug() << "Config option main/ignore_openg
l_warning found, continuing. Expect problems.";
}
else
{
qDebug() << "You can try to run in an unsupp
orted degraded mode by ignoring the warning and continuing.";
qDebug() << "But more than likely problems w
ill persist.";
QMessageBox::StandardButton answerButton=
QMessageBox::critical(0, "Stellarium", q_("Y
our OpenGL subsystem has problems. See log for details.\nIgnore and suppres
s this notice in the future and try to continue in degraded mode anyway?"),
QMessageBox::Ignore|QM
essageBox::Abort, QMessageBox::Abort);
if (answerButton == QMessageBox::Abort)
{
qDebug() << "Aborting due to OpenGL/
GLSL version problems.";
exit(1);
}
else
{
qDebug() << "Ignoring all warnings,
continuing without further question.";
conf->setValue("main/ignore_opengl_w
arning", true);
}
}
}
else
qDebug() << "GLSL version is fine, we should not see
a graphics problem.";
}
else if (posES >-1)
{
float glslesVersion=glslesRegExp.cap(1).toFloat();
qDebug() << "GLSL ES Version Number after parsing: " << glsl
esVersion;
if (glslesVersion<1.0) // TBD: is this possible at all?
{
openGLerror=true;
qDebug() << "This is not enough: we need GLSL ES 1.0
0 or later.";
qDebug() << "You should update graphics drivers, gra
phics hardware, or use the OpenGL-MESA version.";
qDebug() << "Else, please try to use an older versio
n like 0.12.4, and try there with --safe-mode";
if (conf->value("main/ignore_opengl_warning", false)
.toBool())
{
qDebug() << "Config option main/ignore_openg
l_warning found, continuing. Expect problems.";
}
else
{
qDebug() << "You can try to run in an unsupp
orted degraded mode by ignoring the warning and continuing.";
qDebug() << "But more than likely problems w
ill persist.";
QMessageBox::StandardButton answerButton=
QMessageBox::critical(0, "Stellarium", q_("Y
our OpenGL ES subsystem has problems. See log for details.\nIgnore and supp
ress this notice in the future and try to continue in degraded mode anyway?
"),
QMessageBox::Ignore|QM
essageBox::Abort, QMessageBox::Abort);
if (answerButton == QMessageBox::Abort)
{
qDebug() << "Aborting due to OpenGL
ES/GLSL ES version problems.";
exit(1);
}
else
{
qDebug() << "Ignoring all warnings,
continuing without further question.";
conf->setValue("main/ignore_opengl_w
arning", true);
}
}
}
else
{
if (openGLerror)
qDebug() << "GLSL ES version is OK, but ther
e were previous errors, expect problems.";
else
qDebug() << "GLSL ES version is fine, we sho
uld not see a graphics problem.";
}
}
else
{
qDebug() << "Cannot parse GLSL (ES) version string. This may
indicate future problems.";
qDebug() << "Please send a bug report that includes this log
file and states if Stellarium works or has problems.";
}
#endif
} }
// Debug info about OpenGL capabilities.
void StelMainView::dumpOpenGLdiagnostics() const void StelMainView::dumpOpenGLdiagnostics() const
{ {
// GZ: Debug info about OpenGL capabilities.
QOpenGLContext *context = QOpenGLContext::currentContext(); QOpenGLContext *context = QOpenGLContext::currentContext();
if (context) if (context)
{ {
context->functions()->initializeOpenGLFunctions(); context->functions()->initializeOpenGLFunctions();
qDebug() << "initializeOpenGLFunctions()..."; qDebug() << "initializeOpenGLFunctions()...";
} }
else else
qDebug() << "No OpenGL context"; qDebug() << "dumpOpenGLdiagnostics(): No OpenGL context";
QOpenGLFunctions::OpenGLFeatures oglFeatures=context->functions()->o penGLFeatures(); QOpenGLFunctions::OpenGLFeatures oglFeatures=context->functions()->o penGLFeatures();
qDebug() << "OpenGL Features:"; qDebug() << "OpenGL Features:";
qDebug() << " - glActiveTexture() function" << (oglFeatures&QOpenGLF unctions::Multitexture ? "is" : "is NOT") << "available."; qDebug() << " - glActiveTexture() function" << (oglFeatures&QOpenGLF unctions::Multitexture ? "is" : "is NOT") << "available.";
qDebug() << " - Shader functions" << (oglFeatures&QOpenGLFunctions:: Shaders ? "are" : "are NOT ") << "available."; qDebug() << " - Shader functions" << (oglFeatures&QOpenGLFunctions:: Shaders ? "are" : "are NOT ") << "available.";
qDebug() << " - Vertex and index buffer functions" << (oglFeatures&Q OpenGLFunctions::Buffers ? "are" : "are NOT") << "available."; qDebug() << " - Vertex and index buffer functions" << (oglFeatures&Q OpenGLFunctions::Buffers ? "are" : "are NOT") << "available.";
qDebug() << " - Framebuffer object functions" << (oglFeatures&QOpenG LFunctions::Framebuffers ? "are" : "are NOT") << "available."; qDebug() << " - Framebuffer object functions" << (oglFeatures&QOpenG LFunctions::Framebuffers ? "are" : "are NOT") << "available.";
qDebug() << " - glBlendColor()" << (oglFeatures&QOpenGLFunctions::Bl endColor ? "is" : "is NOT") << "available."; qDebug() << " - glBlendColor()" << (oglFeatures&QOpenGLFunctions::Bl endColor ? "is" : "is NOT") << "available.";
qDebug() << " - glBlendEquation()" << (oglFeatures&QOpenGLFunctions: :BlendEquation ? "is" : "is NOT") << "available."; qDebug() << " - glBlendEquation()" << (oglFeatures&QOpenGLFunctions: :BlendEquation ? "is" : "is NOT") << "available.";
qDebug() << " - glBlendEquationSeparate()" << (oglFeatures&QOpenGLFu nctions::BlendEquationSeparate ? "is" : "is NOT") << "available."; qDebug() << " - glBlendEquationSeparate()" << (oglFeatures&QOpenGLFu nctions::BlendEquationSeparate ? "is" : "is NOT") << "available.";
skipping to change at line 499 skipping to change at line 813
QSetIterator<QByteArray> iter(extensionSet); QSetIterator<QByteArray> iter(extensionSet);
while (iter.hasNext()) while (iter.hasNext())
{ {
if (!iter.peekNext().isEmpty()) // Don't insert empty lines if (!iter.peekNext().isEmpty()) // Don't insert empty lines
extensionMap.insert(QString(iter.peekNext()), QStrin g(iter.peekNext())); extensionMap.insert(QString(iter.peekNext()), QStrin g(iter.peekNext()));
iter.next(); iter.next();
} }
QMapIterator<QString, QString> iter2(extensionMap); QMapIterator<QString, QString> iter2(extensionMap);
while (iter2.hasNext()) while (iter2.hasNext())
qDebug() << " -" << iter2.next().key(); qDebug() << " -" << iter2.next().key();
// Apparently EXT_gpu_shader4 is required for GLSL1.3. (http://en.wi
kipedia.org/wiki/OpenGL#OpenGL_3.0).
qDebug() << "EXT_gpu_shader4" << (extensionSet.contains(("EXT_gpu_sh
ader4")) ? "present, OK." : "MISSING!");
QFunctionPointer programParameterPtr =context->getProcAddress("glPro gramParameteri"); QFunctionPointer programParameterPtr =context->getProcAddress("glPro gramParameteri");
if (programParameterPtr == 0) if (programParameterPtr == 0)
qDebug() << "glProgramParameteri cannot be resolved here. BA D!"; qDebug() << "glProgramParameteri cannot be resolved here. BA D!";
//else //else
// qDebug() << "glProgramParameteri can be resolved. GOOD!"; // qDebug() << "glProgramParameteri can be resolved. GOOD!";
programParameterPtr =context->getProcAddress("glProgramParameteriEXT "); programParameterPtr =context->getProcAddress("glProgramParameteriEXT ");
if (programParameterPtr == 0) if (programParameterPtr == 0)
qDebug() << "glProgramParameteriEXT cannot be resolved here. BAD!"; qDebug() << "glProgramParameteriEXT cannot be resolved here. BAD!";
//else //else
skipping to change at line 621 skipping to change at line 937
} }
minFpsTimer = new QTimer(this); minFpsTimer = new QTimer(this);
connect(minFpsTimer, SIGNAL(timeout()), this, SLOT(updateScene())); connect(minFpsTimer, SIGNAL(timeout()), this, SLOT(updateScene()));
minFpsTimer->start((int)(1./getMinFps()*1000.)); minFpsTimer->start((int)(1./getMinFps()*1000.));
} }
void StelMainView::mouseMoveEvent(QMouseEvent* event) void StelMainView::mouseMoveEvent(QMouseEvent* event)
{ {
if (event->buttons()) // We notify the applicatio to increase the fps if a button has been
// clicked, but also if the cursor is currently hidden, so that it g
ets
// restored.
if (event->buttons() || QGuiApplication::overrideCursor()!=0)
thereWasAnEvent(); // Refresh screen ASAP thereWasAnEvent(); // Refresh screen ASAP
QDeclarativeView::mouseMoveEvent(event); QDeclarativeView::mouseMoveEvent(event);
} }
void StelMainView::mousePressEvent(QMouseEvent* event) void StelMainView::mousePressEvent(QMouseEvent* event)
{ {
thereWasAnEvent(); // Refresh screen ASAP thereWasAnEvent(); // Refresh screen ASAP
QDeclarativeView::mousePressEvent(event); QDeclarativeView::mousePressEvent(event);
} }
skipping to change at line 694 skipping to change at line 1013
void StelMainView::saveScreenShot(const QString& filePrefix, const QString& saveDir) void StelMainView::saveScreenShot(const QString& filePrefix, const QString& saveDir)
{ {
screenShotPrefix = filePrefix; screenShotPrefix = filePrefix;
screenShotDir = saveDir; screenShotDir = saveDir;
emit(screenshotRequested()); emit(screenshotRequested());
} }
void StelMainView::doScreenshot(void) void StelMainView::doScreenshot(void)
{ {
QFileInfo shotDir; QFileInfo shotDir;
#if STEL_USE_NEW_OPENGL_WIDGETS
QImage im = glWidget->grabFramebuffer();
#else
QImage im = glWidget->grabFrameBuffer(); QImage im = glWidget->grabFrameBuffer();
#endif
if (flagInvertScreenShotColors) if (flagInvertScreenShotColors)
im.invertPixels(); im.invertPixels();
if (screenShotDir == "") if (screenShotDir == "")
shotDir = QFileInfo(StelFileMgr::getScreenshotDir()); shotDir = QFileInfo(StelFileMgr::getScreenshotDir());
else else
shotDir = QFileInfo(screenShotDir); shotDir = QFileInfo(screenShotDir);
if (!shotDir.isDir()) if (!shotDir.isDir())
{ {
skipping to change at line 727 skipping to change at line 1050
shotPath = QFileInfo(shotDir.filePath() + "/" + screenShotPr efix + QString("%1").arg(j, 3, 10, QLatin1Char('0')) + ".png"); shotPath = QFileInfo(shotDir.filePath() + "/" + screenShotPr efix + QString("%1").arg(j, 3, 10, QLatin1Char('0')) + ".png");
if (!shotPath.exists()) if (!shotPath.exists())
break; break;
} }
qDebug() << "INFO Saving screenshot in file: " << QDir::toNativeSepa rators(shotPath.filePath()); qDebug() << "INFO Saving screenshot in file: " << QDir::toNativeSepa rators(shotPath.filePath());
if (!im.save(shotPath.filePath())) { if (!im.save(shotPath.filePath())) {
qWarning() << "WARNING failed to write screenshot to: " << Q Dir::toNativeSeparators(shotPath.filePath()); qWarning() << "WARNING failed to write screenshot to: " << Q Dir::toNativeSeparators(shotPath.filePath());
} }
} }
QPoint StelMainView::getMousePos()
{
return glWidget->mapFromGlobal(QCursor::pos());
}
 End of changes. 31 change blocks. 
67 lines changed or deleted 516 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/