Merge lp:~georg-zotti/stellarium/gz_shaderloader-message into lp:stellarium
- gz_shaderloader-message
- Merge into trunk
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Fabien Chéreau | Disapprove | ||
Tomasz Buchert | Pending | ||
Review via email: mp+239762@code.launchpad.net |
Commit message
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.
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
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 | 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" |
6 | 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" |
7 | 58 | << " Try this is you have graphics problems\n" | 58 | << " Try this is you have graphics problems\n" |
8 | 59 | << "--ignore-opengl-errors : Suppress warning panels, ignore errors\n" | ||
9 | 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" |
10 | 60 | << " the full screen setting in the config file\n" | 61 | << " the full screen setting in the config file\n" |
11 | 61 | << "--screenshot-dir : Specify directory to save screenshots\n" | 62 | << "--screenshot-dir : Specify directory to save screenshots\n" |
12 | @@ -123,6 +124,8 @@ | |||
13 | 123 | { | 124 | { |
14 | 124 | bool dumpOpenGLDetails = argsGetOption(argList, "-d", "--dump-opengl-details"); | 125 | bool dumpOpenGLDetails = argsGetOption(argList, "-d", "--dump-opengl-details"); |
15 | 125 | qApp->setProperty("dump_OpenGL_details", dumpOpenGLDetails); | 126 | qApp->setProperty("dump_OpenGL_details", dumpOpenGLDetails); |
16 | 127 | bool ignoreOpenGLErrors = argsGetOption(argList, "", "--ignore-opengl-errors"); | ||
17 | 128 | qApp->setProperty("ignore_OpenGL_errors", ignoreOpenGLErrors); | ||
18 | 126 | fullScreen = argsGetYesNoOption(argList, "-f", "--full-screen", -1); | 129 | fullScreen = argsGetYesNoOption(argList, "-f", "--full-screen", -1); |
19 | 127 | landscapeId = argsGetOptionWithArg(argList, "", "--landscape", "").toString(); | 130 | landscapeId = argsGetOptionWithArg(argList, "", "--landscape", "").toString(); |
20 | 128 | homePlanet = argsGetOptionWithArg(argList, "", "--home-planet", "").toString(); | 131 | homePlanet = argsGetOptionWithArg(argList, "", "--home-planet", "").toString(); |
21 | 129 | 132 | ||
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 | 25 | #include "StelProjectorClasses.hpp" | 25 | #include "StelProjectorClasses.hpp" |
27 | 26 | #include "StelUtils.hpp" | 26 | #include "StelUtils.hpp" |
28 | 27 | 27 | ||
29 | 28 | #include <QApplication> | ||
30 | 28 | #include <QDebug> | 29 | #include <QDebug> |
31 | 29 | #include <QString> | 30 | #include <QString> |
32 | 30 | #include <QSettings> | 31 | #include <QSettings> |
33 | @@ -36,7 +37,7 @@ | |||
34 | 36 | #include <QCache> | 37 | #include <QCache> |
35 | 37 | #include <QOpenGLPaintDevice> | 38 | #include <QOpenGLPaintDevice> |
36 | 38 | #include <QOpenGLShader> | 39 | #include <QOpenGLShader> |
38 | 39 | 40 | #include <QMessageBox> | |
39 | 40 | 41 | ||
40 | 41 | #ifndef NDEBUG | 42 | #ifndef NDEBUG |
41 | 42 | QMutex* StelPainter::globalMutex = new QMutex(); | 43 | QMutex* StelPainter::globalMutex = new QMutex(); |
42 | @@ -73,14 +74,6 @@ | |||
43 | 73 | } | 74 | } |
44 | 74 | } | 75 | } |
45 | 75 | 76 | ||
46 | 76 | bool StelPainter::linkProg(QOpenGLShaderProgram* prog, const QString& name) | ||
47 | 77 | { | ||
48 | 78 | bool ret = prog->link(); | ||
49 | 79 | if (!ret || (!prog->log().isEmpty() && !prog->log().contains("Link was successful"))) | ||
50 | 80 | qWarning() << QString("StelPainter: Warnings while linking %1 shader program:\n%2").arg(name, prog->log()); | ||
51 | 81 | return ret; | ||
52 | 82 | } | ||
53 | 83 | |||
54 | 84 | StelPainter::StelPainter(const StelProjectorP& proj) : prj(proj) | 77 | StelPainter::StelPainter(const StelProjectorP& proj) : prj(proj) |
55 | 85 | { | 78 | { |
56 | 86 | Q_ASSERT(proj); | 79 | Q_ASSERT(proj); |
57 | @@ -1552,6 +1545,33 @@ | |||
58 | 1552 | texture2dEnabled = b; | 1545 | texture2dEnabled = b; |
59 | 1553 | } | 1546 | } |
60 | 1554 | 1547 | ||
61 | 1548 | |||
62 | 1549 | |||
63 | 1550 | bool StelPainter::compileShader(QOpenGLShader* shader, const char* src, const char* name) | ||
64 | 1551 | { | ||
65 | 1552 | bool ret=shader->compileSourceCode(src); | ||
66 | 1553 | if ((!ret) && !shader->log().isEmpty()) { qWarning() << "StelPainter: Warnings while compiling " << name << ": " << shader->log(); } | ||
67 | 1554 | return ret; | ||
68 | 1555 | } | ||
69 | 1556 | |||
70 | 1557 | bool StelPainter::addShaders(QOpenGLShaderProgram* prog, QOpenGLShader* vshader, const char* vShaderName, QOpenGLShader* fshader, const char* fShaderName) | ||
71 | 1558 | { | ||
72 | 1559 | bool retv=prog->addShader(vshader); | ||
73 | 1560 | if (!retv) { qWarning() << "StelPainter: Error while adding " << vShaderName; } | ||
74 | 1561 | bool retf=prog->addShader(fshader); | ||
75 | 1562 | if (!retf) { qWarning() << "StelPainter: Error while adding " << fShaderName; } | ||
76 | 1563 | return retv && retf; | ||
77 | 1564 | } | ||
78 | 1565 | |||
79 | 1566 | bool StelPainter::linkProg(QOpenGLShaderProgram* prog, const QString& name) | ||
80 | 1567 | { | ||
81 | 1568 | bool ret = prog->link(); | ||
82 | 1569 | if (!ret || (!prog->log().isEmpty() && !prog->log().contains("Link was successful"))) | ||
83 | 1570 | qWarning() << QString("StelPainter: Warnings while linking %1 shader program:\n%2").arg(name, prog->log()); | ||
84 | 1571 | return ret; | ||
85 | 1572 | } | ||
86 | 1573 | |||
87 | 1574 | |||
88 | 1555 | void StelPainter::initGLShaders() | 1575 | void StelPainter::initGLShaders() |
89 | 1556 | { | 1576 | { |
90 | 1557 | qWarning() << "Intializing basic GL shaders... "; | 1577 | qWarning() << "Intializing basic GL shaders... "; |
91 | @@ -1564,8 +1584,6 @@ | |||
92 | 1564 | "{\n" | 1584 | "{\n" |
93 | 1565 | " gl_Position = projectionMatrix*vec4(vertex, 1.);\n" | 1585 | " gl_Position = projectionMatrix*vec4(vertex, 1.);\n" |
94 | 1566 | "}\n"; | 1586 | "}\n"; |
95 | 1567 | vshader3.compileSourceCode(vsrc3); | ||
96 | 1568 | if (!vshader3.log().isEmpty()) { qWarning() << "StelPainter: Warnings while compiling vshader3: " << vshader3.log(); } | ||
97 | 1569 | QOpenGLShader fshader3(QOpenGLShader::Fragment); | 1587 | QOpenGLShader fshader3(QOpenGLShader::Fragment); |
98 | 1570 | const char *fsrc3 = | 1588 | const char *fsrc3 = |
99 | 1571 | "uniform mediump vec4 color;\n" | 1589 | "uniform mediump vec4 color;\n" |
100 | @@ -1573,16 +1591,28 @@ | |||
101 | 1573 | "{\n" | 1591 | "{\n" |
102 | 1574 | " gl_FragColor = color;\n" | 1592 | " gl_FragColor = color;\n" |
103 | 1575 | "}\n"; | 1593 | "}\n"; |
104 | 1576 | fshader3.compileSourceCode(fsrc3); | ||
105 | 1577 | if (!fshader3.log().isEmpty()) { qWarning() << "StelPainter: Warnings while compiling fshader3: " << fshader3.log(); } | ||
106 | 1578 | basicShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext()); | 1594 | basicShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext()); |
110 | 1579 | basicShaderProgram->addShader(&vshader3); | 1595 | if (!( compileShader(&vshader3, vsrc3, "vshader3") && |
111 | 1580 | basicShaderProgram->addShader(&fshader3); | 1596 | compileShader(&fshader3, fsrc3, "fshader3") && |
112 | 1581 | linkProg(basicShaderProgram, "basicShaderProgram"); | 1597 | addShaders(basicShaderProgram, &vshader3, "vshader3", &fshader3, "fshader3") && |
113 | 1598 | linkProg(basicShaderProgram, "basicShaderProgram")) && | ||
114 | 1599 | !qApp->property("ignore_OpenGL_errors").toBool() ) | ||
115 | 1600 | { | ||
116 | 1601 | // Error handling: Show GUI panel "Ignore possible problems?" | ||
117 | 1602 | QMessageBox::StandardButton answerButton= | ||
118 | 1603 | QMessageBox::critical(0, q_("Stellarium: OpenGL Errors"), | ||
119 | 1604 | q_("Your OpenGL subsystem has problems. See log for details.\nIgnore and try to continue in degraded mode anyway?"), | ||
120 | 1605 | QMessageBox::Ignore|QMessageBox::Abort, QMessageBox::Abort); | ||
121 | 1606 | if (answerButton == QMessageBox::Abort) | ||
122 | 1607 | { | ||
123 | 1608 | qDebug() << "Aborting due to OpenGL initialization problems."; | ||
124 | 1609 | StelApp::getInstance().quit(); // Seems not to be enough(?) | ||
125 | 1610 | exit(0); | ||
126 | 1611 | } | ||
127 | 1612 | } | ||
128 | 1582 | basicShaderVars.projectionMatrix = basicShaderProgram->uniformLocation("projectionMatrix"); | 1613 | basicShaderVars.projectionMatrix = basicShaderProgram->uniformLocation("projectionMatrix"); |
129 | 1583 | basicShaderVars.color = basicShaderProgram->uniformLocation("color"); | 1614 | basicShaderVars.color = basicShaderProgram->uniformLocation("color"); |
130 | 1584 | basicShaderVars.vertex = basicShaderProgram->attributeLocation("vertex"); | 1615 | basicShaderVars.vertex = basicShaderProgram->attributeLocation("vertex"); |
131 | 1585 | |||
132 | 1586 | 1616 | ||
133 | 1587 | // Basic shader: vertex filled with interpolated color | 1617 | // Basic shader: vertex filled with interpolated color |
134 | 1588 | QOpenGLShader vshaderInterpolatedColor(QOpenGLShader::Vertex); | 1618 | QOpenGLShader vshaderInterpolatedColor(QOpenGLShader::Vertex); |
135 | @@ -1596,10 +1626,6 @@ | |||
136 | 1596 | " gl_Position = projectionMatrix*vec4(vertex, 1.);\n" | 1626 | " gl_Position = projectionMatrix*vec4(vertex, 1.);\n" |
137 | 1597 | " fragcolor = color;\n" | 1627 | " fragcolor = color;\n" |
138 | 1598 | "}\n"; | 1628 | "}\n"; |
139 | 1599 | vshaderInterpolatedColor.compileSourceCode(vshaderInterpolatedColorSrc); | ||
140 | 1600 | if (!vshaderInterpolatedColor.log().isEmpty()) { | ||
141 | 1601 | qWarning() << "StelPainter: Warnings while compiling vshaderInterpolatedColor: " << vshaderInterpolatedColor.log(); | ||
142 | 1602 | } | ||
143 | 1603 | QOpenGLShader fshaderInterpolatedColor(QOpenGLShader::Fragment); | 1629 | QOpenGLShader fshaderInterpolatedColor(QOpenGLShader::Fragment); |
144 | 1604 | const char *fshaderInterpolatedColorSrc = | 1630 | const char *fshaderInterpolatedColorSrc = |
145 | 1605 | "varying mediump vec4 fragcolor;\n" | 1631 | "varying mediump vec4 fragcolor;\n" |
146 | @@ -1607,14 +1633,25 @@ | |||
147 | 1607 | "{\n" | 1633 | "{\n" |
148 | 1608 | " gl_FragColor = fragcolor;\n" | 1634 | " gl_FragColor = fragcolor;\n" |
149 | 1609 | "}\n"; | 1635 | "}\n"; |
150 | 1610 | fshaderInterpolatedColor.compileSourceCode(fshaderInterpolatedColorSrc); | ||
151 | 1611 | if (!fshaderInterpolatedColor.log().isEmpty()) { | ||
152 | 1612 | qWarning() << "StelPainter: Warnings while compiling fshaderInterpolatedColor: " << fshaderInterpolatedColor.log(); | ||
153 | 1613 | } | ||
154 | 1614 | colorShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext()); | 1636 | colorShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext()); |
158 | 1615 | colorShaderProgram->addShader(&vshaderInterpolatedColor); | 1637 | if (!( compileShader(&vshaderInterpolatedColor, vshaderInterpolatedColorSrc, "vshaderInterpolatedColor") && |
159 | 1616 | colorShaderProgram->addShader(&fshaderInterpolatedColor); | 1638 | compileShader(&fshaderInterpolatedColor, fshaderInterpolatedColorSrc, "fshaderInterpolatedColor") && |
160 | 1617 | linkProg(colorShaderProgram, "colorShaderProgram"); | 1639 | addShaders(colorShaderProgram, &vshaderInterpolatedColor, "vshaderInterpolatedColor", &fshaderInterpolatedColor, "fshaderInterpolatedColor") && |
161 | 1640 | linkProg(colorShaderProgram, "colorShaderProgram")) && | ||
162 | 1641 | !qApp->property("ignore_OpenGL_errors").toBool() ) | ||
163 | 1642 | { | ||
164 | 1643 | // Error handling: Show GUI panel "Ignore possible problems?" | ||
165 | 1644 | QMessageBox::StandardButton answerButton= | ||
166 | 1645 | QMessageBox::critical(0, q_("Stellarium: OpenGL Errors"), | ||
167 | 1646 | q_("Your OpenGL subsystem has problems. See log for details.\nIgnore and try to continue in degraded mode anyway?"), | ||
168 | 1647 | QMessageBox::Ignore|QMessageBox::Abort, QMessageBox::Abort); | ||
169 | 1648 | if (answerButton == QMessageBox::Abort) | ||
170 | 1649 | { | ||
171 | 1650 | qDebug() << "Aborting due to OpenGL initialization problems."; | ||
172 | 1651 | StelApp::getInstance().quit(); // Seems not to be enough(?) | ||
173 | 1652 | exit(0); | ||
174 | 1653 | } | ||
175 | 1654 | } | ||
176 | 1618 | colorShaderVars.projectionMatrix = colorShaderProgram->uniformLocation("projectionMatrix"); | 1655 | colorShaderVars.projectionMatrix = colorShaderProgram->uniformLocation("projectionMatrix"); |
177 | 1619 | colorShaderVars.color = colorShaderProgram->attributeLocation("color"); | 1656 | colorShaderVars.color = colorShaderProgram->attributeLocation("color"); |
178 | 1620 | colorShaderVars.vertex = colorShaderProgram->attributeLocation("vertex"); | 1657 | colorShaderVars.vertex = colorShaderProgram->attributeLocation("vertex"); |
179 | @@ -1631,9 +1668,6 @@ | |||
180 | 1631 | " gl_Position = projectionMatrix * vec4(vertex, 1.);\n" | 1668 | " gl_Position = projectionMatrix * vec4(vertex, 1.);\n" |
181 | 1632 | " texc = texCoord;\n" | 1669 | " texc = texCoord;\n" |
182 | 1633 | "}\n"; | 1670 | "}\n"; |
183 | 1634 | vshader2.compileSourceCode(vsrc2); | ||
184 | 1635 | if (!vshader2.log().isEmpty()) { qWarning() << "StelPainter: Warnings while compiling vshader2: " << vshader2.log(); } | ||
185 | 1636 | |||
186 | 1637 | QOpenGLShader fshader2(QOpenGLShader::Fragment); | 1671 | QOpenGLShader fshader2(QOpenGLShader::Fragment); |
187 | 1638 | const char *fsrc2 = | 1672 | const char *fsrc2 = |
188 | 1639 | "varying mediump vec2 texc;\n" | 1673 | "varying mediump vec2 texc;\n" |
189 | @@ -1643,13 +1677,26 @@ | |||
190 | 1643 | "{\n" | 1677 | "{\n" |
191 | 1644 | " gl_FragColor = texture2D(tex, texc)*texColor;\n" | 1678 | " gl_FragColor = texture2D(tex, texc)*texColor;\n" |
192 | 1645 | "}\n"; | 1679 | "}\n"; |
193 | 1646 | fshader2.compileSourceCode(fsrc2); | ||
194 | 1647 | if (!fshader2.log().isEmpty()) { qWarning() << "StelPainter: Warnings while compiling fshader2: " << fshader2.log(); } | ||
195 | 1648 | |||
196 | 1649 | texturesShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext()); | 1680 | texturesShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext()); |
200 | 1650 | texturesShaderProgram->addShader(&vshader2); | 1681 | if (!( compileShader(&vshader2, vsrc2, "vshader2") && |
201 | 1651 | texturesShaderProgram->addShader(&fshader2); | 1682 | compileShader(&fshader2, fsrc2, "fshader2") && |
202 | 1652 | linkProg(texturesShaderProgram, "texturesShaderProgram"); | 1683 | addShaders(texturesShaderProgram, &vshader2, "vshader2", &fshader2, "fshader2") && |
203 | 1684 | linkProg(texturesShaderProgram, "texturesShaderProgram")) && | ||
204 | 1685 | !qApp->property("ignore_OpenGL_errors").toBool() ) | ||
205 | 1686 | { | ||
206 | 1687 | // Error handling: Show GUI panel "Ignore possible problems?" | ||
207 | 1688 | QMessageBox::StandardButton answerButton= | ||
208 | 1689 | QMessageBox::critical(0, q_("Stellarium: OpenGL Errors"), | ||
209 | 1690 | q_("Your OpenGL subsystem has problems. See log for details.\nIgnore and try to continue in degraded mode anyway?"), | ||
210 | 1691 | QMessageBox::Ignore|QMessageBox::Abort, QMessageBox::Abort); | ||
211 | 1692 | if (answerButton == QMessageBox::Abort) | ||
212 | 1693 | { | ||
213 | 1694 | qDebug() << "Aborting due to OpenGL initialization problems."; | ||
214 | 1695 | StelApp::getInstance().quit(); // Seems not to be enough(?) | ||
215 | 1696 | exit(0); | ||
216 | 1697 | } | ||
217 | 1698 | } | ||
218 | 1699 | |||
219 | 1653 | texturesShaderVars.projectionMatrix = texturesShaderProgram->uniformLocation("projectionMatrix"); | 1700 | texturesShaderVars.projectionMatrix = texturesShaderProgram->uniformLocation("projectionMatrix"); |
220 | 1654 | texturesShaderVars.texCoord = texturesShaderProgram->attributeLocation("texCoord"); | 1701 | texturesShaderVars.texCoord = texturesShaderProgram->attributeLocation("texCoord"); |
221 | 1655 | texturesShaderVars.vertex = texturesShaderProgram->attributeLocation("vertex"); | 1702 | texturesShaderVars.vertex = texturesShaderProgram->attributeLocation("vertex"); |
222 | @@ -1671,9 +1718,6 @@ | |||
223 | 1671 | " texc = texCoord;\n" | 1718 | " texc = texCoord;\n" |
224 | 1672 | " outColor = color;\n" | 1719 | " outColor = color;\n" |
225 | 1673 | "}\n"; | 1720 | "}\n"; |
226 | 1674 | vshader4.compileSourceCode(vsrc4); | ||
227 | 1675 | if (!vshader4.log().isEmpty()) { qWarning() << "StelPainter: Warnings while compiling vshader4: " << vshader4.log(); } | ||
228 | 1676 | |||
229 | 1677 | QOpenGLShader fshader4(QOpenGLShader::Fragment); | 1721 | QOpenGLShader fshader4(QOpenGLShader::Fragment); |
230 | 1678 | const char *fsrc4 = | 1722 | const char *fsrc4 = |
231 | 1679 | "varying mediump vec2 texc;\n" | 1723 | "varying mediump vec2 texc;\n" |
232 | @@ -1683,13 +1727,25 @@ | |||
233 | 1683 | "{\n" | 1727 | "{\n" |
234 | 1684 | " gl_FragColor = texture2D(tex, texc)*outColor;\n" | 1728 | " gl_FragColor = texture2D(tex, texc)*outColor;\n" |
235 | 1685 | "}\n"; | 1729 | "}\n"; |
236 | 1686 | fshader4.compileSourceCode(fsrc4); | ||
237 | 1687 | if (!fshader4.log().isEmpty()) { qWarning() << "StelPainter: Warnings while compiling fshader4: " << fshader4.log(); } | ||
238 | 1688 | |||
239 | 1689 | texturesColorShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext()); | 1730 | texturesColorShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext()); |
243 | 1690 | texturesColorShaderProgram->addShader(&vshader4); | 1731 | if (!( compileShader(&vshader4, vsrc4, "vshader4") && |
244 | 1691 | texturesColorShaderProgram->addShader(&fshader4); | 1732 | compileShader(&fshader4, fsrc4, "fshader4") && |
245 | 1692 | linkProg(texturesColorShaderProgram, "texturesColorShaderProgram"); | 1733 | addShaders(texturesColorShaderProgram, &vshader4, "vshader4", &fshader4, "fshader4") && |
246 | 1734 | linkProg(texturesColorShaderProgram, "texturesColorShaderProgram")) && | ||
247 | 1735 | !qApp->property("ignore_OpenGL_errors").toBool() ) | ||
248 | 1736 | { | ||
249 | 1737 | // Error handling: Show GUI panel "Ignore possible problems?" | ||
250 | 1738 | QMessageBox::StandardButton answerButton= | ||
251 | 1739 | QMessageBox::critical(0, q_("Stellarium: OpenGL Errors"), | ||
252 | 1740 | q_("Your OpenGL subsystem has problems. See log for details.\nIgnore and try to continue in degraded mode anyway?"), | ||
253 | 1741 | QMessageBox::Ignore|QMessageBox::Abort, QMessageBox::Abort); | ||
254 | 1742 | if (answerButton == QMessageBox::Abort) | ||
255 | 1743 | { | ||
256 | 1744 | qDebug() << "Aborting due to OpenGL initialization problems."; | ||
257 | 1745 | StelApp::getInstance().quit(); // Seems not to be enough(?) | ||
258 | 1746 | exit(0); | ||
259 | 1747 | } | ||
260 | 1748 | } | ||
261 | 1693 | texturesColorShaderVars.projectionMatrix = texturesColorShaderProgram->uniformLocation("projectionMatrix"); | 1749 | texturesColorShaderVars.projectionMatrix = texturesColorShaderProgram->uniformLocation("projectionMatrix"); |
262 | 1694 | texturesColorShaderVars.texCoord = texturesColorShaderProgram->attributeLocation("texCoord"); | 1750 | texturesColorShaderVars.texCoord = texturesColorShaderProgram->attributeLocation("texCoord"); |
263 | 1695 | texturesColorShaderVars.vertex = texturesColorShaderProgram->attributeLocation("vertex"); | 1751 | texturesColorShaderVars.vertex = texturesColorShaderProgram->attributeLocation("vertex"); |
264 | 1696 | 1752 | ||
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 | 263 | //! @param checkDiscontinuity will check and suppress discontinuities if necessary. | 263 | //! @param checkDiscontinuity will check and suppress discontinuities if necessary. |
270 | 264 | void drawStelVertexArray(const StelVertexArray& arr, const bool checkDiscontinuity=true); | 264 | void drawStelVertexArray(const StelVertexArray& arr, const bool checkDiscontinuity=true); |
271 | 265 | 265 | ||
273 | 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 |
274 | 267 | //! Compile an OpenGL shader and log a message in case of error or warnings. | ||
275 | 268 | //! @return true if the compilation was successful. | ||
276 | 269 | static bool compileShader(class QOpenGLShader* shader, const char* src, const char *name); | ||
277 | 270 | //! Add a compiled OpenGL program and log a message in case of error or warnings. | ||
278 | 271 | //! @return true if the addition was successful. | ||
279 | 272 | static bool addShaders(class QOpenGLShaderProgram* prog, class QOpenGLShader* vshader, const char *vShaderName, class QOpenGLShader* fshader, const char *fShaderName); | ||
280 | 273 | //! Link an OpenGL program (after addition of all compiled programs) and log a message in case of error or warnings. | ||
281 | 267 | //! @return true if the link was successful. | 274 | //! @return true if the link was successful. |
282 | 268 | static bool linkProg(class QOpenGLShaderProgram* prog, const QString& name); | 275 | static bool linkProg(class QOpenGLShaderProgram* prog, const QString& name); |
283 | 269 | 276 | ||
284 | 270 | 277 | ||
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 | 37 | #include "StelOpenGL.hpp" | 37 | #include "StelOpenGL.hpp" |
290 | 38 | 38 | ||
291 | 39 | #include <iomanip> | 39 | #include <iomanip> |
292 | 40 | #include <QApplication> | ||
293 | 40 | #include <QTextStream> | 41 | #include <QTextStream> |
294 | 41 | #include <QString> | 42 | #include <QString> |
295 | 42 | #include <QDebug> | 43 | #include <QDebug> |
296 | 43 | #include <QVarLengthArray> | 44 | #include <QVarLengthArray> |
297 | 44 | #include <QOpenGLContext> | 45 | #include <QOpenGLContext> |
298 | 45 | #include <QOpenGLShader> | 46 | #include <QOpenGLShader> |
299 | 47 | #include <QMessageBox> | ||
300 | 46 | 48 | ||
301 | 47 | Vec3f Planet::labelColor = Vec3f(0.4,0.4,0.8); | 49 | Vec3f Planet::labelColor = Vec3f(0.4,0.4,0.8); |
302 | 48 | Vec3f Planet::orbitColor = Vec3f(1,0.6,1); | 50 | Vec3f Planet::orbitColor = Vec3f(1,0.6,1); |
303 | @@ -1165,20 +1167,31 @@ | |||
304 | 1165 | " }\n" | 1167 | " }\n" |
305 | 1166 | "}\n"; | 1168 | "}\n"; |
306 | 1167 | 1169 | ||
307 | 1170 | bool planetShaderInitSuccessful; | ||
308 | 1168 | // Default planet shader program | 1171 | // Default planet shader program |
309 | 1169 | QOpenGLShader vshader(QOpenGLShader::Vertex); | 1172 | QOpenGLShader vshader(QOpenGLShader::Vertex); |
313 | 1170 | vshader.compileSourceCode(vsrc); | 1173 | bool result=vshader.compileSourceCode(vsrc); |
314 | 1171 | if (!vshader.log().isEmpty()) { qWarning() << "Planet: Warnings while compiling vshader: " << vshader.log(); } | 1174 | if (!result) { qWarning() << "Planet: Warnings while compiling vshader: " << vshader.log(); } |
315 | 1172 | 1175 | planetShaderInitSuccessful=result; | |
316 | 1176 | |||
317 | 1173 | QOpenGLShader fshader(QOpenGLShader::Fragment); | 1177 | QOpenGLShader fshader(QOpenGLShader::Fragment); |
320 | 1174 | fshader.compileSourceCode(fsrc); | 1178 | result=fshader.compileSourceCode(fsrc); |
321 | 1175 | if (!fshader.log().isEmpty()) { qWarning() << "Planet: Warnings while compiling fshader: " << fshader.log(); } | 1179 | if (!result) { qWarning() << "Planet: Warnings while compiling fshader: " << fshader.log(); } |
322 | 1180 | planetShaderInitSuccessful=planetShaderInitSuccessful && result; | ||
323 | 1176 | 1181 | ||
324 | 1177 | planetShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext()); | 1182 | planetShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext()); |
329 | 1178 | planetShaderProgram->addShader(&vshader); | 1183 | result=planetShaderProgram->addShader(&vshader); |
330 | 1179 | planetShaderProgram->addShader(&fshader); | 1184 | if (!result) { qWarning() << "Planet: Error while adding vshader: "; } |
331 | 1180 | GL(StelPainter::linkProg(planetShaderProgram, "planetShaderProgram")); | 1185 | planetShaderInitSuccessful=planetShaderInitSuccessful && result; |
332 | 1181 | GL(planetShaderProgram->bind()); | 1186 | result=planetShaderProgram->addShader(&fshader); |
333 | 1187 | if (!result) { qWarning() << "Planet: Error while adding fshader: "; } | ||
334 | 1188 | planetShaderInitSuccessful=planetShaderInitSuccessful && result; | ||
335 | 1189 | GL(result=StelPainter::linkProg(planetShaderProgram, "planetShaderProgram")); | ||
336 | 1190 | if (!result) { qWarning() << "Planet: Error linking planetShaderprogram"; } | ||
337 | 1191 | planetShaderInitSuccessful=planetShaderInitSuccessful && result; | ||
338 | 1192 | GL(result=planetShaderProgram->bind()); | ||
339 | 1193 | if (!result) { qWarning() << "Planet: Error binding planetShaderprogram"; } | ||
340 | 1194 | planetShaderInitSuccessful=planetShaderInitSuccessful && result; | ||
341 | 1182 | planetShaderVars.initLocations(planetShaderProgram); | 1195 | planetShaderVars.initLocations(planetShaderProgram); |
342 | 1183 | GL(planetShaderProgram->release()); | 1196 | GL(planetShaderProgram->release()); |
343 | 1184 | 1197 | ||
344 | @@ -1186,14 +1199,23 @@ | |||
345 | 1186 | QByteArray arr = "#define RINGS_SUPPORT\n\n"; | 1199 | QByteArray arr = "#define RINGS_SUPPORT\n\n"; |
346 | 1187 | arr+=fsrc; | 1200 | arr+=fsrc; |
347 | 1188 | QOpenGLShader ringFragmentShader(QOpenGLShader::Fragment); | 1201 | QOpenGLShader ringFragmentShader(QOpenGLShader::Fragment); |
350 | 1189 | ringFragmentShader.compileSourceCode(arr.constData()); | 1202 | result=ringFragmentShader.compileSourceCode(arr.constData()); |
351 | 1190 | if (!ringFragmentShader.log().isEmpty()) { qWarning() << "Planet: Warnings while compiling ringFragmentShader: " << ringFragmentShader.log(); } | 1203 | if (!result) { qWarning() << "Planet: Warnings while compiling ringFragmentShader: " << ringFragmentShader.log(); } |
352 | 1204 | planetShaderInitSuccessful=planetShaderInitSuccessful && result; | ||
353 | 1191 | 1205 | ||
354 | 1192 | ringPlanetShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext()); | 1206 | ringPlanetShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext()); |
359 | 1193 | ringPlanetShaderProgram->addShader(&vshader); | 1207 | result=ringPlanetShaderProgram->addShader(&vshader); |
360 | 1194 | ringPlanetShaderProgram->addShader(&ringFragmentShader); | 1208 | if (!result) { qWarning() << "Planet: Error while adding vshader to ringPlanetShaderProgram."; } |
361 | 1195 | GL(StelPainter::linkProg(ringPlanetShaderProgram, "ringPlanetShaderProgram")); | 1209 | planetShaderInitSuccessful=planetShaderInitSuccessful && result; |
362 | 1196 | GL(ringPlanetShaderProgram->bind()); | 1210 | result=ringPlanetShaderProgram->addShader(&ringFragmentShader); |
363 | 1211 | if (!result) { qWarning() << "Planet: Error while adding ringFragmentShader."; } | ||
364 | 1212 | planetShaderInitSuccessful=planetShaderInitSuccessful && result; | ||
365 | 1213 | GL(result=StelPainter::linkProg(ringPlanetShaderProgram, "ringPlanetShaderProgram")); | ||
366 | 1214 | if (!result) { qWarning() << "Planet: Error linking ringPlanetShaderprogram"; } | ||
367 | 1215 | planetShaderInitSuccessful=planetShaderInitSuccessful && result; | ||
368 | 1216 | GL(result=ringPlanetShaderProgram->bind()); | ||
369 | 1217 | if (!result) { qWarning() << "Planet: Error binding ringPlanetShaderprogram"; } | ||
370 | 1218 | planetShaderInitSuccessful=planetShaderInitSuccessful && result; | ||
371 | 1197 | ringPlanetShaderVars.initLocations(ringPlanetShaderProgram); | 1219 | ringPlanetShaderVars.initLocations(ringPlanetShaderProgram); |
372 | 1198 | GL(ringPlanetShaderVars.isRing = ringPlanetShaderProgram->uniformLocation("isRing")); | 1220 | GL(ringPlanetShaderVars.isRing = ringPlanetShaderProgram->uniformLocation("isRing")); |
373 | 1199 | GL(ringPlanetShaderVars.ring = ringPlanetShaderProgram->uniformLocation("ring")); | 1221 | GL(ringPlanetShaderVars.ring = ringPlanetShaderProgram->uniformLocation("ring")); |
374 | @@ -1206,30 +1228,59 @@ | |||
375 | 1206 | arr = "#define IS_MOON\n\n"; | 1228 | arr = "#define IS_MOON\n\n"; |
376 | 1207 | arr+=vsrc; | 1229 | arr+=vsrc; |
377 | 1208 | QOpenGLShader moonVertexShader(QOpenGLShader::Vertex); | 1230 | QOpenGLShader moonVertexShader(QOpenGLShader::Vertex); |
381 | 1209 | moonVertexShader.compileSourceCode(arr.constData()); | 1231 | result=moonVertexShader.compileSourceCode(arr.constData()); |
382 | 1210 | if (!moonVertexShader.log().isEmpty()) { qWarning() << "Planet: Warnings while compiling moonVertexShader: " << moonVertexShader.log(); } | 1232 | if (!result) { qWarning() << "Planet: Warnings while compiling moonVertexShader: " << moonVertexShader.log(); } |
383 | 1211 | 1233 | planetShaderInitSuccessful=planetShaderInitSuccessful && result; | |
384 | 1234 | |||
385 | 1212 | arr = "#define IS_MOON\n\n"; | 1235 | arr = "#define IS_MOON\n\n"; |
386 | 1213 | arr+=fsrc; | 1236 | arr+=fsrc; |
387 | 1214 | QOpenGLShader moonFragmentShader(QOpenGLShader::Fragment); | 1237 | QOpenGLShader moonFragmentShader(QOpenGLShader::Fragment); |
390 | 1215 | moonFragmentShader.compileSourceCode(arr.constData()); | 1238 | result=moonFragmentShader.compileSourceCode(arr.constData()); |
391 | 1216 | if (!moonFragmentShader.log().isEmpty()) { qWarning() << "Planet: Warnings while compiling moonFragmentShader: " << moonFragmentShader.log(); } | 1239 | if (!result) { qWarning() << "Planet: Warnings while compiling moonFragmentShader: " << moonFragmentShader.log(); } |
392 | 1240 | planetShaderInitSuccessful=planetShaderInitSuccessful && result; | ||
393 | 1217 | 1241 | ||
394 | 1218 | moonShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext()); | 1242 | moonShaderProgram = new QOpenGLShaderProgram(QOpenGLContext::currentContext()); |
399 | 1219 | moonShaderProgram->addShader(&moonVertexShader); | 1243 | result=moonShaderProgram->addShader(&moonVertexShader); |
400 | 1220 | moonShaderProgram->addShader(&moonFragmentShader); | 1244 | if (!result) { qWarning() << "Planet: Error while adding moonVertexShader."; } |
401 | 1221 | GL(StelPainter::linkProg(moonShaderProgram, "moonPlanetShaderProgram")); | 1245 | planetShaderInitSuccessful=planetShaderInitSuccessful && result; |
402 | 1222 | GL(moonShaderProgram->bind()); | 1246 | result=moonShaderProgram->addShader(&moonFragmentShader); |
403 | 1247 | if (!result) { qWarning() << "Planet: Error while adding moonFragmentShader."; } | ||
404 | 1248 | planetShaderInitSuccessful=planetShaderInitSuccessful && result; | ||
405 | 1249 | GL(result=StelPainter::linkProg(moonShaderProgram, "moonPlanetShaderProgram")); | ||
406 | 1250 | if (!result) { qWarning() << "Planet: Error linking moonPlanetShaderprogram"; } | ||
407 | 1251 | planetShaderInitSuccessful=planetShaderInitSuccessful && result; | ||
408 | 1252 | GL(result=moonShaderProgram->bind()); | ||
409 | 1253 | if (!result) { qWarning() << "Planet: Error binding moonPlanetShaderprogram"; } | ||
410 | 1254 | planetShaderInitSuccessful=planetShaderInitSuccessful && result; | ||
411 | 1223 | moonShaderVars.initLocations(moonShaderProgram); | 1255 | moonShaderVars.initLocations(moonShaderProgram); |
412 | 1224 | GL(moonShaderVars.earthShadow = moonShaderProgram->uniformLocation("earthShadow")); | 1256 | GL(moonShaderVars.earthShadow = moonShaderProgram->uniformLocation("earthShadow")); |
413 | 1225 | GL(moonShaderVars.normalMap = moonShaderProgram->uniformLocation("normalMap")); | 1257 | GL(moonShaderVars.normalMap = moonShaderProgram->uniformLocation("normalMap")); |
414 | 1226 | GL(moonShaderProgram->release()); | 1258 | GL(moonShaderProgram->release()); |
415 | 1259 | |||
416 | 1260 | if ((!planetShaderInitSuccessful) && (!qApp->property("ignore_OpenGL_errors").toBool())) | ||
417 | 1261 | { | ||
418 | 1262 | // Error handling: Show GUI panel "Ignore possible problems?" | ||
419 | 1263 | QMessageBox::StandardButton answerButton= | ||
420 | 1264 | QMessageBox::critical(0, q_("Stellarium: OpenGL Errors"), | ||
421 | 1265 | q_("Your OpenGL subsystem has problems. See log for details.\nIgnore and try to continue in degraded mode anyway?"), | ||
422 | 1266 | QMessageBox::Ignore|QMessageBox::Abort, QMessageBox::Abort); | ||
423 | 1267 | if (answerButton == QMessageBox::Abort) | ||
424 | 1268 | { | ||
425 | 1269 | qDebug() << "Aborting due to OpenGL initialization problems."; | ||
426 | 1270 | StelApp::getInstance().quit(); // Seems not to be enough(?) | ||
427 | 1271 | exit(0); | ||
428 | 1272 | } | ||
429 | 1273 | } | ||
430 | 1227 | } | 1274 | } |
431 | 1228 | 1275 | ||
432 | 1229 | void Planet::deinitShader() | 1276 | void Planet::deinitShader() |
433 | 1230 | { | 1277 | { |
434 | 1231 | delete planetShaderProgram; | 1278 | delete planetShaderProgram; |
435 | 1232 | planetShaderProgram = NULL; | 1279 | planetShaderProgram = NULL; |
436 | 1280 | delete ringPlanetShaderProgram; | ||
437 | 1281 | ringPlanetShaderProgram = NULL; | ||
438 | 1282 | delete moonShaderProgram; | ||
439 | 1283 | moonShaderProgram = NULL; | ||
440 | 1233 | } | 1284 | } |
441 | 1234 | 1285 | ||
442 | 1235 | void Planet::draw3dModel(StelCore* core, StelProjector::ModelViewTranformP transfo, float screenSz, bool drawOnlyRing) | 1286 | void Planet::draw3dModel(StelCore* core, StelProjector::ModelViewTranformP transfo, float screenSz, bool drawOnlyRing) |
443 | 1236 | 1287 | ||
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 | 349 | // some basic diagnostics | 349 | // some basic diagnostics |
449 | 350 | if (!QGLFormat::hasOpenGL()){ | 350 | if (!QGLFormat::hasOpenGL()){ |
450 | 351 | qWarning() << "Oops... This system does not support OpenGL."; | 351 | qWarning() << "Oops... This system does not support OpenGL."; |
452 | 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); |
453 | 353 | appCanRun = false; | 353 | appCanRun = false; |
454 | 354 | } | 354 | } |
457 | 355 | 355 | else if (!(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_1) && !(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0)) // Check supported version of OpenGL | |
456 | 356 | if (!(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_1) && !(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0)) // Check supported version of OpenGL | ||
458 | 357 | { | 356 | { |
459 | 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). |
460 | 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. |
461 | 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. |
462 | 361 | #ifdef Q_OS_WIN | 360 | #ifdef Q_OS_WIN |
463 | 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."; |
465 | 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); |
466 | 364 | #else | 363 | #else |
467 | 365 | qWarning() << "Oops... Insufficient OpenGL version. Please update drivers, or graphics hardware."; | 364 | qWarning() << "Oops... Insufficient OpenGL version. Please update drivers, or graphics hardware."; |
469 | 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); |
470 | 367 | #endif | 366 | #endif |
471 | 368 | appCanRun = false; | 367 | appCanRun = false; |
472 | 369 | } | 368 | } |
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