Merge lp:~georg-zotti/stellarium/gz_shaderloader-message into lp:stellarium

Proposed by gzotti
Status: Rejected
Rejected by: Alexander Wolf
Proposed branch: lp:~georg-zotti/stellarium/gz_shaderloader-message
Merge into: lp:stellarium
Diff against target: 472 lines (+192/-76)
5 files modified
src/CLIProcessor.cpp (+3/-0)
src/core/StelPainter.cpp (+102/-46)
src/core/StelPainter.hpp (+8/-1)
src/core/modules/Planet.cpp (+75/-24)
src/main.cpp (+4/-5)
To merge this branch: bzr merge lp:~georg-zotti/stellarium/gz_shaderloader-message
Reviewer Review Type Date Requested Status
Fabien Chéreau Disapprove
Tomasz Buchert Pending
Review via email: mp+239762@code.launchpad.net

Description of the change

Better OpenGL diagnostics handling. Some folks are unhappy to look into the logfile after a crash on first run on old hardware. This branch adds some GUI message panels in case of critical errors. The panels can be closed, accepting degraded operation. A new command line switch has been added to suppress the panels and continue operation in case of uncritical errors.

Proper operation of this patch can best be tested on old hardware which is known to NOT run properly, like NVidia 6xxx/7xxx, older AMD, older Intel with OpenGL2.1 but missing functions. I would like to have a 32bit Win install package for testing on two such old PCs before merge.

To post a comment you must log in.
7110. By gzotti

merge from trunk at r7108

Revision history for this message
Fabien Chéreau (xalioth) wrote :

I don't really like this patch:
 - it adds GUI dependencies to deep engine code which should be strictly avoided
 - adding some pop ups in case of failure doesn't add value compared to a normal crash
 - I don't think it's even good you can ask the user whether he wants to continue in this case, he just cannot know. We have to decide for him if an error is critical or not. If it's critical we crash, if not we continue.
 - we should find a more elegant, generic and robust way to deal with crashes or opengl failure, for example by displaying logs in a window just before quitting in case of crash

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

OK, this was just following that user request. If I take out the panels, the added tests may still be valuable. Else, we forget it.

Just that I have an Intel office PC with almost working OpenGL2.1 that just has that problem with the semitransparent box bounded by the menu slide-outs in lower left of the display in Night mode. I don't know if one of the compile/link/bind methods would return false on this. It works, but not fully, and it should therefore not simply crash. This and similar would benefit from the new command line switch by not failing completely.

Unmerged revisions

7110. By gzotti

merge from trunk at r7108

7109. By gzotti

added new CLI flag --ignore-opengl-errors to suppress shader warning panels.

7108. By gzotti

More OpenGL shader compilation diagnostics with Messagebox indicating problems in case of OpenGL shader compilation errors.
Also fixed Planet deinit()

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/CLIProcessor.cpp'
2--- src/CLIProcessor.cpp 2014-09-12 11:42:59 +0000
3+++ src/CLIProcessor.cpp 2014-10-27 19:09:08 +0000
4@@ -56,6 +56,7 @@
5 //<< "--safe-mode (or -s) : Disable GL shaders and use older GL engine\n"
6 << "--dump-opengl-details (or -d) : dump information about OpenGL support to logfile\n"
7 << " Try this is you have graphics problems\n"
8+ << "--ignore-opengl-errors : Suppress warning panels, ignore errors\n"
9 << "--full-screen (or -f) : With argument \"yes\" or \"no\" over-rides\n"
10 << " the full screen setting in the config file\n"
11 << "--screenshot-dir : Specify directory to save screenshots\n"
12@@ -123,6 +124,8 @@
13 {
14 bool dumpOpenGLDetails = argsGetOption(argList, "-d", "--dump-opengl-details");
15 qApp->setProperty("dump_OpenGL_details", dumpOpenGLDetails);
16+ bool ignoreOpenGLErrors = argsGetOption(argList, "", "--ignore-opengl-errors");
17+ qApp->setProperty("ignore_OpenGL_errors", ignoreOpenGLErrors);
18 fullScreen = argsGetYesNoOption(argList, "-f", "--full-screen", -1);
19 landscapeId = argsGetOptionWithArg(argList, "", "--landscape", "").toString();
20 homePlanet = argsGetOptionWithArg(argList, "", "--home-planet", "").toString();
21
22=== modified file 'src/core/StelPainter.cpp'
23--- src/core/StelPainter.cpp 2014-06-06 04:26:56 +0000
24+++ src/core/StelPainter.cpp 2014-10-27 19:09:08 +0000
25@@ -25,6 +25,7 @@
26 #include "StelProjectorClasses.hpp"
27 #include "StelUtils.hpp"
28
29+#include <QApplication>
30 #include <QDebug>
31 #include <QString>
32 #include <QSettings>
33@@ -36,7 +37,7 @@
34 #include <QCache>
35 #include <QOpenGLPaintDevice>
36 #include <QOpenGLShader>
37-
38+#include <QMessageBox>
39
40 #ifndef NDEBUG
41 QMutex* StelPainter::globalMutex = new QMutex();
42@@ -73,14 +74,6 @@
43 }
44 }
45
46-bool StelPainter::linkProg(QOpenGLShaderProgram* prog, const QString& name)
47-{
48- bool ret = prog->link();
49- if (!ret || (!prog->log().isEmpty() && !prog->log().contains("Link was successful")))
50- qWarning() << QString("StelPainter: Warnings while linking %1 shader program:\n%2").arg(name, prog->log());
51- return ret;
52-}
53-
54 StelPainter::StelPainter(const StelProjectorP& proj) : prj(proj)
55 {
56 Q_ASSERT(proj);
57@@ -1552,6 +1545,33 @@
58 texture2dEnabled = b;
59 }
60
61+
62+
63+bool StelPainter::compileShader(QOpenGLShader* shader, const char* src, const char* name)
64+{
65+ bool ret=shader->compileSourceCode(src);
66+ if ((!ret) && !shader->log().isEmpty()) { qWarning() << "StelPainter: Warnings while compiling " << name << ": " << shader->log(); }
67+ return ret;
68+}
69+
70+bool StelPainter::addShaders(QOpenGLShaderProgram* prog, QOpenGLShader* vshader, const char* vShaderName, QOpenGLShader* fshader, const char* fShaderName)
71+{
72+ bool retv=prog->addShader(vshader);
73+ if (!retv) { qWarning() << "StelPainter: Error while adding " << vShaderName; }
74+ bool retf=prog->addShader(fshader);
75+ if (!retf) { qWarning() << "StelPainter: Error while adding " << fShaderName; }
76+ return retv && retf;
77+}
78+
79+bool StelPainter::linkProg(QOpenGLShaderProgram* prog, const QString& name)
80+{
81+ bool ret = prog->link();
82+ if (!ret || (!prog->log().isEmpty() && !prog->log().contains("Link was successful")))
83+ qWarning() << QString("StelPainter: Warnings while linking %1 shader program:\n%2").arg(name, prog->log());
84+ return ret;
85+}
86+
87+
88 void StelPainter::initGLShaders()
89 {
90 qWarning() << "Intializing basic GL shaders... ";
91@@ -1564,8 +1584,6 @@
92 "{\n"
93 " gl_Position = projectionMatrix*vec4(vertex, 1.);\n"
94 "}\n";
95- vshader3.compileSourceCode(vsrc3);
96- if (!vshader3.log().isEmpty()) { qWarning() << "StelPainter: Warnings while compiling vshader3: " << vshader3.log(); }
97 QOpenGLShader fshader3(QOpenGLShader::Fragment);
98 const char *fsrc3 =
99 "uniform mediump vec4 color;\n"
100@@ -1573,16 +1591,28 @@
101 "{\n"
102 " gl_FragColor = color;\n"
103 "}\n";
104- fshader3.compileSourceCode(fsrc3);
105- if (!fshader3.log().isEmpty()) { qWarning() << "StelPainter: Warnings while compiling fshader3: " << fshader3.log(); }
106 basicShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext());
107- basicShaderProgram->addShader(&vshader3);
108- basicShaderProgram->addShader(&fshader3);
109- linkProg(basicShaderProgram, "basicShaderProgram");
110+ if (!( compileShader(&vshader3, vsrc3, "vshader3") &&
111+ compileShader(&fshader3, fsrc3, "fshader3") &&
112+ addShaders(basicShaderProgram, &vshader3, "vshader3", &fshader3, "fshader3") &&
113+ linkProg(basicShaderProgram, "basicShaderProgram")) &&
114+ !qApp->property("ignore_OpenGL_errors").toBool() )
115+ {
116+ // Error handling: Show GUI panel "Ignore possible problems?"
117+ QMessageBox::StandardButton answerButton=
118+ QMessageBox::critical(0, q_("Stellarium: OpenGL Errors"),
119+ q_("Your OpenGL subsystem has problems. See log for details.\nIgnore and try to continue in degraded mode anyway?"),
120+ QMessageBox::Ignore|QMessageBox::Abort, QMessageBox::Abort);
121+ if (answerButton == QMessageBox::Abort)
122+ {
123+ qDebug() << "Aborting due to OpenGL initialization problems.";
124+ StelApp::getInstance().quit(); // Seems not to be enough(?)
125+ exit(0);
126+ }
127+ }
128 basicShaderVars.projectionMatrix = basicShaderProgram->uniformLocation("projectionMatrix");
129 basicShaderVars.color = basicShaderProgram->uniformLocation("color");
130 basicShaderVars.vertex = basicShaderProgram->attributeLocation("vertex");
131-
132
133 // Basic shader: vertex filled with interpolated color
134 QOpenGLShader vshaderInterpolatedColor(QOpenGLShader::Vertex);
135@@ -1596,10 +1626,6 @@
136 " gl_Position = projectionMatrix*vec4(vertex, 1.);\n"
137 " fragcolor = color;\n"
138 "}\n";
139- vshaderInterpolatedColor.compileSourceCode(vshaderInterpolatedColorSrc);
140- if (!vshaderInterpolatedColor.log().isEmpty()) {
141- qWarning() << "StelPainter: Warnings while compiling vshaderInterpolatedColor: " << vshaderInterpolatedColor.log();
142- }
143 QOpenGLShader fshaderInterpolatedColor(QOpenGLShader::Fragment);
144 const char *fshaderInterpolatedColorSrc =
145 "varying mediump vec4 fragcolor;\n"
146@@ -1607,14 +1633,25 @@
147 "{\n"
148 " gl_FragColor = fragcolor;\n"
149 "}\n";
150- fshaderInterpolatedColor.compileSourceCode(fshaderInterpolatedColorSrc);
151- if (!fshaderInterpolatedColor.log().isEmpty()) {
152- qWarning() << "StelPainter: Warnings while compiling fshaderInterpolatedColor: " << fshaderInterpolatedColor.log();
153- }
154 colorShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext());
155- colorShaderProgram->addShader(&vshaderInterpolatedColor);
156- colorShaderProgram->addShader(&fshaderInterpolatedColor);
157- linkProg(colorShaderProgram, "colorShaderProgram");
158+ if (!( compileShader(&vshaderInterpolatedColor, vshaderInterpolatedColorSrc, "vshaderInterpolatedColor") &&
159+ compileShader(&fshaderInterpolatedColor, fshaderInterpolatedColorSrc, "fshaderInterpolatedColor") &&
160+ addShaders(colorShaderProgram, &vshaderInterpolatedColor, "vshaderInterpolatedColor", &fshaderInterpolatedColor, "fshaderInterpolatedColor") &&
161+ linkProg(colorShaderProgram, "colorShaderProgram")) &&
162+ !qApp->property("ignore_OpenGL_errors").toBool() )
163+ {
164+ // Error handling: Show GUI panel "Ignore possible problems?"
165+ QMessageBox::StandardButton answerButton=
166+ QMessageBox::critical(0, q_("Stellarium: OpenGL Errors"),
167+ q_("Your OpenGL subsystem has problems. See log for details.\nIgnore and try to continue in degraded mode anyway?"),
168+ QMessageBox::Ignore|QMessageBox::Abort, QMessageBox::Abort);
169+ if (answerButton == QMessageBox::Abort)
170+ {
171+ qDebug() << "Aborting due to OpenGL initialization problems.";
172+ StelApp::getInstance().quit(); // Seems not to be enough(?)
173+ exit(0);
174+ }
175+ }
176 colorShaderVars.projectionMatrix = colorShaderProgram->uniformLocation("projectionMatrix");
177 colorShaderVars.color = colorShaderProgram->attributeLocation("color");
178 colorShaderVars.vertex = colorShaderProgram->attributeLocation("vertex");
179@@ -1631,9 +1668,6 @@
180 " gl_Position = projectionMatrix * vec4(vertex, 1.);\n"
181 " texc = texCoord;\n"
182 "}\n";
183- vshader2.compileSourceCode(vsrc2);
184- if (!vshader2.log().isEmpty()) { qWarning() << "StelPainter: Warnings while compiling vshader2: " << vshader2.log(); }
185-
186 QOpenGLShader fshader2(QOpenGLShader::Fragment);
187 const char *fsrc2 =
188 "varying mediump vec2 texc;\n"
189@@ -1643,13 +1677,26 @@
190 "{\n"
191 " gl_FragColor = texture2D(tex, texc)*texColor;\n"
192 "}\n";
193- fshader2.compileSourceCode(fsrc2);
194- if (!fshader2.log().isEmpty()) { qWarning() << "StelPainter: Warnings while compiling fshader2: " << fshader2.log(); }
195-
196 texturesShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext());
197- texturesShaderProgram->addShader(&vshader2);
198- texturesShaderProgram->addShader(&fshader2);
199- linkProg(texturesShaderProgram, "texturesShaderProgram");
200+ if (!( compileShader(&vshader2, vsrc2, "vshader2") &&
201+ compileShader(&fshader2, fsrc2, "fshader2") &&
202+ addShaders(texturesShaderProgram, &vshader2, "vshader2", &fshader2, "fshader2") &&
203+ linkProg(texturesShaderProgram, "texturesShaderProgram")) &&
204+ !qApp->property("ignore_OpenGL_errors").toBool() )
205+ {
206+ // Error handling: Show GUI panel "Ignore possible problems?"
207+ QMessageBox::StandardButton answerButton=
208+ QMessageBox::critical(0, q_("Stellarium: OpenGL Errors"),
209+ q_("Your OpenGL subsystem has problems. See log for details.\nIgnore and try to continue in degraded mode anyway?"),
210+ QMessageBox::Ignore|QMessageBox::Abort, QMessageBox::Abort);
211+ if (answerButton == QMessageBox::Abort)
212+ {
213+ qDebug() << "Aborting due to OpenGL initialization problems.";
214+ StelApp::getInstance().quit(); // Seems not to be enough(?)
215+ exit(0);
216+ }
217+ }
218+
219 texturesShaderVars.projectionMatrix = texturesShaderProgram->uniformLocation("projectionMatrix");
220 texturesShaderVars.texCoord = texturesShaderProgram->attributeLocation("texCoord");
221 texturesShaderVars.vertex = texturesShaderProgram->attributeLocation("vertex");
222@@ -1671,9 +1718,6 @@
223 " texc = texCoord;\n"
224 " outColor = color;\n"
225 "}\n";
226- vshader4.compileSourceCode(vsrc4);
227- if (!vshader4.log().isEmpty()) { qWarning() << "StelPainter: Warnings while compiling vshader4: " << vshader4.log(); }
228-
229 QOpenGLShader fshader4(QOpenGLShader::Fragment);
230 const char *fsrc4 =
231 "varying mediump vec2 texc;\n"
232@@ -1683,13 +1727,25 @@
233 "{\n"
234 " gl_FragColor = texture2D(tex, texc)*outColor;\n"
235 "}\n";
236- fshader4.compileSourceCode(fsrc4);
237- if (!fshader4.log().isEmpty()) { qWarning() << "StelPainter: Warnings while compiling fshader4: " << fshader4.log(); }
238-
239 texturesColorShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext());
240- texturesColorShaderProgram->addShader(&vshader4);
241- texturesColorShaderProgram->addShader(&fshader4);
242- linkProg(texturesColorShaderProgram, "texturesColorShaderProgram");
243+ if (!( compileShader(&vshader4, vsrc4, "vshader4") &&
244+ compileShader(&fshader4, fsrc4, "fshader4") &&
245+ addShaders(texturesColorShaderProgram, &vshader4, "vshader4", &fshader4, "fshader4") &&
246+ linkProg(texturesColorShaderProgram, "texturesColorShaderProgram")) &&
247+ !qApp->property("ignore_OpenGL_errors").toBool() )
248+ {
249+ // Error handling: Show GUI panel "Ignore possible problems?"
250+ QMessageBox::StandardButton answerButton=
251+ QMessageBox::critical(0, q_("Stellarium: OpenGL Errors"),
252+ q_("Your OpenGL subsystem has problems. See log for details.\nIgnore and try to continue in degraded mode anyway?"),
253+ QMessageBox::Ignore|QMessageBox::Abort, QMessageBox::Abort);
254+ if (answerButton == QMessageBox::Abort)
255+ {
256+ qDebug() << "Aborting due to OpenGL initialization problems.";
257+ StelApp::getInstance().quit(); // Seems not to be enough(?)
258+ exit(0);
259+ }
260+ }
261 texturesColorShaderVars.projectionMatrix = texturesColorShaderProgram->uniformLocation("projectionMatrix");
262 texturesColorShaderVars.texCoord = texturesColorShaderProgram->attributeLocation("texCoord");
263 texturesColorShaderVars.vertex = texturesColorShaderProgram->attributeLocation("vertex");
264
265=== modified file 'src/core/StelPainter.hpp'
266--- src/core/StelPainter.hpp 2014-06-10 19:20:20 +0000
267+++ src/core/StelPainter.hpp 2014-10-27 19:09:08 +0000
268@@ -263,7 +263,14 @@
269 //! @param checkDiscontinuity will check and suppress discontinuities if necessary.
270 void drawStelVertexArray(const StelVertexArray& arr, const bool checkDiscontinuity=true);
271
272- //! Link an opengl program and show a message in case of error or warnings.
273+ // A few wrapper functions to make code better readable
274+ //! Compile an OpenGL shader and log a message in case of error or warnings.
275+ //! @return true if the compilation was successful.
276+ static bool compileShader(class QOpenGLShader* shader, const char* src, const char *name);
277+ //! Add a compiled OpenGL program and log a message in case of error or warnings.
278+ //! @return true if the addition was successful.
279+ static bool addShaders(class QOpenGLShaderProgram* prog, class QOpenGLShader* vshader, const char *vShaderName, class QOpenGLShader* fshader, const char *fShaderName);
280+ //! Link an OpenGL program (after addition of all compiled programs) and log a message in case of error or warnings.
281 //! @return true if the link was successful.
282 static bool linkProg(class QOpenGLShaderProgram* prog, const QString& name);
283
284
285=== modified file 'src/core/modules/Planet.cpp'
286--- src/core/modules/Planet.cpp 2014-10-27 16:19:19 +0000
287+++ src/core/modules/Planet.cpp 2014-10-27 19:09:08 +0000
288@@ -37,12 +37,14 @@
289 #include "StelOpenGL.hpp"
290
291 #include <iomanip>
292+#include <QApplication>
293 #include <QTextStream>
294 #include <QString>
295 #include <QDebug>
296 #include <QVarLengthArray>
297 #include <QOpenGLContext>
298 #include <QOpenGLShader>
299+#include <QMessageBox>
300
301 Vec3f Planet::labelColor = Vec3f(0.4,0.4,0.8);
302 Vec3f Planet::orbitColor = Vec3f(1,0.6,1);
303@@ -1165,20 +1167,31 @@
304 " }\n"
305 "}\n";
306
307+ bool planetShaderInitSuccessful;
308 // Default planet shader program
309 QOpenGLShader vshader(QOpenGLShader::Vertex);
310- vshader.compileSourceCode(vsrc);
311- if (!vshader.log().isEmpty()) { qWarning() << "Planet: Warnings while compiling vshader: " << vshader.log(); }
312-
313+ bool result=vshader.compileSourceCode(vsrc);
314+ if (!result) { qWarning() << "Planet: Warnings while compiling vshader: " << vshader.log(); }
315+ planetShaderInitSuccessful=result;
316+
317 QOpenGLShader fshader(QOpenGLShader::Fragment);
318- fshader.compileSourceCode(fsrc);
319- if (!fshader.log().isEmpty()) { qWarning() << "Planet: Warnings while compiling fshader: " << fshader.log(); }
320+ result=fshader.compileSourceCode(fsrc);
321+ if (!result) { qWarning() << "Planet: Warnings while compiling fshader: " << fshader.log(); }
322+ planetShaderInitSuccessful=planetShaderInitSuccessful && result;
323
324 planetShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext());
325- planetShaderProgram->addShader(&vshader);
326- planetShaderProgram->addShader(&fshader);
327- GL(StelPainter::linkProg(planetShaderProgram, "planetShaderProgram"));
328- GL(planetShaderProgram->bind());
329+ result=planetShaderProgram->addShader(&vshader);
330+ if (!result) { qWarning() << "Planet: Error while adding vshader: "; }
331+ planetShaderInitSuccessful=planetShaderInitSuccessful && result;
332+ result=planetShaderProgram->addShader(&fshader);
333+ if (!result) { qWarning() << "Planet: Error while adding fshader: "; }
334+ planetShaderInitSuccessful=planetShaderInitSuccessful && result;
335+ GL(result=StelPainter::linkProg(planetShaderProgram, "planetShaderProgram"));
336+ if (!result) { qWarning() << "Planet: Error linking planetShaderprogram"; }
337+ planetShaderInitSuccessful=planetShaderInitSuccessful && result;
338+ GL(result=planetShaderProgram->bind());
339+ if (!result) { qWarning() << "Planet: Error binding planetShaderprogram"; }
340+ planetShaderInitSuccessful=planetShaderInitSuccessful && result;
341 planetShaderVars.initLocations(planetShaderProgram);
342 GL(planetShaderProgram->release());
343
344@@ -1186,14 +1199,23 @@
345 QByteArray arr = "#define RINGS_SUPPORT\n\n";
346 arr+=fsrc;
347 QOpenGLShader ringFragmentShader(QOpenGLShader::Fragment);
348- ringFragmentShader.compileSourceCode(arr.constData());
349- if (!ringFragmentShader.log().isEmpty()) { qWarning() << "Planet: Warnings while compiling ringFragmentShader: " << ringFragmentShader.log(); }
350+ result=ringFragmentShader.compileSourceCode(arr.constData());
351+ if (!result) { qWarning() << "Planet: Warnings while compiling ringFragmentShader: " << ringFragmentShader.log(); }
352+ planetShaderInitSuccessful=planetShaderInitSuccessful && result;
353
354 ringPlanetShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext());
355- ringPlanetShaderProgram->addShader(&vshader);
356- ringPlanetShaderProgram->addShader(&ringFragmentShader);
357- GL(StelPainter::linkProg(ringPlanetShaderProgram, "ringPlanetShaderProgram"));
358- GL(ringPlanetShaderProgram->bind());
359+ result=ringPlanetShaderProgram->addShader(&vshader);
360+ if (!result) { qWarning() << "Planet: Error while adding vshader to ringPlanetShaderProgram."; }
361+ planetShaderInitSuccessful=planetShaderInitSuccessful && result;
362+ result=ringPlanetShaderProgram->addShader(&ringFragmentShader);
363+ if (!result) { qWarning() << "Planet: Error while adding ringFragmentShader."; }
364+ planetShaderInitSuccessful=planetShaderInitSuccessful && result;
365+ GL(result=StelPainter::linkProg(ringPlanetShaderProgram, "ringPlanetShaderProgram"));
366+ if (!result) { qWarning() << "Planet: Error linking ringPlanetShaderprogram"; }
367+ planetShaderInitSuccessful=planetShaderInitSuccessful && result;
368+ GL(result=ringPlanetShaderProgram->bind());
369+ if (!result) { qWarning() << "Planet: Error binding ringPlanetShaderprogram"; }
370+ planetShaderInitSuccessful=planetShaderInitSuccessful && result;
371 ringPlanetShaderVars.initLocations(ringPlanetShaderProgram);
372 GL(ringPlanetShaderVars.isRing = ringPlanetShaderProgram->uniformLocation("isRing"));
373 GL(ringPlanetShaderVars.ring = ringPlanetShaderProgram->uniformLocation("ring"));
374@@ -1206,30 +1228,59 @@
375 arr = "#define IS_MOON\n\n";
376 arr+=vsrc;
377 QOpenGLShader moonVertexShader(QOpenGLShader::Vertex);
378- moonVertexShader.compileSourceCode(arr.constData());
379- if (!moonVertexShader.log().isEmpty()) { qWarning() << "Planet: Warnings while compiling moonVertexShader: " << moonVertexShader.log(); }
380-
381+ result=moonVertexShader.compileSourceCode(arr.constData());
382+ if (!result) { qWarning() << "Planet: Warnings while compiling moonVertexShader: " << moonVertexShader.log(); }
383+ planetShaderInitSuccessful=planetShaderInitSuccessful && result;
384+
385 arr = "#define IS_MOON\n\n";
386 arr+=fsrc;
387 QOpenGLShader moonFragmentShader(QOpenGLShader::Fragment);
388- moonFragmentShader.compileSourceCode(arr.constData());
389- if (!moonFragmentShader.log().isEmpty()) { qWarning() << "Planet: Warnings while compiling moonFragmentShader: " << moonFragmentShader.log(); }
390+ result=moonFragmentShader.compileSourceCode(arr.constData());
391+ if (!result) { qWarning() << "Planet: Warnings while compiling moonFragmentShader: " << moonFragmentShader.log(); }
392+ planetShaderInitSuccessful=planetShaderInitSuccessful && result;
393
394 moonShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext());
395- moonShaderProgram->addShader(&moonVertexShader);
396- moonShaderProgram->addShader(&moonFragmentShader);
397- GL(StelPainter::linkProg(moonShaderProgram, "moonPlanetShaderProgram"));
398- GL(moonShaderProgram->bind());
399+ result=moonShaderProgram->addShader(&moonVertexShader);
400+ if (!result) { qWarning() << "Planet: Error while adding moonVertexShader."; }
401+ planetShaderInitSuccessful=planetShaderInitSuccessful && result;
402+ result=moonShaderProgram->addShader(&moonFragmentShader);
403+ if (!result) { qWarning() << "Planet: Error while adding moonFragmentShader."; }
404+ planetShaderInitSuccessful=planetShaderInitSuccessful && result;
405+ GL(result=StelPainter::linkProg(moonShaderProgram, "moonPlanetShaderProgram"));
406+ if (!result) { qWarning() << "Planet: Error linking moonPlanetShaderprogram"; }
407+ planetShaderInitSuccessful=planetShaderInitSuccessful && result;
408+ GL(result=moonShaderProgram->bind());
409+ if (!result) { qWarning() << "Planet: Error binding moonPlanetShaderprogram"; }
410+ planetShaderInitSuccessful=planetShaderInitSuccessful && result;
411 moonShaderVars.initLocations(moonShaderProgram);
412 GL(moonShaderVars.earthShadow = moonShaderProgram->uniformLocation("earthShadow"));
413 GL(moonShaderVars.normalMap = moonShaderProgram->uniformLocation("normalMap"));
414 GL(moonShaderProgram->release());
415+
416+ if ((!planetShaderInitSuccessful) && (!qApp->property("ignore_OpenGL_errors").toBool()))
417+ {
418+ // Error handling: Show GUI panel "Ignore possible problems?"
419+ QMessageBox::StandardButton answerButton=
420+ QMessageBox::critical(0, q_("Stellarium: OpenGL Errors"),
421+ q_("Your OpenGL subsystem has problems. See log for details.\nIgnore and try to continue in degraded mode anyway?"),
422+ QMessageBox::Ignore|QMessageBox::Abort, QMessageBox::Abort);
423+ if (answerButton == QMessageBox::Abort)
424+ {
425+ qDebug() << "Aborting due to OpenGL initialization problems.";
426+ StelApp::getInstance().quit(); // Seems not to be enough(?)
427+ exit(0);
428+ }
429+ }
430 }
431
432 void Planet::deinitShader()
433 {
434 delete planetShaderProgram;
435 planetShaderProgram = NULL;
436+ delete ringPlanetShaderProgram;
437+ ringPlanetShaderProgram = NULL;
438+ delete moonShaderProgram;
439+ moonShaderProgram = NULL;
440 }
441
442 void Planet::draw3dModel(StelCore* core, StelProjector::ModelViewTranformP transfo, float screenSz, bool drawOnlyRing)
443
444=== modified file 'src/main.cpp'
445--- src/main.cpp 2014-09-27 11:37:20 +0000
446+++ src/main.cpp 2014-10-27 19:09:08 +0000
447@@ -349,21 +349,20 @@
448 // some basic diagnostics
449 if (!QGLFormat::hasOpenGL()){
450 qWarning() << "Oops... This system does not support OpenGL.";
451- QMessageBox::warning(0, "Stellarium", q_("This system does not support OpenGL."));
452+ QMessageBox::critical(0, "Stellarium", q_("This system does not support OpenGL."), QMessageBox::Abort, QMessageBox::Abort);
453 appCanRun = false;
454 }
455-
456- if (!(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_1) && !(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0)) // Check supported version of OpenGL
457+ else if (!(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_1) && !(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0)) // Check supported version of OpenGL
458 {
459 // 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).
460 // Recommended OpenGL 3.0 and OpenGL Shading Language 1.30 and above.
461 // If platform does not support this version then say to user about troubles and quit from application.
462 #ifdef Q_OS_WIN
463 qWarning() << "Oops... Insufficient OpenGL version. Please update drivers, graphics hardware, or use MESA (or ANGLE) version.";
464- QMessageBox::warning(0, "Stellarium", q_("Insufficient OpenGL version. Please update drivers, graphics hardware, or use MESA (or ANGLE) version."));
465+ QMessageBox::critical(0, "Stellarium", q_("Insufficient OpenGL version. Please update drivers, graphics hardware, or use MESA (or ANGLE) version."), QMessageBox::Abort, QMessageBox::Abort);
466 #else
467 qWarning() << "Oops... Insufficient OpenGL version. Please update drivers, or graphics hardware.";
468- QMessageBox::warning(0, "Stellarium", q_("Insufficient OpenGL version. Please update drivers, or graphics hardware."));
469+ QMessageBox::critical(0, "Stellarium", q_("Insufficient OpenGL version. Please update drivers, or graphics hardware."), QMessageBox::Abort, QMessageBox::Abort);
470 #endif
471 appCanRun = false;
472 }