Merge lp:~stellarium/stellarium/gz_insufficient-shader-level into lp:stellarium

Proposed by Alexander Wolf
Status: Merged
Merged at revision: 7183
Proposed branch: lp:~stellarium/stellarium/gz_insufficient-shader-level
Merge into: lp:stellarium
Diff against target: 741 lines (+412/-114)
8 files modified
plugins/AngleMeasure/src/AngleMeasure.cpp (+14/-1)
plugins/CompassMarks/src/CompassMarks.cpp (+10/-0)
src/StelMainView.cpp (+332/-58)
src/StelMainView.hpp (+15/-2)
src/core/StelOpenGL.hpp (+6/-0)
src/core/modules/GridLinesMgr.cpp (+12/-2)
src/core/modules/Planet.cpp (+4/-0)
src/main.cpp (+19/-51)
To merge this branch: bzr merge lp:~stellarium/stellarium/gz_insufficient-shader-level
Reviewer Review Type Date Requested Status
gzotti Approve
Alexander Wolf Approve
Fabien Chéreau Pending
Review via email: mp+241412@code.launchpad.net

This proposal supersedes a proposal from 2014-10-31.

To post a comment you must log in.
Revision history for this message
Fabien Chéreau (xalioth) wrote : Posted in a previous version of this proposal

It's fine for me, but it would be good to also allow user to click on something like "Understood, don't show me this again" which will set the option in the config file

review: Needs Fixing
Revision history for this message
gzotti (georg-zotti) wrote : Posted in a previous version of this proposal

OK, I changed this from command line option to config.ini setting.

I don't see a "Run Once" option in the QMessagebox buttons (Ignore without saving), but this whole addition should just be enough to catch most "does not run", "black screen", etc. bug reports. What would be nice would be GLSL1.20 fallback planet shaders for OpenGL2.1-only systems. (No shadows, just Phong model.) I also wonder about the GLSL answer string on OpenGL ES2.0, I have no system to test.

review: Needs Resubmitting
Revision history for this message
Fabien Chéreau (xalioth) wrote : Posted in a previous version of this proposal

Please also get rid of QGLFormat and related deprecated classes.

review: Needs Fixing
Revision history for this message
gzotti (georg-zotti) wrote : Posted in a previous version of this proposal

OK, I could remove all QGLFormat things in the startup tests. But the context creation in StelMainView l.306 was something I did not dare touching. I cannot test the GLES tests, have no ANGLE build system here.

The old version is only commented away, I would remove it on merge.

review: Needs Resubmitting
Revision history for this message
gzotti (georg-zotti) wrote : Posted in a previous version of this proposal

The only thing that remains appears to be changing the (Stel)QGLWidget and other QGL... classes. On http://qt-project.org/wiki/New-Features-in-Qt-5.4 you can read there will be a QOpenGLWidget to replace QGLWidget. I would prefer to make this (hopefully easy) change after Qt5.4 is out, and merge this now so that our test builds and RCs can be tested and diagnosed on the various hardware already now.

review: Needs Resubmitting
Revision history for this message
Alexander Wolf (alexwolf) wrote : Posted in a previous version of this proposal

QOpenGLWidget & QGLWidget should be used with ifdef's IMHO (if we not set minimal Qt as 5.4.0)

Revision history for this message
Alexander Wolf (alexwolf) wrote :

Georg, what will happen when system will have no OpenGL support?

review: Needs Information
Revision history for this message
gzotti (georg-zotti) wrote :

I think we should require Qt5.4 as soon as it is out and when it does not break other things, given several announced advantages: Dynamic ANGLE, and indeed that new QOpenGLWidget, which is hopefully the simplest successor of the aged QGL stuff. Qt5.4 may appear in December (they are a bit behind schedule now). I could try a beta maybe around Nov22. That means for now, we don't have to find a big way around QGLWidget, when a solution is on the horizon.

If there is no OpenGL support at all, I am pretty sure StelMainView line 306 will already fail as it always should have failed. In line 307 a QGLcontext is created, but not verified. A test could be built in here according to Qt docs.
I cannot test this assumption however, as I did not have a completely non-OpenGL system since about 1998 to ever come into this situation. Very early in the new test sequence, I test for minimal version which should be enough at that point.
After moving to Qt5.4, we should quickly abandon QGL... classes, and rewrite also this part with more foolproofing.

Revision history for this message
Alexander Wolf (alexwolf) wrote :

Simple test for non-OpenGL work - x11vnc session. Line 306 in StelMainView will be give failure without OpenGL and application will be crash. It's bad behaviour IMHO - crash without any info about requirement of the OpenGL support.

Revision history for this message
gzotti (georg-zotti) wrote :

Sure, but this was never tested. The major concern of this branch is the
many bug reports after 0.13 about issues with half-working systems with
just OpenGL2.0, 2.1 without GLSL1.30, etc.

Do you want another crash panel around line 306? I can only copy/paste
code here from below (panel similar to OpenGL<2 below ), not test it.

Revision history for this message
Alexander Wolf (alexwolf) wrote :

It was tested on series 0.12 in Debian

7121. By gzotti

added two more test for detection of obviously unusable systems.

Revision history for this message
gzotti (georg-zotti) wrote :

OK, it was not tested as of October 31.

Does the current version abort "nicely" with an abort panel and log message on x11vnc?

7122. By gzotti

Reactivate 0.12 line smoothing for AngleMeasure and CompassMarks plugins and activate it for Gridline drawing on capable systems. It really looks better. Compilation should not fail on ANGLE or other OpenGLES builds.

Revision history for this message
Alexander Wolf (alexwolf) wrote :

It's OK for me now. Fabien?

review: Approve
7123. By gzotti

Started migration towards QOpenGLwidget for Qt5.4. THIS COMPILES, BUT DOES NOT YET RUN!

Revision history for this message
gzotti (georg-zotti) wrote :

Wonderful. r7122 was ready-to-merge. I then tried to go further to get rid of QGL... classes as Fabien asked me. Sorry, I don't know what to do. In r7123 there is conditional compilation of new classes with Qt5.4, but these are not initialized properly, so it does not run yet. Merge r7122, or someone else please fix r7123, I stop here.

7124. By gzotti

added a test for minimal Mesa version (10) if Mesa is used.
changed conditional compiling with the new QtOpenGL... classes from checking Qt version (>=5.4) to a single #define. Migration towards using these new classes is not finished, help wanted...

7125. By gzotti

merged with trunk r7172

Revision history for this message
gzotti (georg-zotti) wrote :

I merged with trunk. This is IMHO as good as tests can currently get us catching errors caused by insufficient graphics capabilities. Small addenda/changes are easily done in trunk. Also next stage of migrating to Qt5.4 classes can continue from here.

review: Needs Resubmitting
Revision history for this message
Alexander Wolf (alexwolf) wrote :

I think one #ifdef not required here but it ready to merge IMHO

review: Approve
Revision history for this message
gzotti (georg-zotti) wrote :

That #if is indeed necessary - Qt managed to rename the method in question (capital B!), at least for Qt5.4beta. Anyway, these #if-excluded sections must be changed for Qt5.4 (release) and later.

I don't know if Launchpad's "Resubmit" means "must be resubmitted" or "this is a resubmit". So I approve my branch...

review: Approve
Revision history for this message
Alexander Wolf (alexwolf) wrote :

Lanchpad has "Resumbit" (review type) and "Resubmit proposal" ;)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/AngleMeasure/src/AngleMeasure.cpp'
2--- plugins/AngleMeasure/src/AngleMeasure.cpp 2014-11-12 17:30:09 +0000
3+++ plugins/AngleMeasure/src/AngleMeasure.cpp 2014-11-24 19:29:55 +0000
4@@ -220,6 +220,15 @@
5 }
6 }
7
8+ glDisable(GL_TEXTURE_2D);
9+ // OpenGL ES 2.0 doesn't have GL_LINE_SMOOTH. But it looks much better.
10+ #ifdef GL_LINE_SMOOTH
11+ if (QOpenGLContext::currentContext()->format().renderableType()==QSurfaceFormat::OpenGL)
12+ glEnable(GL_LINE_SMOOTH);
13+ #endif
14+
15+ glEnable(GL_BLEND);
16+
17 // main line is a great circle
18 painter.setColor(lineColor[0], lineColor[1], lineColor[2], lineVisible.getInterstate());
19 if (frameType==StelCore::FrameEquinoxEqu)
20@@ -237,7 +246,11 @@
21 // End lines
22 painter.drawGreatCircleArc(perp1StartPointHor, perp1EndPointHor, NULL);
23 painter.drawGreatCircleArc(perp2StartPointHor, perp2EndPointHor, NULL);
24- }
25+ }
26+ #ifdef GL_LINE_SMOOTH
27+ if (QOpenGLContext::currentContext()->format().renderableType()==QSurfaceFormat::OpenGL)
28+ glDisable(GL_LINE_SMOOTH);
29+ #endif
30 }
31 if (messageFader.getInterstate() > 0.000001f)
32 {
33
34=== modified file 'plugins/CompassMarks/src/CompassMarks.cpp'
35--- plugins/CompassMarks/src/CompassMarks.cpp 2014-11-12 17:30:09 +0000
36+++ plugins/CompassMarks/src/CompassMarks.cpp 2014-11-24 19:29:55 +0000
37@@ -132,6 +132,11 @@
38 glDisable(GL_TEXTURE_2D);
39 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
40 glEnable(GL_BLEND);
41+ // OpenGL ES 2.0 doesn't have GL_LINE_SMOOTH. But it looks much better.
42+ #ifdef GL_LINE_SMOOTH
43+ if (QOpenGLContext::currentContext()->format().renderableType()==QSurfaceFormat::OpenGL)
44+ glEnable(GL_LINE_SMOOTH);
45+ #endif
46
47 for(int i=0; i<360; i++)
48 {
49@@ -162,6 +167,11 @@
50 //glEnable(GL_TEXTURE_2D);
51 }
52 }
53+ // OpenGL ES 2.0 doesn't have GL_LINE_SMOOTH
54+ #ifdef GL_LINE_SMOOTH
55+ if (QOpenGLContext::currentContext()->format().renderableType()==QSurfaceFormat::OpenGL)
56+ glDisable(GL_LINE_SMOOTH);
57+ #endif
58 glDisable(GL_BLEND);
59 glEnable(GL_TEXTURE_2D);
60
61
62=== modified file 'src/StelMainView.cpp'
63--- src/StelMainView.cpp 2014-10-26 13:26:29 +0000
64+++ src/StelMainView.cpp 2014-11-24 19:29:55 +0000
65@@ -33,7 +33,11 @@
66 #include <QDeclarativeItem>
67 #include <QDebug>
68 #include <QDir>
69+#if STEL_USE_NEW_OPENGL_WIDGETS
70+#include <QOpenGLWidget>
71+#else
72 #include <QGLWidget>
73+#endif
74 #include <QGuiApplication>
75 #include <QFileInfo>
76 #include <QIcon>
77@@ -46,6 +50,7 @@
78 #include <QTimer>
79 #include <QWidget>
80 #include <QWindow>
81+#include <QMessageBox>
82 #include <QDeclarativeContext>
83 #ifdef Q_OS_WIN
84 #include <QPinchGesture>
85@@ -238,12 +243,51 @@
86
87 void StelGuiItem::onSizeChanged()
88 {
89- // I whish I could find a way to let Qt automatically resize the widget
90+ // I wish I could find a way to let Qt automatically resize the widget
91 // when the QDeclarativeItem size changes.
92 widget->setGeometry(0, 0, width(), height());
93 StelApp::getInstance().getGui()->forceRefreshGui();
94 }
95
96+
97+#if STEL_USE_NEW_OPENGL_WIDGETS
98+
99+class StelQOpenGLWidget : public QOpenGLWidget
100+{
101+public:
102+ StelQOpenGLWidget(QWidget* parent) : QOpenGLWidget(parent)
103+ {
104+ // TODO: Unclear if tese attributes make sense?
105+ setAttribute(Qt::WA_PaintOnScreen);
106+ setAttribute(Qt::WA_NoSystemBackground);
107+ setAttribute(Qt::WA_OpaquePaintEvent);
108+ }
109+
110+protected:
111+ virtual void initializeGL()
112+ {
113+ qDebug() << "It appears this was never called?";
114+ qDebug() << "OpenGL supported version: " << QString((char*)glGetString(GL_VERSION));
115+
116+ QOpenGLWidget::initializeGL();
117+ this->makeCurrent(); // Do we need this?
118+ // GZ I have no idea how to proceed, sorry.
119+ QSurfaceFormat format=this->format();
120+ qDebug() << "Current Format: " << this->format();
121+ // TODO: Test something? The old tests may be obsolete as all OpenGL2 formats/contexts have these?
122+ }
123+ virtual void paintGL()
124+ {
125+ // TODO: what shall this do exactly?
126+ }
127+ virtual void resizeGL()
128+ {
129+ // TODO: what shall this do exactly?
130+ }
131+
132+};
133+
134+#else
135 class StelQGLWidget : public QGLWidget
136 {
137 public:
138@@ -273,6 +317,8 @@
139 }
140
141 };
142+#endif
143+
144
145 StelMainView::StelMainView(QWidget* parent)
146 : QDeclarativeView(parent), gui(NULL),
147@@ -301,9 +347,44 @@
148
149 lastEventTimeSec = 0;
150
151+
152+#if STEL_USE_NEW_OPENGL_WIDGETS
153+ // Primary test for OpenGL existence
154+ if (QSurfaceFormat::defaultFormat().majorVersion() < 2)
155+ {
156+ qWarning() << "No OpenGL 2 support on this system. Aborting.";
157+ 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);
158+ exit(0);
159+ }
160+
161+ //QSurfaceFormat format();
162+ //// TBD: What options shall be default?
163+ //QSurfaceFormat::setDefaultFormat(format);
164+ ////QOpenGLContext* context=new QOpenGLContext::create();
165+ glWidget = new StelQOpenGLWidget(this);
166+ //glWidget->setFormat(format);
167+#else
168+ // Primary test for OpenGL existence
169+ if (QGLFormat::openGLVersionFlags() < QGLFormat::OpenGL_Version_2_1)
170+ {
171+ qWarning() << "No OpenGL 2.1 support on this system. Aborting.";
172+ 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);
173+ exit(1);
174+ }
175+
176 // Create an openGL viewport
177 QGLFormat glFormat(QGL::StencilBuffer | QGL::DepthBuffer | QGL::DoubleBuffer);
178- glWidget = new StelQGLWidget(new QGLContext(glFormat), this);
179+ QGLContext* context=new QGLContext(glFormat);
180+
181+ if (context->format() != glFormat)
182+ {
183+ qWarning() << "Cannot provide OpenGL context. Apparently insufficient OpenGL resources on this system.";
184+ QMessageBox::critical(0, "Stellarium", q_("Cannot acquire necessary OpenGL resouces."), QMessageBox::Abort, QMessageBox::Abort);
185+ exit(1);
186+ }
187+ glWidget = new StelQGLWidget(context, this);
188+#endif
189+
190 setViewport(glWidget);
191
192 // Workaround (see Bug #940638) Although we have already explicitly set
193@@ -341,20 +422,256 @@
194 }
195 Q_ASSERT(gui);
196
197+#if STEL_USE_NEW_OPENGL_WIDGETS
198+ //glWidget->initializeGL(); // protected...
199+ //Q_ASSERT(glWidget->isValid());
200+#else
201 Q_ASSERT(glWidget->isValid());
202 glWidget->makeCurrent();
203-
204- // Debug info about supported version of OpenGL and vendor/renderer
205- qDebug() << "OpenGL versions supported:" << getSupportedOpenGLVersion();
206- qDebug() << "Driver version string:" << QString(reinterpret_cast<const char*>(glGetString(GL_VERSION)));
207+#endif
208+
209+ // Find out lots of debug info about supported version of OpenGL and vendor/renderer
210+ QOpenGLContext* context=QOpenGLContext::currentContext();
211+ QSurfaceFormat format=context->format();
212+
213+ bool openGLerror=false;
214+ if (format.renderableType()==QSurfaceFormat::OpenGL || format.renderableType()==QSurfaceFormat::OpenGLES)
215+ {
216+ qDebug() << "Detected:" << (format.renderableType()==QSurfaceFormat::OpenGL ? "OpenGL" : "OpenGL ES" ) << QString("%1.%2").arg(format.majorVersion()).arg(format.minorVersion());
217+ }
218+ else
219+ {
220+ openGLerror=true;
221+ qDebug() << "Neither OpenGL nor OpenGL ES detected: Unsupported Format!";
222+ }
223+
224+ QString glDriver(reinterpret_cast<const char*>(glGetString(GL_VERSION)));
225+ qDebug() << "Driver version string:" << glDriver;
226 qDebug() << "GL vendor is" << QString(reinterpret_cast<const char*>(glGetString(GL_VENDOR)));
227- qDebug() << "GL renderer is" << QString(reinterpret_cast<const char*>(glGetString(GL_RENDERER)));
228- qDebug() << "GL Shading Language version is" << QString(reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION)));
229-
230+ QString glRenderer(reinterpret_cast<const char*>(glGetString(GL_RENDERER)));
231+ qDebug() << "GL renderer is" << glRenderer;
232+
233+ // Minimal required version of OpenGL for Qt5 is 2.1 and OpenGL Shading Language may be 1.20 (or OpenGL ES is 2.0 and GLSL ES is 1.0).
234+ // As of V0.13.0..1, we use GLSL 1.10/GLSL ES 1.00 (implicitly, by omitting version), but in case of using ANGLE we need ps_3 hardware.
235+ // This means, usually systems with OpenGL3 support reported in the driver will work, those with reported 2.1 only will almost certainly fail.
236+ // If platform does not even support minimal OpenGL version for Qt5, then tell the user about troubles and quit from application.
237+ if ( openGLerror ||
238+ ((format.renderableType()==QSurfaceFormat::OpenGL ) && (format.version() < QPair<int, int>(2, 1))) ||
239+ ((format.renderableType()==QSurfaceFormat::OpenGLES) && (format.version() < QPair<int, int>(2, 0))) )
240+ {
241+ #ifdef Q_OS_WIN
242+ qWarning() << "Oops... Insufficient OpenGL version. Please update drivers, graphics hardware, or use MESA (or ANGLE) version.";
243+ QMessageBox::critical(0, "Stellarium", q_("Insufficient OpenGL version. Please update drivers, graphics hardware, or use MESA (or ANGLE) version."), QMessageBox::Abort, QMessageBox::Abort);
244+ #else
245+ qWarning() << "Oops... Insufficient OpenGL version. Please update drivers, or graphics hardware.";
246+ QMessageBox::critical(0, "Stellarium", q_("Insufficient OpenGL version. Please update drivers, or graphics hardware."), QMessageBox::Abort, QMessageBox::Abort);
247+ #endif
248+ exit(1);
249+ }
250+ // This call requires OpenGL2+.
251+ QString glslString(reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION)));
252+ qDebug() << "GL Shading Language version is" << glslString;
253+
254 // Only give extended info if called on command line, for diagnostic.
255 if (qApp->property("dump_OpenGL_details").toBool())
256 dumpOpenGLdiagnostics();
257
258+#ifdef Q_OS_WIN
259+ // If we have ANGLE, check esp. for insufficient ps_2 level.
260+ if (glRenderer.startsWith("ANGLE"))
261+ {
262+ QRegExp angleVsPsRegExp(" vs_(\\d)_(\\d) ps_(\\d)_(\\d)");
263+ int angleVSPSpos=angleVsPsRegExp.indexIn(glRenderer);
264+
265+ if (angleVSPSpos >-1)
266+ {
267+ float vsVersion=angleVsPsRegExp.cap(1).toFloat() + 0.1*angleVsPsRegExp.cap(2).toFloat();
268+ float psVersion=angleVsPsRegExp.cap(3).toFloat() + 0.1*angleVsPsRegExp.cap(4).toFloat();
269+ qDebug() << "VS Version Number after parsing: " << vsVersion;
270+ qDebug() << "PS Version Number after parsing: " << psVersion;
271+ if ((vsVersion<2.0) || (psVersion<3.0))
272+ {
273+ openGLerror=true;
274+ qDebug() << "This is not enough: we need DirectX9 with vs_2_0 and ps_3_0 or later.";
275+ qDebug() << "You should update graphics drivers, graphics hardware, or use the OpenGL-MESA version.";
276+ qDebug() << "Else, please try to use an older version like 0.12.4, and try there with --safe-mode";
277+
278+ if (conf->value("main/ignore_opengl_warning", false).toBool())
279+ {
280+ qDebug() << "Config option main/ignore_opengl_warning found, continuing. Expect problems.";
281+ }
282+ else
283+ {
284+ qDebug() << "You can try to run in an unsupported degraded mode by ignoring the warning and continuing.";
285+ qDebug() << "But more than likely problems will persist.";
286+ QMessageBox::StandardButton answerButton=
287+ 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 degraded mode anyway?"),
288+ QMessageBox::Ignore|QMessageBox::Abort, QMessageBox::Abort);
289+ if (answerButton == QMessageBox::Abort)
290+ {
291+ qDebug() << "Aborting due to ANGLE OpenGL ES / DirectX vs or ps version problems.";
292+ exit(1);
293+ }
294+ else
295+ {
296+ qDebug() << "Ignoring all warnings, continuing without further question.";
297+ conf->setValue("main/ignore_opengl_warning", true);
298+ }
299+ }
300+ }
301+ else
302+ qDebug() << "vs/ps version is fine, we should not see a graphics problem.";
303+ }
304+ else
305+ {
306+ qDebug() << "Cannot parse ANGLE shader version string. This may indicate future problems.";
307+ qDebug() << "Please send a bug report that includes this log file and states if Stellarium runs or has problems.";
308+ }
309+ }
310+#endif
311+
312+ // 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 lose the stars.
313+ if (glDriver.contains("Mesa", Qt::CaseInsensitive))
314+ {
315+ QRegExp mesaRegExp("Mesa (\\d+)\\.(\\d+)"); // we need only major version. Minor should always be here. Test?
316+ int mesaPos=mesaRegExp.indexIn(glDriver);
317+
318+ if (mesaPos >-1)
319+ {
320+ float mesaVersion=mesaRegExp.cap(1).toFloat() + 0.1*mesaRegExp.cap(2).toFloat();
321+ qDebug() << "MESA Version Number after parsing: " << mesaVersion;
322+ if ((mesaVersion<10.0))
323+ {
324+ openGLerror=true;
325+ qDebug() << "This is not enough: we need Mesa 10.0 or later.";
326+ qDebug() << "You should update graphics drivers or graphics hardware.";
327+ qDebug() << "Else, please try to use an older version like 0.12.4, and try there with --safe-mode";
328+
329+ if (conf->value("main/ignore_opengl_warning", false).toBool())
330+ {
331+ qDebug() << "Config option main/ignore_opengl_warning found, continuing. Expect problems.";
332+ }
333+ else
334+ {
335+ qDebug() << "You can try to run in an unsupported degraded mode by ignoring the warning and continuing.";
336+ qDebug() << "But more than likely problems will persist.";
337+ QMessageBox::StandardButton answerButton=
338+ QMessageBox::critical(0, "Stellarium", q_("Your OpenGL/Mesa subsystem has problems. See log for details.\nIgnore and suppress this notice in the future and try to continue in degraded mode anyway?"),
339+ QMessageBox::Ignore|QMessageBox::Abort, QMessageBox::Abort);
340+ if (answerButton == QMessageBox::Abort)
341+ {
342+ qDebug() << "Aborting due to OpenGL/Mesa insufficient version problems.";
343+ exit(1);
344+ }
345+ else
346+ {
347+ qDebug() << "Ignoring all warnings, continuing without further question.";
348+ conf->setValue("main/ignore_opengl_warning", true);
349+ }
350+ }
351+ }
352+ else
353+ qDebug() << "Mesa version is fine, we should not see a graphics problem.";
354+ }
355+ else
356+ {
357+ qDebug() << "Cannot parse Mesa Driver version string. This may indicate future problems.";
358+ qDebug() << "Please send a bug report that includes this log file and states if Stellarium runs or has problems.";
359+ }
360+ }
361+
362+
363+ // If GLSL version is less than 1.30 or GLSL ES 1.00, Stellarium cannot run properly. Depending on whatever driver/implementation details,
364+ // Stellarium may crash or show only minor graphical errors. We show a soft-crash panel that can be suppressed by a startup option.
365+ QRegExp glslRegExp("^(\\d\\.\\d\\d)");
366+ int pos=glslRegExp.indexIn(glslString);
367+ QRegExp glslesRegExp("ES (\\d\\.\\d\\d)");
368+ int posES=glslesRegExp.indexIn(glslString);
369+ if (pos >-1)
370+ {
371+ float glslVersion=glslRegExp.cap(1).toFloat();
372+ qDebug() << "GLSL Version Number after parsing: " << glslVersion;
373+ if (glslVersion<1.3)
374+ {
375+ openGLerror=true;
376+ qDebug() << "This is not enough: we need GLSL1.30 or later.";
377+ qDebug() << "You should update graphics drivers, graphics hardware, or use the MESA version.";
378+ qDebug() << "Else, please try to use an older version like 0.12.4, and try there with --safe-mode";
379+
380+ if (conf->value("main/ignore_opengl_warning", false).toBool())
381+ {
382+ qDebug() << "Config option main/ignore_opengl_warning found, continuing. Expect problems.";
383+ }
384+ else
385+ {
386+ qDebug() << "You can try to run in an unsupported degraded mode by ignoring the warning and continuing.";
387+ qDebug() << "But more than likely problems will persist.";
388+ QMessageBox::StandardButton answerButton=
389+ QMessageBox::critical(0, "Stellarium", q_("Your OpenGL subsystem has problems. See log for details.\nIgnore and suppress this notice in the future and try to continue in degraded mode anyway?"),
390+ QMessageBox::Ignore|QMessageBox::Abort, QMessageBox::Abort);
391+ if (answerButton == QMessageBox::Abort)
392+ {
393+ qDebug() << "Aborting due to OpenGL/GLSL version problems.";
394+ exit(1);
395+ }
396+ else
397+ {
398+ qDebug() << "Ignoring all warnings, continuing without further question.";
399+ conf->setValue("main/ignore_opengl_warning", true);
400+ }
401+ }
402+ }
403+ else
404+ qDebug() << "GLSL version is fine, we should not see a graphics problem.";
405+ }
406+ else if (posES >-1)
407+ {
408+ float glslesVersion=glslesRegExp.cap(1).toFloat();
409+ qDebug() << "GLSL ES Version Number after parsing: " << glslesVersion;
410+ if (glslesVersion<1.0) // TBD: is this possible at all?
411+ {
412+ openGLerror=true;
413+ qDebug() << "This is not enough: we need GLSL ES 1.00 or later.";
414+ qDebug() << "You should update graphics drivers, graphics hardware, or use the OpenGL-MESA version.";
415+ qDebug() << "Else, please try to use an older version like 0.12.4, and try there with --safe-mode";
416+
417+ if (conf->value("main/ignore_opengl_warning", false).toBool())
418+ {
419+ qDebug() << "Config option main/ignore_opengl_warning found, continuing. Expect problems.";
420+ }
421+ else
422+ {
423+ qDebug() << "You can try to run in an unsupported degraded mode by ignoring the warning and continuing.";
424+ qDebug() << "But more than likely problems will persist.";
425+ QMessageBox::StandardButton answerButton=
426+ QMessageBox::critical(0, "Stellarium", q_("Your OpenGL ES subsystem has problems. See log for details.\nIgnore and suppress this notice in the future and try to continue in degraded mode anyway?"),
427+ QMessageBox::Ignore|QMessageBox::Abort, QMessageBox::Abort);
428+ if (answerButton == QMessageBox::Abort)
429+ {
430+ qDebug() << "Aborting due to OpenGL ES/GLSL ES version problems.";
431+ exit(1);
432+ }
433+ else
434+ {
435+ qDebug() << "Ignoring all warnings, continuing without further question.";
436+ conf->setValue("main/ignore_opengl_warning", true);
437+ }
438+ }
439+ }
440+ else
441+ {
442+ if (openGLerror)
443+ qDebug() << "GLSL ES version is OK, but there were previous errors, expect problems.";
444+ else
445+ qDebug() << "GLSL ES version is fine, we should not see a graphics problem.";
446+ }
447+ }
448+ else
449+ {
450+ qDebug() << "Cannot parse GLSL (ES) version string. This may indicate future problems.";
451+ qDebug() << "Please send a bug report that includes this log file and states if Stellarium works or has problems.";
452+ }
453+
454 stelApp= new StelApp();
455 stelApp->setGui(gui);
456 stelApp->init(conf);
457@@ -406,55 +723,6 @@
458 startMainLoop();
459 }
460
461-QString StelMainView::getSupportedOpenGLVersion() const
462-{
463- int version = QGLFormat::openGLVersionFlags();
464- QStringList ver;
465-
466- if (version&QGLFormat::OpenGL_Version_1_1)
467- ver << "1.1";
468- if (version&QGLFormat::OpenGL_Version_1_2)
469- ver << "1.2";
470- if (version&QGLFormat::OpenGL_Version_1_3)
471- ver << "1.3";
472- if (version&QGLFormat::OpenGL_Version_1_4)
473- ver << "1.4";
474- if (version&QGLFormat::OpenGL_Version_1_5)
475- ver << "1.5";
476- if (version&QGLFormat::OpenGL_Version_2_0)
477- ver << "2.0";
478- if (version&QGLFormat::OpenGL_Version_2_1)
479- ver << "2.1";
480- if (version&QGLFormat::OpenGL_Version_3_0)
481- ver << "3.0";
482- if (version&QGLFormat::OpenGL_Version_3_1)
483- ver << "3.1";
484- if (version&QGLFormat::OpenGL_Version_3_2)
485- ver << "3.2";
486- if (version&QGLFormat::OpenGL_Version_3_3)
487- ver << "3.3";
488- if (version&QGLFormat::OpenGL_Version_4_0)
489- ver << "4.0";
490- if (version&QGLFormat::OpenGL_Version_4_1)
491- ver << "4.1";
492- if (version&QGLFormat::OpenGL_Version_4_2)
493- ver << "4.2";
494- if (version&QGLFormat::OpenGL_Version_4_3)
495- ver << "4.3";
496- if (version&QGLFormat::OpenGL_ES_CommonLite_Version_1_0)
497- ver << "1.0 (ES CL)";
498- if (version&QGLFormat::OpenGL_ES_CommonLite_Version_1_1)
499- ver << "1.1 (ES CL)";
500- if (version&QGLFormat::OpenGL_ES_Common_Version_1_0)
501- ver << "1.0 (ES C)";
502- if (version&QGLFormat::OpenGL_ES_Common_Version_1_1)
503- ver << "1.1 (ES C)";
504- if (version&QGLFormat::OpenGL_ES_Version_2_0)
505- ver << "2.0 (ES)";
506-
507- return ver.join(", ");
508-}
509-
510 void StelMainView::dumpOpenGLdiagnostics() const
511 {
512 // GZ: Debug info about OpenGL capabilities.
513@@ -507,6 +775,8 @@
514 QMapIterator<QString, QString> iter2(extensionMap);
515 while (iter2.hasNext())
516 qDebug() << " -" << iter2.next().key();
517+ // Apparently EXT_gpu_shader4 is required for GLSL1.3. (http://en.wikipedia.org/wiki/OpenGL#OpenGL_3.0).
518+ qDebug() << "EXT_gpu_shader4" << (extensionSet.contains(("EXT_gpu_shader4")) ? "present, OK." : "MISSING!");
519
520 QFunctionPointer programParameterPtr =context->getProcAddress("glProgramParameteri");
521 if (programParameterPtr == 0)
522@@ -706,7 +976,11 @@
523 void StelMainView::doScreenshot(void)
524 {
525 QFileInfo shotDir;
526+#if STEL_USE_NEW_OPENGL_WIDGETS
527+ QImage im = glWidget->grabFramebuffer();
528+#else
529 QImage im = glWidget->grabFrameBuffer();
530+#endif
531 if (flagInvertScreenShotColors)
532 im.invertPixels();
533
534
535=== modified file 'src/StelMainView.hpp'
536--- src/StelMainView.hpp 2014-11-04 10:59:12 +0000
537+++ src/StelMainView.hpp 2014-11-24 19:29:55 +0000
538@@ -25,12 +25,22 @@
539 #include <QEventLoop>
540 #include <QOpenGLContext>
541
542+// This define (only used here and in StelMainView.cpp) is temporarily used
543+// to allow uncompromised compiling while the migration to the new QOpenGL... classes
544+// has not been done. As soon as Qt5.4 is out, we should finish this migration process!
545+#define STEL_USE_NEW_OPENGL_WIDGETS false
546+
547 class QDeclarativeItem;
548+#if STEL_USE_NEW_OPENGL_WIDGETS
549+class QOpenGLWidget;
550+class StelQOpenGLWidget;
551+#else
552 class QGLWidget;
553+class StelQGLWidget;
554+#endif
555 class QMoveEvent;
556 class QResizeEvent;
557 class StelGuiBase;
558-class StelQGLWidget;
559 class QMoveEvent;
560
561 //! @class StelMainView
562@@ -145,7 +155,6 @@
563 //! Start the display loop
564 void startMainLoop();
565
566- QString getSupportedOpenGLVersion() const;
567 //! provide extensive OpenGL dignostics in logfile.
568 void dumpOpenGLdiagnostics() const;
569
570@@ -158,7 +167,11 @@
571 QDeclarativeItem* skyItem;
572
573 //! The openGL window
574+#if STEL_USE_NEW_OPENGL_WIDGETS
575+ StelQOpenGLWidget* glWidget;
576+#else
577 StelQGLWidget* glWidget;
578+#endif
579 StelGuiBase* gui;
580 class StelApp* stelApp;
581
582
583=== modified file 'src/core/StelOpenGL.hpp'
584--- src/core/StelOpenGL.hpp 2014-09-12 11:36:20 +0000
585+++ src/core/StelOpenGL.hpp 2014-11-24 19:29:55 +0000
586@@ -149,6 +149,12 @@
587 # define GL(line) line
588 #endif
589
590+// In ANGLE and other OpenGL ES systems, GL_LINE_SMOOTH is undefined.
591+// We can define it here to not break compilation, but must test for real OpenGL context before calling.
592+# ifndef GL_LINE_SMOOTH
593+# define GL_LINE_SMOOTH 0x0B20
594+# endif
595+
596 const char* getGLErrorText(int code);
597 int checkGLErrors(const char *file, int line);
598
599
600=== modified file 'src/core/modules/GridLinesMgr.cpp'
601--- src/core/modules/GridLinesMgr.cpp 2014-11-08 22:04:20 +0000
602+++ src/core/modules/GridLinesMgr.cpp 2014-11-24 19:29:55 +0000
603@@ -337,7 +337,7 @@
604 const SphericalCap& viewPortSphericalCap = prj->getBoundingCap();
605
606 // Compute the first grid starting point. This point is close to the center of the screen
607- // and lays at the intersection of a meridien and a parallel
608+ // and lies at the intersection of a meridian and a parallel
609 lon2 = gridStepMeridianRad*((int)(lon2/gridStepMeridianRad+0.5));
610 lat2 = gridStepParallelRad*((int)(lat2/gridStepParallelRad+0.5));
611 Vec3d firstPoint;
612@@ -346,10 +346,15 @@
613
614 // Q_ASSERT(viewPortSphericalCap.contains(firstPoint));
615
616- // Initialize a painter and set openGL state
617+ // Initialize a painter and set OpenGL state
618 StelPainter sPainter(prj);
619 glEnable(GL_BLEND);
620 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transparency mode
621+ // OpenGL ES 2.0 doesn't have GL_LINE_SMOOTH
622+ #ifdef GL_LINE_SMOOTH
623+ if (QOpenGLContext::currentContext()->format().renderableType()==QSurfaceFormat::OpenGL)
624+ glEnable(GL_LINE_SMOOTH);
625+ #endif
626 Vec4f textColor(color[0], color[1], color[2], 0);
627 sPainter.setColor(color[0],color[1],color[2], fader.getInterstate());
628
629@@ -547,6 +552,11 @@
630 fpt.transfo4d(rotLon);
631 }
632 }
633+ // OpenGL ES 2.0 doesn't have GL_LINE_SMOOTH
634+ #ifdef GL_LINE_SMOOTH
635+ if (QOpenGLContext::currentContext()->format().renderableType()==QSurfaceFormat::OpenGL)
636+ glDisable(GL_LINE_SMOOTH);
637+ #endif
638 }
639
640
641
642=== modified file 'src/core/modules/Planet.cpp'
643--- src/core/modules/Planet.cpp 2014-11-21 18:49:36 +0000
644+++ src/core/modules/Planet.cpp 2014-11-24 19:29:55 +0000
645@@ -1280,6 +1280,10 @@
646 {
647 delete planetShaderProgram;
648 planetShaderProgram = NULL;
649+ delete ringPlanetShaderProgram;
650+ ringPlanetShaderProgram = NULL;
651+ delete moonShaderProgram;
652+ moonShaderProgram = NULL;
653 }
654
655 void Planet::draw3dModel(StelCore* core, StelProjector::ModelViewTranformP transfo, float screenSz, bool drawOnlyRing)
656
657=== modified file 'src/main.cpp'
658--- src/main.cpp 2014-09-27 11:37:20 +0000
659+++ src/main.cpp 2014-11-24 19:29:55 +0000
660@@ -43,7 +43,6 @@
661 #include <QFile>
662 #include <QFileInfo>
663 #include <QFontDatabase>
664-#include <QGLFormat>
665 #include <QGuiApplication>
666 #include <QSettings>
667 #include <QSplashScreen>
668@@ -344,55 +343,24 @@
669 app.installTranslator(&trans);
670
671 StelMainView mainWin;
672-
673- bool appCanRun = true;
674- // some basic diagnostics
675- if (!QGLFormat::hasOpenGL()){
676- qWarning() << "Oops... This system does not support OpenGL.";
677- QMessageBox::warning(0, "Stellarium", q_("This system does not support OpenGL."));
678- appCanRun = false;
679- }
680-
681- if (!(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_1) && !(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0)) // Check supported version of OpenGL
682- {
683- // OK, minimal required version of OpenGL is 2.1 and OpenGL Shading Language is 1.20 (or OpenGL ES is 2.0 and GLSL ES is 2.0).
684- // Recommended OpenGL 3.0 and OpenGL Shading Language 1.30 and above.
685- // If platform does not support this version then say to user about troubles and quit from application.
686- #ifdef Q_OS_WIN
687- qWarning() << "Oops... Insufficient OpenGL version. Please update drivers, graphics hardware, or use MESA (or ANGLE) version.";
688- QMessageBox::warning(0, "Stellarium", q_("Insufficient OpenGL version. Please update drivers, graphics hardware, or use MESA (or ANGLE) version."));
689- #else
690- qWarning() << "Oops... Insufficient OpenGL version. Please update drivers, or graphics hardware.";
691- QMessageBox::warning(0, "Stellarium", q_("Insufficient OpenGL version. Please update drivers, or graphics hardware."));
692- #endif
693- appCanRun = false;
694- }
695-
696- if (appCanRun)
697- {
698- mainWin.init(confSettings);
699- splash.finish(&mainWin);
700- app.exec();
701- mainWin.deinit();
702-
703- delete confSettings;
704- StelLogger::deinit();
705-
706- #ifdef Q_OS_WIN
707- if(timerGrain)
708- timeEndPeriod(timerGrain);
709- #endif //Q_OS_WIN
710- #ifdef Q_OS_MAC
711- delete(newArgv);
712- delete(option);
713- delete(value);
714- #endif
715-
716- return 0;
717- }
718- else
719- {
720- app.quit();
721- }
722+ mainWin.init(confSettings); // May exit(0) when OpenGL subsystem insufficient
723+ splash.finish(&mainWin);
724+ app.exec();
725+ mainWin.deinit();
726+
727+ delete confSettings;
728+ StelLogger::deinit();
729+
730+ #ifdef Q_OS_WIN
731+ if(timerGrain)
732+ timeEndPeriod(timerGrain);
733+ #endif //Q_OS_WIN
734+ #ifdef Q_OS_MAC
735+ delete(newArgv);
736+ delete(option);
737+ delete(value);
738+ #endif
739+
740+ return 0;
741 }
742