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
=== modified file 'src/CLIProcessor.cpp'
--- src/CLIProcessor.cpp 2014-09-12 11:42:59 +0000
+++ src/CLIProcessor.cpp 2014-10-27 19:09:08 +0000
@@ -56,6 +56,7 @@
56 //<< "--safe-mode (or -s) : Disable GL shaders and use older GL engine\n"56 //<< "--safe-mode (or -s) : Disable GL shaders and use older GL engine\n"
57 << "--dump-opengl-details (or -d) : dump information about OpenGL support to logfile\n"57 << "--dump-opengl-details (or -d) : dump information about OpenGL support to logfile\n"
58 << " Try this is you have graphics problems\n"58 << " Try this is you have graphics problems\n"
59 << "--ignore-opengl-errors : Suppress warning panels, ignore errors\n"
59 << "--full-screen (or -f) : With argument \"yes\" or \"no\" over-rides\n"60 << "--full-screen (or -f) : With argument \"yes\" or \"no\" over-rides\n"
60 << " the full screen setting in the config file\n"61 << " the full screen setting in the config file\n"
61 << "--screenshot-dir : Specify directory to save screenshots\n"62 << "--screenshot-dir : Specify directory to save screenshots\n"
@@ -123,6 +124,8 @@
123 {124 {
124 bool dumpOpenGLDetails = argsGetOption(argList, "-d", "--dump-opengl-details");125 bool dumpOpenGLDetails = argsGetOption(argList, "-d", "--dump-opengl-details");
125 qApp->setProperty("dump_OpenGL_details", dumpOpenGLDetails);126 qApp->setProperty("dump_OpenGL_details", dumpOpenGLDetails);
127 bool ignoreOpenGLErrors = argsGetOption(argList, "", "--ignore-opengl-errors");
128 qApp->setProperty("ignore_OpenGL_errors", ignoreOpenGLErrors);
126 fullScreen = argsGetYesNoOption(argList, "-f", "--full-screen", -1);129 fullScreen = argsGetYesNoOption(argList, "-f", "--full-screen", -1);
127 landscapeId = argsGetOptionWithArg(argList, "", "--landscape", "").toString();130 landscapeId = argsGetOptionWithArg(argList, "", "--landscape", "").toString();
128 homePlanet = argsGetOptionWithArg(argList, "", "--home-planet", "").toString();131 homePlanet = argsGetOptionWithArg(argList, "", "--home-planet", "").toString();
129132
=== modified file 'src/core/StelPainter.cpp'
--- src/core/StelPainter.cpp 2014-06-06 04:26:56 +0000
+++ src/core/StelPainter.cpp 2014-10-27 19:09:08 +0000
@@ -25,6 +25,7 @@
25#include "StelProjectorClasses.hpp"25#include "StelProjectorClasses.hpp"
26#include "StelUtils.hpp"26#include "StelUtils.hpp"
2727
28#include <QApplication>
28#include <QDebug>29#include <QDebug>
29#include <QString>30#include <QString>
30#include <QSettings>31#include <QSettings>
@@ -36,7 +37,7 @@
36#include <QCache>37#include <QCache>
37#include <QOpenGLPaintDevice>38#include <QOpenGLPaintDevice>
38#include <QOpenGLShader>39#include <QOpenGLShader>
3940#include <QMessageBox>
4041
41#ifndef NDEBUG42#ifndef NDEBUG
42QMutex* StelPainter::globalMutex = new QMutex();43QMutex* StelPainter::globalMutex = new QMutex();
@@ -73,14 +74,6 @@
73 }74 }
74}75}
7576
76bool StelPainter::linkProg(QOpenGLShaderProgram* prog, const QString& name)
77{
78 bool ret = prog->link();
79 if (!ret || (!prog->log().isEmpty() && !prog->log().contains("Link was successful")))
80 qWarning() << QString("StelPainter: Warnings while linking %1 shader program:\n%2").arg(name, prog->log());
81 return ret;
82}
83
84StelPainter::StelPainter(const StelProjectorP& proj) : prj(proj)77StelPainter::StelPainter(const StelProjectorP& proj) : prj(proj)
85{78{
86 Q_ASSERT(proj);79 Q_ASSERT(proj);
@@ -1552,6 +1545,33 @@
1552 texture2dEnabled = b;1545 texture2dEnabled = b;
1553}1546}
15541547
1548
1549
1550bool StelPainter::compileShader(QOpenGLShader* shader, const char* src, const char* name)
1551{
1552 bool ret=shader->compileSourceCode(src);
1553 if ((!ret) && !shader->log().isEmpty()) { qWarning() << "StelPainter: Warnings while compiling " << name << ": " << shader->log(); }
1554 return ret;
1555}
1556
1557bool StelPainter::addShaders(QOpenGLShaderProgram* prog, QOpenGLShader* vshader, const char* vShaderName, QOpenGLShader* fshader, const char* fShaderName)
1558{
1559 bool retv=prog->addShader(vshader);
1560 if (!retv) { qWarning() << "StelPainter: Error while adding " << vShaderName; }
1561 bool retf=prog->addShader(fshader);
1562 if (!retf) { qWarning() << "StelPainter: Error while adding " << fShaderName; }
1563 return retv && retf;
1564}
1565
1566bool StelPainter::linkProg(QOpenGLShaderProgram* prog, const QString& name)
1567{
1568 bool ret = prog->link();
1569 if (!ret || (!prog->log().isEmpty() && !prog->log().contains("Link was successful")))
1570 qWarning() << QString("StelPainter: Warnings while linking %1 shader program:\n%2").arg(name, prog->log());
1571 return ret;
1572}
1573
1574
1555void StelPainter::initGLShaders()1575void StelPainter::initGLShaders()
1556{1576{
1557 qWarning() << "Intializing basic GL shaders... ";1577 qWarning() << "Intializing basic GL shaders... ";
@@ -1564,8 +1584,6 @@
1564 "{\n"1584 "{\n"
1565 " gl_Position = projectionMatrix*vec4(vertex, 1.);\n"1585 " gl_Position = projectionMatrix*vec4(vertex, 1.);\n"
1566 "}\n";1586 "}\n";
1567 vshader3.compileSourceCode(vsrc3);
1568 if (!vshader3.log().isEmpty()) { qWarning() << "StelPainter: Warnings while compiling vshader3: " << vshader3.log(); }
1569 QOpenGLShader fshader3(QOpenGLShader::Fragment);1587 QOpenGLShader fshader3(QOpenGLShader::Fragment);
1570 const char *fsrc3 =1588 const char *fsrc3 =
1571 "uniform mediump vec4 color;\n"1589 "uniform mediump vec4 color;\n"
@@ -1573,16 +1591,28 @@
1573 "{\n"1591 "{\n"
1574 " gl_FragColor = color;\n"1592 " gl_FragColor = color;\n"
1575 "}\n";1593 "}\n";
1576 fshader3.compileSourceCode(fsrc3);
1577 if (!fshader3.log().isEmpty()) { qWarning() << "StelPainter: Warnings while compiling fshader3: " << fshader3.log(); }
1578 basicShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext());1594 basicShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext());
1579 basicShaderProgram->addShader(&vshader3);1595 if (!( compileShader(&vshader3, vsrc3, "vshader3") &&
1580 basicShaderProgram->addShader(&fshader3);1596 compileShader(&fshader3, fsrc3, "fshader3") &&
1581 linkProg(basicShaderProgram, "basicShaderProgram");1597 addShaders(basicShaderProgram, &vshader3, "vshader3", &fshader3, "fshader3") &&
1598 linkProg(basicShaderProgram, "basicShaderProgram")) &&
1599 !qApp->property("ignore_OpenGL_errors").toBool() )
1600 {
1601 // Error handling: Show GUI panel "Ignore possible problems?"
1602 QMessageBox::StandardButton answerButton=
1603 QMessageBox::critical(0, q_("Stellarium: OpenGL Errors"),
1604 q_("Your OpenGL subsystem has problems. See log for details.\nIgnore and try to continue in degraded mode anyway?"),
1605 QMessageBox::Ignore|QMessageBox::Abort, QMessageBox::Abort);
1606 if (answerButton == QMessageBox::Abort)
1607 {
1608 qDebug() << "Aborting due to OpenGL initialization problems.";
1609 StelApp::getInstance().quit(); // Seems not to be enough(?)
1610 exit(0);
1611 }
1612 }
1582 basicShaderVars.projectionMatrix = basicShaderProgram->uniformLocation("projectionMatrix");1613 basicShaderVars.projectionMatrix = basicShaderProgram->uniformLocation("projectionMatrix");
1583 basicShaderVars.color = basicShaderProgram->uniformLocation("color");1614 basicShaderVars.color = basicShaderProgram->uniformLocation("color");
1584 basicShaderVars.vertex = basicShaderProgram->attributeLocation("vertex");1615 basicShaderVars.vertex = basicShaderProgram->attributeLocation("vertex");
1585
15861616
1587 // Basic shader: vertex filled with interpolated color1617 // Basic shader: vertex filled with interpolated color
1588 QOpenGLShader vshaderInterpolatedColor(QOpenGLShader::Vertex);1618 QOpenGLShader vshaderInterpolatedColor(QOpenGLShader::Vertex);
@@ -1596,10 +1626,6 @@
1596 " gl_Position = projectionMatrix*vec4(vertex, 1.);\n"1626 " gl_Position = projectionMatrix*vec4(vertex, 1.);\n"
1597 " fragcolor = color;\n"1627 " fragcolor = color;\n"
1598 "}\n";1628 "}\n";
1599 vshaderInterpolatedColor.compileSourceCode(vshaderInterpolatedColorSrc);
1600 if (!vshaderInterpolatedColor.log().isEmpty()) {
1601 qWarning() << "StelPainter: Warnings while compiling vshaderInterpolatedColor: " << vshaderInterpolatedColor.log();
1602 }
1603 QOpenGLShader fshaderInterpolatedColor(QOpenGLShader::Fragment);1629 QOpenGLShader fshaderInterpolatedColor(QOpenGLShader::Fragment);
1604 const char *fshaderInterpolatedColorSrc =1630 const char *fshaderInterpolatedColorSrc =
1605 "varying mediump vec4 fragcolor;\n"1631 "varying mediump vec4 fragcolor;\n"
@@ -1607,14 +1633,25 @@
1607 "{\n"1633 "{\n"
1608 " gl_FragColor = fragcolor;\n"1634 " gl_FragColor = fragcolor;\n"
1609 "}\n";1635 "}\n";
1610 fshaderInterpolatedColor.compileSourceCode(fshaderInterpolatedColorSrc);
1611 if (!fshaderInterpolatedColor.log().isEmpty()) {
1612 qWarning() << "StelPainter: Warnings while compiling fshaderInterpolatedColor: " << fshaderInterpolatedColor.log();
1613 }
1614 colorShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext());1636 colorShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext());
1615 colorShaderProgram->addShader(&vshaderInterpolatedColor);1637 if (!( compileShader(&vshaderInterpolatedColor, vshaderInterpolatedColorSrc, "vshaderInterpolatedColor") &&
1616 colorShaderProgram->addShader(&fshaderInterpolatedColor);1638 compileShader(&fshaderInterpolatedColor, fshaderInterpolatedColorSrc, "fshaderInterpolatedColor") &&
1617 linkProg(colorShaderProgram, "colorShaderProgram");1639 addShaders(colorShaderProgram, &vshaderInterpolatedColor, "vshaderInterpolatedColor", &fshaderInterpolatedColor, "fshaderInterpolatedColor") &&
1640 linkProg(colorShaderProgram, "colorShaderProgram")) &&
1641 !qApp->property("ignore_OpenGL_errors").toBool() )
1642 {
1643 // Error handling: Show GUI panel "Ignore possible problems?"
1644 QMessageBox::StandardButton answerButton=
1645 QMessageBox::critical(0, q_("Stellarium: OpenGL Errors"),
1646 q_("Your OpenGL subsystem has problems. See log for details.\nIgnore and try to continue in degraded mode anyway?"),
1647 QMessageBox::Ignore|QMessageBox::Abort, QMessageBox::Abort);
1648 if (answerButton == QMessageBox::Abort)
1649 {
1650 qDebug() << "Aborting due to OpenGL initialization problems.";
1651 StelApp::getInstance().quit(); // Seems not to be enough(?)
1652 exit(0);
1653 }
1654 }
1618 colorShaderVars.projectionMatrix = colorShaderProgram->uniformLocation("projectionMatrix");1655 colorShaderVars.projectionMatrix = colorShaderProgram->uniformLocation("projectionMatrix");
1619 colorShaderVars.color = colorShaderProgram->attributeLocation("color");1656 colorShaderVars.color = colorShaderProgram->attributeLocation("color");
1620 colorShaderVars.vertex = colorShaderProgram->attributeLocation("vertex");1657 colorShaderVars.vertex = colorShaderProgram->attributeLocation("vertex");
@@ -1631,9 +1668,6 @@
1631 " gl_Position = projectionMatrix * vec4(vertex, 1.);\n"1668 " gl_Position = projectionMatrix * vec4(vertex, 1.);\n"
1632 " texc = texCoord;\n"1669 " texc = texCoord;\n"
1633 "}\n";1670 "}\n";
1634 vshader2.compileSourceCode(vsrc2);
1635 if (!vshader2.log().isEmpty()) { qWarning() << "StelPainter: Warnings while compiling vshader2: " << vshader2.log(); }
1636
1637 QOpenGLShader fshader2(QOpenGLShader::Fragment);1671 QOpenGLShader fshader2(QOpenGLShader::Fragment);
1638 const char *fsrc2 =1672 const char *fsrc2 =
1639 "varying mediump vec2 texc;\n"1673 "varying mediump vec2 texc;\n"
@@ -1643,13 +1677,26 @@
1643 "{\n"1677 "{\n"
1644 " gl_FragColor = texture2D(tex, texc)*texColor;\n"1678 " gl_FragColor = texture2D(tex, texc)*texColor;\n"
1645 "}\n";1679 "}\n";
1646 fshader2.compileSourceCode(fsrc2);
1647 if (!fshader2.log().isEmpty()) { qWarning() << "StelPainter: Warnings while compiling fshader2: " << fshader2.log(); }
1648
1649 texturesShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext());1680 texturesShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext());
1650 texturesShaderProgram->addShader(&vshader2);1681 if (!( compileShader(&vshader2, vsrc2, "vshader2") &&
1651 texturesShaderProgram->addShader(&fshader2);1682 compileShader(&fshader2, fsrc2, "fshader2") &&
1652 linkProg(texturesShaderProgram, "texturesShaderProgram");1683 addShaders(texturesShaderProgram, &vshader2, "vshader2", &fshader2, "fshader2") &&
1684 linkProg(texturesShaderProgram, "texturesShaderProgram")) &&
1685 !qApp->property("ignore_OpenGL_errors").toBool() )
1686 {
1687 // Error handling: Show GUI panel "Ignore possible problems?"
1688 QMessageBox::StandardButton answerButton=
1689 QMessageBox::critical(0, q_("Stellarium: OpenGL Errors"),
1690 q_("Your OpenGL subsystem has problems. See log for details.\nIgnore and try to continue in degraded mode anyway?"),
1691 QMessageBox::Ignore|QMessageBox::Abort, QMessageBox::Abort);
1692 if (answerButton == QMessageBox::Abort)
1693 {
1694 qDebug() << "Aborting due to OpenGL initialization problems.";
1695 StelApp::getInstance().quit(); // Seems not to be enough(?)
1696 exit(0);
1697 }
1698 }
1699
1653 texturesShaderVars.projectionMatrix = texturesShaderProgram->uniformLocation("projectionMatrix");1700 texturesShaderVars.projectionMatrix = texturesShaderProgram->uniformLocation("projectionMatrix");
1654 texturesShaderVars.texCoord = texturesShaderProgram->attributeLocation("texCoord");1701 texturesShaderVars.texCoord = texturesShaderProgram->attributeLocation("texCoord");
1655 texturesShaderVars.vertex = texturesShaderProgram->attributeLocation("vertex");1702 texturesShaderVars.vertex = texturesShaderProgram->attributeLocation("vertex");
@@ -1671,9 +1718,6 @@
1671 " texc = texCoord;\n"1718 " texc = texCoord;\n"
1672 " outColor = color;\n"1719 " outColor = color;\n"
1673 "}\n";1720 "}\n";
1674 vshader4.compileSourceCode(vsrc4);
1675 if (!vshader4.log().isEmpty()) { qWarning() << "StelPainter: Warnings while compiling vshader4: " << vshader4.log(); }
1676
1677 QOpenGLShader fshader4(QOpenGLShader::Fragment);1721 QOpenGLShader fshader4(QOpenGLShader::Fragment);
1678 const char *fsrc4 =1722 const char *fsrc4 =
1679 "varying mediump vec2 texc;\n"1723 "varying mediump vec2 texc;\n"
@@ -1683,13 +1727,25 @@
1683 "{\n"1727 "{\n"
1684 " gl_FragColor = texture2D(tex, texc)*outColor;\n"1728 " gl_FragColor = texture2D(tex, texc)*outColor;\n"
1685 "}\n";1729 "}\n";
1686 fshader4.compileSourceCode(fsrc4);
1687 if (!fshader4.log().isEmpty()) { qWarning() << "StelPainter: Warnings while compiling fshader4: " << fshader4.log(); }
1688
1689 texturesColorShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext());1730 texturesColorShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext());
1690 texturesColorShaderProgram->addShader(&vshader4);1731 if (!( compileShader(&vshader4, vsrc4, "vshader4") &&
1691 texturesColorShaderProgram->addShader(&fshader4);1732 compileShader(&fshader4, fsrc4, "fshader4") &&
1692 linkProg(texturesColorShaderProgram, "texturesColorShaderProgram");1733 addShaders(texturesColorShaderProgram, &vshader4, "vshader4", &fshader4, "fshader4") &&
1734 linkProg(texturesColorShaderProgram, "texturesColorShaderProgram")) &&
1735 !qApp->property("ignore_OpenGL_errors").toBool() )
1736 {
1737 // Error handling: Show GUI panel "Ignore possible problems?"
1738 QMessageBox::StandardButton answerButton=
1739 QMessageBox::critical(0, q_("Stellarium: OpenGL Errors"),
1740 q_("Your OpenGL subsystem has problems. See log for details.\nIgnore and try to continue in degraded mode anyway?"),
1741 QMessageBox::Ignore|QMessageBox::Abort, QMessageBox::Abort);
1742 if (answerButton == QMessageBox::Abort)
1743 {
1744 qDebug() << "Aborting due to OpenGL initialization problems.";
1745 StelApp::getInstance().quit(); // Seems not to be enough(?)
1746 exit(0);
1747 }
1748 }
1693 texturesColorShaderVars.projectionMatrix = texturesColorShaderProgram->uniformLocation("projectionMatrix");1749 texturesColorShaderVars.projectionMatrix = texturesColorShaderProgram->uniformLocation("projectionMatrix");
1694 texturesColorShaderVars.texCoord = texturesColorShaderProgram->attributeLocation("texCoord");1750 texturesColorShaderVars.texCoord = texturesColorShaderProgram->attributeLocation("texCoord");
1695 texturesColorShaderVars.vertex = texturesColorShaderProgram->attributeLocation("vertex");1751 texturesColorShaderVars.vertex = texturesColorShaderProgram->attributeLocation("vertex");
16961752
=== modified file 'src/core/StelPainter.hpp'
--- src/core/StelPainter.hpp 2014-06-10 19:20:20 +0000
+++ src/core/StelPainter.hpp 2014-10-27 19:09:08 +0000
@@ -263,7 +263,14 @@
263 //! @param checkDiscontinuity will check and suppress discontinuities if necessary.263 //! @param checkDiscontinuity will check and suppress discontinuities if necessary.
264 void drawStelVertexArray(const StelVertexArray& arr, const bool checkDiscontinuity=true);264 void drawStelVertexArray(const StelVertexArray& arr, const bool checkDiscontinuity=true);
265265
266 //! Link an opengl program and show a message in case of error or warnings.266 // A few wrapper functions to make code better readable
267 //! Compile an OpenGL shader and log a message in case of error or warnings.
268 //! @return true if the compilation was successful.
269 static bool compileShader(class QOpenGLShader* shader, const char* src, const char *name);
270 //! Add a compiled OpenGL program and log a message in case of error or warnings.
271 //! @return true if the addition was successful.
272 static bool addShaders(class QOpenGLShaderProgram* prog, class QOpenGLShader* vshader, const char *vShaderName, class QOpenGLShader* fshader, const char *fShaderName);
273 //! Link an OpenGL program (after addition of all compiled programs) and log a message in case of error or warnings.
267 //! @return true if the link was successful.274 //! @return true if the link was successful.
268 static bool linkProg(class QOpenGLShaderProgram* prog, const QString& name);275 static bool linkProg(class QOpenGLShaderProgram* prog, const QString& name);
269276
270277
=== modified file 'src/core/modules/Planet.cpp'
--- src/core/modules/Planet.cpp 2014-10-27 16:19:19 +0000
+++ src/core/modules/Planet.cpp 2014-10-27 19:09:08 +0000
@@ -37,12 +37,14 @@
37#include "StelOpenGL.hpp"37#include "StelOpenGL.hpp"
3838
39#include <iomanip>39#include <iomanip>
40#include <QApplication>
40#include <QTextStream>41#include <QTextStream>
41#include <QString>42#include <QString>
42#include <QDebug>43#include <QDebug>
43#include <QVarLengthArray>44#include <QVarLengthArray>
44#include <QOpenGLContext>45#include <QOpenGLContext>
45#include <QOpenGLShader>46#include <QOpenGLShader>
47#include <QMessageBox>
4648
47Vec3f Planet::labelColor = Vec3f(0.4,0.4,0.8);49Vec3f Planet::labelColor = Vec3f(0.4,0.4,0.8);
48Vec3f Planet::orbitColor = Vec3f(1,0.6,1);50Vec3f Planet::orbitColor = Vec3f(1,0.6,1);
@@ -1165,20 +1167,31 @@
1165 " }\n"1167 " }\n"
1166 "}\n";1168 "}\n";
1167 1169
1170 bool planetShaderInitSuccessful;
1168 // Default planet shader program1171 // Default planet shader program
1169 QOpenGLShader vshader(QOpenGLShader::Vertex);1172 QOpenGLShader vshader(QOpenGLShader::Vertex);
1170 vshader.compileSourceCode(vsrc);1173 bool result=vshader.compileSourceCode(vsrc);
1171 if (!vshader.log().isEmpty()) { qWarning() << "Planet: Warnings while compiling vshader: " << vshader.log(); }1174 if (!result) { qWarning() << "Planet: Warnings while compiling vshader: " << vshader.log(); }
1172 1175 planetShaderInitSuccessful=result;
1176
1173 QOpenGLShader fshader(QOpenGLShader::Fragment);1177 QOpenGLShader fshader(QOpenGLShader::Fragment);
1174 fshader.compileSourceCode(fsrc);1178 result=fshader.compileSourceCode(fsrc);
1175 if (!fshader.log().isEmpty()) { qWarning() << "Planet: Warnings while compiling fshader: " << fshader.log(); }1179 if (!result) { qWarning() << "Planet: Warnings while compiling fshader: " << fshader.log(); }
1180 planetShaderInitSuccessful=planetShaderInitSuccessful && result;
11761181
1177 planetShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext());1182 planetShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext());
1178 planetShaderProgram->addShader(&vshader);1183 result=planetShaderProgram->addShader(&vshader);
1179 planetShaderProgram->addShader(&fshader);1184 if (!result) { qWarning() << "Planet: Error while adding vshader: "; }
1180 GL(StelPainter::linkProg(planetShaderProgram, "planetShaderProgram"));1185 planetShaderInitSuccessful=planetShaderInitSuccessful && result;
1181 GL(planetShaderProgram->bind());1186 result=planetShaderProgram->addShader(&fshader);
1187 if (!result) { qWarning() << "Planet: Error while adding fshader: "; }
1188 planetShaderInitSuccessful=planetShaderInitSuccessful && result;
1189 GL(result=StelPainter::linkProg(planetShaderProgram, "planetShaderProgram"));
1190 if (!result) { qWarning() << "Planet: Error linking planetShaderprogram"; }
1191 planetShaderInitSuccessful=planetShaderInitSuccessful && result;
1192 GL(result=planetShaderProgram->bind());
1193 if (!result) { qWarning() << "Planet: Error binding planetShaderprogram"; }
1194 planetShaderInitSuccessful=planetShaderInitSuccessful && result;
1182 planetShaderVars.initLocations(planetShaderProgram);1195 planetShaderVars.initLocations(planetShaderProgram);
1183 GL(planetShaderProgram->release());1196 GL(planetShaderProgram->release());
1184 1197
@@ -1186,14 +1199,23 @@
1186 QByteArray arr = "#define RINGS_SUPPORT\n\n";1199 QByteArray arr = "#define RINGS_SUPPORT\n\n";
1187 arr+=fsrc;1200 arr+=fsrc;
1188 QOpenGLShader ringFragmentShader(QOpenGLShader::Fragment);1201 QOpenGLShader ringFragmentShader(QOpenGLShader::Fragment);
1189 ringFragmentShader.compileSourceCode(arr.constData());1202 result=ringFragmentShader.compileSourceCode(arr.constData());
1190 if (!ringFragmentShader.log().isEmpty()) { qWarning() << "Planet: Warnings while compiling ringFragmentShader: " << ringFragmentShader.log(); }1203 if (!result) { qWarning() << "Planet: Warnings while compiling ringFragmentShader: " << ringFragmentShader.log(); }
1204 planetShaderInitSuccessful=planetShaderInitSuccessful && result;
11911205
1192 ringPlanetShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext());1206 ringPlanetShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext());
1193 ringPlanetShaderProgram->addShader(&vshader);1207 result=ringPlanetShaderProgram->addShader(&vshader);
1194 ringPlanetShaderProgram->addShader(&ringFragmentShader);1208 if (!result) { qWarning() << "Planet: Error while adding vshader to ringPlanetShaderProgram."; }
1195 GL(StelPainter::linkProg(ringPlanetShaderProgram, "ringPlanetShaderProgram"));1209 planetShaderInitSuccessful=planetShaderInitSuccessful && result;
1196 GL(ringPlanetShaderProgram->bind());1210 result=ringPlanetShaderProgram->addShader(&ringFragmentShader);
1211 if (!result) { qWarning() << "Planet: Error while adding ringFragmentShader."; }
1212 planetShaderInitSuccessful=planetShaderInitSuccessful && result;
1213 GL(result=StelPainter::linkProg(ringPlanetShaderProgram, "ringPlanetShaderProgram"));
1214 if (!result) { qWarning() << "Planet: Error linking ringPlanetShaderprogram"; }
1215 planetShaderInitSuccessful=planetShaderInitSuccessful && result;
1216 GL(result=ringPlanetShaderProgram->bind());
1217 if (!result) { qWarning() << "Planet: Error binding ringPlanetShaderprogram"; }
1218 planetShaderInitSuccessful=planetShaderInitSuccessful && result;
1197 ringPlanetShaderVars.initLocations(ringPlanetShaderProgram);1219 ringPlanetShaderVars.initLocations(ringPlanetShaderProgram);
1198 GL(ringPlanetShaderVars.isRing = ringPlanetShaderProgram->uniformLocation("isRing"));1220 GL(ringPlanetShaderVars.isRing = ringPlanetShaderProgram->uniformLocation("isRing"));
1199 GL(ringPlanetShaderVars.ring = ringPlanetShaderProgram->uniformLocation("ring"));1221 GL(ringPlanetShaderVars.ring = ringPlanetShaderProgram->uniformLocation("ring"));
@@ -1206,30 +1228,59 @@
1206 arr = "#define IS_MOON\n\n";1228 arr = "#define IS_MOON\n\n";
1207 arr+=vsrc;1229 arr+=vsrc;
1208 QOpenGLShader moonVertexShader(QOpenGLShader::Vertex);1230 QOpenGLShader moonVertexShader(QOpenGLShader::Vertex);
1209 moonVertexShader.compileSourceCode(arr.constData());1231 result=moonVertexShader.compileSourceCode(arr.constData());
1210 if (!moonVertexShader.log().isEmpty()) { qWarning() << "Planet: Warnings while compiling moonVertexShader: " << moonVertexShader.log(); }1232 if (!result) { qWarning() << "Planet: Warnings while compiling moonVertexShader: " << moonVertexShader.log(); }
1211 1233 planetShaderInitSuccessful=planetShaderInitSuccessful && result;
1234
1212 arr = "#define IS_MOON\n\n";1235 arr = "#define IS_MOON\n\n";
1213 arr+=fsrc;1236 arr+=fsrc;
1214 QOpenGLShader moonFragmentShader(QOpenGLShader::Fragment);1237 QOpenGLShader moonFragmentShader(QOpenGLShader::Fragment);
1215 moonFragmentShader.compileSourceCode(arr.constData());1238 result=moonFragmentShader.compileSourceCode(arr.constData());
1216 if (!moonFragmentShader.log().isEmpty()) { qWarning() << "Planet: Warnings while compiling moonFragmentShader: " << moonFragmentShader.log(); }1239 if (!result) { qWarning() << "Planet: Warnings while compiling moonFragmentShader: " << moonFragmentShader.log(); }
1240 planetShaderInitSuccessful=planetShaderInitSuccessful && result;
12171241
1218 moonShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext());1242 moonShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext());
1219 moonShaderProgram->addShader(&moonVertexShader);1243 result=moonShaderProgram->addShader(&moonVertexShader);
1220 moonShaderProgram->addShader(&moonFragmentShader);1244 if (!result) { qWarning() << "Planet: Error while adding moonVertexShader."; }
1221 GL(StelPainter::linkProg(moonShaderProgram, "moonPlanetShaderProgram"));1245 planetShaderInitSuccessful=planetShaderInitSuccessful && result;
1222 GL(moonShaderProgram->bind());1246 result=moonShaderProgram->addShader(&moonFragmentShader);
1247 if (!result) { qWarning() << "Planet: Error while adding moonFragmentShader."; }
1248 planetShaderInitSuccessful=planetShaderInitSuccessful && result;
1249 GL(result=StelPainter::linkProg(moonShaderProgram, "moonPlanetShaderProgram"));
1250 if (!result) { qWarning() << "Planet: Error linking moonPlanetShaderprogram"; }
1251 planetShaderInitSuccessful=planetShaderInitSuccessful && result;
1252 GL(result=moonShaderProgram->bind());
1253 if (!result) { qWarning() << "Planet: Error binding moonPlanetShaderprogram"; }
1254 planetShaderInitSuccessful=planetShaderInitSuccessful && result;
1223 moonShaderVars.initLocations(moonShaderProgram);1255 moonShaderVars.initLocations(moonShaderProgram);
1224 GL(moonShaderVars.earthShadow = moonShaderProgram->uniformLocation("earthShadow"));1256 GL(moonShaderVars.earthShadow = moonShaderProgram->uniformLocation("earthShadow"));
1225 GL(moonShaderVars.normalMap = moonShaderProgram->uniformLocation("normalMap"));1257 GL(moonShaderVars.normalMap = moonShaderProgram->uniformLocation("normalMap"));
1226 GL(moonShaderProgram->release());1258 GL(moonShaderProgram->release());
1259
1260 if ((!planetShaderInitSuccessful) && (!qApp->property("ignore_OpenGL_errors").toBool()))
1261 {
1262 // Error handling: Show GUI panel "Ignore possible problems?"
1263 QMessageBox::StandardButton answerButton=
1264 QMessageBox::critical(0, q_("Stellarium: OpenGL Errors"),
1265 q_("Your OpenGL subsystem has problems. See log for details.\nIgnore and try to continue in degraded mode anyway?"),
1266 QMessageBox::Ignore|QMessageBox::Abort, QMessageBox::Abort);
1267 if (answerButton == QMessageBox::Abort)
1268 {
1269 qDebug() << "Aborting due to OpenGL initialization problems.";
1270 StelApp::getInstance().quit(); // Seems not to be enough(?)
1271 exit(0);
1272 }
1273 }
1227}1274}
12281275
1229void Planet::deinitShader()1276void Planet::deinitShader()
1230{1277{
1231 delete planetShaderProgram;1278 delete planetShaderProgram;
1232 planetShaderProgram = NULL;1279 planetShaderProgram = NULL;
1280 delete ringPlanetShaderProgram;
1281 ringPlanetShaderProgram = NULL;
1282 delete moonShaderProgram;
1283 moonShaderProgram = NULL;
1233}1284}
12341285
1235void Planet::draw3dModel(StelCore* core, StelProjector::ModelViewTranformP transfo, float screenSz, bool drawOnlyRing)1286void Planet::draw3dModel(StelCore* core, StelProjector::ModelViewTranformP transfo, float screenSz, bool drawOnlyRing)
12361287
=== modified file 'src/main.cpp'
--- src/main.cpp 2014-09-27 11:37:20 +0000
+++ src/main.cpp 2014-10-27 19:09:08 +0000
@@ -349,21 +349,20 @@
349 // some basic diagnostics349 // some basic diagnostics
350 if (!QGLFormat::hasOpenGL()){350 if (!QGLFormat::hasOpenGL()){
351 qWarning() << "Oops... This system does not support OpenGL.";351 qWarning() << "Oops... This system does not support OpenGL.";
352 QMessageBox::warning(0, "Stellarium", q_("This system does not support OpenGL."));352 QMessageBox::critical(0, "Stellarium", q_("This system does not support OpenGL."), QMessageBox::Abort, QMessageBox::Abort);
353 appCanRun = false;353 appCanRun = false;
354 }354 }
355355 else if (!(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_1) && !(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0)) // Check supported version of OpenGL
356 if (!(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_1) && !(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0)) // Check supported version of OpenGL
357 {356 {
358 // 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).357 // 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).
359 // Recommended OpenGL 3.0 and OpenGL Shading Language 1.30 and above.358 // Recommended OpenGL 3.0 and OpenGL Shading Language 1.30 and above.
360 // If platform does not support this version then say to user about troubles and quit from application.359 // If platform does not support this version then say to user about troubles and quit from application.
361 #ifdef Q_OS_WIN360 #ifdef Q_OS_WIN
362 qWarning() << "Oops... Insufficient OpenGL version. Please update drivers, graphics hardware, or use MESA (or ANGLE) version.";361 qWarning() << "Oops... Insufficient OpenGL version. Please update drivers, graphics hardware, or use MESA (or ANGLE) version.";
363 QMessageBox::warning(0, "Stellarium", q_("Insufficient OpenGL version. Please update drivers, graphics hardware, or use MESA (or ANGLE) version."));362 QMessageBox::critical(0, "Stellarium", q_("Insufficient OpenGL version. Please update drivers, graphics hardware, or use MESA (or ANGLE) version."), QMessageBox::Abort, QMessageBox::Abort);
364 #else363 #else
365 qWarning() << "Oops... Insufficient OpenGL version. Please update drivers, or graphics hardware.";364 qWarning() << "Oops... Insufficient OpenGL version. Please update drivers, or graphics hardware.";
366 QMessageBox::warning(0, "Stellarium", q_("Insufficient OpenGL version. Please update drivers, or graphics hardware."));365 QMessageBox::critical(0, "Stellarium", q_("Insufficient OpenGL version. Please update drivers, or graphics hardware."), QMessageBox::Abort, QMessageBox::Abort);
367 #endif366 #endif
368 appCanRun = false;367 appCanRun = false;
369 }368 }