StelMainView.cpp   StelMainView.cpp 
skipping to change at line 33 skipping to change at line 33
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include "StelGui.hpp" #include "StelGui.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 <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
#if STEL_USE_NEW_OPENGL_WIDGETS #if STEL_USE_NEW_OPENGL_WIDGETS
#include <QOpenGLWidget> #include <QOpenGLWidget>
#else #else
#include <QGLWidget> #include <QGLWidget>
#endif #endif
#include <QApplication> #include <QApplication>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QGuiApplication> #include <QGuiApplication>
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsAnchorLayout>
#include <QGraphicsWidget>
#include <QGraphicsEffect>
#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 <QMessageBox>
#include <QDeclarativeContext>
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#include <QPinchGesture> #include <QPinchGesture>
#endif #endif
#include <QOpenGLShader> #include <QOpenGLShader>
#include <QOpenGLShaderProgram> #include <QOpenGLShaderProgram>
#include <QGLFramebufferObject>
#include <QGLShaderProgram>
#include <clocale> #include <clocale>
// Initialize static variables // Initialize static variables
StelMainView* StelMainView::singleton = NULL; StelMainView* StelMainView::singleton = NULL;
// A custom QGraphicsEffect to apply the night mode on top of the screen.
class NightModeGraphicsEffect : public QGraphicsEffect
{
public:
NightModeGraphicsEffect(QObject* parent = NULL);
protected:
virtual void draw(QPainter* painter);
private:
QGLFramebufferObject* fbo;
QGLShaderProgram *program;
struct {
int pos;
int texCoord;
int source;
} vars;
};
NightModeGraphicsEffect::NightModeGraphicsEffect(QObject* parent) :
QGraphicsEffect(parent)
, fbo(NULL)
{
program = new QGLShaderProgram(this);
QString vertexCode =
"attribute highp vec4 a_pos;\n"
"attribute highp vec2 a_texCoord;\n"
"varying highp vec2 v_texCoord;\n"
"void main(void)\n"
"{\n"
"v_texCoord = a_texCoord;\n"
"gl_Position = a_pos;\n"
"}\n";
QString fragmentCode =
"varying highp vec2 v_texCoord;\n"
"uniform sampler2D u_source;\n"
"void main(void)\n"
"{\n"
" mediump vec3 color = texture2D(u_source, v_texCoord)
.rgb;\n"
" mediump float luminance = max(max(color.r, color.g),
color.b);\n"
" gl_FragColor = vec4(luminance, 0.0, 0.0, 1.0);\n"
"}\n";
program->addShaderFromSourceCode(QGLShader::Vertex, vertexCode);
program->addShaderFromSourceCode(QGLShader::Fragment, fragmentCode);
program->link();
vars.pos = program->attributeLocation("a_pos");
vars.texCoord = program->attributeLocation("a_texCoord");
vars.source = program->uniformLocation("u_source");
}
// Qt 5.5 does not support setting the devicePixelRatio of a QGLFramebuffer
Object,
// So here we make a sub class just so that we can return the correct ratio
when
// using the buffer on a retina display.
class NightModeGraphicsEffectFbo : public QGLFramebufferObject
{
public:
NightModeGraphicsEffectFbo(const QSize& s, const QGLFramebufferObjec
tFormat& f, int pixelRatio_) :
QGLFramebufferObject(s, f), pixelRatio(pixelRatio_) {}
protected:
virtual int metric(PaintDeviceMetric m) const
{
if (m == QPaintDevice::PdmDevicePixelRatio) return pixelRati
o;
return QGLFramebufferObject::metric(m);
}
private:
int pixelRatio;
};
void NightModeGraphicsEffect::draw(QPainter* painter)
{
int pixelRatio = painter->device()->devicePixelRatio();
QSize size(painter->device()->width() * pixelRatio, painter->device(
)->height() * pixelRatio);
if (fbo && fbo->size() != size)
{
delete fbo;
fbo = NULL;
}
if (!fbo)
{
QGLFramebufferObjectFormat format;
format.setAttachment(QGLFramebufferObject::CombinedDepthSten
cil);
format.setInternalTextureFormat(GL_RGBA);
fbo = new NightModeGraphicsEffectFbo(size, format, pixelRati
o);
}
QPainter fboPainter(fbo);
drawSource(&fboPainter);
painter->save();
painter->beginNativePainting();
program->bind();
const GLfloat pos[] = {-1, -1, +1, -1, -1, +1, +1, +1};
const GLfloat texCoord[] = {0, 0, 1, 0, 0, 1, 1, 1};
program->setUniformValue(vars.source, 0);
program->setAttributeArray(vars.pos, pos, 2);
program->setAttributeArray(vars.texCoord, texCoord, 2);
program->enableAttributeArray(vars.pos);
program->enableAttributeArray(vars.texCoord);
glBindTexture(GL_TEXTURE_2D, fbo->texture());
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
program->release();
painter->endNativePainting();
painter->restore();
}
//! Render Stellarium sky. //! Render Stellarium sky.
class StelSkyItem : public QDeclarativeItem class StelSkyItem : public QGraphicsWidget
{ {
public: public:
StelSkyItem(QDeclarativeItem* parent = NULL); StelSkyItem(QGraphicsItem* 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);
void resizeEvent(QGraphicsSceneResizeEvent* event);
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
bool event(QEvent * e); bool event(QEvent * e);
#endif #endif
private: private:
double previousPaintTime; double previousPaintTime;
void onSizeChanged(); // void onSizeChanged();
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
void pinchTriggered(QPinchGesture *gesture); void pinchTriggered(QPinchGesture *gesture);
bool gestureEvent(QGestureEvent *event); bool gestureEvent(QGestureEvent *event);
#endif #endif
}; };
//! Initialize and render Stellarium gui. //! Initialize and render Stellarium gui.
class StelGuiItem : public QDeclarativeItem class StelGuiItem : public QGraphicsWidget
{ {
public: public:
StelGuiItem(QDeclarativeItem* parent = NULL); StelGuiItem(QGraphicsItem* parent = NULL);
protected:
void resizeEvent(QGraphicsSceneResizeEvent* event);
private: private:
QGraphicsWidget *widget; QGraphicsWidget *widget;
void onSizeChanged(); // void onSizeChanged();
}; };
StelSkyItem::StelSkyItem(QDeclarativeItem* parent) StelSkyItem::StelSkyItem(QGraphicsItem* parent)
{ {
Q_UNUSED(parent); Q_UNUSED(parent);
setObjectName("SkyItem"); setObjectName("SkyItem");
setFlag(QGraphicsItem::ItemHasNoContents, false); setFlag(QGraphicsItem::ItemHasNoContents, false);
setFlag(QGraphicsItem::ItemIsFocusable, true);
setAcceptHoverEvents(true); setAcceptHoverEvents(true);
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
setAcceptTouchEvents(true); setAcceptTouchEvents(true);
grabGesture(Qt::PinchGesture); grabGesture(Qt::PinchGesture);
#endif #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::heightChanged, this, &StelSkyItem::onSiz
eChanged);
previousPaintTime = StelApp::getTotalRunTime(); previousPaintTime = StelApp::getTotalRunTime();
StelMainView::getInstance().skyItem = this; setFocus();
setFocus(true);
} }
void StelSkyItem::onSizeChanged() void StelSkyItem::resizeEvent(QGraphicsSceneResizeEvent* event)
{ {
StelApp::getInstance().glWindowHasBeenResized(x(), y(), width(), hei QGraphicsWidget::resizeEvent(event);
ght()); StelApp::getInstance().glWindowHasBeenResized(scenePos().x(), scene(
)->sceneRect().height()-(scenePos().y()+geometry().height()), geometry().wi
dth(), geometry().height());
} }
void StelSkyItem::paint(QPainter *painter, const QStyleOptionGraphicsItem * option, QWidget *widget) void StelSkyItem::paint(QPainter *painter, const QStyleOptionGraphicsItem * option, QWidget *widget)
{ {
Q_UNUSED(option); Q_UNUSED(option);
Q_UNUSED(widget); Q_UNUSED(widget);
const double now = StelApp::getTotalRunTime(); const double now = StelApp::getTotalRunTime();
double dt = now - previousPaintTime; double dt = now - previousPaintTime;
previousPaintTime = now; previousPaintTime = now;
skipping to change at line 147 skipping to change at line 255
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
StelApp::getInstance().update(dt); StelApp::getInstance().update(dt);
StelApp::getInstance().draw(); StelApp::getInstance().draw();
painter->endNativePainting(); painter->endNativePainting();
} }
void StelSkyItem::mousePressEvent(QGraphicsSceneMouseEvent *event) void StelSkyItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
//To get back the focus from dialogs //To get back the focus from dialogs
this->setFocus(true); setFocus();
QPointF pos = event->scenePos(); QPointF pos = event->scenePos();
pos.setY(height() - 1 - pos.y()); pos.setY(size().height() - 1 - pos.y());
QMouseEvent newEvent(QEvent::MouseButtonPress, QPoint(pos.x(), pos.y ()), event->button(), event->buttons(), event->modifiers()); QMouseEvent newEvent(QEvent::MouseButtonPress, QPoint(pos.x(), pos.y ()), event->button(), event->buttons(), event->modifiers());
StelApp::getInstance().handleClick(&newEvent); StelApp::getInstance().handleClick(&newEvent);
} }
void StelSkyItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) void StelSkyItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
{ {
QPointF pos = event->scenePos(); QPointF pos = event->scenePos();
pos.setY(height() - 1 - pos.y()); pos.setY(size().height() - 1 - pos.y());
QMouseEvent newEvent(QEvent::MouseButtonRelease, QPoint(pos.x(), pos .y()), event->button(), event->buttons(), event->modifiers()); QMouseEvent newEvent(QEvent::MouseButtonRelease, QPoint(pos.x(), pos .y()), event->button(), event->buttons(), event->modifiers());
StelApp::getInstance().handleClick(&newEvent); StelApp::getInstance().handleClick(&newEvent);
} }
void StelSkyItem::mouseMoveEvent(QGraphicsSceneMouseEvent* event) void StelSkyItem::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
{ {
QPointF pos = event->scenePos(); QPointF pos = event->scenePos();
pos.setY(height() - 1 - pos.y()); pos.setY(size().height() - 1 - pos.y());
StelApp::getInstance().handleMove(pos.x(), pos.y(), event->buttons() ); StelApp::getInstance().handleMove(pos.x(), pos.y(), event->buttons() );
} }
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(size().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 #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:
skipping to change at line 201 skipping to change at line 309
return true; return true;
break; break;
} }
case QEvent::Gesture: case QEvent::Gesture:
setAcceptedMouseButtons(0); setAcceptedMouseButtons(0);
return gestureEvent(static_cast<QGestureEvent*>(e)); return gestureEvent(static_cast<QGestureEvent*>(e));
break; break;
default: default:
return false; return QGraphicsWidget::event(e);
} }
} }
bool StelSkyItem::gestureEvent(QGestureEvent *event) bool StelSkyItem::gestureEvent(QGestureEvent *event)
{ {
if (QGesture *pinch = event->gesture(Qt::PinchGesture)) if (QGesture *pinch = event->gesture(Qt::PinchGesture))
pinchTriggered(static_cast<QPinchGesture *>(pinch)); pinchTriggered(static_cast<QPinchGesture *>(pinch));
return true; return true;
} }
skipping to change at line 236 skipping to change at line 344
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);
} }
StelGuiItem::StelGuiItem(QDeclarativeItem* parent) : QDeclarativeItem(paren t) StelGuiItem::StelGuiItem(QGraphicsItem* parent) : QGraphicsWidget(parent)
{ {
connect(this, &StelGuiItem::widthChanged, this, &StelGuiItem::onSize
Changed);
connect(this, &StelGuiItem::heightChanged, this, &StelGuiItem::onSiz
eChanged);
widget = new QGraphicsWidget(this); widget = new QGraphicsWidget(this);
StelMainView::getInstance().guiWidget = widget;
StelApp::getInstance().getGui()->init(widget); StelApp::getInstance().getGui()->init(widget);
} }
void StelGuiItem::onSizeChanged() void StelGuiItem::resizeEvent(QGraphicsSceneResizeEvent* event)
{ {
// I wish I could find a way to let Qt automatically resize the widget Q_UNUSED(event);
// when the QDeclarativeItem size changes. widget->setGeometry(0, 0, size().width(), size().height());
widget->setGeometry(0, 0, width(), height());
StelApp::getInstance().getGui()->forceRefreshGui(); StelApp::getInstance().getGui()->forceRefreshGui();
} }
#if STEL_USE_NEW_OPENGL_WIDGETS #if STEL_USE_NEW_OPENGL_WIDGETS
class StelQOpenGLWidget : public QOpenGLWidget class StelQOpenGLWidget : public QOpenGLWidget
{ {
public: public:
StelQOpenGLWidget(QWidget* parent) : QOpenGLWidget(parent) StelQOpenGLWidget(QWidget* parent) : QOpenGLWidget(parent)
{ {
skipping to change at line 323 skipping to change at line 427
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 #endif
StelMainView::StelMainView(QWidget* parent) StelMainView::StelMainView(QWidget* parent)
: QDeclarativeView(parent), gui(NULL), : QGraphicsView(parent), guiItem(NULL), 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();
// Can't create 2 StelMainView instances // Can't create 2 StelMainView instances
Q_ASSERT(!singleton); Q_ASSERT(!singleton);
singleton = this; singleton = this;
skipping to change at line 393 skipping to change at line 497
QMessageBox::critical(0, "Stellarium", q_("Cannot acquire ne cessary OpenGL resources."), QMessageBox::Abort, QMessageBox::Abort); QMessageBox::critical(0, "Stellarium", q_("Cannot acquire ne cessary OpenGL resources."), QMessageBox::Abort, QMessageBox::Abort);
exit(1); exit(1);
} }
glWidget = new StelQGLWidget(context, this); glWidget = new StelQGLWidget(context, this);
// This does not return the version number set previously! // This does not return the version number set previously!
// qDebug() << "glWidget.context.format.version, result:" << glWidge t->context()->format().majorVersion() << "." << glWidget->context()->format ().minorVersion(); // qDebug() << "glWidget.context.format.version, result:" << glWidge t->context()->format().majorVersion() << "." << glWidget->context()->format ().minorVersion();
#endif #endif
setViewport(glWidget); setViewport(glWidget);
setScene(new QGraphicsScene(this));
scene()->setItemIndexMethod(QGraphicsScene::NoIndex);
rootItem = new QGraphicsWidget();
rootItem->setFocusPolicy(Qt::NoFocus);
// 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
} }
void StelMainView::resizeEvent(QResizeEvent* event)
{
scene()->setSceneRect(QRect(QPoint(0, 0), event->size()));
rootItem->setGeometry(0,0,event->size().width(),event->size().height
());
QGraphicsView::resizeEvent(event);
}
void StelMainView::focusSky() { void StelMainView::focusSky() {
StelMainView::getInstance().scene()->setActiveWindow(0); scene()->setActiveWindow(0);
QGraphicsObject* skyItem = rootObject()->findChild<QGraphicsObject*>
("SkyItem");
Q_ASSERT(skyItem);
skyItem->setFocus(); skyItem->setFocus();
} }
StelMainView::~StelMainView() StelMainView::~StelMainView()
{ {
StelApp::deinitStatic(); StelApp::deinitStatic();
} }
void StelMainView::init(QSettings* conf) void StelMainView::init(QSettings* conf)
{ {
skipping to change at line 442 skipping to change at line 556
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();
setResizeMode(QDeclarativeView::SizeRootObjectToView); skyItem = new StelSkyItem();
qmlRegisterType<StelSkyItem>("Stellarium", 1, 0, "StelSky"); guiItem = new StelGuiItem();
qmlRegisterType<StelGuiItem>("Stellarium", 1, 0, "StelGui"); QGraphicsAnchorLayout* l = new QGraphicsAnchorLayout(rootItem);
rootContext()->setContextProperty("stelApp", stelApp); l->setSpacing(0);
setSource(QUrl("qrc:/qml/main.qml")); l->setContentsMargins(0,0,0,0);
l->addCornerAnchors(skyItem, Qt::TopLeftCorner, l, Qt::TopLeftCorner
);
l->addCornerAnchors(skyItem, Qt::BottomRightCorner, l, Qt::BottomRig
htCorner);
l->addCornerAnchors(guiItem, Qt::BottomLeftCorner, l, Qt::BottomLeft
Corner);
l->addCornerAnchors(guiItem, Qt::TopRightCorner, l, Qt::TopRightCorn
er);
rootItem->setLayout(l);
scene()->addItem(rootItem);
nightModeEffect = new NightModeGraphicsEffect(this);
updateNightModeProperty();
rootItem->setGraphicsEffect(nightModeEffect);
QSize size = glWidget->windowHandle()->screen()->size(); QSize size = glWidget->windowHandle()->screen()->size();
size = QSize(conf->value("video/screen_w", size.width()).toInt(), size = QSize(conf->value("video/screen_w", size.width()).toInt(),
conf->value("video/screen_h", size.height()).toInt()); conf->value("video/screen_h", size.height()).toInt());
bool fullscreen = conf->value("video/fullscreen", true).toBool(); bool fullscreen = conf->value("video/fullscreen", true).toBool();
// Without this, the screen is not shown on a Mac + we should use re size() for correct work of fullscreen/windowed mode switch. --AW WTF??? // Without this, the screen is not shown on a Mac + we should use re size() for correct work of fullscreen/windowed mode switch. --AW WTF???
resize(size); resize(size);
skipping to change at line 495 skipping to change at line 618
setFlagCursorTimeout(conf->value("gui/flag_mouse_cursor_timeout", fa lse).toBool()); setFlagCursorTimeout(conf->value("gui/flag_mouse_cursor_timeout", fa lse).toBool());
setCursorTimeout(conf->value("gui/mouse_cursor_timeout", 10.f).toFlo at()); setCursorTimeout(conf->value("gui/mouse_cursor_timeout", 10.f).toFlo at());
maxfps = conf->value("video/maximum_fps",10000.f).toFloat(); maxfps = conf->value("video/maximum_fps",10000.f).toFloat();
minfps = conf->value("video/minimum_fps",10000.f).toFloat(); minfps = conf->value("video/minimum_fps",10000.f).toFloat();
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();
// The script manager can only be fully initialized after the plugin
s have loaded.
StelApp::getInstance().initScriptMgr();
// Set the global stylesheet, this is only useful for the tooltips.
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui(
));
if (gui!=NULL)
setStyleSheet(gui->getStelStyle().qtStyleSheet);
connect(&StelApp::getInstance(), SIGNAL(visionNightModeChanged(bool)
), this, SLOT(updateNightModeProperty()));
QThread::currentThread()->setPriority(QThread::HighestPriority); QThread::currentThread()->setPriority(QThread::HighestPriority);
startMainLoop(); startMainLoop();
} }
void StelMainView::updateNightModeProperty()
{
// So that the bottom bar tooltips get properly rendered in night mo
de.
setProperty("nightMode", StelApp::getInstance().getVisionModeNight()
);
nightModeEffect->setEnabled(StelApp::getInstance().getVisionModeNigh
t());
}
// This is a series of various diagnostics based on "bugs" reported for 0.1 3.0 and 0.13.1. // This is a series of various diagnostics based on "bugs" reported for 0.1 3.0 and 0.13.1.
// Almost all can be traced to insufficient driver level. // Almost all can be traced to insufficient driver level.
// No changes of OpenGL state is done here. // 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. // 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. // 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. // Several tests do not apply to MacOS X.
#if STEL_USE_NEW_OPENGL_WIDGETS #if STEL_USE_NEW_OPENGL_WIDGETS
void StelMainView::processOpenGLdiagnosticsAndWarnings(QSettings *co nf, StelQOpenGLWidget* glWidget) const; void StelMainView::processOpenGLdiagnosticsAndWarnings(QSettings *co nf, StelQOpenGLWidget* glWidget) const;
#else #else
void StelMainView::processOpenGLdiagnosticsAndWarnings(QSettings *co nf, StelQGLWidget* glWidget) const void StelMainView::processOpenGLdiagnosticsAndWarnings(QSettings *co nf, StelQGLWidget* glWidget) const
skipping to change at line 547 skipping to change at line 686
// Minimal required version of OpenGL for Qt5 is 2.1 and OpenGL Shad ing Language may be 1.20 (or OpenGL ES is 2.0 and GLSL ES is 1.0). // Minimal required version of OpenGL for Qt5 is 2.1 and OpenGL Shad ing Language may be 1.20 (or OpenGL ES is 2.0 and GLSL ES is 1.0).
// As of V0.13.0..1, we use GLSL 1.10/GLSL ES 1.00 (implicitly, by o mitting a #version line), but in case of using ANGLE we need hardware // As of V0.13.0..1, we use GLSL 1.10/GLSL ES 1.00 (implicitly, by o mitting a #version line), but in case of using ANGLE we need hardware
// detected as providing ps_3_0. // detected as providing ps_3_0.
// This means, usually systems with OpenGL3 support reported in the driver will work, those with reported 2.1 only will almost certainly fail. // This means, usually systems with OpenGL3 support reported in the driver will work, those with reported 2.1 only will almost certainly fail.
// If platform does not even support minimal OpenGL version for Qt5, then tell the user about troubles and quit from application. // If platform does not even support minimal OpenGL version for Qt5, then tell the user about troubles and quit from application.
// This test is apparently not applicable on MacOS X due to its beha ving differently from all other known OSes. // This test is apparently not applicable on MacOS X due to its beha ving differently from all other known OSes.
// The correct way to handle driver issues on MacOS X remains howeve r unclear for now. // The correct way to handle driver issues on MacOS X remains howeve r unclear for now.
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
bool isMesa=glDriver.contains("Mesa", Qt::CaseInsensitive); bool isMesa=glDriver.contains("Mesa", Qt::CaseInsensitive);
#ifdef Q_OS_WIN
bool isANGLE=glRenderer.startsWith("ANGLE", Qt::CaseSensitive);
#endif
if ( openGLerror || if ( openGLerror ||
((format.renderableType()==QSurfaceFormat::OpenGL ) && (format .version() < QPair<int, int>(2, 1)) && !isMesa) || ((format.renderableType()==QSurfaceFormat::OpenGL ) && (format .version() < QPair<int, int>(2, 1)) && !isMesa) ||
((format.renderableType()==QSurfaceFormat::OpenGL ) && (format .version() < QPair<int, int>(2, 0)) && isMesa) || // Mesa defaults to 2.0 but works! ((format.renderableType()==QSurfaceFormat::OpenGL ) && (format .version() < QPair<int, int>(2, 0)) && isMesa) || // Mesa defaults to 2.0 but works!
((format.renderableType()==QSurfaceFormat::OpenGLES) && (format .version() < QPair<int, int>(2, 0))) ) ((format.renderableType()==QSurfaceFormat::OpenGLES) && (format .version() < QPair<int, int>(2, 0))) )
{ {
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
qWarning() << "Oops... Insufficient OpenGL version. Please u if ((!isANGLE) && (!isMesa))
pdate drivers, graphics hardware, or use MESA (or ANGLE) version."; qWarning() << "Oops... Insufficient OpenGL version.
QMessageBox::critical(0, "Stellarium", q_("Insufficient Open Please update drivers, graphics hardware, or use --angle-mode (or even --me
GL version. Please update drivers, graphics hardware, or use MESA (or ANGLE sa-mode) option.";
) version."), QMessageBox::Abort, QMessageBox::Abort); else if (isANGLE)
qWarning() << "Oops... Insufficient OpenGL version i
n ANGLE. Please update drivers, graphics hardware, or use --mesa-mode optio
n.";
else
qWarning() << "Oops... Insufficient OpenGL version.
Mesa failed! Please send a bug report.";
QMessageBox::critical(0, "Stellarium", q_("Insufficient Open
GL version. Please update drivers, graphics hardware, or use --angle-mode (
or --mesa-mode) option."), QMessageBox::Abort, QMessageBox::Abort);
#else #else
qWarning() << "Oops... Insufficient OpenGL version. Please u pdate drivers, or graphics hardware."; 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); QMessageBox::critical(0, "Stellarium", q_("Insufficient Open GL version. Please update drivers, or graphics hardware."), QMessageBox::Ab ort, QMessageBox::Abort);
#endif #endif
exit(1); exit(1);
} }
#endif #endif
// This call requires OpenGL2+. // This call requires OpenGL2+.
QString glslString(reinterpret_cast<const char*>(glGetString(GL_SHAD ING_LANGUAGE_VERSION))); QString glslString(reinterpret_cast<const char*>(glGetString(GL_SHAD ING_LANGUAGE_VERSION)));
qDebug() << "GL Shading Language version is" << glslString; qDebug() << "GL Shading Language version is" << glslString;
// Only give extended info if called on command line, for diagnostic . // Only give extended info if called on command line, for diagnostic .
if (qApp->property("dump_OpenGL_details").toBool()) if (qApp->property("dump_OpenGL_details").toBool())
dumpOpenGLdiagnostics(); dumpOpenGLdiagnostics();
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
// If we have ANGLE, check esp. for insufficient ps_2 level. // If we have ANGLE, check esp. for insufficient ps_2 level.
if (glRenderer.startsWith("ANGLE")) if (isANGLE)
{ {
QRegExp angleVsPsRegExp(" vs_(\\d)_(\\d) ps_(\\d)_(\\d)"); QRegExp angleVsPsRegExp(" vs_(\\d)_(\\d) ps_(\\d)_(\\d)");
int angleVSPSpos=angleVsPsRegExp.indexIn(glRenderer); int angleVSPSpos=angleVsPsRegExp.indexIn(glRenderer);
if (angleVSPSpos >-1) if (angleVSPSpos >-1)
{ {
float vsVersion=angleVsPsRegExp.cap(1).toFloat() + 0 .1*angleVsPsRegExp.cap(2).toFloat(); float vsVersion=angleVsPsRegExp.cap(1).toFloat() + 0 .1*angleVsPsRegExp.cap(2).toFloat();
float psVersion=angleVsPsRegExp.cap(3).toFloat() + 0 .1*angleVsPsRegExp.cap(4).toFloat(); float psVersion=angleVsPsRegExp.cap(3).toFloat() + 0 .1*angleVsPsRegExp.cap(4).toFloat();
qDebug() << "VS Version Number after parsing: " << v qDebug() << "VS Version Number detected: " << vsVers
sVersion; ion;
qDebug() << "PS Version Number after parsing: " << p qDebug() << "PS Version Number detected: " << psVers
sVersion; ion;
if ((vsVersion<2.0) || (psVersion<3.0)) if ((vsVersion<2.0) || (psVersion<3.0))
{ {
openGLerror=true; openGLerror=true;
qDebug() << "This is not enough: we need Dir ectX9 with vs_2_0 and ps_3_0 or later."; 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 qDebug() << "You should update graphics driv
ers, graphics hardware, or use the OpenGL-MESA version."; ers, graphics hardware, or use the --mesa-mode option.";
qDebug() << "Else, please try to use an olde qDebug() << "Else, please try to use an olde
r version like 0.12.4, and try there with --safe-mode"; r version like 0.12.5, and try with --safe-mode";
if (conf->value("main/ignore_opengl_warning" , false).toBool()) if (conf->value("main/ignore_opengl_warning" , false).toBool())
{ {
qDebug() << "Config option main/igno re_opengl_warning found, continuing. Expect problems."; qDebug() << "Config option main/igno re_opengl_warning found, continuing. Expect problems.";
} }
else else
{ {
qDebug() << "You can try to run in a n unsupported degraded mode by ignoring the warning and continuing."; 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."; qDebug() << "But more than likely pr oblems will persist.";
QMessageBox::StandardButton answerBu tton= QMessageBox::StandardButton answerBu tton=
skipping to change at line 633 skipping to change at line 781
#ifndef Q_OS_MAC #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. // 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) if (isMesa)
{ {
QRegExp mesaRegExp("Mesa (\\d+\\.\\d+)"); // we need only ma jor version. Minor should always be here. Test? QRegExp mesaRegExp("Mesa (\\d+\\.\\d+)"); // we need only ma jor version. Minor should always be here. Test?
int mesaPos=mesaRegExp.indexIn(glDriver); int mesaPos=mesaRegExp.indexIn(glDriver);
if (mesaPos >-1) if (mesaPos >-1)
{ {
float mesaVersion=mesaRegExp.cap(1).toFloat(); float mesaVersion=mesaRegExp.cap(1).toFloat();
qDebug() << "MESA Version Number after parsing: " << mesaVersion; qDebug() << "MESA Version Number detected: " << mesa Version;
if ((mesaVersion<10.0f)) if ((mesaVersion<10.0f))
{ {
openGLerror=true; openGLerror=true;
qDebug() << "This is not enough: we need Mes a 10.0 or later."; qDebug() << "This is not enough: we need Mes a 10.0 or later.";
qDebug() << "You should update graphics driv ers or graphics hardware."; 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"; qDebug() << "Else, please try to use an olde r version like 0.12.5, and try there with --safe-mode";
if (conf->value("main/ignore_opengl_warning" , false).toBool()) if (conf->value("main/ignore_opengl_warning" , false).toBool())
{ {
qDebug() << "Config option main/igno re_opengl_warning found, continuing. Expect problems."; qDebug() << "Config option main/igno re_opengl_warning found, continuing. Expect problems.";
} }
else else
{ {
qDebug() << "You can try to run in a n unsupported degraded mode by ignoring the warning and continuing."; 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."; qDebug() << "But more than likely pr oblems will persist.";
QMessageBox::StandardButton answerBu tton= QMessageBox::StandardButton answerBu tton=
skipping to change at line 688 skipping to change at line 836
// On these systems, we show a warning panel that can be suppressed by a config option which is automatically added on first run. // 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. // Again, based on a sample size of one, Macs have been reported alr eady to always work in this case.
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
QRegExp glslRegExp("^(\\d\\.\\d\\d)"); QRegExp glslRegExp("^(\\d\\.\\d\\d)");
int pos=glslRegExp.indexIn(glslString); int pos=glslRegExp.indexIn(glslString);
QRegExp glslesRegExp("ES (\\d\\.\\d\\d)"); QRegExp glslesRegExp("ES (\\d\\.\\d\\d)");
int posES=glslesRegExp.indexIn(glslString); int posES=glslesRegExp.indexIn(glslString);
if (pos >-1) if (pos >-1)
{ {
float glslVersion=glslRegExp.cap(1).toFloat(); float glslVersion=glslRegExp.cap(1).toFloat();
qDebug() << "GLSL Version Number after parsing: " << glslVer sion; qDebug() << "GLSL Version Number detected: " << glslVersion;
if (glslVersion<1.3f) if (glslVersion<1.3f)
{ {
openGLerror=true; openGLerror=true;
qDebug() << "This is not enough: we need GLSL1.30 or later."; qDebug() << "This is not enough: we need GLSL1.30 or later.";
qDebug() << "You should update graphics drivers, gra qDebug() << "You should update graphics drivers, gra
phics hardware, or use the MESA version."; phics hardware, or use the --mesa-mode option.";
qDebug() << "Else, please try to use an older versio qDebug() << "Else, please try to use an older versio
n like 0.12.4, and try there with --safe-mode"; n like 0.12.5, and try there with --safe-mode";
if (conf->value("main/ignore_opengl_warning", false) .toBool()) if (conf->value("main/ignore_opengl_warning", false) .toBool())
{ {
qDebug() << "Config option main/ignore_openg l_warning found, continuing. Expect problems."; qDebug() << "Config option main/ignore_openg l_warning found, continuing. Expect problems.";
} }
else else
{ {
qDebug() << "You can try to run in an unsupp orted degraded mode by ignoring the warning and continuing."; 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."; qDebug() << "But more than likely problems w ill persist.";
QMessageBox::StandardButton answerButton= QMessageBox::StandardButton answerButton=
skipping to change at line 725 skipping to change at line 873
conf->setValue("main/ignore_opengl_w arning", true); conf->setValue("main/ignore_opengl_w arning", true);
} }
} }
} }
else else
qDebug() << "GLSL version is fine, we should not see a graphics problem."; qDebug() << "GLSL version is fine, we should not see a graphics problem.";
} }
else if (posES >-1) else if (posES >-1)
{ {
float glslesVersion=glslesRegExp.cap(1).toFloat(); float glslesVersion=glslesRegExp.cap(1).toFloat();
qDebug() << "GLSL ES Version Number after parsing: " << glsl esVersion; qDebug() << "GLSL ES Version Number detected: " << glslesVer sion;
if (glslesVersion<1.0) // TBD: is this possible at all? if (glslesVersion<1.0) // TBD: is this possible at all?
{ {
openGLerror=true; openGLerror=true;
qDebug() << "This is not enough: we need GLSL ES 1.0 0 or later."; qDebug() << "This is not enough: we need GLSL ES 1.0 0 or later.";
qDebug() << "You should update graphics drivers, gra #ifdef Q_OS_WIN
phics hardware, or use the OpenGL-MESA version."; qDebug() << "You should update graphics drivers, gra
qDebug() << "Else, please try to use an older versio phics hardware, or use the --mesa-mode option.";
n like 0.12.4, and try there with --safe-mode"; #else
qDebug() << "You should update graphics drivers or g
raphics hardware.";
#endif
qDebug() << "Else, please try to use an older versio
n like 0.12.5, and try there with --safe-mode";
if (conf->value("main/ignore_opengl_warning", false) .toBool()) if (conf->value("main/ignore_opengl_warning", false) .toBool())
{ {
qDebug() << "Config option main/ignore_openg l_warning found, continuing. Expect problems."; qDebug() << "Config option main/ignore_openg l_warning found, continuing. Expect problems.";
} }
else else
{ {
qDebug() << "You can try to run in an unsupp orted degraded mode by ignoring the warning and continuing."; 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."; qDebug() << "But more than likely problems w ill persist.";
QMessageBox::StandardButton answerButton= QMessageBox::StandardButton answerButton=
skipping to change at line 780 skipping to change at line 932
} }
// Debug info about OpenGL capabilities. // Debug info about OpenGL capabilities.
void StelMainView::dumpOpenGLdiagnostics() const void StelMainView::dumpOpenGLdiagnostics() const
{ {
QOpenGLContext *context = QOpenGLContext::currentContext(); QOpenGLContext *context = QOpenGLContext::currentContext();
if (context) if (context)
{ {
context->functions()->initializeOpenGLFunctions(); context->functions()->initializeOpenGLFunctions();
qDebug() << "initializeOpenGLFunctions()..."; qDebug() << "initializeOpenGLFunctions()...";
QOpenGLFunctions::OpenGLFeatures oglFeatures=context->functi
ons()->openGLFeatures();
qDebug() << "OpenGL Features:";
qDebug() << " - glActiveTexture() function" << (oglFeatures&
QOpenGLFunctions::Multitexture ? "is" : "is NOT") << "available.";
qDebug() << " - Shader functions" << (oglFeatures&QOpenGLFun
ctions::Shaders ? "are" : "are NOT ") << "available.";
qDebug() << " - Vertex and index buffer functions" << (oglFe
atures&QOpenGLFunctions::Buffers ? "are" : "are NOT") << "available.";
qDebug() << " - Framebuffer object functions" << (oglFeature
s&QOpenGLFunctions::Framebuffers ? "are" : "are NOT") << "available.";
qDebug() << " - glBlendColor()" << (oglFeatures&QOpenGLFunct
ions::BlendColor ? "is" : "is NOT") << "available.";
qDebug() << " - glBlendEquation()" << (oglFeatures&QOpenGLFu
nctions::BlendEquation ? "is" : "is NOT") << "available.";
qDebug() << " - glBlendEquationSeparate()" << (oglFeatures&Q
OpenGLFunctions::BlendEquationSeparate ? "is" : "is NOT") << "available.";
qDebug() << " - glBlendFuncSeparate()" << (oglFeatures&QOpen
GLFunctions::BlendFuncSeparate ? "is" : "is NOT") << "available.";
qDebug() << " - Blend subtract mode" << (oglFeatures&QOpenGL
Functions::BlendSubtract ? "is" : "is NOT") << "available.";
qDebug() << " - Compressed texture functions" << (oglFeature
s&QOpenGLFunctions::CompressedTextures ? "are" : "are NOT") << "available."
;
qDebug() << " - glSampleCoverage() function" << (oglFeatures
&QOpenGLFunctions::Multisample ? "is" : "is NOT") << "available.";
qDebug() << " - Separate stencil functions" << (oglFeatures&
QOpenGLFunctions::StencilSeparate ? "are" : "are NOT") << "available.";
qDebug() << " - Non power of two textures" << (oglFeatures&Q
OpenGLFunctions::NPOTTextures ? "are" : "are NOT") << "available.";
qDebug() << " - Non power of two textures" << (oglFeatures&Q
OpenGLFunctions::NPOTTextureRepeat ? "can" : "CANNOT") << "use GL_REPEAT as
wrap parameter.";
qDebug() << " - The fixed function pipeline" << (oglFeatures
&QOpenGLFunctions::FixedFunctionPipeline ? "is" : "is NOT") << "available."
;
qDebug() << "OpenGL shader capabilities and details:";
qDebug() << " - Vertex Shader:" << (QOpenGLShader::hasOpenGL
Shaders(QOpenGLShader::Vertex, context) ? "YES" : "NO");
qDebug() << " - Fragment Shader:" << (QOpenGLShader::hasOpen
GLShaders(QOpenGLShader::Fragment, context) ? "YES" : "NO");
qDebug() << " - Geometry Shader:" << (QOpenGLShader::hasOpen
GLShaders(QOpenGLShader::Geometry, context) ? "YES" : "NO");
qDebug() << " - TessellationControl Shader:" << (QOpenGLShad
er::hasOpenGLShaders(QOpenGLShader::TessellationControl, context) ? "YES" :
"NO");
qDebug() << " - TessellationEvaluation Shader:" << (QOpenGLS
hader::hasOpenGLShaders(QOpenGLShader::TessellationEvaluation, context) ? "
YES" : "NO");
qDebug() << " - Compute Shader:" << (QOpenGLShader::hasOpenG
LShaders(QOpenGLShader::Compute, context) ? "YES" : "NO");
// GZ: List available extensions. Not sure if this is in any
way useful?
QSet<QByteArray> extensionSet=context->extensions();
qDebug() << "We have" << extensionSet.count() << "OpenGL ext
ensions:";
QMap<QString, QString> extensionMap;
QSetIterator<QByteArray> iter(extensionSet);
while (iter.hasNext())
{
if (!iter.peekNext().isEmpty()) {// Don't insert emp
ty lines
extensionMap.insert(QString(iter.peekNext())
, QString(iter.peekNext()));
}
iter.next();
}
QMapIterator<QString, QString> iter2(extensionMap);
while (iter2.hasNext()) {
qDebug() << " -" << iter2.next().key();
}
// Apparently EXT_gpu_shader4 is required for GLSL1.3. (http
://en.wikipedia.org/wiki/OpenGL#OpenGL_3.0).
qDebug() << "EXT_gpu_shader4" << (extensionSet.contains(("EX
T_gpu_shader4")) ? "present, OK." : "MISSING!");
QFunctionPointer programParameterPtr =context->getProcAddres
s("glProgramParameteri");
if (programParameterPtr == 0) {
qDebug() << "glProgramParameteri cannot be resolved
here. BAD!";
}
programParameterPtr =context->getProcAddress("glProgramParam
eteriEXT");
if (programParameterPtr == 0) {
qDebug() << "glProgramParameteriEXT cannot be resolv
ed here. BAD!";
}
} }
else else
{
qDebug() << "dumpOpenGLdiagnostics(): No OpenGL context"; qDebug() << "dumpOpenGLdiagnostics(): No OpenGL context";
}
QOpenGLFunctions::OpenGLFeatures oglFeatures=context->functions()->o
penGLFeatures();
qDebug() << "OpenGL Features:";
qDebug() << " - glActiveTexture() function" << (oglFeatures&QOpenGLF
unctions::Multitexture ? "is" : "is 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() << " - Framebuffer object functions" << (oglFeatures&QOpenG
LFunctions::Framebuffers ? "are" : "are NOT") << "available.";
qDebug() << " - glBlendColor()" << (oglFeatures&QOpenGLFunctions::Bl
endColor ? "is" : "is NOT") << "available.";
qDebug() << " - glBlendEquation()" << (oglFeatures&QOpenGLFunctions:
:BlendEquation ? "is" : "is NOT") << "available.";
qDebug() << " - glBlendEquationSeparate()" << (oglFeatures&QOpenGLFu
nctions::BlendEquationSeparate ? "is" : "is NOT") << "available.";
qDebug() << " - glBlendFuncSeparate()" << (oglFeatures&QOpenGLFuncti
ons::BlendFuncSeparate ? "is" : "is NOT") << "available.";
qDebug() << " - Blend subtract mode" << (oglFeatures&QOpenGLFunction
s::BlendSubtract ? "is" : "is NOT") << "available.";
qDebug() << " - Compressed texture functions" << (oglFeatures&QOpenG
LFunctions::CompressedTextures ? "are" : "are NOT") << "available.";
qDebug() << " - glSampleCoverage() function" << (oglFeatures&QOpenGL
Functions::Multisample ? "is" : "is NOT") << "available.";
qDebug() << " - Separate stencil functions" << (oglFeatures&QOpenGLF
unctions::StencilSeparate ? "are" : "are NOT") << "available.";
qDebug() << " - Non power of two textures" << (oglFeatures&QOpenGLFu
nctions::NPOTTextures ? "are" : "are NOT") << "available.";
qDebug() << " - Non power of two textures" << (oglFeatures&QOpenGLFu
nctions::NPOTTextureRepeat ? "can" : "CANNOT") << "use GL_REPEAT as wrap pa
rameter.";
qDebug() << " - The fixed function pipeline" << (oglFeatures&QOpenGL
Functions::FixedFunctionPipeline ? "is" : "is NOT") << "available.";
qDebug() << "OpenGL shader capabilities and details:";
qDebug() << " - Vertex Shader:" << (QOpenGLShader::hasOpenGLShaders(
QOpenGLShader::Vertex, context) ? "YES" : "NO");
qDebug() << " - Fragment Shader:" << (QOpenGLShader::hasOpenGLShader
s(QOpenGLShader::Fragment, context) ? "YES" : "NO");
qDebug() << " - Geometry Shader:" << (QOpenGLShader::hasOpenGLShader
s(QOpenGLShader::Geometry, context) ? "YES" : "NO");
qDebug() << " - TessellationControl Shader:" << (QOpenGLShader::hasO
penGLShaders(QOpenGLShader::TessellationControl, context) ? "YES" : "NO");
qDebug() << " - TessellationEvaluation Shader:" << (QOpenGLShader::h
asOpenGLShaders(QOpenGLShader::TessellationEvaluation, context) ? "YES" : "
NO");
qDebug() << " - Compute Shader:" << (QOpenGLShader::hasOpenGLShaders
(QOpenGLShader::Compute, context) ? "YES" : "NO");
// GZ: List available extensions. Not sure if this is in any way use
ful?
QSet<QByteArray> extensionSet=context->extensions();
qDebug() << "We have" << extensionSet.count() << "OpenGL extensions:
";
QMap<QString, QString> extensionMap;
QSetIterator<QByteArray> iter(extensionSet);
while (iter.hasNext())
{
if (!iter.peekNext().isEmpty()) // Don't insert empty lines
extensionMap.insert(QString(iter.peekNext()), QStrin
g(iter.peekNext()));
iter.next();
}
QMapIterator<QString, QString> iter2(extensionMap);
while (iter2.hasNext())
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");
if (programParameterPtr == 0)
qDebug() << "glProgramParameteri cannot be resolved here. BA
D!";
//else
// qDebug() << "glProgramParameteri can be resolved. GOOD!";
programParameterPtr =context->getProcAddress("glProgramParameteriEXT
");
if (programParameterPtr == 0)
qDebug() << "glProgramParameteriEXT cannot be resolved here.
BAD!";
//else
// qDebug() << "glProgramParameteriEXT can be resolved here. GO
OD!";
} }
void StelMainView::deinit() void StelMainView::deinit()
{ {
deinitGL(); deinitGL();
delete stelApp; delete stelApp;
stelApp = NULL; stelApp = NULL;
} }
skipping to change at line 953 skipping to change at line 1106
minFpsTimer->start((int)(1./getMinFps()*1000.)); minFpsTimer->start((int)(1./getMinFps()*1000.));
} }
void StelMainView::mouseMoveEvent(QMouseEvent* event) void StelMainView::mouseMoveEvent(QMouseEvent* event)
{ {
// We notify the applicatio to increase the fps if a button has been // 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 // clicked, but also if the cursor is currently hidden, so that it g ets
// restored. // restored.
if (event->buttons() || QGuiApplication::overrideCursor()!=0) if (event->buttons() || QGuiApplication::overrideCursor()!=0)
thereWasAnEvent(); // Refresh screen ASAP thereWasAnEvent(); // Refresh screen ASAP
QDeclarativeView::mouseMoveEvent(event); QGraphicsView::mouseMoveEvent(event);
} }
void StelMainView::mousePressEvent(QMouseEvent* event) void StelMainView::mousePressEvent(QMouseEvent* event)
{ {
thereWasAnEvent(); // Refresh screen ASAP thereWasAnEvent(); // Refresh screen ASAP
QDeclarativeView::mousePressEvent(event); QGraphicsView::mousePressEvent(event);
} }
void StelMainView::mouseReleaseEvent(QMouseEvent* event) void StelMainView::mouseReleaseEvent(QMouseEvent* event)
{ {
thereWasAnEvent(); // Refresh screen ASAP thereWasAnEvent(); // Refresh screen ASAP
QDeclarativeView::mouseReleaseEvent(event); QGraphicsView::mouseReleaseEvent(event);
} }
void StelMainView::wheelEvent(QWheelEvent* event) void StelMainView::wheelEvent(QWheelEvent* event)
{ {
thereWasAnEvent(); // Refresh screen ASAP thereWasAnEvent(); // Refresh screen ASAP
QDeclarativeView::wheelEvent(event); QGraphicsView::wheelEvent(event);
} }
void StelMainView::moveEvent(QMoveEvent * event) void StelMainView::moveEvent(QMoveEvent * event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
// We use the glWidget instead of the even, as we want the screen th at shows most of the widget. // We use the glWidget instead of the even, as we want the screen th at shows most of the widget.
StelApp::getInstance().setDevicePixelsPerPixel(glWidget->windowHandl e()->devicePixelRatio()); StelApp::getInstance().setDevicePixelsPerPixel(glWidget->windowHandl e()->devicePixelRatio());
} }
skipping to change at line 997 skipping to change at line 1150
void StelMainView::keyPressEvent(QKeyEvent* event) void StelMainView::keyPressEvent(QKeyEvent* event)
{ {
thereWasAnEvent(); // Refresh screen ASAP thereWasAnEvent(); // Refresh screen ASAP
// Try to trigger a gobal shortcut. // Try to trigger a gobal shortcut.
StelActionMgr* actionMgr = StelApp::getInstance().getStelActionManag er(); StelActionMgr* actionMgr = StelApp::getInstance().getStelActionManag er();
if (actionMgr->pushKey(event->key() + event->modifiers(), true)) { if (actionMgr->pushKey(event->key() + event->modifiers(), true)) {
event->setAccepted(true); event->setAccepted(true);
return; return;
} }
QDeclarativeView::keyPressEvent(event); QGraphicsView::keyPressEvent(event);
} }
void StelMainView::keyReleaseEvent(QKeyEvent* event) void StelMainView::keyReleaseEvent(QKeyEvent* event)
{ {
thereWasAnEvent(); // Refresh screen ASAP thereWasAnEvent(); // Refresh screen ASAP
QDeclarativeView::keyReleaseEvent(event); QGraphicsView::keyReleaseEvent(event);
} }
//! Delete openGL textures (to call before the GLContext disappears) //! Delete openGL textures (to call before the GLContext disappears)
void StelMainView::deinitGL() void StelMainView::deinitGL()
{ {
StelApp::getInstance().deinit(); StelApp::getInstance().deinit();
delete gui; delete gui;
gui = NULL; gui = NULL;
} }
 End of changes. 56 change blocks. 
164 lines changed or deleted 341 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/