Merge lp:~fschauk/stellarium/qopenglwidget into lp:stellarium

Proposed by Florian Schaukowitsch
Status: Merged
Merged at revision: 9082
Proposed branch: lp:~fschauk/stellarium/qopenglwidget
Merge into: lp:stellarium
Diff against target: 6644 lines (+1643/-1820)
111 files modified
CMakeLists.txt (+70/-25)
cmake/default_config.ini.cmake (+1/-0)
cmake/stellarium.iss.cmake (+1/-2)
data/shaders/s3d_pixellit.frag (+14/-7)
guide/version.tex (+1/-1)
plugins/AngleMeasure/src/AngleMeasure.cpp (+5/-14)
plugins/AngleMeasure/src/CMakeLists.txt (+1/-4)
plugins/ArchaeoLines/src/ArchaeoLines.cpp (+10/-37)
plugins/ArchaeoLines/src/CMakeLists.txt (+1/-4)
plugins/ArchaeoLines/src/gui/ArchaeoLinesDialog.cpp (+2/-2)
plugins/CompassMarks/src/CMakeLists.txt (+1/-3)
plugins/CompassMarks/src/CompassMarks.cpp (+4/-20)
plugins/EquationOfTime/src/CMakeLists.txt (+1/-4)
plugins/Exoplanets/src/CMakeLists.txt (+1/-4)
plugins/Exoplanets/src/Exoplanet.cpp (+1/-2)
plugins/Exoplanets/src/Exoplanets.cpp (+1/-3)
plugins/Exoplanets/src/gui/ExoplanetsDialog.cpp (+1/-1)
plugins/Exoplanets/src/gui/exoplanetsDialog.ui (+1/-1)
plugins/FOV/src/CMakeLists.txt (+1/-4)
plugins/HelloStelModule/src/CMakeLists.txt (+1/-5)
plugins/MeteorShowers/src/CMakeLists.txt (+1/-4)
plugins/MeteorShowers/src/MeteorShower.cpp (+1/-3)
plugins/MeteorShowers/src/MeteorShowers.cpp (+2/-3)
plugins/MeteorShowers/src/MeteorShowersMgr.hpp (+1/-1)
plugins/NavStars/src/CMakeLists.txt (+1/-4)
plugins/NavStars/src/NavStars.cpp (+1/-3)
plugins/Novae/src/CMakeLists.txt (+1/-4)
plugins/Novae/src/Novae.cpp (+1/-3)
plugins/Observability/src/CMakeLists.txt (+1/-4)
plugins/Oculars/src/CMakeLists.txt (+1/-5)
plugins/Oculars/src/Oculars.cpp (+4/-23)
plugins/PointerCoordinates/src/CMakeLists.txt (+1/-4)
plugins/Pulsars/src/CMakeLists.txt (+1/-4)
plugins/Pulsars/src/Pulsar.cpp (+2/-2)
plugins/Pulsars/src/Pulsars.cpp (+1/-3)
plugins/Quasars/src/CMakeLists.txt (+1/-4)
plugins/Quasars/src/Quasar.cpp (+1/-2)
plugins/Quasars/src/Quasars.cpp (+1/-3)
plugins/RemoteControl/src/CMakeLists.txt (+1/-4)
plugins/RemoteControl/src/MainService.cpp (+2/-0)
plugins/RemoteControl/src/ScriptService.cpp (+3/-0)
plugins/RemoteSync/src/CMakeLists.txt (+1/-4)
plugins/Satellites/src/CMakeLists.txt (+1/-11)
plugins/Satellites/src/Satellite.cpp (+1/-6)
plugins/Satellites/src/Satellites.cpp (+2/-6)
plugins/Scenery3d/src/CMakeLists.txt (+1/-6)
plugins/Scenery3d/src/OBJ.cpp (+20/-17)
plugins/Scenery3d/src/OBJ.hpp (+2/-0)
plugins/Scenery3d/src/Scenery3d.cpp (+34/-33)
plugins/Scenery3d/src/Scenery3d.hpp (+2/-2)
plugins/Scenery3d/src/ShaderManager.cpp (+6/-3)
plugins/Scenery3d/src/ShaderManager.hpp (+5/-1)
plugins/SimpleDrawLine/src/CMakeLists.txt (+3/-5)
plugins/SolarSystemEditor/src/CMakeLists.txt (+1/-5)
plugins/Supernovae/src/CMakeLists.txt (+1/-4)
plugins/Supernovae/src/Supernovae.cpp (+1/-3)
plugins/TelescopeControl/src/CMakeLists.txt (+7/-3)
plugins/TelescopeControl/src/TelescopeControl.cpp (+2/-9)
plugins/TextUserInterface/src/CMakeLists.txt (+1/-4)
plugins/TextUserInterface/src/TextUserInterface.cpp (+1/-3)
src/CMakeLists.txt (+59/-199)
src/StelLogger.cpp (+14/-6)
src/StelMainView.cpp (+657/-577)
src/StelMainView.hpp (+83/-58)
src/core/OctahedronPolygon.cpp (+1/-1)
src/core/SpoutSender.cpp (+1/-1)
src/core/StelApp.cpp (+36/-20)
src/core/StelApp.hpp (+27/-10)
src/core/StelCore.cpp (+3/-4)
src/core/StelOpenGL.cpp (+12/-12)
src/core/StelOpenGL.hpp (+16/-171)
src/core/StelPainter.cpp (+149/-39)
src/core/StelPainter.hpp (+46/-16)
src/core/StelSkyDrawer.cpp (+8/-21)
src/core/StelSkyDrawer.hpp (+2/-1)
src/core/StelSkyImageTile.cpp (+6/-8)
src/core/StelSkyLayerMgr.cpp (+1/-2)
src/core/StelSkyPolygon.cpp (+1/-2)
src/core/StelTexture.cpp (+10/-3)
src/core/StelTexture.hpp (+1/-1)
src/core/StelToast.cpp (+5/-7)
src/core/StelViewportEffect.cpp (+9/-10)
src/core/TrailGroup.cpp (+1/-2)
src/core/modules/Atmosphere.cpp (+2/-4)
src/core/modules/Comet.cpp (+16/-24)
src/core/modules/Constellation.cpp (+4/-10)
src/core/modules/ConstellationMgr.cpp (+10/-25)
src/core/modules/CustomObject.cpp (+1/-2)
src/core/modules/CustomObjectMgr.cpp (+1/-3)
src/core/modules/GridLinesMgr.cpp (+19/-60)
src/core/modules/LabelMgr.cpp (+1/-3)
src/core/modules/Landscape.cpp (+27/-58)
src/core/modules/LandscapeMgr.cpp (+1/-4)
src/core/modules/Meteor.cpp (+4/-6)
src/core/modules/MilkyWay.cpp (+3/-4)
src/core/modules/Nebula.cpp (+1/-2)
src/core/modules/NebulaMgr.cpp (+2/-6)
src/core/modules/Planet.cpp (+18/-20)
src/core/modules/SolarSystem.cpp (+2/-6)
src/core/modules/StarMgr.cpp (+1/-3)
src/core/modules/ZodiacalLight.cpp (+3/-5)
src/external/CMakeLists.txt (+85/-0)
src/gui/AstroCalcDialog.cpp (+1/-1)
src/gui/HelpDialog.cpp (+0/-1)
src/gui/ScriptConsole.cpp (+1/-0)
src/gui/StelDialog.cpp (+1/-0)
src/gui/StelGuiItems.cpp (+1/-1)
src/gui/astroCalcDialog.ui (+1/-1)
src/main.cpp (+2/-2)
src/scripting/StelScriptMgr.cpp (+45/-27)
src/scripting/StelScriptMgr.hpp (+2/-20)
To merge this branch: bzr merge lp:~fschauk/stellarium/qopenglwidget
Reviewer Review Type Date Requested Status
Fabien Chéreau Approve
gzotti Approve
Review via email: mp+314653@code.launchpad.net

Description of the change

This branch removes the dependency on the deprecated QtOpenGL module by changing the main viewport to use the newer QOpenGLWidget from the QtGUI module instead of the old QGLWidget.

Additionally, it changes the way the Qt libraries are linked with CMake by using the provided imported targets, instead of the deprecated QT5_USE_MODULES. Also, the external depedencies are now built as static libraries and linked in later, this is a cleaner setup and accelerates rebuilding (especially the tests).

The OpenGL library is now only directly linked when building for an ES2-only platform. All GL access is done through the QtGUI module and QOpenGLFunctions directly. The troublesome macros from StelOpenGL have all been removed.

Many classes used the same GL calls to repeatedly set up blending modes, line smoothing, etc. This is now part of StelPainter, which tracks the current state and avoids GL calls if possible. Only very few classes now call GL directly.

QOpenGLWidget requires Qt 5.4 at a minimum. A CMake flag USE_OLD_QGLWIDGET can be used to switch back to the QGLWidget, this allows Stellarium to still be built with 5.3.
The widget change has an effect on performance. On Windows, there generally seems to be a slight FPS decrease when QOpenGLWidget is used (220 instead of 240 FPS for me), while on Linux Georg and I noticed an improved performance (in a case even ~50%!).
I'm not fully sure what causes this, but most likely the internal changes QOpenGLWidget has are at fault. It uses an explicit framebuffer object for rendering, and context sharing.

I need further help testing:
- Touch/Pinch input (Windows)
- HiDPI/Retina rendering
because I don't have the necessary hardware.

To post a comment you must log in.
Revision history for this message
gzotti (georg-zotti) wrote :

Looks like a thorough cleanout of old stuff, restructuring of the CMakefile for a faster build esp of the tests, and the removal of the deprecated QGLWidgets is a clear step forwards which should ensure longevity even beyond Qt5.7.
I have tested pinch/touch now on my netbook (40min compile...), works nicely on Win10!
I don't have any HiDPI hardware to test either, sorry.
I have tested a week ago on RaspberryPi. I compiles with the old classes from its old Qt5.3.2.
The performance loss on Windows is strange, maybe we should keep the old class on Windows for a while? On 2 PC-based Linux systems I saw consistently higher framerate.
I would like to hear about Mac compatibility, but from my side, I approve.

review: Approve
Revision history for this message
Guillaume Chereau (guillaume-chereau) wrote :

Approve.

I agree: the cleanup of the CMakeFile.txt is very welcome!

Could we remove USE_OLD_QGLWIDGET in StelMainView now? Or is that still
needed?

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

Good patch! Fine for me.

I also don't think it makes much sense to support Qt < 5.3 as we already have too many configuration to deal with so I'd also just drop USE_OLD_QGLWIDGET to clean up the code further.

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

Just FYI: There are systems still around which don't have upgraded to Qt5.4 yet. Esp. Raspbian on the Raspberry Pi 2 or 3 platform has Qt5.3.2, and I have failed so far to compile and setup Qt myself successfully in a way that wold allow Stellarium to run (I am not familiar enough with X11 and EGL to understand the error messages). I consider this platform interesting for education and low-power use, there is a new open-source OpenGL driver just being completed (actually Mesa13 has it, but I now noted a new heavy bug in it). Else Stellarium runs with 12-20fps now, that's competitive to my AMD Win10 netbook. When Raspbian (and any other platforms we can regard important) comes with Qt5.4+, we can remove USE_OLD_QGLWIDGET.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2017-01-03 08:56:34 +0000
3+++ CMakeLists.txt 2017-01-12 21:08:38 +0000
4@@ -16,6 +16,9 @@
5 CMAKE_POLICY(SET CMP0054 OLD)
6 ENDIF()
7
8+# warn about deprecated stuff so that we may try fixing it
9+SET(CMAKE_WARN_DEPRECATED 1)
10+
11 ########### Project name ###########
12 PROJECT(Stellarium)
13 # Use integer versions instead of strings for easier handling if required
14@@ -37,6 +40,7 @@
15 # Write version of Stellarium to Stellarium User Guide
16 FILE(WRITE ${PROJECT_SOURCE_DIR}/guide/version.tex "\\newcommand{\\StelVersion}{${VERSION}}\n")
17
18+# currently Qt 5.4 - 5.6 is recommended, we can still build with Qt 5.3, and 5.7 may have some bugs
19 SET(MINIMAL_QT_VERSION "5.3.0")
20
21 # Use customized cmake macros
22@@ -58,6 +62,13 @@
23 ADD_DEFINITIONS(-DQT_NO_DEBUG -DNDEBUG)
24 endif()
25
26+set(OPENGL_DEBUG_LOGGING 0 CACHE BOOL "Enable to log OpenGL information using the GL_KHR_debug extension/QOpenGLLogger")
27+if(OPENGL_DEBUG_LOGGING)
28+ add_definitions(-DOPENGL_DEBUG_LOGGING)
29+ # This enables logging of QOpenGLFunctions through forced glGetError after each call
30+ add_definitions(-DQ_ENABLE_OPENGL_FUNCTIONS_DEBUG)
31+endif()
32+
33 # Use ccache if possible
34 find_program(CCACHE_PROGRAM ccache)
35 if(CCACHE_PROGRAM)
36@@ -276,6 +287,7 @@
37 ADD_PLUGIN(Exoplanets 1)
38 ADD_PLUGIN(EquationOfTime 1)
39 ADD_PLUGIN(FOV 1)
40+# TODO: Logbook build is broken for quite some time
41 ADD_PLUGIN(LogBook 0)
42 ADD_PLUGIN(MeteorShowers 1)
43 ADD_PLUGIN(NavStars 1)
44@@ -318,8 +330,9 @@
45 FIND_PACKAGE(Qt5Concurrent REQUIRED)
46 FIND_PACKAGE(Qt5Gui REQUIRED)
47 FIND_PACKAGE(Qt5Network REQUIRED)
48-FIND_PACKAGE(Qt5OpenGL REQUIRED)
49 FIND_PACKAGE(Qt5Widgets REQUIRED)
50+# required for qcustomplot external dependency
51+# not used elsewhere
52 FIND_PACKAGE(Qt5PrintSupport REQUIRED)
53 IF(USE_PLUGIN_TELESCOPECONTROL)
54 FIND_PACKAGE(Qt5SerialPort REQUIRED)
55@@ -355,6 +368,38 @@
56 ENDIF()
57 ENDIF()
58
59+# when using Qt 5.3, default to using the old QGLWidget, but warn
60+if(${Qt5Core_VERSION_STRING} VERSION_LESS "5.4")
61+ set(USE_OLD_QGLWIDGET 1)
62+ message(WARNING "You are using Qt ${Qt5Core_VERSION_STRING} to build, falling back to legacy QGLWidget rendering. Consider using at least Qt 5.4 if possible.")
63+else()
64+ # offer the old widget as an alternative, default off
65+ set(USE_OLD_QGLWIDGET 0 CACHE BOOL "Use the legacy QGLWidget instead of the new QOpenGLWidget for the main viewport, and link to the QtOpenGL module")
66+endif()
67+
68+if(USE_OLD_QGLWIDGET)
69+ add_definitions(-DUSE_OLD_QGLWIDGET)
70+ find_package(Qt5OpenGL REQUIRED)
71+endif()
72+
73+# Since Qt 5.4, linking to OpenGL is basically not required anymore,
74+# because the QtGui module re-implements the GL functions, and perhaps even
75+# dispatches the calls to a dynamically selected GL library.
76+#
77+# The only exception where this does not work with CMake is for
78+# ES2-only/ANGLE-only builds, which are seemingly not included in
79+# official Qt downloads, but may be required as a custom build
80+# for some embedded systems. Interestingly, this works with qmake,
81+# but CMake needs an explicit link definition.
82+# See also this bug: https://bugreports.qt.io/browse/QTBUG-29132
83+
84+# Check if we have a GLES-only build
85+# On dynamic builds, this property is also "GL"
86+if(${Qt5Gui_OPENGL_IMPLEMENTATION} MATCHES "GLES")
87+ message(STATUS "Building an OpenGL ES build (${Qt5Gui_OPENGL_IMPLEMENTATION})")
88+ set(STEL_GLES_LIBS Qt5::Gui_EGL Qt5::Gui_GLESv2)
89+endif()
90+
91
92 # Tell CMake to run moc when necessary:
93 set(CMAKE_AUTOMOC ON)
94@@ -362,31 +407,38 @@
95 set(CMAKE_INCLUDE_CURRENT_DIR ON)
96
97 IF(ENABLE_SCRIPTING)
98- SET(QT_USE_QTSCRIPT TRUE)
99 FIND_PACKAGE(Qt5Script REQUIRED)
100- INCLUDE_DIRECTORIES(${Qt5Script_INCLUDE_DIRS})
101 ENDIF()
102 IF(ENABLE_MEDIA)
103 ADD_DEFINITIONS(-DENABLE_MEDIA)
104 FIND_PACKAGE(Qt5Multimedia REQUIRED)
105 FIND_PACKAGE(Qt5MultimediaWidgets REQUIRED)
106- INCLUDE_DIRECTORIES(${Qt5Multimedia_INCLUDE_DIRS})
107- INCLUDE_DIRECTORIES(${Qt5MultimediaWidgets_INCLUDE_DIRS})
108-ENDIF()
109-
110-# I add this test because on Windows with angle we should not link
111-# with OpenGL. Maybe there is a better way to do that.
112-IF("${Qt5Gui_OPENGL_LIBRARIES}" MATCHES "opengl")
113- FIND_PACKAGE(OpenGL REQUIRED)
114-ENDIF()
115-IF(NOT WIN32)
116- FIND_PACKAGE(ZLIB)
117-ELSE()
118- SET(ZLIB_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/src/core/external/zlib)
119 ENDIF()
120
121 FIND_PACKAGE(Qt5Test)
122-INCLUDE_DIRECTORIES(${Qt5Test_INCLUDE_DIRS})
123+
124+### Setup external packages
125+
126+find_package(ZLIB QUIET) #quiet warnings about not found, we have our own version anyway
127+
128+# if a system zlib is found, let the user choose if to instead use our bundled version
129+if(ZLIB_FOUND)
130+ if(WIN32) #on win, we default to "no"
131+ set(USE_SYSTEM_ZLIB 0 CACHE BOOL "Use system-provided zlib instead of the bundled version")
132+ else() #else, we default to "yes"
133+ set(USE_SYSTEM_ZLIB 1 CACHE BOOL "Use system-provided zlib instead of the bundled version")
134+ endif()
135+else()
136+ set(USE_SYSTEM_ZLIB 0)
137+endif()
138+
139+if(NOT USE_SYSTEM_ZLIB)
140+ #use our own zlib
141+ message(STATUS "Using bundled zlib version at ${CMAKE_SOURCE_DIR}/src/external/zlib")
142+ set(ZLIB_LIBRARIES zlib_stel)
143+else()
144+ message(STATUS "Using system-provided zlib at ${ZLIB_LIBRARIES}")
145+endif()
146
147 ########### Set some global variables ###########
148 IF(UNIX AND NOT WIN32)
149@@ -408,7 +460,6 @@
150 ADD_DEFINITIONS(-DINSTALL_LOCALEDIR_FOR_DEBUG="${CMAKE_SOURCE_DIR}")
151 endif()
152
153-
154 ########### Get revision number for non-release builds ###########
155 IF(NOT STELLARIUM_RELEASE_BUILD)
156 # Hack until CMake detection for Bazaar is finished
157@@ -502,12 +553,12 @@
158 GET_TARGET_PROPERTY(QtConcurrent_location Qt5::Concurrent LOCATION)
159 GET_TARGET_PROPERTY(QtCore_location Qt5::Core LOCATION)
160 GET_TARGET_PROPERTY(QtGui_location Qt5::Gui LOCATION)
161- GET_TARGET_PROPERTY(QtOpenGL_location Qt5::OpenGL LOCATION)
162 GET_TARGET_PROPERTY(QtNetwork_location Qt5::Network LOCATION)
163 GET_TARGET_PROPERTY(QtWidgets_location Qt5::Widgets LOCATION)
164 GET_TARGET_PROPERTY(QtSql_location Qt5::Sql LOCATION)
165 GET_TARGET_PROPERTY(QtXmlPatterns_location Qt5::XmlPatterns LOCATION)
166 GET_TARGET_PROPERTY(QtPrintSupport_location Qt5::PrintSupport LOCATION)
167+ SET(ISS_QT_PRINTSUPPORT "Source: \"${QtPrintSupport_location}\"; DestDir: \"{app}\";")
168 IF(ENABLE_SCRIPTING)
169 GET_TARGET_PROPERTY(QtScript_location Qt5::Script LOCATION)
170 SET(ISS_QT_SCRIPT "Source: \"${QtScript_location}\"; DestDir: \"{app}\";")
171@@ -685,16 +736,10 @@
172 ${CMAKE_SOURCE_DIR}/src/core
173 ${CMAKE_SOURCE_DIR}/src/core/modules
174 ${CMAKE_SOURCE_DIR}/src/core/planetsephems
175- ${CMAKE_SOURCE_DIR}/src/core/external
176- ${CMAKE_SOURCE_DIR}/src/core/external/qtcompress
177- ${CMAKE_SOURCE_DIR}/src/core/external/qcustomplot
178- ${CMAKE_SOURCE_DIR}/src/core/external/glues_stel/source/
179- ${CMAKE_SOURCE_DIR}/src/core/external/glues_stel/source/libtess
180 ${CMAKE_SOURCE_DIR}/src/gui
181 ${CMAKE_SOURCE_DIR}/src/scripting
182 ${INTL_INCLUDE_DIR}
183 ${CMAKE_BINARY_DIR}/src
184- ${ZLIB_INCLUDE_DIR}
185 )
186
187 ########### Subdirectories ###############
188
189=== modified file 'cmake/default_config.ini.cmake'
190--- cmake/default_config.ini.cmake 2016-10-29 12:45:33 +0000
191+++ cmake/default_config.ini.cmake 2017-01-12 21:08:38 +0000
192@@ -22,6 +22,7 @@
193 maximum_fps = 10000
194 #viewport_effect = sphericMirrorDistorter
195 viewport_effect = none
196+vsync = true
197
198 [projection]
199 type = ProjectionStereographic
200
201=== modified file 'cmake/stellarium.iss.cmake'
202--- cmake/stellarium.iss.cmake 2017-01-03 08:56:34 +0000
203+++ cmake/stellarium.iss.cmake 2017-01-12 21:08:38 +0000
204@@ -47,13 +47,12 @@
205 Source: "@CMAKE_SOURCE_DIR@\ChangeLog"; DestDir: "{app}"; Flags: ignoreversion; DestName: "ChangeLog.rtf"
206 Source: "@QtCore_location@"; DestDir: "{app}";
207 Source: "@QtGui_location@"; DestDir: "{app}";
208-Source: "@QtOpenGL_location@"; DestDir: "{app}";
209 Source: "@QtNetwork_location@"; DestDir: "{app}";
210 Source: "@QtWidgets_location@"; DestDir: "{app}";
211 Source: "@QtSql_location@"; DestDir: "{app}";
212 Source: "@QtXmlPatterns_location@"; DestDir: "{app}";
213 Source: "@QtConcurrent_location@"; DestDir: "{app}";
214-Source: "@QtPrintSupport_location@"; DestDir: "{app}";
215+@ISS_QT_PRINTSUPPORT@
216 @ISS_QT_SCRIPT@
217 @ISS_QT_MULTIMEDIA@
218 @ISS_QT_SERIALPORT@
219
220=== modified file 'data/shaders/s3d_pixellit.frag'
221--- data/shaders/s3d_pixellit.frag 2015-09-11 16:34:17 +0000
222+++ data/shaders/s3d_pixellit.frag 2017-01-12 21:08:38 +0000
223@@ -32,6 +32,7 @@
224 #define SHADOW_FILTER 0
225 #define SHADOW_FILTER_HQ 0
226 #define SINGLE_SHADOW_FRUSTUM 1
227+#define HW_SHADOW_SAMPLERS 0
228 #define PCSS 0
229 #define MAT_DIFFUSETEX 1
230 #define MAT_EMISSIVETEX 1
231@@ -254,10 +255,10 @@
232 #endif
233 //shadow related uniforms
234 uniform vec4 u_vSplits; //the frustum splits
235-#if PCSS
236+#if HW_SHADOW_SAMPLERS
237+ #define SHADOWSAMPLER sampler2DShadow
238+#else
239 #define SHADOWSAMPLER sampler2D
240-#else
241- #define SHADOWSAMPLER sampler2DShadow
242 #endif
243
244 //for some reason, Intel does absolutely not like it if the shadowmaps are passed as an array
245@@ -311,23 +312,29 @@
246 {
247 vec2 offset = poissonDisk[i] * filterRadiusUV;
248 //TODO offsets should probably depend on light ortho size?
249- #if PCSS
250+ #if HW_SHADOW_SAMPLERS
251+ sum+=shadow2D(tex,vec3(texC.xy + offset, texC.z)).x;
252+ #else
253 //texture is a normal sampler2D because we need depth values in blocker calculation
254 //opengl does not allow to sample this texture in 2 different ways (unless sampler objects are used, but needs version >= 3.3)
255 //so we have to do comparison ourselves
256 sum+= (texture2D(tex,texC.xy + offset).r > texC.z) ? 1.0f : 0.0f;
257- #else
258- sum+=shadow2D(tex,vec3(texC.xy + offset, texC.z)).x;
259 #endif
260 }
261 return sum / FILTER_STEPS;
262- #else
263+ #elif HW_SHADOW_SAMPLERS
264 //no filtering performed, just return the sampled tex
265 return shadow2DProj(tex,coord).x;
266+ #else
267+ vec3 texC = coord.xyz / coord.w;
268+ return texture2D(tex,texC.xy).x > texC.z ? 1.0f : 0.0f;
269 #endif
270 }
271
272 #if PCSS
273+#if HW_SHADOW_SAMPLERS
274+#error Tried to compile PCSS shader compiled with HW shadow samplers
275+#endif
276 //Based on the PCSS implementation of NVidia, ported to GLSL
277 //see http://developer.download.nvidia.com/whitepapers/2008/PCSS_Integration.pdf
278 //Some modifications to work better with directional light are included
279
280=== modified file 'guide/version.tex'
281--- guide/version.tex 2017-01-02 14:34:22 +0000
282+++ guide/version.tex 2017-01-12 21:08:38 +0000
283@@ -1,1 +1,1 @@
284-\newcommand{\StelVersion}{0.90.0}
285+\newcommand{\StelVersion}{0.90.0}
286
287=== modified file 'plugins/AngleMeasure/src/AngleMeasure.cpp'
288--- plugins/AngleMeasure/src/AngleMeasure.cpp 2017-01-06 16:52:05 +0000
289+++ plugins/AngleMeasure/src/AngleMeasure.cpp 2017-01-12 21:08:38 +0000
290@@ -34,7 +34,6 @@
291 #include <QDebug>
292 #include <QTimer>
293 #include <QPixmap>
294-#include <QtNetwork>
295 #include <QSettings>
296 #include <QKeyEvent>
297 #include <QMouseEvent>
298@@ -188,9 +187,8 @@
299 const StelProjectorP prj = core->getProjection(frameType, refractionMode);
300 StelPainter painter(prj);
301 painter.setFont(font);
302+ painter.setBlending(true);
303
304- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
305- glEnable(GL_BLEND);
306 if (lineVisible.getInterstate() > 0.000001f)
307 {
308 Vec3d xy;
309@@ -220,12 +218,7 @@
310 }
311 }
312
313- glDisable(GL_TEXTURE_2D);
314- // OpenGL ES 2.0 doesn't have GL_LINE_SMOOTH. But it looks much better.
315- #ifdef GL_LINE_SMOOTH
316- if (QOpenGLContext::currentContext()->format().renderableType()==QSurfaceFormat::OpenGL)
317- glEnable(GL_LINE_SMOOTH);
318- #endif
319+ painter.setLineSmooth(true);
320
321 // main line is a great circle
322 painter.setColor(lineColor[0], lineColor[1], lineColor[2], lineVisible.getInterstate());
323@@ -245,10 +238,8 @@
324 painter.drawGreatCircleArc(perp1StartPointHor, perp1EndPointHor, NULL);
325 painter.drawGreatCircleArc(perp2StartPointHor, perp2EndPointHor, NULL);
326 }
327- #ifdef GL_LINE_SMOOTH
328- if (QOpenGLContext::currentContext()->format().renderableType()==QSurfaceFormat::OpenGL)
329- glDisable(GL_LINE_SMOOTH);
330- #endif
331+
332+ painter.setLineSmooth(false);
333 }
334 if (messageFader.getInterstate() > 0.000001f)
335 {
336@@ -262,7 +253,7 @@
337 y -= ls;
338 painter.drawText(x, y, messageRightButton);
339 }
340- glDisable(GL_BLEND);
341+ painter.setBlending(false);
342 }
343
344 //! Draw any parts on the screen which are for our module
345
346=== modified file 'plugins/AngleMeasure/src/CMakeLists.txt'
347--- plugins/AngleMeasure/src/CMakeLists.txt 2015-10-20 17:16:34 +0000
348+++ plugins/AngleMeasure/src/CMakeLists.txt 2017-01-12 21:08:38 +0000
349@@ -18,12 +18,9 @@
350 SET(AngleMeasure_RES ../AngleMeasure.qrc)
351 QT5_ADD_RESOURCES(AngleMeasure_RES_CXX ${AngleMeasure_RES})
352
353-SET(extLinkerOption ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${OPENGL_LIBRARIES})
354-
355 ADD_LIBRARY(AngleMeasure-static STATIC ${AngleMeasure_SRCS} ${AngleMeasure_RES_CXX} ${AngleMeasure_UIS_H})
356-QT5_USE_MODULES(AngleMeasure-static Core Network Widgets)
357+TARGET_LINK_LIBRARIES(AngleMeasure-static Qt5::Core Qt5::Widgets)
358 # The library target "AngleMeasure-static" has a default OUTPUT_NAME of "AngleMeasure-static", so change it.
359 SET_TARGET_PROPERTIES(AngleMeasure-static PROPERTIES OUTPUT_NAME "AngleMeasure")
360-TARGET_LINK_LIBRARIES(AngleMeasure-static ${extLinkerOption})
361 SET_TARGET_PROPERTIES(AngleMeasure-static PROPERTIES COMPILE_FLAGS "-DQT_STATICPLUGIN")
362 ADD_DEPENDENCIES(AllStaticPlugins AngleMeasure-static)
363
364=== modified file 'plugins/ArchaeoLines/src/ArchaeoLines.cpp'
365--- plugins/ArchaeoLines/src/ArchaeoLines.cpp 2016-12-24 10:33:14 +0000
366+++ plugins/ArchaeoLines/src/ArchaeoLines.cpp 2017-01-12 21:08:38 +0000
367@@ -37,7 +37,6 @@
368 #include <QTimer>
369 #include <QPixmap>
370 #include <QColor>
371-#include <QtNetwork>
372 #include <QSettings>
373 #include <QMouseEvent>
374 #include <cmath>
375@@ -1223,9 +1222,7 @@
376
377 d->sPainter->drawText(screenPos[0], screenPos[1], text, angleDeg, xshift, 3);
378 //d->sPainter->setColor(tmpColor[0], tmpColor[1], tmpColor[2], tmpColor[3]); // RESTORE
379- glDisable(GL_TEXTURE_2D);
380- glEnable(GL_BLEND);
381- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
382+ d->sPainter->setBlending(true);
383 }
384
385
386@@ -1324,16 +1321,8 @@
387
388 // Initialize a painter and set OpenGL state
389 StelPainter sPainter(prj);
390- glEnable(GL_BLEND);
391- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transparency mode
392- glDisable(GL_TEXTURE_2D);
393-
394- // OpenGL ES 2.0 doesn't have GL_LINE_SMOOTH
395- #ifdef GL_LINE_SMOOTH
396- if (QOpenGLContext::currentContext()->format().renderableType()==QSurfaceFormat::OpenGL)
397- glEnable(GL_LINE_SMOOTH);
398- #endif
399-
400+ sPainter.setBlending(true);
401+ sPainter.setLineSmooth(true);
402 sPainter.setColor(color[0], color[1], color[2], intensity*fader.getInterstate());
403 //Vec4f textColor(color[0], color[1], color[2], intensity*fader.getInterstate());
404
405@@ -1419,22 +1408,11 @@
406 sPainter.drawSmallCircleArc(pt1, pt2, rotCenter, alViewportEdgeIntersectCallback, &userData);
407 sPainter.drawSmallCircleArc(pt2, pt3, rotCenter, alViewportEdgeIntersectCallback, &userData);
408 sPainter.drawSmallCircleArc(pt3, pt1, rotCenter, alViewportEdgeIntersectCallback, &userData);
409- #ifdef GL_LINE_SMOOTH
410- if (QOpenGLContext::currentContext()->format().renderableType()==QSurfaceFormat::OpenGL)
411- glDisable(GL_LINE_SMOOTH);
412- #endif
413- glDisable(GL_BLEND);
414- return;
415- }
416- else
417- {
418- #ifdef GL_LINE_SMOOTH
419- if (QOpenGLContext::currentContext()->format().renderableType()==QSurfaceFormat::OpenGL)
420- glDisable(GL_LINE_SMOOTH);
421- #endif
422- glDisable(GL_BLEND);
423- return;
424- }
425+ }
426+
427+ sPainter.setLineSmooth(false);
428+ sPainter.setBlending(false);
429+ return;
430 }
431 // Draw the arc in 2 sub-arcs to avoid lengths > 180 deg
432 Vec3d middlePoint = p1-rotCenter+p2-rotCenter;
433@@ -1451,11 +1429,6 @@
434 sPainter.drawSmallCircleArc(p1, middlePoint, rotCenter,alViewportEdgeIntersectCallback, &userData);
435 sPainter.drawSmallCircleArc(p2, middlePoint, rotCenter, alViewportEdgeIntersectCallback, &userData);
436
437- // OpenGL ES 2.0 doesn't have GL_LINE_SMOOTH
438- #ifdef GL_LINE_SMOOTH
439- if (QOpenGLContext::currentContext()->format().renderableType()==QSurfaceFormat::OpenGL)
440- glDisable(GL_LINE_SMOOTH);
441- #endif
442-
443- glDisable(GL_BLEND);
444+ sPainter.setLineSmooth(false);
445+ sPainter.setBlending(false);
446 }
447
448=== modified file 'plugins/ArchaeoLines/src/CMakeLists.txt'
449--- plugins/ArchaeoLines/src/CMakeLists.txt 2015-10-20 17:16:34 +0000
450+++ plugins/ArchaeoLines/src/CMakeLists.txt 2017-01-12 21:08:38 +0000
451@@ -18,12 +18,9 @@
452 SET(ArchaeoLines_RES ../ArchaeoLines.qrc)
453 QT5_ADD_RESOURCES(ArchaeoLines_RES_CXX ${ArchaeoLines_RES})
454
455-SET(extLinkerOption ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${OPENGL_LIBRARIES})
456-
457 ADD_LIBRARY(ArchaeoLines-static STATIC ${ArchaeoLines_SRCS} ${ArchaeoLines_RES_CXX} ${ArchaeoLines_UIS_H})
458-QT5_USE_MODULES(ArchaeoLines-static Core Network Widgets)
459+TARGET_LINK_LIBRARIES(ArchaeoLines-static Qt5::Core Qt5::Widgets)
460 # The library target "ArchaeoLines-static" has a default OUTPUT_NAME of "ArchaeoLines-static", so change it.
461 SET_TARGET_PROPERTIES(ArchaeoLines-static PROPERTIES OUTPUT_NAME "ArchaeoLines")
462-TARGET_LINK_LIBRARIES(ArchaeoLines-static ${extLinkerOption})
463 SET_TARGET_PROPERTIES(ArchaeoLines-static PROPERTIES COMPILE_FLAGS "-DQT_STATICPLUGIN")
464 ADD_DEPENDENCIES(AllStaticPlugins ArchaeoLines-static)
465
466=== modified file 'plugins/ArchaeoLines/src/gui/ArchaeoLinesDialog.cpp'
467--- plugins/ArchaeoLines/src/gui/ArchaeoLinesDialog.cpp 2017-01-05 15:28:52 +0000
468+++ plugins/ArchaeoLines/src/gui/ArchaeoLinesDialog.cpp 2017-01-12 21:08:38 +0000
469@@ -222,8 +222,8 @@
470 #ifndef Q_OS_WIN
471 ui->switchToWindowedModeLabel->hide();
472 #else
473- QString glRenderer(reinterpret_cast<const char*>(glGetString(GL_RENDERER)));
474- if (glRenderer.startsWith("ANGLE", Qt::CaseSensitive))
475+ // don't call GL functions in GUI code please
476+ if (StelMainView::getInstance().getGLInformation().renderer.startsWith("ANGLE", Qt::CaseSensitive))
477 ui->switchToWindowedModeLabel->hide();
478 #endif
479 setAboutHtml();
480
481=== modified file 'plugins/CompassMarks/src/CMakeLists.txt'
482--- plugins/CompassMarks/src/CMakeLists.txt 2015-10-20 17:16:34 +0000
483+++ plugins/CompassMarks/src/CMakeLists.txt 2017-01-12 21:08:38 +0000
484@@ -8,12 +8,10 @@
485
486 SET(CompassMarks_RES ../CompassMarks.qrc)
487 QT5_ADD_RESOURCES(CompassMarks_RES_CXX ${CompassMarks_RES})
488-SET(extLinkerOption ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${OPENGL_LIBRARIES})
489
490 ADD_LIBRARY(CompassMarks-static STATIC ${CompassMarks_SRCS} ${CompassMarks_RES_CXX})
491-QT5_USE_MODULES(CompassMarks-static Core Network Widgets)
492+TARGET_LINK_LIBRARIES(CompassMarks-static Qt5::Core Qt5::Widgets)
493 # The library target "CompassMarks-static" has a default OUTPUT_NAME of "CompassMarks-static", so change it.
494 SET_TARGET_PROPERTIES(CompassMarks-static PROPERTIES OUTPUT_NAME "CompassMarks")
495-TARGET_LINK_LIBRARIES(CompassMarks-static ${extLinkerOption})
496 SET_TARGET_PROPERTIES(CompassMarks-static PROPERTIES COMPILE_FLAGS "-DQT_STATICPLUGIN")
497 ADD_DEPENDENCIES(AllStaticPlugins CompassMarks-static)
498
499=== modified file 'plugins/CompassMarks/src/CompassMarks.cpp'
500--- plugins/CompassMarks/src/CompassMarks.cpp 2015-10-28 13:39:43 +0000
501+++ plugins/CompassMarks/src/CompassMarks.cpp 2017-01-12 21:08:38 +0000
502@@ -35,7 +35,6 @@
503 #include <QPixmap>
504 #include <QSettings>
505 #include <QKeyEvent>
506-#include <QtNetwork>
507 #include <cmath>
508
509 StelModule* CompassMarksStelPluginInterface::getStelModule() const
510@@ -129,14 +128,8 @@
511 painter.setFont(font);
512
513 painter.setColor(markColor[0], markColor[1], markColor[2], markFader.getInterstate());
514- glDisable(GL_TEXTURE_2D);
515- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
516- glEnable(GL_BLEND);
517- // OpenGL ES 2.0 doesn't have GL_LINE_SMOOTH. But it looks much better.
518- #ifdef GL_LINE_SMOOTH
519- if (QOpenGLContext::currentContext()->format().renderableType()==QSurfaceFormat::OpenGL)
520- glEnable(GL_LINE_SMOOTH);
521- #endif
522+ painter.setBlending(true);
523+ painter.setLineSmooth(true);
524
525 for(int i=0; i<360; i++)
526 {
527@@ -161,20 +154,11 @@
528 // Limit arcs to those that are visible for improved performance
529 if (prj->project(pos, screenPos) &&
530 screenPos[0]>prj->getViewportPosX() && screenPos[0] < prj->getViewportPosX() + prj->getViewportWidth()) {
531- // This has been disabled above already...
532- //glDisable(GL_TEXTURE_2D);
533 painter.drawGreatCircleArc(pos, Vec3d(pos[0], pos[1], h), NULL);
534- //glEnable(GL_TEXTURE_2D);
535 }
536 }
537- // OpenGL ES 2.0 doesn't have GL_LINE_SMOOTH
538- #ifdef GL_LINE_SMOOTH
539- if (QOpenGLContext::currentContext()->format().renderableType()==QSurfaceFormat::OpenGL)
540- glDisable(GL_LINE_SMOOTH);
541- #endif
542- glDisable(GL_BLEND);
543- glEnable(GL_TEXTURE_2D);
544-
545+ painter.setBlending(false);
546+ painter.setLineSmooth(false);
547 }
548
549 void CompassMarks::update(double deltaTime)
550
551=== modified file 'plugins/EquationOfTime/src/CMakeLists.txt'
552--- plugins/EquationOfTime/src/CMakeLists.txt 2015-10-20 17:16:34 +0000
553+++ plugins/EquationOfTime/src/CMakeLists.txt 2017-01-12 21:08:38 +0000
554@@ -25,11 +25,8 @@
555 SET(EQUATIONOFTIME_RES ../resources/EquationOfTime.qrc)
556 QT5_ADD_RESOURCES(EQUATIONOFTIME_RES_CXX ${EQUATIONOFTIME_RES})
557
558-SET(extLinkerOption ${OPENGL_LIBRARIES})
559-
560 ADD_LIBRARY(EquationOfTime-static STATIC ${EQUATIONOFTIME_SRCS} ${EQUATIONOFTIME_RES_CXX} ${EQUATIONOFTIME_UIS_H})
561-QT5_USE_MODULES(EquationOfTime-static Core Network Gui Widgets)
562+TARGET_LINK_LIBRARIES(EquationOfTime-static Qt5::Core Qt5::Widgets)
563 SET_TARGET_PROPERTIES(EquationOfTime-static PROPERTIES OUTPUT_NAME "EquationOfTime")
564-TARGET_LINK_LIBRARIES(EquationOfTime-static ${extLinkerOption})
565 SET_TARGET_PROPERTIES(EquationOfTime-static PROPERTIES COMPILE_FLAGS "-DQT_STATICPLUGIN")
566 ADD_DEPENDENCIES(AllStaticPlugins EquationOfTime-static)
567
568=== modified file 'plugins/Exoplanets/src/CMakeLists.txt'
569--- plugins/Exoplanets/src/CMakeLists.txt 2016-01-30 17:47:43 +0000
570+++ plugins/Exoplanets/src/CMakeLists.txt 2017-01-12 21:08:38 +0000
571@@ -24,11 +24,8 @@
572 SET(Exoplanets_RES ../resources/Exoplanets.qrc)
573 QT5_ADD_RESOURCES(Exoplanets_RES_CXX ${Exoplanets_RES})
574
575-SET(extLinkerOption ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${OPENGL_LIBRARIES})
576-
577 ADD_LIBRARY(Exoplanets-static STATIC ${Exoplanets_SRCS} ${Exoplanets_RES_CXX} ${ExoplanetsDialog_UIS_H})
578-QT5_USE_MODULES(Exoplanets-static Core Network Widgets)
579+TARGET_LINK_LIBRARIES(Exoplanets-static Qt5::Core Qt5::Network Qt5::Widgets qcustomplot_stel)
580 SET_TARGET_PROPERTIES(Exoplanets-static PROPERTIES OUTPUT_NAME "Exoplanets")
581-TARGET_LINK_LIBRARIES(Exoplanets-static ${extLinkerOption})
582 SET_TARGET_PROPERTIES(Exoplanets-static PROPERTIES COMPILE_FLAGS "-DQT_STATICPLUGIN")
583 ADD_DEPENDENCIES(AllStaticPlugins Exoplanets-static)
584
585=== modified file 'plugins/Exoplanets/src/Exoplanet.cpp'
586--- plugins/Exoplanets/src/Exoplanet.cpp 2016-11-17 17:47:59 +0000
587+++ plugins/Exoplanets/src/Exoplanet.cpp 2017-01-12 21:08:38 +0000
588@@ -559,8 +559,7 @@
589 StelUtils::spheToRect(RA, DE, XYZ);
590 double mag = getVMagnitudeWithExtinction(core);
591
592- glEnable(GL_BLEND);
593- glBlendFunc(GL_ONE, GL_ONE);
594+ painter->setBlending(true, GL_ONE, GL_ONE);
595 painter->setColor(color[0], color[1], color[2], 1);
596
597 if (timelineMode)
598
599=== modified file 'plugins/Exoplanets/src/Exoplanets.cpp'
600--- plugins/Exoplanets/src/Exoplanets.cpp 2016-11-18 19:24:45 +0000
601+++ plugins/Exoplanets/src/Exoplanets.cpp 2017-01-12 21:08:38 +0000
602@@ -252,9 +252,7 @@
603 const Vec3f& c(obj->getInfoColor());
604 painter.setColor(c[0],c[1],c[2]);
605 texPointer->bind();
606- painter.enableTexture2d(true);
607- glEnable(GL_BLEND);
608- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transparency mode
609+ painter.setBlending(true);
610 painter.drawSprite2dMode(screenpos[0], screenpos[1], 13.f, StelApp::getInstance().getTotalRunTime()*40.);
611 }
612 }
613
614=== modified file 'plugins/Exoplanets/src/gui/ExoplanetsDialog.cpp'
615--- plugins/Exoplanets/src/gui/ExoplanetsDialog.cpp 2017-01-05 15:28:52 +0000
616+++ plugins/Exoplanets/src/gui/ExoplanetsDialog.cpp 2017-01-12 21:08:38 +0000
617@@ -39,7 +39,7 @@
618 #include "StelTranslator.hpp"
619 #include "StelLocaleMgr.hpp"
620
621-#include "qcustomplot/qcustomplot.h"
622+#include "external/qcustomplot/qcustomplot.h"
623
624 ExoplanetsDialog::ExoplanetsDialog()
625 : StelDialog("Exoplanets")
626
627=== modified file 'plugins/Exoplanets/src/gui/exoplanetsDialog.ui'
628--- plugins/Exoplanets/src/gui/exoplanetsDialog.ui 2016-11-29 13:26:25 +0000
629+++ plugins/Exoplanets/src/gui/exoplanetsDialog.ui 2017-01-12 21:08:38 +0000
630@@ -606,7 +606,7 @@
631 <customwidget>
632 <class>QCustomPlot</class>
633 <extends>QWidget</extends>
634- <header>qcustomplot.h</header>
635+ <header>external/qcustomplot/qcustomplot.h</header>
636 </customwidget>
637 </customwidgets>
638 <resources/>
639
640=== modified file 'plugins/FOV/src/CMakeLists.txt'
641--- plugins/FOV/src/CMakeLists.txt 2015-10-20 17:16:34 +0000
642+++ plugins/FOV/src/CMakeLists.txt 2017-01-12 21:08:38 +0000
643@@ -22,11 +22,8 @@
644
645 QT5_WRAP_UI(FOV_UIS_H ${FOV_UIS})
646
647-SET(extLinkerOption ${OPENGL_LIBRARIES})
648-
649 ADD_LIBRARY(FOV-static STATIC ${FOV_SRCS} ${FOV_RES_CXX} ${FOV_UIS_H})
650-QT5_USE_MODULES(FOV-static Core Network Widgets)
651+TARGET_LINK_LIBRARIES(FOV-static Qt5::Core Qt5::Widgets)
652 SET_TARGET_PROPERTIES(FOV-static PROPERTIES OUTPUT_NAME "FOV")
653-TARGET_LINK_LIBRARIES(FOV-static ${extLinkerOption})
654 SET_TARGET_PROPERTIES(FOV-static PROPERTIES COMPILE_FLAGS "-DQT_STATICPLUGIN")
655 ADD_DEPENDENCIES(AllStaticPlugins FOV-static)
656
657=== modified file 'plugins/HelloStelModule/src/CMakeLists.txt'
658--- plugins/HelloStelModule/src/CMakeLists.txt 2015-10-20 17:16:34 +0000
659+++ plugins/HelloStelModule/src/CMakeLists.txt 2017-01-12 21:08:38 +0000
660@@ -7,14 +7,10 @@
661 HelloStelModule.cpp
662 )
663
664-
665-SET(extLinkerOption ${OPENGL_LIBRARIES})
666-
667 ADD_LIBRARY(HelloStelModule-static STATIC ${HelloStelModule_SRCS})
668 # The library target "HelloStelModule-static" has a default OUTPUT_NAME of "HelloStelModule-static", so change it.
669-QT5_USE_MODULES(HelloStelModule-static Core Gui)
670 SET_TARGET_PROPERTIES(HelloStelModule-static PROPERTIES OUTPUT_NAME "HelloStelModule")
671-TARGET_LINK_LIBRARIES(HelloStelModule-static ${extLinkerOption})
672+TARGET_LINK_LIBRARIES(HelloStelModule-static Qt5::Core Qt5::Gui)
673 SET_TARGET_PROPERTIES(HelloStelModule-static PROPERTIES COMPILE_FLAGS "-DQT_STATICPLUGIN")
674 ADD_DEPENDENCIES(AllStaticPlugins HelloStelModule-static)
675
676
677=== modified file 'plugins/MeteorShowers/src/CMakeLists.txt'
678--- plugins/MeteorShowers/src/CMakeLists.txt 2015-10-20 17:16:34 +0000
679+++ plugins/MeteorShowers/src/CMakeLists.txt 2017-01-12 21:08:38 +0000
680@@ -33,11 +33,8 @@
681 SET(MeteorShowers_RES ../resources/MeteorShower.qrc)
682 QT5_ADD_RESOURCES(MeteorShowers_RES_CXX ${MeteorShowers_RES})
683
684-SET(extLinkerOption ${QT_LIBRARIES} ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${OPENGL_LIBRARIES} ${ICONV_LIBRARIES} ${INTL_LIBRARIES})
685-
686 ADD_LIBRARY(MeteorShowers-static STATIC ${MeteorShowers_SRCS} ${MeteorShowers_MOC_SRCS} ${MeteorShowers_RES_CXX} ${MeteorShowersDialog_UIS_H})
687-QT5_USE_MODULES(MeteorShowers-static Core Network Widgets)
688+TARGET_LINK_LIBRARIES(MeteorShowers-static Qt5::Core Qt5::Network Qt5::Widgets)
689 SET_TARGET_PROPERTIES(MeteorShowers-static PROPERTIES OUTPUT_NAME "MeteorShowers")
690-TARGET_LINK_LIBRARIES(MeteorShowers-static ${extLinkerOption})
691 SET_TARGET_PROPERTIES(MeteorShowers-static PROPERTIES COMPILE_FLAGS "-DQT_STATICPLUGIN")
692 ADD_DEPENDENCIES(AllStaticPlugins MeteorShowers-static)
693
694=== modified file 'plugins/MeteorShowers/src/MeteorShower.cpp'
695--- plugins/MeteorShowers/src/MeteorShower.cpp 2017-01-07 17:36:45 +0000
696+++ plugins/MeteorShowers/src/MeteorShower.cpp 2017-01-12 21:08:38 +0000
697@@ -333,9 +333,7 @@
698 StelUtils::spheToRect(m_radiantAlpha, m_radiantDelta, m_position);
699 painter.getProjector()->project(m_position, XY);
700
701- glEnable(GL_TEXTURE_2D);
702- glEnable(GL_BLEND);
703- glBlendFunc(GL_SRC_ALPHA, GL_ONE);
704+ painter.setBlending(true, GL_SRC_ALPHA, GL_ONE);
705
706 Vec3f rgb;
707 float alpha = 0.85f + ((float) qrand() / (float) RAND_MAX) / 10.f;
708
709=== modified file 'plugins/MeteorShowers/src/MeteorShowers.cpp'
710--- plugins/MeteorShowers/src/MeteorShowers.cpp 2016-07-03 21:58:54 +0000
711+++ plugins/MeteorShowers/src/MeteorShowers.cpp 2017-01-12 21:08:38 +0000
712@@ -81,9 +81,8 @@
713 const Vec3f& c(obj->getInfoColor());
714 painter.setColor(c[0],c[1],c[2]);
715 m_mgr->getPointerTexture()->bind();
716- painter.enableTexture2d(true);
717- glEnable(GL_BLEND);
718- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transparency mode
719+
720+ painter.setBlending(true);
721
722 float size = obj->getAngularSize(core) * M_PI / 180. * painter.getProjector()->getPixelPerRadAtCenter();
723 size += 20.f + 10.f * qSin(2.f * StelApp::getInstance().getTotalRunTime());
724
725=== modified file 'plugins/MeteorShowers/src/MeteorShowersMgr.hpp'
726--- plugins/MeteorShowers/src/MeteorShowersMgr.hpp 2016-07-10 03:16:07 +0000
727+++ plugins/MeteorShowers/src/MeteorShowersMgr.hpp 2017-01-12 21:08:38 +0000
728@@ -325,7 +325,7 @@
729 QString m_url;
730 QDateTime m_lastUpdate;
731 DownloadStatus m_statusOfLastUpdate;
732- QNetworkAccessManager* m_downloadMgr;
733+ QNetworkAccessManager* m_downloadMgr;
734 class StelProgressController* m_progressBar;
735
736 void createActions();
737
738=== modified file 'plugins/NavStars/src/CMakeLists.txt'
739--- plugins/NavStars/src/CMakeLists.txt 2016-05-21 14:14:31 +0000
740+++ plugins/NavStars/src/CMakeLists.txt 2017-01-12 21:08:38 +0000
741@@ -23,11 +23,8 @@
742 SET(NavStars_RES ../resources/NavStars.qrc)
743 QT5_ADD_RESOURCES(NavStars_RES_CXX ${NavStars_RES})
744
745-SET(extLinkerOption ${PNG_LIBRARIES} ${OPENGL_LIBRARIES})
746-
747 ADD_LIBRARY(NavStars-static STATIC ${NavStars_SRCS} ${NavStars_RES_CXX} ${NavStars_UIS_H})
748-QT5_USE_MODULES(NavStars-static Core Network Widgets)
749+TARGET_LINK_LIBRARIES(NavStars-static Qt5::Core Qt5::Widgets)
750 SET_TARGET_PROPERTIES(NavStars-static PROPERTIES OUTPUT_NAME "NavStars")
751-TARGET_LINK_LIBRARIES(NavStars-static ${extLinkerOption})
752 SET_TARGET_PROPERTIES(NavStars-static PROPERTIES COMPILE_FLAGS "-DQT_STATICPLUGIN")
753 ADD_DEPENDENCIES(AllStaticPlugins NavStars-static)
754
755=== modified file 'plugins/NavStars/src/NavStars.cpp'
756--- plugins/NavStars/src/NavStars.cpp 2016-08-01 12:55:49 +0000
757+++ plugins/NavStars/src/NavStars.cpp 2017-01-12 21:08:38 +0000
758@@ -182,9 +182,7 @@
759 // ... and draw a marker around it
760 if (!markerTexture.isNull())
761 {
762- glEnable(GL_BLEND);
763- painter.enableTexture2d(true);
764- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
765+ painter.setBlending(true);
766 painter.setColor(markerColor[0], markerColor[1], markerColor[2], markerFader.getInterstate());
767 markerTexture->bind();
768 painter.drawSprite2dMode(pos[0], pos[1], 11.f);
769
770=== modified file 'plugins/Novae/src/CMakeLists.txt'
771--- plugins/Novae/src/CMakeLists.txt 2015-10-20 17:16:34 +0000
772+++ plugins/Novae/src/CMakeLists.txt 2017-01-12 21:08:38 +0000
773@@ -25,11 +25,8 @@
774 SET(Novae_RES ../resources/Novae.qrc)
775 QT5_ADD_RESOURCES(Novae_RES_CXX ${Novae_RES})
776
777-SET(extLinkerOption ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${OPENGL_LIBRARIES})
778-
779 ADD_LIBRARY(Novae-static STATIC ${Novae_SRCS} ${Novae_RES_CXX} ${NovaeDialog_UIS_H})
780-QT5_USE_MODULES(Novae-static Core Network OpenGL)
781+TARGET_LINK_LIBRARIES(Novae-static Qt5::Core Qt5::Network Qt5::Widgets)
782 SET_TARGET_PROPERTIES(Novae-static PROPERTIES OUTPUT_NAME "Novae")
783-TARGET_LINK_LIBRARIES(Novae-static ${extLinkerOption})
784 SET_TARGET_PROPERTIES(Novae-static PROPERTIES COMPILE_FLAGS "-DQT_STATICPLUGIN")
785 ADD_DEPENDENCIES(AllStaticPlugins Novae-static)
786
787=== modified file 'plugins/Novae/src/Novae.cpp'
788--- plugins/Novae/src/Novae.cpp 2016-09-28 13:19:24 +0000
789+++ plugins/Novae/src/Novae.cpp 2017-01-12 21:08:38 +0000
790@@ -224,9 +224,7 @@
791 const Vec3f& c(obj->getInfoColor());
792 painter.setColor(c[0],c[1],c[2]);
793 texPointer->bind();
794- painter.enableTexture2d(true);
795- glEnable(GL_BLEND);
796- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transparency mode
797+ painter.setBlending(true);
798 painter.drawSprite2dMode(screenpos[0], screenpos[1], 13.f, StelApp::getInstance().getTotalRunTime()*40.);
799 }
800 }
801
802=== modified file 'plugins/Observability/src/CMakeLists.txt'
803--- plugins/Observability/src/CMakeLists.txt 2015-10-20 17:16:34 +0000
804+++ plugins/Observability/src/CMakeLists.txt 2017-01-12 21:08:38 +0000
805@@ -25,11 +25,8 @@
806 SET(Observability_RES ../Observability.qrc)
807 QT5_ADD_RESOURCES(Observability_RES_CXX ${Observability_RES})
808
809-SET(extLinkerOption ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${OPENGL_LIBRARIES})
810-
811 ADD_LIBRARY(Observability-static STATIC ${Observability_SRCS} ${Observability_RES_CXX} ${ObservabilityDialog_UIS_H})
812-QT5_USE_MODULES(Observability-static Core Network Widgets)
813+TARGET_LINK_LIBRARIES(Observability-static Qt5::Core Qt5::Widgets)
814 SET_TARGET_PROPERTIES(Observability-static PROPERTIES OUTPUT_NAME "Observability")
815-TARGET_LINK_LIBRARIES(Observability-static ${extLinkerOption})
816 SET_TARGET_PROPERTIES(Observability-static PROPERTIES COMPILE_FLAGS "-DQT_STATICPLUGIN")
817 ADD_DEPENDENCIES(AllStaticPlugins Observability-static)
818
819=== modified file 'plugins/Oculars/src/CMakeLists.txt'
820--- plugins/Oculars/src/CMakeLists.txt 2015-10-20 17:16:34 +0000
821+++ plugins/Oculars/src/CMakeLists.txt 2017-01-12 21:08:38 +0000
822@@ -34,12 +34,8 @@
823 )
824 QT5_WRAP_UI(Oculars_UIS_H ${Oculars_UIS})
825
826-SET(extLinkerOption ${OPENGL_LIBRARIES})
827-
828 ADD_LIBRARY(Oculars-static STATIC ${Oculars_SRCS} ${Oculars_RES_CXX} ${Oculars_UIS_H})
829 SET_TARGET_PROPERTIES(Oculars-static PROPERTIES OUTPUT_NAME "Oculars")
830-QT5_USE_MODULES(Oculars-static Core Network OpenGL Widgets)
831-
832-TARGET_LINK_LIBRARIES(Oculars-static ${StelMain} ${extLinkerOption})
833+TARGET_LINK_LIBRARIES(Oculars-static Qt5::Core Qt5::Widgets)
834 SET_TARGET_PROPERTIES(Oculars-static PROPERTIES COMPILE_FLAGS "-DQT_STATICPLUGIN")
835 ADD_DEPENDENCIES(AllStaticPlugins Oculars-static)
836
837=== modified file 'plugins/Oculars/src/Oculars.cpp'
838--- plugins/Oculars/src/Oculars.cpp 2017-01-10 17:21:30 +0000
839+++ plugins/Oculars/src/Oculars.cpp 2017-01-12 21:08:38 +0000
840@@ -50,7 +50,6 @@
841 #include <QKeyEvent>
842 #include <QMenu>
843 #include <QMouseEvent>
844-#include <QtNetwork>
845 #include <QPixmap>
846 #include <QSignalMapper>
847
848@@ -335,14 +334,7 @@
849 paintCrosshairs();
850 }
851 }
852- if (guiPanelEnabled)
853- {
854- // Reset the state to allow the panel to be painted normally
855- glDisable(GL_TEXTURE_2D);
856- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
857- glEnable(GL_BLEND);
858- }
859- else
860+ if (!guiPanelEnabled)
861 {
862 // Paint the information in the upper-right hand corner
863 paintText(core);
864@@ -352,14 +344,7 @@
865 else if (flagShowCCD)
866 {
867 paintCCDBounds();
868- if (guiPanelEnabled)
869- {
870- // Reset the state to allow the panel to be painted normally
871- glDisable(GL_TEXTURE_2D);
872- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
873- glEnable(GL_BLEND);
874- }
875- else
876+ if (!guiPanelEnabled)
877 {
878 // Paint the information in the upper-right hand corner
879 paintText(core);
880@@ -1768,15 +1753,13 @@
881 inner = oculars[selectedOcularIndex]->appearentFOV() * inner / maxEyepieceAngle;
882 }
883
884- glEnable(GL_BLEND);
885- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transparency mode
886+ painter.setBlending(true);
887
888 Vec2i centerScreen(prj->getViewportPosX()+prj->getViewportWidth()/2, prj->getViewportPosY()+prj->getViewportHeight()/2);
889
890 // Paint the reticale, if needed
891 if (!reticleTexture.isNull())
892 {
893- painter.enableTexture2d(true);
894 painter.setColor(0.77f, 0.14f, 0.16f, 1.f);
895
896 reticleTexture->bind();
897@@ -1869,9 +1852,7 @@
898
899 // set up the color and the GL state
900 painter.setColor(0.8f, 0.48f, 0.f, 1.f);
901- glDisable(GL_TEXTURE_2D);
902- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
903- glEnable(GL_BLEND);
904+ painter.setBlending(true);
905
906 // Get the X & Y positions, and the line height
907 painter.setFont(font);
908
909=== modified file 'plugins/PointerCoordinates/src/CMakeLists.txt'
910--- plugins/PointerCoordinates/src/CMakeLists.txt 2015-10-20 17:16:34 +0000
911+++ plugins/PointerCoordinates/src/CMakeLists.txt 2017-01-12 21:08:38 +0000
912@@ -25,11 +25,8 @@
913 SET(POINTERCOORDINATES_RES ../resources/PointerCoordinates.qrc)
914 QT5_ADD_RESOURCES(POINTERCOORDINATES_RES_CXX ${POINTERCOORDINATES_RES})
915
916-SET(extLinkerOption ${OPENGL_LIBRARIES})
917-
918 ADD_LIBRARY(PointerCoordinates-static STATIC ${POINTERCOORDINATES_SRCS} ${POINTERCOORDINATES_RES_CXX} ${POINTERCOORDINATES_UIS_H})
919-QT5_USE_MODULES(PointerCoordinates-static Core Network Widgets)
920+TARGET_LINK_LIBRARIES(PointerCoordinates-static Qt5::Core Qt5::Widgets)
921 SET_TARGET_PROPERTIES(PointerCoordinates-static PROPERTIES OUTPUT_NAME "PointerCoordinates")
922-TARGET_LINK_LIBRARIES(PointerCoordinates-static ${extLinkerOption})
923 SET_TARGET_PROPERTIES(PointerCoordinates-static PROPERTIES COMPILE_FLAGS "-DQT_STATICPLUGIN")
924 ADD_DEPENDENCIES(AllStaticPlugins PointerCoordinates-static)
925
926=== modified file 'plugins/Pulsars/src/CMakeLists.txt'
927--- plugins/Pulsars/src/CMakeLists.txt 2015-10-20 17:16:34 +0000
928+++ plugins/Pulsars/src/CMakeLists.txt 2017-01-12 21:08:38 +0000
929@@ -25,11 +25,8 @@
930 SET(Pulsars_RES ../resources/Pulsars.qrc)
931 QT5_ADD_RESOURCES(Pulsars_RES_CXX ${Pulsars_RES})
932
933-SET(extLinkerOption ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${OPENGL_LIBRARIES})
934-
935 ADD_LIBRARY(Pulsars-static STATIC ${Pulsars_SRCS} ${Pulsars_RES_CXX} ${PulsarsDialog_UIS_H})
936-QT5_USE_MODULES(Pulsars-static Core Network Widgets)
937+TARGET_LINK_LIBRARIES(Pulsars-static Qt5::Core Qt5::Network Qt5::Widgets)
938 SET_TARGET_PROPERTIES(Pulsars-static PROPERTIES OUTPUT_NAME "Pulsars")
939-TARGET_LINK_LIBRARIES(Pulsars-static ${extLinkerOption})
940 SET_TARGET_PROPERTIES(Pulsars-static PROPERTIES COMPILE_FLAGS "-DQT_STATICPLUGIN")
941 ADD_DEPENDENCIES(AllStaticPlugins Pulsars-static)
942
943=== modified file 'plugins/Pulsars/src/Pulsar.cpp'
944--- plugins/Pulsars/src/Pulsar.cpp 2016-07-30 18:20:22 +0000
945+++ plugins/Pulsars/src/Pulsar.cpp 2017-01-12 21:08:38 +0000
946@@ -384,8 +384,8 @@
947 if (!(painter->getProjector()->projectCheck(XYZ, win)))
948 return;
949
950- glEnable(GL_BLEND);
951- glBlendFunc(GL_ONE, GL_ONE);
952+ painter->setBlending(true, GL_ONE, GL_ONE);
953+
954 if (glitch>0 && glitchFlag)
955 painter->setColor(glitchColor[0], glitchColor[1], glitchColor[2], 1.f);
956 else
957
958=== modified file 'plugins/Pulsars/src/Pulsars.cpp'
959--- plugins/Pulsars/src/Pulsars.cpp 2016-07-03 21:58:54 +0000
960+++ plugins/Pulsars/src/Pulsars.cpp 2017-01-12 21:08:38 +0000
961@@ -259,9 +259,7 @@
962 const Vec3f& c(obj->getInfoColor());
963 painter.setColor(c[0],c[1],c[2]);
964 texPointer->bind();
965- painter.enableTexture2d(true);
966- glEnable(GL_BLEND);
967- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transparency mode
968+ painter.setBlending(true);
969 painter.drawSprite2dMode(screenpos[0], screenpos[1], 13.f, StelApp::getInstance().getTotalRunTime()*40.);
970 }
971 }
972
973=== modified file 'plugins/Quasars/src/CMakeLists.txt'
974--- plugins/Quasars/src/CMakeLists.txt 2015-10-20 17:16:34 +0000
975+++ plugins/Quasars/src/CMakeLists.txt 2017-01-12 21:08:38 +0000
976@@ -25,11 +25,8 @@
977 SET(Quasars_RES ../resources/Quasars.qrc)
978 QT5_ADD_RESOURCES(Quasars_RES_CXX ${Quasars_RES})
979
980-SET(extLinkerOption ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${OPENGL_LIBRARIES})
981-
982 ADD_LIBRARY(Quasars-static STATIC ${Quasars_SRCS} ${Quasars_RES_CXX} ${QuasarsDialog_UIS_H})
983-QT5_USE_MODULES(Quasars-static Core Network Widgets)
984+TARGET_LINK_LIBRARIES(Quasars-static Qt5::Core Qt5::Network Qt5::Widgets)
985 SET_TARGET_PROPERTIES(Quasars-static PROPERTIES OUTPUT_NAME "Quasars")
986-TARGET_LINK_LIBRARIES(Quasars-static ${extLinkerOption})
987 SET_TARGET_PROPERTIES(Quasars-static PROPERTIES COMPILE_FLAGS "-DQT_STATICPLUGIN")
988 ADD_DEPENDENCIES(AllStaticPlugins Quasars-static)
989
990=== modified file 'plugins/Quasars/src/Quasar.cpp'
991--- plugins/Quasars/src/Quasar.cpp 2016-07-30 18:20:22 +0000
992+++ plugins/Quasars/src/Quasar.cpp 2017-01-12 21:08:38 +0000
993@@ -180,8 +180,7 @@
994
995 if (distributionMode)
996 {
997- glEnable(GL_BLEND);
998- glBlendFunc(GL_ONE, GL_ONE);
999+ painter.setBlending(true, GL_ONE, GL_ONE);
1000 painter.setColor(markerColor[0], markerColor[1], markerColor[2], 1);
1001
1002 Quasar::markerTexture->bind();
1003
1004=== modified file 'plugins/Quasars/src/Quasars.cpp'
1005--- plugins/Quasars/src/Quasars.cpp 2016-07-22 09:25:03 +0000
1006+++ plugins/Quasars/src/Quasars.cpp 2017-01-12 21:08:38 +0000
1007@@ -261,9 +261,7 @@
1008 const Vec3f& c(obj->getInfoColor());
1009 painter.setColor(c[0],c[1],c[2]);
1010 texPointer->bind();
1011- painter.enableTexture2d(true);
1012- glEnable(GL_BLEND);
1013- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transparency mode
1014+ painter.setBlending(true);
1015 painter.drawSprite2dMode(screenpos[0], screenpos[1], 13.f, StelApp::getInstance().getTotalRunTime()*40.);
1016 }
1017 }
1018
1019=== modified file 'plugins/RemoteControl/src/CMakeLists.txt'
1020--- plugins/RemoteControl/src/CMakeLists.txt 2016-01-18 16:55:10 +0000
1021+++ plugins/RemoteControl/src/CMakeLists.txt 2017-01-12 21:08:38 +0000
1022@@ -67,12 +67,9 @@
1023 SET(RemoteControl_RES ../RemoteControl.qrc)
1024 QT5_ADD_RESOURCES(RemoteControl_RES_CXX ${RemoteControl_RES})
1025
1026-SET(extLinkerOption ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${OPENGL_LIBRARIES})
1027-
1028 ADD_LIBRARY(RemoteControl-static STATIC ${RemoteControl_SRCS} ${RemoteControl_RES_CXX} ${RemoteControl_UIS_H} ${QtWebApp_SRCS})
1029-QT5_USE_MODULES(RemoteControl-static Core Network Widgets)
1030+TARGET_LINK_LIBRARIES(RemoteControl-static Qt5::Core Qt5::Network Qt5::Widgets)
1031 # The library target "RemoteControl-static" has a default OUTPUT_NAME of "RemoteControl-static", so change it.
1032 SET_TARGET_PROPERTIES(RemoteControl-static PROPERTIES OUTPUT_NAME "RemoteControl")
1033-TARGET_LINK_LIBRARIES(RemoteControl-static ${extLinkerOption})
1034 SET_TARGET_PROPERTIES(RemoteControl-static PROPERTIES COMPILE_FLAGS "-DQT_STATICPLUGIN")
1035 ADD_DEPENDENCIES(AllStaticPlugins RemoteControl-static)
1036
1037=== modified file 'plugins/RemoteControl/src/MainService.cpp'
1038--- plugins/RemoteControl/src/MainService.cpp 2017-01-11 14:13:45 +0000
1039+++ plugins/RemoteControl/src/MainService.cpp 2017-01-12 21:08:38 +0000
1040@@ -35,6 +35,8 @@
1041 #include "StelUtils.hpp"
1042
1043 #include <QJsonDocument>
1044+#include <QJsonObject>
1045+#include <QJsonArray>
1046
1047
1048 MainService::MainService(const QByteArray &serviceName, QObject *parent)
1049
1050=== modified file 'plugins/RemoteControl/src/ScriptService.cpp'
1051--- plugins/RemoteControl/src/ScriptService.cpp 2016-05-10 19:03:51 +0000
1052+++ plugins/RemoteControl/src/ScriptService.cpp 2017-01-12 21:08:38 +0000
1053@@ -24,6 +24,9 @@
1054 #include "StelTranslator.hpp"
1055
1056 #include <QJsonDocument>
1057+#include <QJsonObject>
1058+#include <QJsonArray>
1059+#include <QVariant>
1060
1061 ScriptService::ScriptService(const QByteArray &serviceName, QObject *parent) : AbstractAPIService(serviceName,parent)
1062 {
1063
1064=== modified file 'plugins/RemoteSync/src/CMakeLists.txt'
1065--- plugins/RemoteSync/src/CMakeLists.txt 2016-02-05 14:05:45 +0000
1066+++ plugins/RemoteSync/src/CMakeLists.txt 2017-01-12 21:08:38 +0000
1067@@ -32,12 +32,9 @@
1068 SET(RemoteSync_RES ../RemoteSync.qrc)
1069 QT5_ADD_RESOURCES(RemoteSync_RES_CXX ${RemoteSync_RES})
1070
1071-SET(extLinkerOption ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${OPENGL_LIBRARIES})
1072-
1073 ADD_LIBRARY(RemoteSync-static STATIC ${RemoteSync_SRCS} ${RemoteSync_UIS_H} ${RemoteSync_RES_CXX})
1074-QT5_USE_MODULES(RemoteSync-static Core Network Widgets)
1075+TARGET_LINK_LIBRARIES(RemoteSync-static Qt5::Core Qt5::Network Qt5::Widgets)
1076 # The library target "RemoteSync-static" has a default OUTPUT_NAME of "RemoteSync-static", so change it.
1077 SET_TARGET_PROPERTIES(RemoteSync-static PROPERTIES OUTPUT_NAME "RemoteSync")
1078-TARGET_LINK_LIBRARIES(RemoteSync-static ${extLinkerOption})
1079 SET_TARGET_PROPERTIES(RemoteSync-static PROPERTIES COMPILE_FLAGS "-DQT_STATICPLUGIN")
1080 ADD_DEPENDENCIES(AllStaticPlugins RemoteSync-static)
1081
1082=== modified file 'plugins/Satellites/src/CMakeLists.txt'
1083--- plugins/Satellites/src/CMakeLists.txt 2015-10-20 17:16:34 +0000
1084+++ plugins/Satellites/src/CMakeLists.txt 2017-01-12 21:08:38 +0000
1085@@ -53,23 +53,13 @@
1086 SET(Satellites_RES ../resources/Satellites.qrc)
1087 QT5_ADD_RESOURCES(Satellites_RES_CXX ${Satellites_RES})
1088
1089-SET(extLinkerOption ${OPENGL_LIBRARIES})
1090-
1091 ADD_LIBRARY(Satellites-static STATIC ${Satellites_SRCS} ${Satellites_RES_CXX} ${SatellitesDialog_UIS_H})
1092-QT5_USE_MODULES(Satellites-static Core Network OpenGL)
1093+TARGET_LINK_LIBRARIES(Satellites-static Qt5::Core Qt5::Network Qt5::Widgets)
1094 # The library target "Satellites-static" has a default OUTPUT_NAME of "Satellites-static", so change it.
1095 SET_TARGET_PROPERTIES(Satellites-static PROPERTIES OUTPUT_NAME "Satellites")
1096-TARGET_LINK_LIBRARIES(Satellites-static ${StelMain} ${extLinkerOption})
1097 IF(MSVC)
1098 SET_TARGET_PROPERTIES(Satellites-static PROPERTIES COMPILE_FLAGS "-DQT_STATICPLUGIN")
1099 ELSE()
1100 SET_TARGET_PROPERTIES(Satellites-static PROPERTIES COMPILE_FLAGS "-DQT_STATICPLUGIN -Wno-unused-parameter")
1101 ENDIF()
1102 ADD_DEPENDENCIES(AllStaticPlugins Satellites-static)
1103-
1104-
1105-
1106-
1107-
1108-
1109-
1110
1111=== modified file 'plugins/Satellites/src/Satellite.cpp'
1112--- plugins/Satellites/src/Satellite.cpp 2017-01-05 17:00:35 +0000
1113+++ plugins/Satellites/src/Satellite.cpp 2017-01-12 21:08:38 +0000
1114@@ -834,8 +834,7 @@
1115 if (Satellite::showLabels)
1116 painter.drawText(xy[0], xy[1], name, 0, 10, 10, false);
1117
1118- glEnable(GL_BLEND);
1119- glBlendFunc(GL_ONE, GL_ONE);
1120+ painter.setBlending(true, GL_ONE, GL_ONE);
1121
1122 Satellite::hintTexture->bind();
1123 painter.drawSprite2dMode(xy[0], xy[1], 11);
1124@@ -851,8 +850,6 @@
1125 Vec3f drawColor;
1126 int size = orbitPoints.size();
1127
1128- glDisable(GL_TEXTURE_2D);
1129-
1130 QList<Vec3d>::iterator it= orbitPoints.begin();
1131 it++;
1132
1133@@ -881,8 +878,6 @@
1134 }
1135 }
1136 painter.drawPath(vertexArray, colorArray);
1137-
1138- glEnable(GL_TEXTURE_2D);
1139 painter.enableClientStates(false);
1140 }
1141
1142
1143=== modified file 'plugins/Satellites/src/Satellites.cpp'
1144--- plugins/Satellites/src/Satellites.cpp 2017-01-05 17:00:35 +0000
1145+++ plugins/Satellites/src/Satellites.cpp 2017-01-12 21:08:38 +0000
1146@@ -1607,9 +1607,7 @@
1147 painter.setFont(labelFont);
1148 Satellite::hintBrightness = hintFader.getInterstate();
1149
1150- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1151- glEnable(GL_BLEND);
1152- glEnable(GL_TEXTURE_2D);
1153+ painter.setBlending(true);
1154 Satellite::hintTexture->bind();
1155 Satellite::viewportHalfspace = painter.getProjector()->getBoundingCap();
1156 foreach (const SatelliteP& sat, satellites)
1157@@ -1639,9 +1637,7 @@
1158 painter.setColor(0.4f,0.5f,0.8f);
1159 texPointer->bind();
1160
1161- glEnable(GL_TEXTURE_2D);
1162- glEnable(GL_BLEND);
1163- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transparency mode
1164+ painter.setBlending(true);
1165
1166 // Size on screen
1167 float size = obj->getAngularSize(core)*M_PI/180.*prj->getPixelPerRadAtCenter();
1168
1169=== modified file 'plugins/Scenery3d/src/CMakeLists.txt'
1170--- plugins/Scenery3d/src/CMakeLists.txt 2015-10-20 17:16:34 +0000
1171+++ plugins/Scenery3d/src/CMakeLists.txt 2017-01-12 21:08:38 +0000
1172@@ -60,14 +60,9 @@
1173 )
1174 QT5_WRAP_UI(Scenery3d_UIS_H ${Scenery3d_UIS})
1175
1176-SET(extLinkerOption ${QT_LIBRARIES} ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${OPENGL_LIBRARIES} )
1177-
1178 ############### For building the static library ######################
1179 ADD_LIBRARY(Scenery3d-static STATIC ${Scenery3d_SRCS} ${Scenery3d_RES_CXX} ${Scenery3d_UIS_H} ${Scenery3d_MOC_SRCS} )
1180-QT5_USE_MODULES(Scenery3d-static Core Concurrent Gui Widgets)
1181+TARGET_LINK_LIBRARIES(Scenery3d-static Qt5::Core Qt5::Concurrent Qt5::Gui ${STEL_GLES_LIBS} Qt5::Widgets)
1182 SET_TARGET_PROPERTIES(Scenery3d-static PROPERTIES OUTPUT_NAME "Scenery3d")
1183-TARGET_LINK_LIBRARIES(Scenery3d-static ${extLinkerOption})
1184 SET_TARGET_PROPERTIES(Scenery3d-static PROPERTIES COMPILE_FLAGS "-DQT_STATICPLUGIN")
1185 ADD_DEPENDENCIES(AllStaticPlugins Scenery3d-static)
1186-
1187-
1188
1189=== modified file 'plugins/Scenery3d/src/OBJ.cpp'
1190--- plugins/Scenery3d/src/OBJ.cpp 2016-11-21 21:04:36 +0000
1191+++ plugins/Scenery3d/src/OBJ.cpp 2017-01-12 21:08:38 +0000
1192@@ -100,12 +100,16 @@
1193 bool OBJ::vertexArraysSupported=false;
1194 GLenum OBJ::indexBufferType=GL_UNSIGNED_SHORT;
1195 size_t OBJ::indexBufferTypeSize=0;
1196+QOpenGLFunctions* OBJ::gl=Q_NULLPTR;
1197
1198 //static function
1199 void OBJ::setupGL()
1200 {
1201+ QOpenGLContext* ctx = QOpenGLContext::currentContext();
1202+ gl = ctx->functions();
1203+
1204 //disable VAOs on Intel because of serious bugs in their implemenation...
1205- QString vendor(reinterpret_cast<const char*>(glGetString(GL_VENDOR)));
1206+ QString vendor(reinterpret_cast<const char*>(gl->glGetString(GL_VENDOR)));
1207 if(vendor.contains("Intel",Qt::CaseInsensitive))
1208 {
1209 OBJ::vertexArraysSupported = false;
1210@@ -130,7 +134,6 @@
1211 }
1212
1213 //check if we can enable int index buffers
1214- QOpenGLContext* ctx = QOpenGLContext::currentContext();
1215 if(ctx->isOpenGLES())
1216 {
1217 //query for extension
1218@@ -1709,19 +1712,19 @@
1219 //(but may be stored in a VAO to enable faster binding/unbinding)
1220
1221 //enable the attrib arrays
1222- glEnableVertexAttribArray(ShaderMgr::ATTLOC_VERTEX);
1223- glEnableVertexAttribArray(ShaderMgr::ATTLOC_NORMAL);
1224- glEnableVertexAttribArray(ShaderMgr::ATTLOC_TEXCOORD);
1225- glEnableVertexAttribArray(ShaderMgr::ATTLOC_TANGENT);
1226- glEnableVertexAttribArray(ShaderMgr::ATTLOC_BITANGENT);
1227+ gl->glEnableVertexAttribArray(ShaderMgr::ATTLOC_VERTEX);
1228+ gl->glEnableVertexAttribArray(ShaderMgr::ATTLOC_NORMAL);
1229+ gl->glEnableVertexAttribArray(ShaderMgr::ATTLOC_TEXCOORD);
1230+ gl->glEnableVertexAttribArray(ShaderMgr::ATTLOC_TANGENT);
1231+ gl->glEnableVertexAttribArray(ShaderMgr::ATTLOC_BITANGENT);
1232
1233 const GLsizei stride = sizeof(Vertex);
1234
1235- glVertexAttribPointer(ShaderMgr::ATTLOC_VERTEX, 3,GL_FLOAT,GL_FALSE,stride,reinterpret_cast<const void *>(offsetof(struct Vertex, position)));
1236- glVertexAttribPointer(ShaderMgr::ATTLOC_NORMAL, 3,GL_FLOAT,GL_FALSE,stride,reinterpret_cast<const void *>(offsetof(struct Vertex, normal)));
1237- glVertexAttribPointer(ShaderMgr::ATTLOC_TEXCOORD, 2,GL_FLOAT,GL_FALSE,stride,reinterpret_cast<const void *>(offsetof(struct Vertex, texCoord)));
1238- glVertexAttribPointer(ShaderMgr::ATTLOC_TANGENT, 4,GL_FLOAT,GL_FALSE,stride,reinterpret_cast<const void *>(offsetof(struct Vertex, tangent)));
1239- glVertexAttribPointer(ShaderMgr::ATTLOC_BITANGENT,3,GL_FLOAT,GL_FALSE,stride,reinterpret_cast<const void *>(offsetof(struct Vertex, bitangent)));
1240+ gl->glVertexAttribPointer(ShaderMgr::ATTLOC_VERTEX, 3,GL_FLOAT,GL_FALSE,stride,reinterpret_cast<const void *>(offsetof(struct Vertex, position)));
1241+ gl->glVertexAttribPointer(ShaderMgr::ATTLOC_NORMAL, 3,GL_FLOAT,GL_FALSE,stride,reinterpret_cast<const void *>(offsetof(struct Vertex, normal)));
1242+ gl->glVertexAttribPointer(ShaderMgr::ATTLOC_TEXCOORD, 2,GL_FLOAT,GL_FALSE,stride,reinterpret_cast<const void *>(offsetof(struct Vertex, texCoord)));
1243+ gl->glVertexAttribPointer(ShaderMgr::ATTLOC_TANGENT, 4,GL_FLOAT,GL_FALSE,stride,reinterpret_cast<const void *>(offsetof(struct Vertex, tangent)));
1244+ gl->glVertexAttribPointer(ShaderMgr::ATTLOC_BITANGENT,3,GL_FLOAT,GL_FALSE,stride,reinterpret_cast<const void *>(offsetof(struct Vertex, bitangent)));
1245
1246 //vertex buffer does not need to remain bound, because the binding is stored by glVertexAttribPointer
1247 m_vertexBuffer.release();
1248@@ -1736,11 +1739,11 @@
1249 m_indexBuffer.release();
1250
1251 //disable our attribute arrays
1252- glDisableVertexAttribArray(ShaderMgr::ATTLOC_VERTEX);
1253- glDisableVertexAttribArray(ShaderMgr::ATTLOC_NORMAL);
1254- glDisableVertexAttribArray(ShaderMgr::ATTLOC_TEXCOORD);
1255- glDisableVertexAttribArray(ShaderMgr::ATTLOC_TANGENT);
1256- glDisableVertexAttribArray(ShaderMgr::ATTLOC_BITANGENT);
1257+ gl->glDisableVertexAttribArray(ShaderMgr::ATTLOC_VERTEX);
1258+ gl->glDisableVertexAttribArray(ShaderMgr::ATTLOC_NORMAL);
1259+ gl->glDisableVertexAttribArray(ShaderMgr::ATTLOC_TEXCOORD);
1260+ gl->glDisableVertexAttribArray(ShaderMgr::ATTLOC_TANGENT);
1261+ gl->glDisableVertexAttribArray(ShaderMgr::ATTLOC_BITANGENT);
1262 }
1263
1264 void OBJ::transform(QMatrix4x4 mat)
1265
1266=== modified file 'plugins/Scenery3d/src/OBJ.hpp'
1267--- plugins/Scenery3d/src/OBJ.hpp 2015-04-15 13:42:29 +0000
1268+++ plugins/Scenery3d/src/OBJ.hpp 2017-01-12 21:08:38 +0000
1269@@ -336,6 +336,8 @@
1270 QOpenGLBuffer m_indexBuffer;
1271 QOpenGLVertexArrayObject* m_vertexArrayObject;
1272
1273+ static QOpenGLFunctions* gl;
1274+
1275 //! Heightmap
1276 friend class Heightmap;
1277 };
1278
1279=== modified file 'plugins/Scenery3d/src/Scenery3d.cpp'
1280--- plugins/Scenery3d/src/Scenery3d.cpp 2016-11-24 18:15:41 +0000
1281+++ plugins/Scenery3d/src/Scenery3d.cpp 2017-01-12 21:08:38 +0000
1282@@ -20,13 +20,7 @@
1283
1284 #include <QtGlobal>
1285
1286-#if !defined(Q_OS_WIN)
1287-//exclude StelOpenGL here on windows because of conflicts with GLFuncs.hpp otherwise (uses QOpenGLFunctions_1_0 directly)
1288-#include "StelOpenGL.hpp"
1289-#endif
1290-//needs to be included before StelOpenGL on Windows
1291 #include "GLFuncs.hpp"
1292-
1293 #include "Scenery3d.hpp"
1294
1295 #include "StelApp.hpp"
1296@@ -49,15 +43,8 @@
1297 #include <stdexcept>
1298 #include <cmath>
1299 #include <QOpenGLShaderProgram>
1300-#include <QOpenGLFramebufferObject>
1301
1302-#define GET_GLERROR() \
1303-{ \
1304- GLenum err = glGetError(); \
1305- if (err != GL_NO_ERROR) { \
1306- qWarning("[line %d] GL Error: %d",__LINE__, err); \
1307- } \
1308-}
1309+#define GET_GLERROR() StelOpenGL::checkGLErrors(__FILE__,__LINE__);
1310
1311 //macro for easier uniform setting
1312 #define SET_UNIFORM(shd,uni,val) shd->setUniformValue(shaderManager.uniformLocation(shd,uni),val)
1313@@ -112,6 +99,7 @@
1314 shaderParameters.geometryShader = false;
1315 shaderParameters.torchLight = false;
1316 shaderParameters.frustumSplits = 0;
1317+ shaderParameters.hwShadowSamplers = false;
1318
1319 sceneBoundingBox = AABB(Vec3f(0.0f), Vec3f(0.0f));
1320
1321@@ -253,6 +241,10 @@
1322
1323 void Scenery3d::finalizeLoad()
1324 {
1325+ //must ensure the correct GL context is active!
1326+ //this is not guaranteed with the new QOpenGLWidget outside of init() and draw()!
1327+ StelApp::getInstance().ensureGLContextCurrent();
1328+
1329 currentScene = loadingScene;
1330
1331 //move load data to current one
1332@@ -594,7 +586,7 @@
1333 {
1334 //send size of light ortho for each frustum
1335 loc = shaderManager.uniformLocation(shader,ShaderMgr::UNIFORM_VEC_LIGHTORTHOSCALE);
1336- shader->setUniformValueArray(loc,shadowFrustumSize.constData(),4);
1337+ shader->setUniformValueArray(loc,shadowFrustumSize.constData(),shaderParameters.frustumSplits);
1338 }
1339 }
1340
1341@@ -802,7 +794,7 @@
1342 }
1343 }
1344
1345-
1346+ GET_GLERROR()
1347 glDrawElements(GL_TRIANGLES, pStelModel->triangleCount * 3, indexDataType, reinterpret_cast<const void*>(pStelModel->startIndex * indexDataTypeSize));
1348 drawnTriangles+=pStelModel->triangleCount;
1349 }
1350@@ -1130,7 +1122,7 @@
1351
1352
1353 //Unbind
1354- glBindFramebuffer(GL_FRAMEBUFFER, 0);
1355+ glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO);
1356
1357 //reset viewport (see StelPainter::setProjector)
1358 const Vec4i& vp = altAzProjector->getViewport();
1359@@ -1576,7 +1568,7 @@
1360 }
1361
1362 //cubemap fbo must be released
1363- glBindFramebuffer(GL_FRAMEBUFFER,0);
1364+ glBindFramebuffer(GL_FRAMEBUFFER,defaultFBO);
1365
1366 //reset GL state
1367 glDepthMask(GL_FALSE);
1368@@ -2052,9 +2044,11 @@
1369
1370 void Scenery3d::init()
1371 {
1372+ initializeOpenGLFunctions();
1373 OBJ::setupGL();
1374
1375 QOpenGLContext* ctx = QOpenGLContext::currentContext();
1376+ Q_ASSERT(ctx);
1377
1378 #ifndef QT_OPENGL_ES_2
1379 //initialize additional functions needed and not provided through StelOpenGL
1380@@ -2369,7 +2363,7 @@
1381 }
1382
1383 //unbind last framebuffer
1384- glBindFramebuffer(GL_FRAMEBUFFER,0);
1385+ glBindFramebuffer(GL_FRAMEBUFFER,defaultFBO);
1386
1387 //initialize cube rotations... found by trial and error :)
1388 QMatrix4x4 stackBase;
1389@@ -2633,7 +2627,23 @@
1390 //for OpenGL ES2, type has to be UNSIGNED_SHORT or UNSIGNED_INT for depth textures, desktop does probably not care
1391 glTexImage2D(GL_TEXTURE_2D, 0, (pcssEnabled ? depthPcss : depthNormal), shadowmapSize, shadowmapSize, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, NULL);
1392
1393- GLint filter = (shaderParameters.shadowFilterQuality == S3DEnum::SFQ_HARDWARE
1394+ //we use hardware-accelerated depth compare mode, unless pcss is used
1395+ shaderParameters.hwShadowSamplers = false;
1396+ //NOTE: cant use depth compare mode on ES2
1397+ if(!pcssEnabled)
1398+ {
1399+#ifndef QT_OPENGL_ES_2
1400+ if(!isEs)
1401+ {
1402+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
1403+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
1404+ shaderParameters.hwShadowSamplers = true;
1405+ }
1406+#endif
1407+ }
1408+
1409+ //IF we support hw shadow sampling, then we may enable linear filtering, otherwise filtering depth values directly would not make much sense
1410+ GLint filter = shaderParameters.hwShadowSamplers && (shaderParameters.shadowFilterQuality == S3DEnum::SFQ_HARDWARE
1411 || shaderParameters.shadowFilterQuality == S3DEnum::SFQ_LOW_HARDWARE
1412 || shaderParameters.shadowFilterQuality == S3DEnum::SFQ_HIGH_HARDWARE) ? GL_LINEAR : GL_NEAREST;
1413 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
1414@@ -2649,18 +2659,6 @@
1415 glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, ones);
1416 }
1417 #endif
1418- //we use hardware-accelerated depth compare mode, unless pcss is used
1419- //NOTE: cant use depth compare mode on ES2
1420- if(!pcssEnabled)
1421- {
1422-#ifndef QT_OPENGL_ES_2
1423- if(!isEs)
1424- {
1425- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
1426- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
1427- }
1428-#endif
1429- }
1430
1431 //Attach the depthmap to the Buffer
1432 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, shadowMapsArray[i], 0);
1433@@ -2689,7 +2687,7 @@
1434 }
1435
1436 //Done. Unbind and switch to normal texture unit 0
1437- glBindFramebuffer(GL_FRAMEBUFFER, 0);
1438+ glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO);
1439 glActiveTexture(GL_TEXTURE0);
1440
1441 qDebug()<<"[Scenery3D] shadowmapping initialized";
1442@@ -2713,6 +2711,9 @@
1443 if(!objModel || !objModel->hasStelModels())
1444 return;
1445
1446+ //find out the default FBO
1447+ defaultFBO = StelApp::getInstance().getDefaultFBO();
1448+
1449 //reset render statistic
1450 drawnTriangles = drawnModels = materialSwitches = shaderSwitches = 0;
1451
1452
1453=== modified file 'plugins/Scenery3d/src/Scenery3d.hpp'
1454--- plugins/Scenery3d/src/Scenery3d.hpp 2016-11-24 18:15:41 +0000
1455+++ plugins/Scenery3d/src/Scenery3d.hpp 2017-01-12 21:08:38 +0000
1456@@ -38,12 +38,11 @@
1457 #include <QMatrix4x4>
1458
1459 //predeclarations
1460-class QOpenGLFramebufferObject;
1461 class Scenery3dMgr;
1462 class LandscapeMgr;
1463
1464 //! Representation of a complete 3D scenery
1465-class Scenery3d
1466+class Scenery3d : protected QOpenGLFunctions
1467 {
1468 public:
1469 //! Initializes an empty Scenery3d object.
1470@@ -178,6 +177,7 @@
1471 bool supportsShadowFiltering; //if shadow filtering is supported
1472 bool isANGLE; //true if running on ANGLE
1473 unsigned int maximumFramebufferSize;
1474+ GLuint defaultFBO; //the default background FBO handle
1475
1476 float torchBrightness; // toggle light brightness
1477 float torchRange; // used to calculate attenuation like in the second form at http://framebunker.com/blog/lighting-2-attenuation/
1478
1479=== modified file 'plugins/Scenery3d/src/ShaderManager.cpp'
1480--- plugins/Scenery3d/src/ShaderManager.cpp 2015-05-18 12:01:39 +0000
1481+++ plugins/Scenery3d/src/ShaderManager.cpp 2017-01-12 21:08:38 +0000
1482@@ -102,6 +102,7 @@
1483 featureFlagsStrings["PCSS"] = PCSS;
1484 featureFlagsStrings["SINGLE_SHADOW_FRUSTUM"] = SINGLE_SHADOW_FRUSTUM;
1485 featureFlagsStrings["OGL_ES2"] = OGL_ES2;
1486+ featureFlagsStrings["HW_SHADOW_SAMPLERS"] = HW_SHADOW_SAMPLERS;
1487 }
1488 }
1489
1490@@ -437,8 +438,10 @@
1491 //this enumerates all available uniforms of this shader, and stores their locations in a map
1492 GLuint prog = program.programId();
1493 GLint numUniforms=0,bufSize;
1494- glGetProgramiv(prog, GL_ACTIVE_UNIFORMS, &numUniforms);
1495- glGetProgramiv(prog, GL_ACTIVE_UNIFORM_MAX_LENGTH, &bufSize);
1496+
1497+ QOpenGLFunctions* gl = QOpenGLContext::currentContext()->functions();
1498+ GL(gl->glGetProgramiv(prog, GL_ACTIVE_UNIFORMS, &numUniforms));
1499+ GL(gl->glGetProgramiv(prog, GL_ACTIVE_UNIFORM_MAX_LENGTH, &bufSize));
1500
1501 QByteArray buf(bufSize,'\0');
1502 GLsizei length;
1503@@ -450,7 +453,7 @@
1504 #endif
1505 for(int i =0;i<numUniforms;++i)
1506 {
1507- glGetActiveUniform(prog,i,bufSize,&length,&size,&type,buf.data());
1508+ GL(gl->glGetActiveUniform(prog,i,bufSize,&length,&size,&type,buf.data()));
1509 QString str(buf);
1510 str = str.trimmed(); // no idea if this is required
1511
1512
1513=== modified file 'plugins/Scenery3d/src/ShaderManager.hpp'
1514--- plugins/Scenery3d/src/ShaderManager.hpp 2015-05-18 12:01:39 +0000
1515+++ plugins/Scenery3d/src/ShaderManager.hpp 2017-01-12 21:08:38 +0000
1516@@ -42,6 +42,7 @@
1517 bool torchLight;
1518 //for now, only 1 or 4 really supported
1519 int frustumSplits;
1520+ bool hwShadowSamplers;
1521 };
1522
1523 //! A simple shader cache class that gives us the correct shader depending on desired configuration.
1524@@ -199,6 +200,8 @@
1525 SINGLE_SHADOW_FRUSTUM = (1<<18),
1526 //set if opengl es2
1527 OGL_ES2 = (1<<19),
1528+ //true if shadow samplers (shadow2d) should be used for shadow maps instead of normal samplers (texture2d)
1529+ HW_SHADOW_SAMPLERS = (1<<20)
1530 };
1531
1532 typedef QMap<QString,FeatureFlags> t_FeatureFlagStrings;
1533@@ -238,7 +241,8 @@
1534 if(globals.pixelLighting && globals.shadows) flags|= SHADOWS;
1535 if(globals.pixelLighting && globals.shadows && globals.shadowFilterQuality>S3DEnum::SFQ_HARDWARE) flags|= SHADOW_FILTER;
1536 if(globals.pixelLighting && globals.shadows && globals.shadowFilterQuality>S3DEnum::SFQ_LOW_HARDWARE) flags|= SHADOW_FILTER_HQ;
1537- if(globals.pixelLighting && globals.shadows && (globals.shadowFilterQuality == S3DEnum::SFQ_LOW || globals.shadowFilterQuality == S3DEnum::SFQ_HIGH) && globals.pcss) flags|= PCSS;
1538+ if(globals.pixelLighting && globals.shadows && !globals.hwShadowSamplers && (globals.shadowFilterQuality == S3DEnum::SFQ_LOW || globals.shadowFilterQuality == S3DEnum::SFQ_HIGH) && globals.pcss) flags|= PCSS;
1539+ if(globals.hwShadowSamplers) flags|=HW_SHADOW_SAMPLERS;
1540 if(globals.geometryShader) flags|= GEOMETRY_SHADER;
1541 if(globals.torchLight) flags|= TORCH;
1542 if(globals.frustumSplits == 1) flags|= SINGLE_SHADOW_FRUSTUM;
1543
1544=== modified file 'plugins/SimpleDrawLine/src/CMakeLists.txt'
1545--- plugins/SimpleDrawLine/src/CMakeLists.txt 2015-10-20 17:16:34 +0000
1546+++ plugins/SimpleDrawLine/src/CMakeLists.txt 2017-01-12 21:08:38 +0000
1547@@ -7,12 +7,11 @@
1548 SimpleDrawLine.cpp
1549 )
1550
1551-SET(extLinkerOption ${OPENGL_LIBRARIES})
1552+SET(SimpleDrawLine_Qt_Libraries Qt5::Core Qt5::Gui)
1553
1554 ############### For building the dynamic library ######################
1555 IF(BUILD_DYNAMIC_PLUGIN)
1556 ADD_LIBRARY(SimpleDrawLine MODULE ${SimpleDrawLine_SRCS})
1557- QT5_USE_MODULES(SimpleDrawLine-static Core OpenGL)
1558 IF(APPLE)
1559 FIND_LIBRARY(OPENGL_LIBRARY OpenGL)
1560 MARK_AS_ADVANCED(OPENGL_LIBRARY)
1561@@ -26,15 +25,14 @@
1562 SET(StelMain )
1563 ENDIF(WIN32)
1564
1565- TARGET_LINK_LIBRARIES(SimpleDrawLine ${StelMain} ${extLinkerOption})
1566+ TARGET_LINK_LIBRARIES(SimpleDrawLine ${StelMain} ${SimpleDrawLine_Qt_Libraries})
1567 INSTALL(TARGETS SimpleDrawLine DESTINATION "modules/SimpleDrawLine")
1568 ELSE()
1569 ############### For building the static library ######################
1570 ADD_LIBRARY(SimpleDrawLine-static STATIC ${SimpleDrawLine_SRCS})
1571 # The library target "SimpleDrawLine-static" has a default OUTPUT_NAME of "SimpleDrawLine-static", so change it.
1572- QT5_USE_MODULES(SimpleDrawLine-static Core OpenGL)
1573 SET_TARGET_PROPERTIES(SimpleDrawLine-static PROPERTIES OUTPUT_NAME "SimpleDrawLine")
1574- TARGET_LINK_LIBRARIES(SimpleDrawLine-static ${extLinkerOption})
1575+ TARGET_LINK_LIBRARIES(SimpleDrawLine-static ${StelMain} ${SimpleDrawLine_Qt_Libraries})
1576 SET_TARGET_PROPERTIES(SimpleDrawLine-static PROPERTIES COMPILE_FLAGS "-DQT_STATICPLUGIN")
1577 ADD_DEPENDENCIES(AllStaticPlugins SimpleDrawLine-static)
1578 ENDIF()
1579
1580=== modified file 'plugins/SolarSystemEditor/src/CMakeLists.txt'
1581--- plugins/SolarSystemEditor/src/CMakeLists.txt 2015-10-20 17:16:34 +0000
1582+++ plugins/SolarSystemEditor/src/CMakeLists.txt 2017-01-12 21:08:38 +0000
1583@@ -28,12 +28,8 @@
1584
1585 QT5_WRAP_UI(SolarSystemEditor_UIS_H ${SolarSystemEditor_UIS})
1586
1587-
1588-SET(extLinkerOption ${OPENGL_LIBRARIES})
1589-
1590 ADD_LIBRARY(SolarSystemEditor-static STATIC ${SolarSystemEditor_SRCS} ${SolarSystemEditor_RES_CXX} ${SolarSystemEditor_UIS_H})
1591-QT5_USE_MODULES(SolarSystemEditor-static Core Network Widgets)
1592+TARGET_LINK_LIBRARIES(SolarSystemEditor-static Qt5::Core Qt5::Network Qt5::Widgets)
1593 SET_TARGET_PROPERTIES(SolarSystemEditor-static PROPERTIES OUTPUT_NAME "SolarSystemEditor")
1594-TARGET_LINK_LIBRARIES(SolarSystemEditor-static ${extLinkerOption})
1595 SET_TARGET_PROPERTIES(SolarSystemEditor-static PROPERTIES COMPILE_FLAGS "-DQT_STATICPLUGIN")
1596 ADD_DEPENDENCIES(AllStaticPlugins SolarSystemEditor-static)
1597
1598=== modified file 'plugins/Supernovae/src/CMakeLists.txt'
1599--- plugins/Supernovae/src/CMakeLists.txt 2015-10-20 17:16:34 +0000
1600+++ plugins/Supernovae/src/CMakeLists.txt 2017-01-12 21:08:38 +0000
1601@@ -25,11 +25,8 @@
1602 SET(Supernovae_RES ../resources/Supernovae.qrc)
1603 QT5_ADD_RESOURCES(Supernovae_RES_CXX ${Supernovae_RES})
1604
1605-SET(extLinkerOption ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${OPENGL_LIBRARIES})
1606-
1607 ADD_LIBRARY(Supernovae-static STATIC ${Supernovae_SRCS} ${Supernovae_RES_CXX} ${SupernovaeDialog_UIS_H})
1608-QT5_USE_MODULES(Supernovae-static Core Network Widgets)
1609+TARGET_LINK_LIBRARIES(Supernovae-static Qt5::Core Qt5::Network Qt5::Widgets)
1610 SET_TARGET_PROPERTIES(Supernovae-static PROPERTIES OUTPUT_NAME "Supernovae")
1611-TARGET_LINK_LIBRARIES(Supernovae-static ${extLinkerOption})
1612 SET_TARGET_PROPERTIES(Supernovae-static PROPERTIES COMPILE_FLAGS "-DQT_STATICPLUGIN")
1613 ADD_DEPENDENCIES(AllStaticPlugins Supernovae-static)
1614
1615=== modified file 'plugins/Supernovae/src/Supernovae.cpp'
1616--- plugins/Supernovae/src/Supernovae.cpp 2016-08-07 10:10:32 +0000
1617+++ plugins/Supernovae/src/Supernovae.cpp 2017-01-12 21:08:38 +0000
1618@@ -227,9 +227,7 @@
1619 const Vec3f& c(obj->getInfoColor());
1620 painter.setColor(c[0],c[1],c[2]);
1621 texPointer->bind();
1622- painter.enableTexture2d(true);
1623- glEnable(GL_BLEND);
1624- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transparency mode
1625+ painter.setBlending(true);
1626 painter.drawSprite2dMode(screenpos[0], screenpos[1], 13.f, StelApp::getInstance().getTotalRunTime()*40.);
1627 }
1628 }
1629
1630=== modified file 'plugins/TelescopeControl/src/CMakeLists.txt'
1631--- plugins/TelescopeControl/src/CMakeLists.txt 2015-11-12 12:38:13 +0000
1632+++ plugins/TelescopeControl/src/CMakeLists.txt 2017-01-12 21:08:38 +0000
1633@@ -66,11 +66,15 @@
1634 SET(TelescopeControl_RES ../resources/TelescopeControl.qrc)
1635 QT5_ADD_RESOURCES(TelescopeControl_RES_CXX ${TelescopeControl_RES})
1636
1637-SET(extLinkerOption ${OPENGL_LIBRARIES})
1638+#IF(WIN32 AND NOT MSVC)
1639+# TODO: Test if winsock is still necessary if the Telescope Control plug-in is disabled.
1640+# Because including it here seems to duplicate STELLARIUM_STATIC_PLUGINS_LIBRARIES
1641+# SET(extLinkerOption ${extLinkerOption} libwinmm.a -lws2_32)
1642+#ENDIF()
1643+#
1644
1645 ADD_LIBRARY(TelescopeControl-static STATIC ${TelescopeControl_SRCS} ${TelescopeControl_RES_CXX} ${TelescopeControl_UIS_H})
1646 SET_TARGET_PROPERTIES(TelescopeControl-static PROPERTIES OUTPUT_NAME "TelescopeControl")
1647-TARGET_LINK_LIBRARIES(TelescopeControl-static ${extLinkerOption})
1648-QT5_USE_MODULES(TelescopeControl-static Core Network Widgets SerialPort OpenGL)
1649+TARGET_LINK_LIBRARIES(TelescopeControl-static Qt5::Core Qt5::Network Qt5::Widgets Qt5::SerialPort)
1650 SET_TARGET_PROPERTIES(TelescopeControl-static PROPERTIES COMPILE_FLAGS "-DQT_STATICPLUGIN")
1651 ADD_DEPENDENCIES(AllStaticPlugins TelescopeControl-static)
1652
1653=== modified file 'plugins/TelescopeControl/src/TelescopeControl.cpp'
1654--- plugins/TelescopeControl/src/TelescopeControl.cpp 2016-07-03 21:58:54 +0000
1655+++ plugins/TelescopeControl/src/TelescopeControl.cpp 2017-01-12 21:08:38 +0000
1656@@ -278,21 +278,16 @@
1657 if (circleFader.getInterstate() >= 0)
1658 {
1659 sPainter.setColor(circleColor[0], circleColor[1], circleColor[2], circleFader.getInterstate());
1660- glDisable(GL_TEXTURE_2D);
1661 foreach (double circle, telescope->getOculars())
1662 {
1663 sPainter.drawCircle(XY[0], XY[1], 0.5 * prj->getPixelPerRadAtCenter() * (M_PI/180) * (circle));
1664 }
1665- glEnable(GL_TEXTURE_2D);
1666 }
1667 if (reticleFader.getInterstate() >= 0)
1668 {
1669- glEnable(GL_TEXTURE_2D);
1670- glEnable(GL_BLEND);
1671- glBlendFunc(GL_SRC_ALPHA, GL_ONE);
1672+ sPainter.setBlending(true, GL_SRC_ALPHA, GL_ONE);
1673 sPainter.setColor(reticleColor[0], reticleColor[1], reticleColor[2], reticleFader.getInterstate());
1674 sPainter.drawSprite2dMode(XY[0],XY[1],15.f);
1675- glDisable(GL_TEXTURE_2D);
1676 }
1677 if (labelFader.getInterstate() >= 0)
1678 {
1679@@ -423,9 +418,7 @@
1680 const Vec3f& c(obj->getInfoColor());
1681 sPainter.setColor(c[0], c[1], c[2]);
1682 selectionTexture->bind();
1683- glEnable(GL_TEXTURE_2D);
1684- glEnable(GL_BLEND);
1685- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transparency mode
1686+ sPainter.setBlending(true);
1687 sPainter.drawSprite2dMode(screenpos[0], screenpos[1], 25., StelApp::getInstance().getTotalRunTime() * 40.);
1688 }
1689 #endif //COMPATIBILITY_001002
1690
1691=== modified file 'plugins/TextUserInterface/src/CMakeLists.txt'
1692--- plugins/TextUserInterface/src/CMakeLists.txt 2015-10-20 17:16:34 +0000
1693+++ plugins/TextUserInterface/src/CMakeLists.txt 2017-01-12 21:08:38 +0000
1694@@ -29,12 +29,9 @@
1695 TextUserInterface.cpp
1696 )
1697
1698-SET(extLinkerOption ${OPENGL_LIBRARIES})
1699-
1700 ADD_LIBRARY(TextUserInterface-static STATIC ${TextUserInterface_SRCS})
1701-QT5_USE_MODULES(TextUserInterface-static Core Widgets)
1702+TARGET_LINK_LIBRARIES(TextUserInterface-static Qt5::Core Qt5::Widgets)
1703 # The library target "TextUserInterface-static" has a default OUTPUT_NAME of "TextUserInterface-static", so change it.
1704 SET_TARGET_PROPERTIES(TextUserInterface-static PROPERTIES OUTPUT_NAME "TextUserInterface")
1705-TARGET_LINK_LIBRARIES(TextUserInterface-static ${extLinkerOption})
1706 SET_TARGET_PROPERTIES(TextUserInterface-static PROPERTIES COMPILE_FLAGS "-DQT_STATICPLUGIN")
1707 ADD_DEPENDENCIES(AllStaticPlugins TextUserInterface-static)
1708
1709=== modified file 'plugins/TextUserInterface/src/TextUserInterface.cpp'
1710--- plugins/TextUserInterface/src/TextUserInterface.cpp 2017-01-10 15:51:22 +0000
1711+++ plugins/TextUserInterface/src/TextUserInterface.cpp 2017-01-12 21:08:38 +0000
1712@@ -61,9 +61,7 @@
1713 #include <QTime>
1714 #include <QProcess>
1715 #include <QDir>
1716-#ifdef DISABLE_SCRIPTING
1717-#include "QSettings" // WTF?
1718-#endif
1719+#include <QSettings>
1720
1721
1722 /*************************************************************************
1723
1724=== modified file 'src/CMakeLists.txt'
1725--- src/CMakeLists.txt 2016-12-18 22:26:48 +0000
1726+++ src/CMakeLists.txt 2017-01-12 21:08:38 +0000
1727@@ -1,65 +1,9 @@
1728-SET(glues_lib_SRCS
1729- core/external/glues_stel/source/glues_error.c
1730- core/external/glues_stel/source/glues_error.h
1731- core/external/glues_stel/source/glues.h
1732- core/external/glues_stel/source/libtess/dict.h
1733- core/external/glues_stel/source/libtess/dict.c
1734- core/external/glues_stel/source/libtess/dict-list.h
1735- core/external/glues_stel/source/libtess/geom.c
1736- core/external/glues_stel/source/libtess/geom.h
1737- core/external/glues_stel/source/libtess/memalloc.c
1738- core/external/glues_stel/source/libtess/memalloc.h
1739- core/external/glues_stel/source/libtess/mesh.c
1740- core/external/glues_stel/source/libtess/mesh.h
1741- core/external/glues_stel/source/libtess/normal.c
1742- core/external/glues_stel/source/libtess/normal.h
1743- core/external/glues_stel/source/libtess/priorityq.c
1744- core/external/glues_stel/source/libtess/priorityq.h
1745- core/external/glues_stel/source/libtess/priorityq-heap.h
1746- core/external/glues_stel/source/libtess/priorityq-heap.i
1747- core/external/glues_stel/source/libtess/priorityq-sort.h
1748- core/external/glues_stel/source/libtess/render.c
1749- core/external/glues_stel/source/libtess/render.h
1750- core/external/glues_stel/source/libtess/sweep.c
1751- core/external/glues_stel/source/libtess/sweep.h
1752- core/external/glues_stel/source/libtess/tess.c
1753- core/external/glues_stel/source/libtess/tess.h
1754- core/external/glues_stel/source/libtess/tessmono.c
1755- core/external/glues_stel/source/libtess/tessmono.h
1756-)
1757-
1758-SET(zlib_SRCS
1759- core/external/zlib/adler32.c
1760- core/external/zlib/compress.c
1761- core/external/zlib/crc32.c
1762- core/external/zlib/crc32.h
1763- core/external/zlib/deflate.c
1764- core/external/zlib/deflate.h
1765- core/external/zlib/gzclose.c
1766- core/external/zlib/gzguts.h
1767- core/external/zlib/gzlib.c
1768- core/external/zlib/gzread.c
1769- core/external/zlib/gzwrite.c
1770- core/external/zlib/infback.c
1771- core/external/zlib/inffast.c
1772- core/external/zlib/inffast.h
1773- core/external/zlib/inffixed.h
1774- core/external/zlib/inflate.c
1775- core/external/zlib/inflate.h
1776- core/external/zlib/inftrees.c
1777- core/external/zlib/inftrees.h
1778- core/external/zlib/trees.c
1779- core/external/zlib/trees.h
1780- core/external/zlib/uncompr.c
1781- core/external/zlib/zconf.h
1782- core/external/zlib/zlib.h
1783- core/external/zlib/zutil.c
1784- core/external/zlib/zutil.h
1785-)
1786+#add our external dependencies first
1787+add_subdirectory(external)
1788
1789 IF(ENABLE_SPOUT)
1790 SET(spout_SRCS
1791- core/external/SpoutLibrary.h
1792+ external/SpoutLibrary.h
1793 core/SpoutSender.hpp
1794 core/SpoutSender.cpp
1795 )
1796@@ -171,10 +115,6 @@
1797 core/StelPropertyMgr.hpp
1798 core/StelPropertyMgr.cpp
1799
1800- ${gl_lib_SRCS}
1801-
1802- ${glues_lib_SRCS}
1803-
1804 ${spout_SRCS}
1805
1806 core/planetsephems/calc_interpolated_elements.c
1807@@ -295,14 +235,6 @@
1808 )
1809 ENDIF()
1810
1811-SET(stellarium_lib_SRCS ${stellarium_lib_SRCS}
1812- core/external/qtcompress/qzip.cpp
1813- core/external/qtcompress/qzipreader.h
1814- core/external/qtcompress/qzipwriter.h
1815- core/external/qcustomplot/qcustomplot.cpp
1816- core/external/qcustomplot/qcustomplot.h
1817-)
1818-
1819 IF(ENABLE_SCRIPTING)
1820 SET(stellarium_lib_SRCS ${stellarium_lib_SRCS}
1821 scripting/StelScriptOutput.hpp
1822@@ -318,12 +250,6 @@
1823 )
1824 ENDIF()
1825
1826-IF(WIN32)
1827- SET(stellarium_lib_SRCS ${stellarium_lib_SRCS}
1828- ${zlib_SRCS}
1829- )
1830-ENDIF()
1831-
1832 SET(stellarium_exe_SRCS main.cpp)
1833
1834 ################# compiles resources files ############
1835@@ -424,7 +350,6 @@
1836 SET(stellarium_gui_RES ${CMAKE_SOURCE_DIR}/data/gui/guiRes.qrc)
1837 QT5_ADD_RESOURCES(stellarium_gui_RES_CXX ${stellarium_gui_RES})
1838
1839- SET(extLinkerOption ${extLinkerOption} ${QT_QTSCRIPT_LIBRARY} ${OPENGL_LIBRARIES})
1840 SET(stellarium_lib_SRCS ${stellarium_lib_SRCS} ${stellarium_gui_SRCS} ${stellarium_UIS_H} ${stellarium_gui_RES_CXX})
1841 ENDIF()
1842
1843@@ -467,15 +392,9 @@
1844 ################################ Build main program #########################################
1845 #############################################################################################
1846
1847-SET(extLinkerOption ${extLinkerOption} ${OPENGL_LIBRARIES} ${ZLIB_LIBRARIES})
1848-IF(ENABLE_MEDIA)
1849- # Forced linkage to Qt5MultimediaWidgets library when media support is enabled
1850- SET(extLinkerOption ${extLinkerOption} ${Qt5MultimediaWidgets_LIBRARIES})
1851-ENDIF()
1852 IF(WIN32 AND NOT MSVC)
1853-# TODO: Test if winsock is still necessary if the Telescope Control plug-in is disabled.
1854-# Because including it here seems to duplicate STELLARIUM_STATIC_PLUGINS_LIBRARIES
1855- SET(extLinkerOption ${extLinkerOption} libwinmm.a -lws2_32)
1856+ # This library is required on MinGW builds for some native methods used in a fix in main.cpp
1857+ SET(winMMLib libwinmm.a)
1858 ENDIF()
1859
1860 IF(WIN32 AND ENABLE_WINDOWS_EXE_ICON)
1861@@ -491,51 +410,37 @@
1862 ENDIF()
1863 ENDIF()
1864
1865+# Setup Qt5 dependencies
1866+SET(STELLARIUM_QT_LIBRARIES Qt5::Core Qt5::Concurrent Qt5::Gui ${STEL_GLES_LIBS} Qt5::Network Qt5::Widgets)
1867+IF(ENABLE_MEDIA)
1868+ SET(STELLARIUM_QT_LIBRARIES ${STELLARIUM_QT_LIBRARIES} Qt5::Multimedia Qt5::MultimediaWidgets)
1869+ENDIF()
1870+IF(ENABLE_SCRIPTING)
1871+ SET(STELLARIUM_QT_LIBRARIES ${STELLARIUM_QT_LIBRARIES} Qt5::Script)
1872+ENDIF()
1873+if(USE_OLD_QGLWIDGET)
1874+ # The Qt5OpenGL library is only required when using the legacy viewport
1875+ SET(STELLARIUM_QT_LIBRARIES ${STELLARIUM_QT_LIBRARIES} Qt5::OpenGL)
1876+endif()
1877+
1878 if(ENABLE_SPOUT AND SPOUT_LIBRARY_DLL)
1879 # automatically copy the spout .dll to the binary directory, if possible
1880 configure_file(${SPOUT_LIBRARY_DLL} ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
1881 endif()
1882
1883+set(STELMAIN_DEPS ${ZLIB_LIBRARIES} qtcompress_stel glues_stel qcustomplot_stel ${STELLARIUM_STATIC_PLUGINS_LIBRARIES} ${STELLARIUM_QT_LIBRARIES} ${SPOUT_LIBRARY})
1884+
1885+# Main executable/library setup
1886 IF(GENERATE_STELMAINLIB)
1887 ADD_LIBRARY(stelMain SHARED ${stellarium_lib_SRCS} ${stellarium_RES_CXX})
1888- TARGET_LINK_LIBRARIES(stelMain ${extLinkerOption} ${STELLARIUM_STATIC_PLUGINS_LIBRARIES})
1889- QT5_USE_MODULES(stelMain Core Concurrent Gui Network OpenGL Widgets PrintSupport)
1890- IF(ENABLE_MEDIA)
1891- QT5_USE_MODULES(stelMain Multimedia MultimediaWidgets)
1892- ENDIF()
1893- IF(ENABLE_SCRIPTING)
1894- QT5_USE_MODULES(stelMain Script)
1895- ENDIF()
1896- IF(USE_PLUGIN_TELESCOPECONTROL)
1897- QT5_USE_MODULES(stelMain SerialPort)
1898- ENDIF()
1899- IF(ENABLE_SPOUT)
1900- TARGET_LINK_LIBRARIES(stelMain ${SPOUT_LIBRARY})
1901- ENDIF(ENABLE_SPOUT)
1902-
1903+ TARGET_LINK_LIBRARIES(stelMain ${STELMAIN_DEPS})
1904 INSTALL(TARGETS stelMain DESTINATION lib)
1905 ADD_EXECUTABLE(stellarium ${stellarium_exe_SRCS})
1906 #stelMain should be after the plug-ins, otherwise the build crashes
1907- TARGET_LINK_LIBRARIES(stellarium ${STELLARIUM_STATIC_PLUGINS_LIBRARIES} stelMain ${extLinkerOption})
1908+ TARGET_LINK_LIBRARIES(stellarium stelMain ${winMMLib})
1909 ELSE()
1910 ADD_EXECUTABLE(stellarium ${stellarium_lib_SRCS} ${stellarium_RES_CXX} ${stellarium_exe_SRCS})
1911- TARGET_LINK_LIBRARIES(stellarium ${extLinkerOption} ${STELLARIUM_STATIC_PLUGINS_LIBRARIES})
1912- # This will add the ANGLE lib if the Qt version supports it.
1913- TARGET_LINK_LIBRARIES(stellarium ${Qt5Gui_LIBRARIES} ${Qt5Gui_OPENGL_LIBRARIES})
1914-
1915- QT5_USE_MODULES(stellarium Core Concurrent Gui Network OpenGL Widgets PrintSupport)
1916- IF(ENABLE_MEDIA)
1917- QT5_USE_MODULES(stellarium Multimedia MultimediaWidgets)
1918- ENDIF()
1919- IF(ENABLE_SCRIPTING)
1920- QT5_USE_MODULES(stellarium Script)
1921- ENDIF()
1922- IF(USE_PLUGIN_TELESCOPECONTROL)
1923- QT5_USE_MODULES(stellarium SerialPort)
1924- ENDIF()
1925- IF(ENABLE_SPOUT)
1926- TARGET_LINK_LIBRARIES(stellarium ${SPOUT_LIBRARY})
1927- ENDIF(ENABLE_SPOUT)
1928+ TARGET_LINK_LIBRARIES(stellarium ${winMMLib} ${STELMAIN_DEPS})
1929
1930 IF(APPLE)
1931 SET_TARGET_PROPERTIES(stellarium PROPERTIES LINK_FLAGS " -framework Cocoa -framework OpenGL")
1932@@ -566,7 +471,7 @@
1933 SET(STELLARIUM_TESTS ${STELLARIUM_TESTS} ${NAME})
1934 ENDMACRO()
1935
1936-SET(extLinkerOptionTest ${QT_QTCORE_LIBRARY} ${QT_QTNETWORK_LIBRARY} ${QT_QTTEST_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${OPENGL_LIBRARIES} ${ZLIB_LIBRARIES})
1937+SET(TESTS_LIBRARIES ${ZLIB_LIBRARIES} Qt5::Core Qt5::Gui Qt5::Test)
1938
1939 # Custom target used to build all tests at once
1940 ADD_CUSTOM_TARGET(buildTests)
1941@@ -577,13 +482,8 @@
1942 core/StelUtils.hpp
1943 core/StelUtils.cpp
1944 )
1945-IF(WIN32)
1946- # StelUtils required zlib sources
1947- SET(tests_testDates_SRCS ${tests_testDates_SRCS} ${zlib_SRCS})
1948-ENDIF()
1949 ADD_EXECUTABLE(testDates EXCLUDE_FROM_ALL ${tests_testDates_SRCS})
1950-QT5_USE_MODULES(testDates Core Test)
1951-TARGET_LINK_LIBRARIES(testDates ${extLinkerOptionTest})
1952+TARGET_LINK_LIBRARIES(testDates ${TESTS_LIBRARIES})
1953 ADD_DEPENDENCIES(buildTests testDates)
1954 ADD_TEST(testDates)
1955
1956@@ -594,8 +494,7 @@
1957 core/StelFileMgr.cpp
1958 )
1959 ADD_EXECUTABLE(testStelFileMgr EXCLUDE_FROM_ALL ${tests_testStelFileMgr_SRCS})
1960-QT5_USE_MODULES(testStelFileMgr Core Test)
1961-TARGET_LINK_LIBRARIES(testStelFileMgr ${extLinkerOptionTest})
1962+TARGET_LINK_LIBRARIES(testStelFileMgr ${TESTS_LIBRARIES})
1963 ADD_DEPENDENCIES(buildTests testStelFileMgr)
1964 ADD_TEST(testStelFileMgr)
1965
1966@@ -618,50 +517,35 @@
1967 core/StelFileMgr.cpp
1968 core/StelTranslator.hpp
1969 core/StelTranslator.cpp
1970- ${glues_lib_SRCS}
1971 )
1972-IF(WIN32)
1973- # StelUtils required zlib sources
1974- SET(tests_testStelSphereGeometry_SRCS ${tests_testStelSphereGeometry_SRCS} ${zlib_SRCS})
1975-ENDIF()
1976 ADD_EXECUTABLE(testStelSphereGeometry EXCLUDE_FROM_ALL ${tests_testStelSphereGeometry_SRCS})
1977-QT5_USE_MODULES(testStelSphereGeometry Core OpenGL Test)
1978-TARGET_LINK_LIBRARIES(testStelSphereGeometry ${extLinkerOptionTest})
1979+TARGET_LINK_LIBRARIES(testStelSphereGeometry ${TESTS_LIBRARIES} glues_stel)
1980 ADD_DEPENDENCIES(buildTests testStelSphereGeometry)
1981 ADD_TEST(testStelSphereGeometry)
1982
1983-SET(tests_testStelSphericalIndex_SRCS
1984- tests/testStelSphericalIndex.hpp
1985- tests/testStelSphericalIndex.cpp
1986- core/StelSphericalIndex.hpp
1987- core/StelSphericalIndex.cpp
1988- core/StelSphereGeometry.hpp
1989- core/StelSphereGeometry.cpp
1990- core/StelVertexArray.hpp
1991- core/StelVertexArray.cpp
1992- core/OctahedronPolygon.hpp
1993- core/OctahedronPolygon.cpp
1994- core/StelJsonParser.hpp
1995- core/StelJsonParser.cpp
1996- core/StelUtils.cpp
1997- core/StelUtils.hpp
1998- core/StelProjector.cpp
1999- core/StelProjector.hpp
2000- core/StelTranslator.cpp
2001- core/StelTranslator.hpp
2002- core/StelFileMgr.cpp
2003- core/StelFileMgr.hpp
2004- ${glues_lib_SRCS}
2005-)
2006-IF(WIN32)
2007- # StelUtils required zlib sources
2008- SET(tests_testStelSphericalIndex_SRCS ${tests_testStelSphericalIndex_SRCS} ${zlib_SRCS})
2009-ENDIF()
2010-ADD_EXECUTABLE(testStelSphericalIndex EXCLUDE_FROM_ALL ${tests_testStelSphericalIndex_SRCS})
2011-QT5_USE_MODULES(testStelSphericalIndex Core OpenGL Test)
2012-TARGET_LINK_LIBRARIES(testStelSphericalIndex ${extLinkerOptionTest})
2013-ADD_DEPENDENCIES(buildTests testStelSphericalIndex)
2014-ADD_TEST(testStelSphericalIndex)
2015+#SET(tests_testStelSphericalIndex_SRCS
2016+# tests/testStelSphericalIndex.hpp
2017+# tests/testStelSphericalIndex.cpp
2018+# core/StelSphericalIndex.hpp
2019+# core/StelSphericalIndex.cpp
2020+# core/StelSphereGeometry.hpp
2021+# core/StelSphereGeometry.cpp
2022+# core/StelVertexArray.hpp
2023+# core/StelVertexArray.cpp
2024+# core/OctahedronPolygon.hpp
2025+# core/OctahedronPolygon.cpp
2026+# core/StelJsonParser.hpp
2027+# core/StelJsonParser.cpp
2028+# core/StelUtils.cpp
2029+# core/StelUtils.hpp
2030+# core/StelProjector.cpp
2031+# core/StelProjector.hpp
2032+# core/StelTranslator.cpp
2033+# core/StelTranslator.hpp
2034+# ${glues_lib_SRCS})
2035+#ADD_EXECUTABLE(testStelSphericalIndex EXCLUDE_FROM_ALL ${tests_testStelSphericalIndex_SRCS})
2036+#TARGET_LINK_LIBRARIES(testStelSphericalIndex ${TESTS_LIBRARIES})
2037+#ADD_DEPENDENCIES(buildTests testStelSphericalIndex)
2038
2039 SET(tests_testStelJsonParser_SRCS
2040 tests/testStelJsonParser.hpp
2041@@ -670,8 +554,7 @@
2042 core/StelJsonParser.cpp
2043 )
2044 ADD_EXECUTABLE(testStelJsonParser EXCLUDE_FROM_ALL ${tests_testStelJsonParser_SRCS})
2045-QT5_USE_MODULES(testStelJsonParser Core Test)
2046-TARGET_LINK_LIBRARIES(testStelJsonParser ${extLinkerOptionTest})
2047+TARGET_LINK_LIBRARIES(testStelJsonParser ${TESTS_LIBRARIES})
2048 ADD_DEPENDENCIES(buildTests testStelJsonParser)
2049 ADD_TEST(testStelJsonParser)
2050
2051@@ -681,8 +564,7 @@
2052 core/StelVertexArray.hpp
2053 )
2054 ADD_EXECUTABLE(testStelVertexArray EXCLUDE_FROM_ALL ${tests_testStelVertexArray_SRCS})
2055-QT5_USE_MODULES(testStelVertexArray Core Test OpenGL)
2056-TARGET_LINK_LIBRARIES(testStelVertexArray ${extLinkerOptionTest})
2057+TARGET_LINK_LIBRARIES(testStelVertexArray ${TESTS_LIBRARIES})
2058 ADD_DEPENDENCIES(buildTests testStelVertexArray)
2059 ADD_TEST(testStelVertexArray)
2060
2061@@ -692,13 +574,8 @@
2062 core/StelUtils.hpp
2063 core/StelUtils.cpp
2064 )
2065-IF(WIN32)
2066- # StelUtils required zlib sources
2067- SET(tests_testDeltaT_SRCS ${tests_testDeltaT_SRCS} ${zlib_SRCS})
2068-ENDIF()
2069 ADD_EXECUTABLE(testDeltaT EXCLUDE_FROM_ALL ${tests_testDeltaT_SRCS})
2070-QT5_USE_MODULES(testDeltaT Core Test)
2071-TARGET_LINK_LIBRARIES(testDeltaT ${extLinkerOptionTest})
2072+TARGET_LINK_LIBRARIES(testDeltaT ${TESTS_LIBRARIES})
2073 ADD_DEPENDENCIES(buildTests testDeltaT)
2074 ADD_TEST(testDeltaT)
2075
2076@@ -708,13 +585,8 @@
2077 core/StelUtils.hpp
2078 core/StelUtils.cpp
2079 )
2080-IF(WIN32)
2081- # StelUtils required zlib sources
2082- SET(tests_testConversions_SRCS ${tests_testConversions_SRCS} ${zlib_SRCS})
2083-ENDIF()
2084 ADD_EXECUTABLE(testConversions EXCLUDE_FROM_ALL ${tests_testConversions_SRCS})
2085-QT5_USE_MODULES(testConversions Core Test)
2086-TARGET_LINK_LIBRARIES(testConversions ${extLinkerOptionTest})
2087+TARGET_LINK_LIBRARIES(testConversions ${TESTS_LIBRARIES})
2088 ADD_DEPENDENCIES(buildTests testConversions)
2089 ADD_TEST(testConversions)
2090
2091@@ -725,8 +597,7 @@
2092 core/RefractionExtinction.cpp
2093 )
2094 ADD_EXECUTABLE(testExtinction EXCLUDE_FROM_ALL ${tests_testExtinction_SRCS})
2095-QT5_USE_MODULES(testExtinction Core Test)
2096-TARGET_LINK_LIBRARIES(testExtinction ${extLinkerOptionTest})
2097+TARGET_LINK_LIBRARIES(testExtinction ${TESTS_LIBRARIES})
2098 ADD_DEPENDENCIES(buildTests testExtinction)
2099 ADD_TEST(testExtinction)
2100
2101@@ -738,13 +609,8 @@
2102 core/StelUtils.hpp
2103 core/StelUtils.cpp
2104 )
2105-IF(WIN32)
2106- # StelUtils required zlib sources
2107- SET(tests_testRefraction_SRCS ${tests_testRefraction_SRCS} ${zlib_SRCS})
2108-ENDIF()
2109 ADD_EXECUTABLE(testRefraction EXCLUDE_FROM_ALL ${tests_testRefraction_SRCS})
2110-QT5_USE_MODULES(testRefraction Core Test)
2111-TARGET_LINK_LIBRARIES(testRefraction ${extLinkerOptionTest})
2112+TARGET_LINK_LIBRARIES(testRefraction ${TESTS_LIBRARIES})
2113 ADD_DEPENDENCIES(buildTests testRefraction)
2114 ADD_TEST(testRefraction)
2115
2116@@ -756,13 +622,8 @@
2117 core/StelUtils.hpp
2118 core/StelUtils.cpp
2119 )
2120-IF(WIN32)
2121- # StelUtils required zlib sources
2122- SET(tests_testPrecession_SRCS ${tests_testPrecession_SRCS} ${zlib_SRCS})
2123-ENDIF()
2124 ADD_EXECUTABLE(testPrecession EXCLUDE_FROM_ALL ${tests_testPrecession_SRCS})
2125-QT5_USE_MODULES(testPrecession Core Test)
2126-TARGET_LINK_LIBRARIES(testPrecession ${extLinkerOptionTest})
2127+TARGET_LINK_LIBRARIES(testPrecession ${TESTS_LIBRARIES})
2128 ADD_DEPENDENCIES(buildTests testPrecession)
2129 ADD_TEST(testPrecession)
2130
2131@@ -788,8 +649,7 @@
2132 core/planetsephems/jpleph.cpp
2133 )
2134 ADD_EXECUTABLE(testEphemeris EXCLUDE_FROM_ALL ${tests_testEphemeris_SRCS})
2135-QT5_USE_MODULES(testEphemeris Core Test)
2136-TARGET_LINK_LIBRARIES(testEphemeris ${extLinkerOptionTest})
2137+TARGET_LINK_LIBRARIES(testEphemeris ${TESTS_LIBRARIES})
2138 TARGET_COMPILE_DEFINITIONS(testEphemeris PRIVATE UNIT_TEST)
2139 ADD_DEPENDENCIES(buildTests testEphemeris)
2140 ADD_TEST(testEphemeris)
2141
2142=== modified file 'src/StelLogger.cpp'
2143--- src/StelLogger.cpp 2016-07-05 15:30:52 +0000
2144+++ src/StelLogger.cpp 2017-01-12 21:08:38 +0000
2145@@ -254,6 +254,8 @@
2146
2147 void StelLogger::debugLogHandler(QtMsgType type, const QMessageLogContext& ctx, const QString& msg)
2148 {
2149+ // *** NOTE: see original Qt source in qlogging.cpp (qDefaultMessageHandler) for sensible default code
2150+
2151 #if (QT_VERSION>=QT_VERSION_CHECK(5,4,0))
2152 //use Qt to format the log message, if possible
2153 //this uses the format set by qSetMessagePattern
2154@@ -268,24 +270,30 @@
2155 if(fmt.isNull())
2156 return;
2157
2158+ //always append newline
2159+ fmt.append(QLatin1Char('\n'));
2160+
2161 #ifdef Q_OS_WIN
2162 //Send debug messages to Debugger, if one is attached, instead of stderr
2163 //This seems to avoid output delays in Qt Creator, allowing for easier debugging
2164 //Seems to work fine with MSVC and MinGW
2165- if(IsDebuggerPresent())
2166- OutputDebugStringW(reinterpret_cast<LPCWSTR>(fmt.utf16()));
2167+ if (IsDebuggerPresent())
2168+ {
2169+ OutputDebugStringW(reinterpret_cast<const wchar_t *>(fmt.utf16()));
2170+ }
2171 else
2172 #endif
2173- //this does the same as the default handler in qlogging.cpp
2174- fprintf(stderr, "%s\n", qPrintable(fmt));
2175- fflush(stderr);
2176+ {
2177+ //this does the same as the default handler in qlogging.cpp
2178+ fprintf(stderr, "%s", qPrintable(fmt));
2179+ fflush(stderr);
2180+ }
2181 writeLog(fmt);
2182 }
2183
2184 void StelLogger::writeLog(QString msg)
2185 {
2186 fileMutex.lock();
2187- msg += "\n";
2188 logFile.write(qPrintable(msg), msg.size());
2189 log += msg;
2190 fileMutex.unlock();
2191
2192=== modified file 'src/StelMainView.cpp'
2193--- src/StelMainView.cpp 2016-12-11 22:57:16 +0000
2194+++ src/StelMainView.cpp 2017-01-12 21:08:38 +0000
2195@@ -32,10 +32,10 @@
2196
2197 #include <QDebug>
2198 #include <QDir>
2199-#if STEL_USE_NEW_OPENGL_WIDGETS
2200+#ifdef USE_OLD_QGLWIDGET
2201+#include <QGLWidget>
2202+#else
2203 #include <QOpenGLWidget>
2204-#else
2205-#include <QGLWidget>
2206 #endif
2207 #include <QApplication>
2208 #include <QDesktopWidget>
2209@@ -61,24 +61,199 @@
2210 #endif
2211 #include <QOpenGLShader>
2212 #include <QOpenGLShaderProgram>
2213-#include <QGLFramebufferObject>
2214-#include <QGLShaderProgram>
2215+#include <QOpenGLFramebufferObject>
2216+#include <QOpenGLPaintDevice>
2217+#ifdef OPENGL_DEBUG_LOGGING
2218+#include <QOpenGLDebugLogger>
2219+#endif
2220
2221 #include <clocale>
2222
2223 // Initialize static variables
2224 StelMainView* StelMainView::singleton = NULL;
2225
2226+#ifdef USE_OLD_QGLWIDGET
2227+class StelGLWidget : public QGLWidget
2228+#else
2229+class StelGLWidget : public QOpenGLWidget
2230+#endif
2231+{
2232+public:
2233+ StelGLWidget(StelMainView* parent)
2234+ :
2235+#ifdef USE_OLD_QGLWIDGET
2236+ QGLWidget(parent),
2237+#else
2238+ QOpenGLWidget(parent),
2239+#endif
2240+ parent(parent),
2241+ initialized(false)
2242+ {
2243+ qDebug()<<"StelGLWidget constructor";
2244+
2245+ //because we always draw the full background,
2246+ //lets skip drawing the system background
2247+ setAttribute(Qt::WA_OpaquePaintEvent);
2248+ setAutoFillBackground(false);
2249+ }
2250+
2251+ ~StelGLWidget()
2252+ {
2253+ qDebug()<<"StelGLWidget destroyed";
2254+ }
2255+
2256+ virtual void initializeGL() Q_DECL_OVERRIDE
2257+ {
2258+ if(initialized)
2259+ {
2260+ qWarning()<<"Double initialization, should not happen";
2261+ Q_ASSERT(false);
2262+ return;
2263+ }
2264+
2265+ //This seems to be the correct place to initialize all
2266+ //GL related stuff of the application
2267+ //this includes all the init() calls of the modules
2268+
2269+#ifdef USE_OLD_QGLWIDGET
2270+ QOpenGLContext* ctx = context()->contextHandle();
2271+#else
2272+ QOpenGLContext* ctx = context();
2273+#endif
2274+ Q_ASSERT(ctx == QOpenGLContext::currentContext());
2275+ StelOpenGL::mainContext = ctx; //throw an error when StelOpenGL functions are executed in another context
2276+
2277+ qDebug()<<"initializeGL";
2278+ qDebug() << "OpenGL supported version: " << QString((char*)ctx->functions()->glGetString(GL_VERSION));
2279+ qDebug() << "Current Format: " << this->format();
2280+
2281+ if (qApp->property("onetime_compat33")==true)
2282+ {
2283+ // This may not return the version number set previously!
2284+ qDebug() << "StelGLWidget context format version:" << ctx->format().majorVersion() << "." << context()->format().minorVersion();
2285+ qDebug() << "StelGLWidget has CompatibilityProfile:" << (ctx->format().profile()==QSurfaceFormat::CompatibilityProfile ? "yes" : "no") << "(" <<context()->format().profile() << ")";
2286+ }
2287+
2288+ parent->init();
2289+ initialized = true;
2290+ }
2291+
2292+protected:
2293+ virtual void paintGL() Q_DECL_OVERRIDE
2294+ {
2295+ //this is actually never called because the
2296+ //QGraphicsView intercepts the paint event
2297+ //we have to draw in the background of the scene
2298+ //or as a QGraphicsItem
2299+ qDebug()<<"paintGL";
2300+ }
2301+ virtual void resizeGL(int w, int h) Q_DECL_OVERRIDE
2302+ {
2303+ //we probably can ignore this method,
2304+ //it seems it is also never called
2305+ qDebug()<<"resizeGL"<<w<<h;
2306+ }
2307+
2308+private:
2309+ StelMainView* parent;
2310+ bool initialized;
2311+};
2312+
2313 // A custom QGraphicsEffect to apply the night mode on top of the screen.
2314 class NightModeGraphicsEffect : public QGraphicsEffect
2315 {
2316 public:
2317- NightModeGraphicsEffect(QObject* parent = NULL);
2318+ NightModeGraphicsEffect(StelMainView* parent = NULL)
2319+ : QGraphicsEffect(parent),
2320+ parent(parent), fbo(NULL)
2321+ {
2322+ Q_ASSERT(parent->glContext() == QOpenGLContext::currentContext());
2323+
2324+ program = new QOpenGLShaderProgram(this);
2325+ QString vertexCode =
2326+ "attribute highp vec4 a_pos;\n"
2327+ "attribute highp vec2 a_texCoord;\n"
2328+ "varying highp vec2 v_texCoord;\n"
2329+ "void main(void)\n"
2330+ "{\n"
2331+ "v_texCoord = a_texCoord;\n"
2332+ "gl_Position = a_pos;\n"
2333+ "}\n";
2334+ QString fragmentCode =
2335+ "varying highp vec2 v_texCoord;\n"
2336+ "uniform sampler2D u_source;\n"
2337+ "void main(void)\n"
2338+ "{\n"
2339+ " mediump vec3 color = texture2D(u_source, v_texCoord).rgb;\n"
2340+ " mediump float luminance = max(max(color.r, color.g), color.b);\n"
2341+ " gl_FragColor = vec4(luminance, 0.0, 0.0, 1.0);\n"
2342+ "}\n";
2343+ program->addShaderFromSourceCode(QOpenGLShader::Vertex, vertexCode);
2344+ program->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentCode);
2345+ program->link();
2346+ vars.pos = program->attributeLocation("a_pos");
2347+ vars.texCoord = program->attributeLocation("a_texCoord");
2348+ vars.source = program->uniformLocation("u_source");
2349+ }
2350+
2351+ virtual ~NightModeGraphicsEffect()
2352+ {
2353+ Q_ASSERT(parent->glContext() == QOpenGLContext::currentContext());
2354+ //clean up fbo
2355+ delete fbo;
2356+ }
2357 protected:
2358- virtual void draw(QPainter* painter);
2359+ virtual void draw(QPainter* painter) Q_DECL_OVERRIDE
2360+ {
2361+ Q_ASSERT(parent->glContext() == QOpenGLContext::currentContext());
2362+ QOpenGLFunctions* gl = QOpenGLContext::currentContext()->functions();
2363+
2364+ int mainFBO;
2365+ gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &mainFBO);
2366+
2367+ int pixelRatio = painter->device()->devicePixelRatio();
2368+ QSize size(painter->device()->width() * pixelRatio, painter->device()->height() * pixelRatio);
2369+ if (fbo && fbo->size() != size)
2370+ {
2371+ delete fbo;
2372+ fbo = NULL;
2373+ }
2374+ if (!fbo)
2375+ {
2376+ QOpenGLFramebufferObjectFormat format;
2377+ format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
2378+ format.setInternalTextureFormat(GL_RGBA);
2379+ fbo = new QOpenGLFramebufferObject(size, format);
2380+ }
2381+
2382+ fbo->bind();
2383+ QOpenGLPaintDevice device(size);
2384+ QPainter fboPainter(&device);
2385+ drawSource(&fboPainter);
2386+ //dont use QOpenGLFramebufferObject::release here
2387+ gl->glBindFramebuffer(GL_FRAMEBUFFER,mainFBO);
2388+
2389+ painter->save();
2390+ painter->beginNativePainting();
2391+ program->bind();
2392+ const GLfloat pos[] = {-1, -1, +1, -1, -1, +1, +1, +1};
2393+ const GLfloat texCoord[] = {0, 0, 1, 0, 0, 1, 1, 1};
2394+ program->setUniformValue(vars.source, 0);
2395+ program->setAttributeArray(vars.pos, pos, 2);
2396+ program->setAttributeArray(vars.texCoord, texCoord, 2);
2397+ program->enableAttributeArray(vars.pos);
2398+ program->enableAttributeArray(vars.texCoord);
2399+ gl->glBindTexture(GL_TEXTURE_2D, fbo->texture());
2400+ gl->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
2401+ program->release();
2402+ painter->endNativePainting();
2403+ painter->restore();
2404+ }
2405+
2406 private:
2407- QGLFramebufferObject* fbo;
2408- QGLShaderProgram *program;
2409+ StelMainView* parent;
2410+ QOpenGLFramebufferObject* fbo;
2411+ QOpenGLShaderProgram *program;
2412 struct {
2413 int pos;
2414 int texCoord;
2415@@ -86,355 +261,271 @@
2416 } vars;
2417 };
2418
2419-NightModeGraphicsEffect::NightModeGraphicsEffect(QObject* parent) :
2420- QGraphicsEffect(parent)
2421- , fbo(NULL)
2422-{
2423- program = new QGLShaderProgram(this);
2424- QString vertexCode =
2425- "attribute highp vec4 a_pos;\n"
2426- "attribute highp vec2 a_texCoord;\n"
2427- "varying highp vec2 v_texCoord;\n"
2428- "void main(void)\n"
2429- "{\n"
2430- "v_texCoord = a_texCoord;\n"
2431- "gl_Position = a_pos;\n"
2432- "}\n";
2433- QString fragmentCode =
2434- "varying highp vec2 v_texCoord;\n"
2435- "uniform sampler2D u_source;\n"
2436- "void main(void)\n"
2437- "{\n"
2438- " mediump vec3 color = texture2D(u_source, v_texCoord).rgb;\n"
2439- " mediump float luminance = max(max(color.r, color.g), color.b);\n"
2440- " gl_FragColor = vec4(luminance, 0.0, 0.0, 1.0);\n"
2441- "}\n";
2442- program->addShaderFromSourceCode(QGLShader::Vertex, vertexCode);
2443- program->addShaderFromSourceCode(QGLShader::Fragment, fragmentCode);
2444- program->link();
2445- vars.pos = program->attributeLocation("a_pos");
2446- vars.texCoord = program->attributeLocation("a_texCoord");
2447- vars.source = program->uniformLocation("u_source");
2448-}
2449-
2450-// Qt 5.5 does not support setting the devicePixelRatio of a QGLFramebufferObject,
2451-// So here we make a sub class just so that we can return the correct ratio when
2452-// using the buffer on a retina display.
2453-class NightModeGraphicsEffectFbo : public QGLFramebufferObject
2454+class StelGraphicsScene : public QGraphicsScene
2455 {
2456 public:
2457- NightModeGraphicsEffectFbo(const QSize& s, const QGLFramebufferObjectFormat& f, int pixelRatio_) :
2458- QGLFramebufferObject(s, f), pixelRatio(pixelRatio_) {}
2459+ StelGraphicsScene(StelMainView* parent)
2460+ : QGraphicsScene(parent), parent(parent)
2461+ {
2462+ qDebug()<<"StelGraphicsScene constructor";
2463+ }
2464+
2465 protected:
2466- virtual int metric(PaintDeviceMetric m) const
2467+
2468+ void keyPressEvent(QKeyEvent* event) Q_DECL_OVERRIDE
2469 {
2470- if (m == QPaintDevice::PdmDevicePixelRatio) return pixelRatio;
2471- return QGLFramebufferObject::metric(m);
2472+ // Try to trigger a global shortcut.
2473+ StelActionMgr* actionMgr = StelApp::getInstance().getStelActionManager();
2474+ if (actionMgr->pushKey(event->key() + event->modifiers(), true)) {
2475+ event->setAccepted(true);
2476+ parent->thereWasAnEvent(); // Refresh screen ASAP
2477+ return;
2478+ }
2479+ //pass event on to items otherwise
2480+ QGraphicsScene::keyPressEvent(event);
2481 }
2482+
2483 private:
2484- int pixelRatio;
2485+ StelMainView* parent;
2486 };
2487
2488-void NightModeGraphicsEffect::draw(QPainter* painter)
2489-{
2490- int pixelRatio = painter->device()->devicePixelRatio();
2491- QSize size(painter->device()->width() * pixelRatio, painter->device()->height() * pixelRatio);
2492- if (fbo && fbo->size() != size)
2493- {
2494- delete fbo;
2495- fbo = NULL;
2496- }
2497- if (!fbo)
2498- {
2499- QGLFramebufferObjectFormat format;
2500- format.setAttachment(QGLFramebufferObject::CombinedDepthStencil);
2501- format.setInternalTextureFormat(GL_RGBA);
2502- fbo = new NightModeGraphicsEffectFbo(size, format, pixelRatio);
2503- }
2504- QPainter fboPainter(fbo);
2505- drawSource(&fboPainter);
2506-
2507- painter->save();
2508- painter->beginNativePainting();
2509- program->bind();
2510- const GLfloat pos[] = {-1, -1, +1, -1, -1, +1, +1, +1};
2511- const GLfloat texCoord[] = {0, 0, 1, 0, 0, 1, 1, 1};
2512- program->setUniformValue(vars.source, 0);
2513- program->setAttributeArray(vars.pos, pos, 2);
2514- program->setAttributeArray(vars.texCoord, texCoord, 2);
2515- program->enableAttributeArray(vars.pos);
2516- program->enableAttributeArray(vars.texCoord);
2517- glBindTexture(GL_TEXTURE_2D, fbo->texture());
2518- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
2519- program->release();
2520- painter->endNativePainting();
2521- painter->restore();
2522-}
2523-
2524-//! Render Stellarium sky.
2525-class StelSkyItem : public QGraphicsWidget
2526+class StelRootItem : public QGraphicsObject
2527 {
2528 public:
2529- StelSkyItem(QGraphicsItem* parent = NULL);
2530- void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
2531+ StelRootItem(StelMainView* mainView, QGraphicsItem* parent = NULL)
2532+ : QGraphicsObject(parent), mainView(mainView)
2533+ {
2534+ setFlag(QGraphicsItem::ItemClipsToShape);
2535+ setFlag(QGraphicsItem::ItemClipsChildrenToShape);
2536+ setFlag(QGraphicsItem::ItemIsFocusable);
2537+
2538+ setAcceptHoverEvents(true);
2539+
2540+#ifdef Q_OS_WIN
2541+ setAcceptTouchEvents(true);
2542+ grabGesture(Qt::PinchGesture);
2543+#endif
2544+ setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton | Qt::MiddleButton);
2545+ previousPaintTime = StelApp::getTotalRunTime();
2546+ }
2547+
2548+ void setSize(const QSize& size)
2549+ {
2550+ prepareGeometryChange();
2551+ rect.setSize(size);
2552+ }
2553+
2554 protected:
2555- void mousePressEvent(QGraphicsSceneMouseEvent* event);
2556- void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
2557- void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
2558- void wheelEvent(QGraphicsSceneWheelEvent *event);
2559- void keyPressEvent(QKeyEvent *event);
2560- void keyReleaseEvent(QKeyEvent *event);
2561- void resizeEvent(QGraphicsSceneResizeEvent* event);
2562+ virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) Q_DECL_OVERRIDE
2563+ {
2564+ Q_UNUSED(option);
2565+ Q_UNUSED(widget);
2566+
2567+ //a sanity check
2568+ Q_ASSERT(mainView->glContext() == QOpenGLContext::currentContext());
2569+
2570+ const double now = StelApp::getTotalRunTime();
2571+ double dt = now - previousPaintTime;
2572+ //qDebug()<<"dt"<<dt;
2573+ previousPaintTime = now;
2574+
2575+ //update and draw
2576+ StelApp& app = StelApp::getInstance();
2577+ app.update(dt);
2578+
2579+ //important to call this, or Qt may have invalid state after we have drawn (wrong textures, etc...)
2580+ painter->beginNativePainting();
2581+ app.draw();
2582+ painter->endNativePainting();
2583+
2584+ mainView->drawEnded();
2585+ }
2586+
2587+ virtual QRectF boundingRect() const Q_DECL_OVERRIDE
2588+ {
2589+ return rect;
2590+ }
2591+
2592+ //*** Main event handlers to pass on to StelApp ***//
2593+ void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE
2594+ {
2595+ QMouseEvent ev = convertMouseEvent(event);
2596+ StelApp::getInstance().handleClick(&ev);
2597+ event->setAccepted(ev.isAccepted());
2598+ if(ev.isAccepted())
2599+ mainView->thereWasAnEvent();
2600+ }
2601+
2602+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE
2603+ {
2604+ QMouseEvent ev = convertMouseEvent(event);
2605+ StelApp::getInstance().handleClick(&ev);
2606+ event->setAccepted(ev.isAccepted());
2607+ if(ev.isAccepted())
2608+ mainView->thereWasAnEvent();
2609+ }
2610+
2611+ void mouseMoveEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE
2612+ {
2613+ QMouseEvent ev = convertMouseEvent(event);
2614+ QPointF pos = ev.pos();
2615+ event->setAccepted(StelApp::getInstance().handleMove(pos.x(), pos.y(), ev.buttons()));
2616+ if(event->isAccepted())
2617+ mainView->thereWasAnEvent();
2618+ }
2619+
2620+ void wheelEvent(QGraphicsSceneWheelEvent *event) Q_DECL_OVERRIDE
2621+ {
2622+ QPointF pos = event->scenePos();
2623+ pos.setY(rect.height() - 1 - pos.y());
2624+ QWheelEvent newEvent(QPoint(pos.x(),pos.y()), event->delta(), event->buttons(), event->modifiers(), event->orientation());
2625+ StelApp::getInstance().handleWheel(&newEvent);
2626+ event->setAccepted(newEvent.isAccepted());
2627+ if(newEvent.isAccepted())
2628+ mainView->thereWasAnEvent();
2629+ }
2630+
2631+ void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE
2632+ {
2633+ StelApp::getInstance().handleKeys(event);
2634+ if(event->isAccepted())
2635+ mainView->thereWasAnEvent();
2636+ }
2637+
2638+ void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE
2639+ {
2640+ StelApp::getInstance().handleKeys(event);
2641+ if(event->isAccepted())
2642+ mainView->thereWasAnEvent();
2643+ }
2644+
2645+ //*** Gesture and touch support, currently only for Windows
2646 #ifdef Q_OS_WIN
2647- bool event(QEvent * e);
2648+ bool event(QEvent * e) Q_DECL_OVERRIDE
2649+ {
2650+ switch (e->type()){
2651+ case QEvent::TouchBegin:
2652+ case QEvent::TouchUpdate:
2653+ case QEvent::TouchEnd:
2654+ {
2655+ QTouchEvent *touchEvent = static_cast<QTouchEvent *>(e);
2656+ QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints();
2657+
2658+ if (touchPoints.count() == 1)
2659+ setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton | Qt::MiddleButton);
2660+
2661+ return true;
2662+ break;
2663+ }
2664+
2665+ case QEvent::Gesture:
2666+ setAcceptedMouseButtons(0);
2667+ return gestureEvent(static_cast<QGestureEvent*>(e));
2668+ break;
2669+
2670+ default:
2671+ return QGraphicsObject::event(e);
2672+ }
2673+ }
2674+
2675+private:
2676+ bool gestureEvent(QGestureEvent *event)
2677+ {
2678+ if (QGesture *pinch = event->gesture(Qt::PinchGesture))
2679+ pinchTriggered(static_cast<QPinchGesture *>(pinch));
2680+
2681+ return true;
2682+ }
2683+
2684+ void pinchTriggered(QPinchGesture *gesture)
2685+ {
2686+ QPinchGesture::ChangeFlags changeFlags = gesture->changeFlags();
2687+ if (changeFlags & QPinchGesture::ScaleFactorChanged) {
2688+ qreal zoom = gesture->scaleFactor();
2689+
2690+ if (zoom < 2 && zoom > 0.5){
2691+ StelApp::getInstance().handlePinch(zoom, true);
2692+ }
2693+ }
2694+ }
2695 #endif
2696+
2697 private:
2698+ //! Helper function to convert a QGraphicsSceneMouseEvent to a QMouseEvent suitable for StelApp consumption
2699+ QMouseEvent convertMouseEvent(QGraphicsSceneMouseEvent *event) const
2700+ {
2701+ //convert graphics scene mouse event to widget style mouse event
2702+ QEvent::Type t = QEvent::None;
2703+ switch(event->type())
2704+ {
2705+ case QEvent::GraphicsSceneMousePress:
2706+ t = QEvent::MouseButtonPress;
2707+ break;
2708+ case QEvent::GraphicsSceneMouseRelease:
2709+ t = QEvent::MouseButtonRelease;
2710+ break;
2711+ case QEvent::GraphicsSceneMouseMove:
2712+ t = QEvent::MouseMove;
2713+ break;
2714+ default:
2715+ qFatal("Invalid mouse event type %d",event->type());
2716+ }
2717+
2718+ QPointF pos = event->scenePos();
2719+ //Y needs to be inverted
2720+ pos.setY(rect.height() - 1 - pos.y());
2721+ return QMouseEvent(t,pos,event->button(),event->buttons(),event->modifiers());
2722+ }
2723+
2724+ QRectF rect;
2725 double previousPaintTime;
2726- // void onSizeChanged();
2727-#ifdef Q_OS_WIN
2728- void pinchTriggered(QPinchGesture *gesture);
2729- bool gestureEvent(QGestureEvent *event);
2730-#endif
2731+ StelMainView* mainView;
2732 };
2733
2734 //! Initialize and render Stellarium gui.
2735 class StelGuiItem : public QGraphicsWidget
2736 {
2737 public:
2738- StelGuiItem(QGraphicsItem* parent = NULL);
2739+ StelGuiItem(QGraphicsItem* parent = NULL)
2740+ : QGraphicsWidget(parent)
2741+ {
2742+ StelApp::getInstance().getGui()->init(this);
2743+ }
2744+
2745 protected:
2746- void resizeEvent(QGraphicsSceneResizeEvent* event);
2747+ void resizeEvent(QGraphicsSceneResizeEvent* event) Q_DECL_OVERRIDE
2748+ {
2749+ Q_UNUSED(event);
2750+ //widget->setGeometry(0, 0, size().width(), size().height());
2751+ StelApp::getInstance().getGui()->forceRefreshGui();
2752+ }
2753 private:
2754- QGraphicsWidget *widget;
2755+ //QGraphicsWidget *widget;
2756 // void onSizeChanged();
2757 };
2758
2759-StelSkyItem::StelSkyItem(QGraphicsItem* parent)
2760-{
2761- Q_UNUSED(parent);
2762- setObjectName("SkyItem");
2763- setFlag(QGraphicsItem::ItemHasNoContents, false);
2764- setFlag(QGraphicsItem::ItemIsFocusable, true);
2765- setAcceptHoverEvents(true);
2766-#ifdef Q_OS_WIN
2767- setAcceptTouchEvents(true);
2768- grabGesture(Qt::PinchGesture);
2769-#endif
2770- setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton | Qt::MiddleButton);
2771- previousPaintTime = StelApp::getTotalRunTime();
2772- setFocus();
2773-}
2774-
2775-void StelSkyItem::resizeEvent(QGraphicsSceneResizeEvent* event)
2776-{
2777- QGraphicsWidget::resizeEvent(event);
2778- StelApp::getInstance().glWindowHasBeenResized(scenePos().x(), scene()->sceneRect().height()-(scenePos().y()+geometry().height()), geometry().width(), geometry().height());
2779-}
2780-
2781-void StelSkyItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
2782-{
2783- Q_UNUSED(option);
2784- Q_UNUSED(widget);
2785-
2786- const double now = StelApp::getTotalRunTime();
2787- double dt = now - previousPaintTime;
2788- previousPaintTime = now;
2789-
2790- painter->beginNativePainting();
2791- glClearColor(0, 0, 0, 1);
2792- glClear(GL_COLOR_BUFFER_BIT);
2793- StelApp::getInstance().update(dt);
2794- StelApp::getInstance().draw();
2795-
2796- painter->endNativePainting();
2797-}
2798-
2799-void StelSkyItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
2800-{
2801- //To get back the focus from dialogs
2802- setFocus();
2803- QPointF pos = event->scenePos();
2804- pos.setY(size().height() - 1 - pos.y());
2805- QMouseEvent newEvent(QEvent::MouseButtonPress, QPoint(pos.x(), pos.y()), event->button(), event->buttons(), event->modifiers());
2806- StelApp::getInstance().handleClick(&newEvent);
2807-}
2808-
2809-void StelSkyItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
2810-{
2811- QPointF pos = event->scenePos();
2812- pos.setY(size().height() - 1 - pos.y());
2813- QMouseEvent newEvent(QEvent::MouseButtonRelease, QPoint(pos.x(), pos.y()), event->button(), event->buttons(), event->modifiers());
2814- StelApp::getInstance().handleClick(&newEvent);
2815-}
2816-
2817-void StelSkyItem::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
2818-{
2819- QPointF pos = event->scenePos();
2820- pos.setY(size().height() - 1 - pos.y());
2821- StelApp::getInstance().handleMove(pos.x(), pos.y(), event->buttons());
2822-}
2823-
2824-void StelSkyItem::wheelEvent(QGraphicsSceneWheelEvent *event)
2825-{
2826- QPointF pos = event->scenePos();
2827- pos.setY(size().height() - 1 - pos.y());
2828- QWheelEvent newEvent(QPoint(pos.x(),pos.y()), event->delta(), event->buttons(), event->modifiers(), event->orientation());
2829- StelApp::getInstance().handleWheel(&newEvent);
2830-}
2831-
2832-#ifdef Q_OS_WIN
2833-bool StelSkyItem::event(QEvent * e)
2834-{
2835- switch (e->type()){
2836- case QEvent::TouchBegin:
2837- case QEvent::TouchUpdate:
2838- case QEvent::TouchEnd:
2839- {
2840- QTouchEvent *touchEvent = static_cast<QTouchEvent *>(e);
2841- QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints();
2842-
2843- if (touchPoints.count() == 1)
2844- setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton | Qt::MiddleButton);
2845-
2846- return true;
2847- break;
2848- }
2849-
2850- case QEvent::Gesture:
2851- setAcceptedMouseButtons(0);
2852- return gestureEvent(static_cast<QGestureEvent*>(e));
2853- break;
2854-
2855- default:
2856- return QGraphicsWidget::event(e);
2857- }
2858-}
2859-
2860-bool StelSkyItem::gestureEvent(QGestureEvent *event)
2861-{
2862- if (QGesture *pinch = event->gesture(Qt::PinchGesture))
2863- pinchTriggered(static_cast<QPinchGesture *>(pinch));
2864-
2865- return true;
2866-}
2867-
2868-void StelSkyItem::pinchTriggered(QPinchGesture *gesture)
2869-{
2870- QPinchGesture::ChangeFlags changeFlags = gesture->changeFlags();
2871- if (changeFlags & QPinchGesture::ScaleFactorChanged) {
2872- qreal zoom = gesture->scaleFactor();
2873-
2874- if (zoom < 2 && zoom > 0.5){
2875- StelApp::getInstance().handlePinch(zoom, true);
2876- }
2877- }
2878-}
2879-#endif
2880-
2881-void StelSkyItem::keyPressEvent(QKeyEvent* event)
2882-{
2883- StelApp::getInstance().handleKeys(event);
2884-}
2885-
2886-void StelSkyItem::keyReleaseEvent(QKeyEvent* event)
2887-{
2888- StelApp::getInstance().handleKeys(event);
2889-}
2890-
2891-
2892-StelGuiItem::StelGuiItem(QGraphicsItem* parent) : QGraphicsWidget(parent)
2893-{
2894- widget = new QGraphicsWidget(this);
2895- StelApp::getInstance().getGui()->init(widget);
2896-}
2897-
2898-void StelGuiItem::resizeEvent(QGraphicsSceneResizeEvent* event)
2899-{
2900- Q_UNUSED(event);
2901- widget->setGeometry(0, 0, size().width(), size().height());
2902- StelApp::getInstance().getGui()->forceRefreshGui();
2903-}
2904-
2905-#if STEL_USE_NEW_OPENGL_WIDGETS
2906-
2907-class StelQOpenGLWidget : public QOpenGLWidget
2908-{
2909-public:
2910- StelQOpenGLWidget(QWidget* parent) : QOpenGLWidget(parent)
2911- {
2912- // TODO: Unclear if tese attributes make sense?
2913- setAttribute(Qt::WA_PaintOnScreen);
2914- setAttribute(Qt::WA_NoSystemBackground);
2915- setAttribute(Qt::WA_OpaquePaintEvent);
2916- }
2917-
2918-protected:
2919- virtual void initializeGL()
2920- {
2921- qDebug() << "It appears this was never called?";
2922- qDebug() << "OpenGL supported version: " << QString((char*)glGetString(GL_VERSION));
2923-
2924- QOpenGLWidget::initializeGL();
2925- this->makeCurrent(); // Do we need this?
2926- // GZ I have no idea how to proceed, sorry.
2927- QSurfaceFormat format=this->format();
2928- qDebug() << "Current Format: " << this->format();
2929- // TODO: Test something? The old tests may be obsolete as all OpenGL2 formats/contexts have these?
2930- }
2931- virtual void paintGL()
2932- {
2933- // TODO: what shall this do exactly?
2934- }
2935- virtual void resizeGL()
2936- {
2937- // TODO: what shall this do exactly?
2938- }
2939-
2940-};
2941-
2942-#else
2943-class StelQGLWidget : public QGLWidget
2944-{
2945-public:
2946- StelQGLWidget(QGLContext* ctx, QWidget* parent) : QGLWidget(ctx, parent)
2947- {
2948- setAttribute(Qt::WA_PaintOnScreen);
2949- setAttribute(Qt::WA_NoSystemBackground);
2950- setAttribute(Qt::WA_OpaquePaintEvent);
2951- }
2952-
2953-protected:
2954- virtual void initializeGL()
2955- {
2956- qDebug() << "It appears this is never called?";
2957- Q_ASSERT(0);
2958- qDebug() << "OpenGL supported version: " << QString((char*)glGetString(GL_VERSION));
2959-
2960- QGLWidget::initializeGL();
2961-
2962- qDebug() << "Current Context: " << this->format();
2963- if (!format().stencil())
2964- qWarning("Could not get stencil buffer; results will be suboptimal");
2965- if (!format().depth())
2966- qWarning("Could not get depth buffer; results will be suboptimal");
2967- if (!format().doubleBuffer())
2968- qWarning("Could not get double buffer; results will be suboptimal");
2969- }
2970-
2971-};
2972-#endif
2973-
2974-
2975-StelMainView::StelMainView(QWidget* parent)
2976- : QGraphicsView(parent), guiItem(NULL),
2977+StelMainView::StelMainView(QSettings* settings)
2978+ : QGraphicsView(),
2979+ guiItem(NULL),
2980 gui(NULL),
2981+ stelApp(NULL),
2982+ updateQueued(false),
2983 flagInvertScreenShotColors(false),
2984 flagOverwriteScreenshots(false),
2985 screenShotPrefix("stellarium-"),
2986 screenShotDir(""),
2987- cursorTimeout(-1.f), flagCursorTimeout(false), minFpsTimer(NULL), maxfps(10000.f)
2988+ cursorTimeout(-1.f), flagCursorTimeout(false), maxfps(10000.f)
2989 {
2990+ setAttribute(Qt::WA_OpaquePaintEvent);
2991+ setAutoFillBackground(false);
2992+
2993+ configuration = settings;
2994 StelApp::initStatic();
2995+
2996+ minFpsTimer = new QTimer(this);
2997+ minFpsTimer->setTimerType(Qt::PreciseTimer);
2998+ minFpsTimer->setInterval(1000/minfps);
2999+ connect(minFpsTimer,SIGNAL(timeout()),this,SLOT(minFPSUpdate()));
3000
3001 // Can't create 2 StelMainView instances
3002 Q_ASSERT(!singleton);
3003@@ -444,83 +535,48 @@
3004 initTitleI18n();
3005 setObjectName("Mainview");
3006
3007- // Allows for precise FPS control
3008 setViewportUpdateMode(QGraphicsView::NoViewportUpdate);
3009 setFrameShape(QFrame::NoFrame);
3010 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
3011 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
3012- setFocusPolicy(Qt::StrongFocus);
3013+ //because we only want child elements to have focus, we turn it off here
3014+ setFocusPolicy(Qt::NoFocus);
3015 connect(this, SIGNAL(screenshotRequested()), this, SLOT(doScreenshot()));
3016
3017 lastEventTimeSec = 0;
3018
3019-
3020-#if STEL_USE_NEW_OPENGL_WIDGETS
3021- // Primary test for OpenGL existence
3022- if (QSurfaceFormat::defaultFormat().majorVersion() < 2)
3023- {
3024- qWarning() << "No OpenGL 2 support on this system. Aborting.";
3025- QMessageBox::critical(0, "Stellarium", q_("No OpenGL 2 found on this system. Please upgrade hardware or use MESA or an older version."), QMessageBox::Abort, QMessageBox::Abort);
3026- exit(0);
3027- }
3028-
3029- //QSurfaceFormat format();
3030- //// TBD: What options shall be default?
3031- //QSurfaceFormat::setDefaultFormat(format);
3032- ////QOpenGLContext* context=new QOpenGLContext::create();
3033- glWidget = new StelQOpenGLWidget(this);
3034- //glWidget->setFormat(format);
3035+#ifdef OPENGL_DEBUG_LOGGING
3036+ glLogger = new QOpenGLDebugLogger(this);
3037+ connect(glLogger, SIGNAL(messageLogged(QOpenGLDebugMessage)), this, SLOT(logGLMessage(QOpenGLDebugMessage)));
3038+#endif
3039+
3040+ // VSync control
3041+ bool vsync = configuration->value("video/vsync", true).toBool();
3042+#if QT_VERSION >= QT_VERSION_CHECK(5,4,0)
3043+ // with the QOpenGLWidget, this seems to be needed on the default surface format before creating any windows
3044+ QSurfaceFormat defFmt = QSurfaceFormat::defaultFormat();
3045+ defFmt.setSwapInterval(vsync);
3046+ QSurfaceFormat::setDefaultFormat(defFmt);
3047+#endif
3048+
3049+ QSurfaceFormat widgetFormat = getDesiredGLFormat();
3050+ widgetFormat.setSwapInterval(vsync);
3051+ glWidget = new StelGLWidget(this);
3052+ //Set the surface format BEFORE showing the widget
3053+ //We could also set this as default format instead of just the widget's format,
3054+ //but I don't know if some background Qt stuff needs another buffer configuration or something,
3055+ //so let's be safe and just set it here
3056+#ifdef USE_OLD_QGLWIDGET
3057+ glWidget->setFormat(QGLFormat::fromSurfaceFormat(widgetFormat));
3058 #else
3059- // Primary test for OpenGL existence
3060- if (QGLFormat::openGLVersionFlags() < QGLFormat::OpenGL_Version_2_1)
3061- {
3062- qWarning() << "No OpenGL 2.1 support on this system. Aborting.";
3063- QMessageBox::critical(0, "Stellarium", q_("No OpenGL 2 found on this system. Please upgrade hardware or use MESA or an older version."), QMessageBox::Abort, QMessageBox::Abort);
3064- exit(1);
3065- }
3066-
3067- // Create an openGL viewport
3068- QGLFormat glFormat(QGL::StencilBuffer | QGL::DepthBuffer | QGL::DoubleBuffer);
3069- // Even if setting a version here, it may not be accepted in StelQGLWidget()!
3070- // Currently, not setting a version explicitly works on Windows and Linux.
3071- // Apparently some Macs have problems however and default to 2.1.
3072- // We try a new CLI flag here which requests 3.3 Compatibiliy Profile which modern Macs should deliver.
3073- // OpenGL Specs say this will deliver at least the requested version, if possible.
3074- // TBD: Maybe this must make a differentiation between OpenGL and OpenGL ES!
3075- // TBD: If this works for Mac, it should be requested on all Macs without CLI option!
3076- if (qApp->property("onetime_compat33")==true)
3077- {
3078- if (!(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_3_3))
3079- {
3080- qWarning() << "No OpenGL 3.3 found here. We will get whatever is available.";
3081- qDebug() << "FYI: OpenGL Versions Supported: " << QGLFormat::openGLVersionFlags();
3082- }
3083- glFormat.setVersion(3, 3);
3084- glFormat.setProfile(QGLFormat::CompatibilityProfile);
3085- }
3086- QGLContext* context=new QGLContext(glFormat);
3087-
3088- if (context->format() != glFormat)
3089- {
3090- qWarning() << "Cannot provide requested OpenGL format. Apparently insufficient OpenGL resources on this system.";
3091- QMessageBox::critical(0, "Stellarium", q_("Cannot acquire necessary OpenGL resources."), QMessageBox::Abort, QMessageBox::Abort);
3092- exit(1);
3093- }
3094- glWidget = new StelQGLWidget(context, this);
3095- if (qApp->property("onetime_compat33")==true)
3096- {
3097- // This may not return the version number set previously!
3098- qDebug() << "StelQGLWidget context format version:" << glWidget->context()->format().majorVersion() << "." << glWidget->context()->format().minorVersion();
3099- qDebug() << "StelQGLWidget has CompatibilityProfile:" << (glWidget->context()->format().profile()==QGLFormat::CompatibilityProfile ? "yes" : "no") << "(" <<glWidget->context()->format().profile() << ")";
3100- }
3101+ glWidget->setFormat(widgetFormat);
3102 #endif
3103-
3104 setViewport(glWidget);
3105
3106- setScene(new QGraphicsScene(this));
3107+ stelScene = new StelGraphicsScene(this);
3108+ setScene(stelScene);
3109 scene()->setItemIndexMethod(QGraphicsScene::NoIndex);
3110- rootItem = new QGraphicsWidget();
3111- rootItem->setFocusPolicy(Qt::NoFocus);
3112+ rootItem = new StelRootItem(this);
3113
3114 // Workaround (see Bug #940638) Although we have already explicitly set
3115 // LC_NUMERIC to "C" in main.cpp there seems to be a bug in OpenGL where
3116@@ -529,79 +585,157 @@
3117 // circumstances, so here we set it again just to be on the safe side.
3118 setlocale(LC_NUMERIC, "C");
3119 // End workaround
3120+
3121+#ifdef USE_OLD_QGLWIDGET
3122+ // StelGLWidget::initializeGL is seemingly never called automatically with the QGLWidget, so we have to do it ourselves
3123+ //we have to force context creation here
3124+ glWidget->makeCurrent();
3125+ glWidget->initializeGL();
3126+#endif
3127 }
3128
3129 void StelMainView::resizeEvent(QResizeEvent* event)
3130 {
3131- scene()->setSceneRect(QRect(QPoint(0, 0), event->size()));
3132- rootItem->setGeometry(0,0,event->size().width(),event->size().height());
3133+ if(scene())
3134+ {
3135+ const QSize& sz = event->size();
3136+ scene()->setSceneRect(QRect(QPoint(0, 0), sz));
3137+ rootItem->setSize(sz);
3138+ if(guiItem)
3139+ guiItem->setGeometry(QRectF(0.0f,0.0f,sz.width(),sz.height()));
3140+ }
3141 QGraphicsView::resizeEvent(event);
3142 }
3143
3144 void StelMainView::focusSky() {
3145- scene()->setActiveWindow(0);
3146- skyItem->setFocus();
3147+ //scene()->setActiveWindow(0);
3148+ rootItem->setFocus();
3149 }
3150
3151 StelMainView::~StelMainView()
3152 {
3153+ //delete the night view graphic effect here while GL context is still valid
3154+ rootItem->setGraphicsEffect(Q_NULLPTR);
3155 StelApp::deinitStatic();
3156 }
3157
3158-void StelMainView::init(QSettings* conf)
3159-{
3160+QSurfaceFormat StelMainView::getDesiredGLFormat() const
3161+{
3162+#if QT_VERSION < QT_VERSION_CHECK(5,4,0)
3163+ //default-constructed format
3164+ QSurfaceFormat fmt;
3165+#else
3166+ //use the default format as basis
3167+ QSurfaceFormat fmt = QSurfaceFormat::defaultFormat();
3168+ qDebug()<<"Default surface format: "<<fmt;
3169+#endif
3170+
3171+ //if on an GLES build, do not set the format
3172+#ifndef QT_OPENGL_ES_2
3173+ // OGL 2.1 + FBOs should basically be the minimum required for Stellarium
3174+ fmt.setRenderableType(QSurfaceFormat::OpenGL);
3175+ fmt.setMajorVersion(2);
3176+ fmt.setMinorVersion(1);
3177+
3178+ // The following is NOT needed (or even supported) when we request a 2.1 context
3179+ // The implementation may give us a newer context,
3180+ // but compatibility with 2.1 should be ensured automatically
3181+ //fmt.setProfile(QSurfaceFormat::CompatibilityProfile);
3182+ //fmt.setOption(QSurfaceFormat::DeprecatedFunctions);
3183+#endif
3184+
3185+ //request some sane buffer formats
3186+ fmt.setRedBufferSize(8);
3187+ fmt.setGreenBufferSize(8);
3188+ fmt.setBlueBufferSize(8);
3189+ fmt.setAlphaBufferSize(8);
3190+ fmt.setDepthBufferSize(24);
3191+ //I dont think we use the stencil buffer for anything
3192+ //but maybe Qt needs it
3193+ fmt.setStencilBufferSize(8);
3194+
3195+#ifdef OPENGL_DEBUG_LOGGING
3196+ //try to enable GL debugging using GL_KHR_debug
3197+ fmt.setOption(QSurfaceFormat::DebugContext);
3198+#endif
3199+ //vsync needs to be set on the default format for it to work
3200+ //fmt.setSwapInterval(0);
3201+
3202+ qDebug()<<"Desired surface format: "<<fmt;
3203+ return fmt;
3204+}
3205+
3206+void StelMainView::init()
3207+{
3208+#ifdef OPENGL_DEBUG_LOGGING
3209+ if(!QOpenGLContext::currentContext()->hasExtension(QByteArrayLiteral("GL_KHR_debug")))
3210+ qWarning()<<"GL_KHR_debug extension missing, OpenGL debug logger will likely not work";
3211+ if(glLogger->initialize())
3212+ {
3213+ qDebug()<<"OpenGL debug logger initialized";
3214+ QVector<GLuint> disabledMsgs;
3215+ //if your GL implementation spams some output you are not interested in,
3216+ //you can disable their message IDs here
3217+ //disabledMsgs.append(100);
3218+ glLogger->disableMessages(disabledMsgs);
3219+ glLogger->startLogging(QOpenGLDebugLogger::SynchronousLogging);
3220+ //the internal log buffer may not be empty, so check it
3221+ foreach(const QOpenGLDebugMessage& msg, glLogger->loggedMessages())
3222+ {
3223+ logGLMessage(msg);
3224+ }
3225+ }
3226+ else
3227+ qWarning()<<"Failed to initialize OpenGL debug logger";
3228+
3229+ connect(QOpenGLContext::currentContext(),SIGNAL(aboutToBeDestroyed()),this,SLOT(contextDestroyed()));
3230+ //for easier debugging, print the adress of the main GL context
3231+ qDebug()<<"CurCtxPtr:"<<QOpenGLContext::currentContext();
3232+#endif
3233+
3234+ qDebug()<<"StelMainView::init";
3235+
3236+ glInfo.mainContext = QOpenGLContext::currentContext();
3237+ glInfo.functions = glInfo.mainContext->functions();
3238+ glInfo.vendor = QString(reinterpret_cast<const char*>(glInfo.functions->glGetString(GL_VENDOR)));
3239+ glInfo.renderer = QString(reinterpret_cast<const char*>(glInfo.functions->glGetString(GL_RENDERER)));
3240+
3241 gui = new StelGui();
3242
3243-#if STEL_USE_NEW_OPENGL_WIDGETS
3244- //glWidget->initializeGL(); // protected...
3245- //Q_ASSERT(glWidget->isValid());
3246-#else
3247- Q_ASSERT(glWidget->isValid());
3248- glWidget->makeCurrent();
3249-#endif
3250+ QSettings* conf = configuration;
3251
3252 // Should be check of requirements disabled?
3253 if (conf->value("main/check_requirements", true).toBool())
3254 {
3255 // Find out lots of debug info about supported version of OpenGL and vendor/renderer.
3256- processOpenGLdiagnosticsAndWarnings(conf, glWidget);
3257+ processOpenGLdiagnosticsAndWarnings(conf, QOpenGLContext::currentContext());
3258 }
3259
3260-
3261- stelApp= new StelApp();
3262+ //create and initialize main app
3263+ stelApp = new StelApp(this);
3264 stelApp->setGui(gui);
3265
3266 stelApp->init(conf);
3267+ //this makes sure the app knows how large the window is
3268+ connect(stelScene,SIGNAL(sceneRectChanged(QRectF)),stelApp,SLOT(glWindowHasBeenResized(QRectF)));
3269+ //also immediately set the current values
3270+ stelApp->glWindowHasBeenResized(stelScene->sceneRect());
3271+
3272 StelActionMgr *actionMgr = stelApp->getStelActionManager();
3273 actionMgr->addAction("actionSave_Screenshot_Global", N_("Miscellaneous"), N_("Save screenshot"), this, "saveScreenShot()", "Ctrl+S");
3274 actionMgr->addAction("actionSet_Full_Screen_Global", N_("Display Options"), N_("Full-screen mode"), this, "fullScreen", "F11");
3275
3276 StelPainter::initGLShaders();
3277
3278- skyItem = new StelSkyItem();
3279- guiItem = new StelGuiItem();
3280- QGraphicsAnchorLayout* l = new QGraphicsAnchorLayout(rootItem);
3281- l->setSpacing(0);
3282- l->setContentsMargins(0,0,0,0);
3283- l->addCornerAnchors(skyItem, Qt::TopLeftCorner, l, Qt::TopLeftCorner);
3284- l->addCornerAnchors(skyItem, Qt::BottomRightCorner, l, Qt::BottomRightCorner);
3285- l->addCornerAnchors(guiItem, Qt::BottomLeftCorner, l, Qt::BottomLeftCorner);
3286- l->addCornerAnchors(guiItem, Qt::TopRightCorner, l, Qt::TopRightCorner);
3287- rootItem->setLayout(l);
3288+ guiItem = new StelGuiItem(rootItem);
3289 scene()->addItem(rootItem);
3290+ //set the default focus to the sky
3291+ focusSky();
3292 nightModeEffect = new NightModeGraphicsEffect(this);
3293 updateNightModeProperty(StelApp::getInstance().getVisionModeNight());
3294+ //install the effect on the whole view
3295 rootItem->setGraphicsEffect(nightModeEffect);
3296
3297- QSize size = glWidget->windowHandle()->screen()->size();
3298- size = QSize(conf->value("video/screen_w", size.width()).toInt(),
3299- conf->value("video/screen_h", size.height()).toInt());
3300-
3301- bool fullscreen = conf->value("video/fullscreen", true).toBool();
3302-
3303- // Without this, the screen is not shown on a Mac + we should use resize() for correct work of fullscreen/windowed mode switch. --AW WTF???
3304- resize(size);
3305-
3306 QDesktopWidget *desktop = QApplication::desktop();
3307 int screen = conf->value("video/screen_number", 0).toInt();
3308 if (screen < 0 || screen >= desktop->screenCount())
3309@@ -611,6 +745,14 @@
3310 }
3311 QRect screenGeom = desktop->screenGeometry(screen);
3312
3313+ QSize size = QSize(conf->value("video/screen_w", screenGeom.width()).toInt(),
3314+ conf->value("video/screen_h", screenGeom.height()).toInt());
3315+
3316+ bool fullscreen = conf->value("video/fullscreen", true).toBool();
3317+
3318+ // Without this, the screen is not shown on a Mac + we should use resize() for correct work of fullscreen/windowed mode switch. --AW WTF???
3319+ resize(size);
3320+
3321 if (fullscreen)
3322 {
3323 // The "+1" below is to work around Linux/Gnome problem with mouse focus.
3324@@ -632,26 +774,23 @@
3325 flagInvertScreenShotColors = conf->value("main/invert_screenshots_colors", false).toBool();
3326 setFlagCursorTimeout(conf->value("gui/flag_mouse_cursor_timeout", false).toBool());
3327 setCursorTimeout(conf->value("gui/mouse_cursor_timeout", 10.f).toFloat());
3328- maxfps = conf->value("video/maximum_fps",10000.f).toFloat();
3329- minfps = conf->value("video/minimum_fps",10000.f).toFloat();
3330- flagMaxFpsUpdatePending = false;
3331+ setMaxFps(conf->value("video/maximum_fps",10000.f).toFloat());
3332+ setMinFps(conf->value("video/minimum_fps",10000.f).toFloat());
3333
3334 // XXX: This should be done in StelApp::init(), unfortunately for the moment we need to init the gui before the
3335 // plugins, because the gui creates the QActions needed by some plugins.
3336- StelApp::getInstance().initPlugIns();
3337-
3338- // activate DE430/431
3339- StelApp::getInstance().getCore()->initEphemeridesFunctions();
3340+ stelApp->initPlugIns();
3341
3342 // The script manager can only be fully initialized after the plugins have loaded.
3343- StelApp::getInstance().initScriptMgr();
3344+ stelApp->initScriptMgr();
3345
3346 // Set the global stylesheet, this is only useful for the tooltips.
3347- StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui());
3348+ StelGui* gui = dynamic_cast<StelGui*>(stelApp->getGui());
3349 if (gui!=NULL)
3350 setStyleSheet(gui->getStelStyle().qtStyleSheet);
3351- connect(&StelApp::getInstance(), SIGNAL(visionNightModeChanged(bool)), this, SLOT(updateNightModeProperty(bool)));
3352+ connect(stelApp, SIGNAL(visionNightModeChanged(bool)), this, SLOT(updateNightModeProperty(bool)));
3353
3354+ // I doubt this will have any effect on framerate, but may cause problems elsewhere?
3355 QThread::currentThread()->setPriority(QThread::HighestPriority);
3356 #ifndef NDEBUG
3357 // Get an overview of module callOrders
3358@@ -664,7 +803,6 @@
3359 StelApp::getInstance().dumpModuleActionPriorities(StelModule::ActionHandleKeys);
3360 }
3361 #endif
3362- startMainLoop();
3363 }
3364
3365 void StelMainView::updateNightModeProperty(bool b)
3366@@ -680,17 +818,11 @@
3367 // If problems are detected, warn the user one time, but continue. Warning panel will be suppressed on next start.
3368 // Work in progress, as long as we get reports about bad systems or until OpenGL startup is finalized and safe.
3369 // Several tests do not apply to MacOS X.
3370-#if STEL_USE_NEW_OPENGL_WIDGETS
3371- void StelMainView::processOpenGLdiagnosticsAndWarnings(QSettings *conf, StelQOpenGLWidget* glWidget) const
3372-#else
3373- void StelMainView::processOpenGLdiagnosticsAndWarnings(QSettings *conf, StelQGLWidget* glWidget) const
3374-#endif
3375+void StelMainView::processOpenGLdiagnosticsAndWarnings(QSettings *conf, QOpenGLContext *context) const
3376 {
3377 #ifdef Q_OS_MAC
3378 Q_UNUSED(conf);
3379 #endif
3380-
3381- QOpenGLContext* context=glWidget->context()->contextHandle();
3382 QSurfaceFormat format=context->format();
3383
3384 // These tests are not required on MacOS X
3385@@ -706,12 +838,13 @@
3386 qDebug() << "Neither OpenGL nor OpenGL ES detected: Unsupported Format!";
3387 }
3388 #endif
3389+ QOpenGLFunctions* gl = context->functions();
3390
3391- QString glDriver(reinterpret_cast<const char*>(glGetString(GL_VERSION)));
3392+ QString glDriver(reinterpret_cast<const char*>(gl->glGetString(GL_VERSION)));
3393 qDebug() << "Driver version string:" << glDriver;
3394- qDebug() << "GL vendor is" << QString(reinterpret_cast<const char*>(glGetString(GL_VENDOR)));
3395- QString glRenderer(reinterpret_cast<const char*>(glGetString(GL_RENDERER)));
3396- qDebug() << "GL renderer is" << glRenderer;
3397+ qDebug() << "GL vendor is" << QString(reinterpret_cast<const char*>(gl->glGetString(GL_VENDOR)));
3398+ QString glRenderer(reinterpret_cast<const char*>(gl->glGetString(GL_RENDERER)));
3399+ qDebug() << "GL renderer is" << glRenderer;
3400
3401 // Minimal required version of OpenGL for Qt5 is 2.1 and OpenGL Shading Language may be 1.20 (or OpenGL ES is 2.0 and GLSL ES is 1.0).
3402 // As of V0.13.0..1, we use GLSL 1.10/GLSL ES 1.00 (implicitly, by omitting a #version line), but in case of using ANGLE we need hardware
3403@@ -739,7 +872,7 @@
3404 qWarning() << "Oops... Insufficient OpenGL version. Mesa failed! Please send a bug report.";
3405
3406 QMessageBox::critical(0, "Stellarium", q_("Insufficient OpenGL version. Please update drivers, graphics hardware, or use --angle-mode (or --mesa-mode) option."), QMessageBox::Abort, QMessageBox::Abort);
3407- #else
3408+ #else
3409 qWarning() << "Oops... Insufficient OpenGL version. Please update drivers, or graphics hardware.";
3410 QMessageBox::critical(0, "Stellarium", q_("Insufficient OpenGL version. Please update drivers, or graphics hardware."), QMessageBox::Abort, QMessageBox::Abort);
3411 #endif
3412@@ -747,7 +880,7 @@
3413 }
3414 #endif
3415 // This call requires OpenGL2+.
3416- QString glslString(reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION)));
3417+ QString glslString(reinterpret_cast<const char*>(gl->glGetString(GL_SHADING_LANGUAGE_VERSION)));
3418 qDebug() << "GL Shading Language version is" << glslString;
3419
3420 // Only give extended info if called on command line, for diagnostic.
3421@@ -1034,6 +1167,7 @@
3422
3423 void StelMainView::deinit()
3424 {
3425+ glContextMakeCurrent();
3426 deinitGL();
3427 delete stelApp;
3428 stelApp = NULL;
3429@@ -1057,7 +1191,7 @@
3430 // Therefore moving is not possible. We must move to the stored position or at least defaults.
3431 if ( (x()<0) && (y()<0))
3432 {
3433- QSettings *conf = StelApp::getInstance().getSettings();
3434+ QSettings *conf = stelApp->getSettings();
3435 QDesktopWidget *desktop = QApplication::desktop();
3436 int screen = conf->value("video/screen_number", 0).toInt();
3437 if (screen < 0 || screen >= desktop->screenCount())
3438@@ -1074,118 +1208,66 @@
3439 emit fullScreenChanged(b);
3440 }
3441
3442-void StelMainView::updateScene() {
3443- // For some reason the skyItem is not updated when the night mode shader is on.
3444- // To fix this we manually do it here.
3445- skyItem->update();
3446- scene()->update();
3447-}
3448+void StelMainView::drawEnded()
3449+{
3450+ updateQueued = false;
3451+
3452+ //requeue the next draw
3453+ if(needsMaxFPS())
3454+ {
3455+ updateQueued = true;
3456+ minFpsTimer->stop();
3457+ glWidget->update();
3458+ }
3459+ else
3460+ {
3461+ if(!minFpsTimer->isActive())
3462+ minFpsTimer->start();
3463+ }
3464+}
3465+
3466+void StelMainView::minFPSUpdate()
3467+{
3468+ if(!updateQueued)
3469+ {
3470+ updateQueued = true;
3471+ //qDebug()<<"minFPSUpdate";
3472+ glWidget->update();
3473+ }
3474+ else
3475+ {
3476+ //qDebug()<<"double update";
3477+ }
3478+}
3479+
3480+#ifdef OPENGL_DEBUG_LOGGING
3481+void StelMainView::logGLMessage(const QOpenGLDebugMessage &debugMessage)
3482+{
3483+ qDebug()<<debugMessage;
3484+}
3485+
3486+void StelMainView::contextDestroyed()
3487+{
3488+ qDebug()<<"Main OpenGL context destroyed";
3489+}
3490+#endif
3491
3492 void StelMainView::thereWasAnEvent()
3493 {
3494+ //qDebug()<<"event";
3495 lastEventTimeSec = StelApp::getTotalRunTime();
3496 }
3497
3498-void StelMainView::maxFpsSceneUpdate()
3499-{
3500- updateScene();
3501- flagMaxFpsUpdatePending = false;
3502-}
3503-
3504-void StelMainView::drawBackground(QPainter*, const QRectF&)
3505+bool StelMainView::needsMaxFPS() const
3506 {
3507 const double now = StelApp::getTotalRunTime();
3508- const double JD_SECOND=0.000011574074074074074074;
3509
3510 // Determines when the next display will need to be triggered
3511 // The current policy is that after an event, the FPS is maximum for 2.5 seconds
3512 // after that, it switches back to the default minfps value to save power.
3513 // The fps is also kept to max if the timerate is higher than normal speed.
3514- const float timeRate = StelApp::getInstance().getCore()->getTimeRate();
3515- const bool needMaxFps = (now - lastEventTimeSec < 2.5) || fabs(timeRate) > JD_SECOND;
3516- if (needMaxFps)
3517- {
3518- if (!flagMaxFpsUpdatePending)
3519- {
3520- double duration = 1./getMaxFps();
3521- int dur = (int)(duration*1000);
3522-
3523- if (minFpsTimer!=NULL)
3524- {
3525- disconnect(minFpsTimer, SIGNAL(timeout()), 0, 0);
3526- delete minFpsTimer;
3527- minFpsTimer = NULL;
3528- }
3529- flagMaxFpsUpdatePending = true;
3530- QTimer::singleShot(dur<5 ? 5 : dur, this, SLOT(maxFpsSceneUpdate()));
3531- }
3532- } else if (minFpsTimer == NULL) {
3533- // Restart the minfps timer
3534- minFpsChanged();
3535- }
3536-
3537- // Manage cursor timeout
3538- if (cursorTimeout>0.f && (now-lastEventTimeSec>cursorTimeout) && flagCursorTimeout)
3539- {
3540- if (QGuiApplication::overrideCursor()==0)
3541- QGuiApplication::setOverrideCursor(Qt::BlankCursor);
3542- }
3543- else
3544- {
3545- if (QGuiApplication::overrideCursor()!=0)
3546- QGuiApplication::restoreOverrideCursor();
3547- }
3548-}
3549-
3550-void StelMainView::startMainLoop()
3551-{
3552- // Set a timer refreshing for every minfps frames
3553- minFpsChanged();
3554-}
3555-
3556-void StelMainView::minFpsChanged()
3557-{
3558- if (minFpsTimer!=NULL)
3559- {
3560- disconnect(minFpsTimer, SIGNAL(timeout()), 0, 0);
3561- delete minFpsTimer;
3562- minFpsTimer = NULL;
3563- }
3564-
3565- minFpsTimer = new QTimer(this);
3566- connect(minFpsTimer, SIGNAL(timeout()), this, SLOT(updateScene()));
3567-
3568- minFpsTimer->start((int)(1./getMinFps()*1000.));
3569-}
3570-
3571-
3572-
3573-void StelMainView::mouseMoveEvent(QMouseEvent* event)
3574-{
3575- // We notify the application to increase the fps if a button has been
3576- // clicked, but also if the cursor is currently hidden, so that it gets
3577- // restored.
3578- if (event->buttons() || QGuiApplication::overrideCursor()!=0)
3579- thereWasAnEvent(); // Refresh screen ASAP
3580- QGraphicsView::mouseMoveEvent(event);
3581-}
3582-
3583-void StelMainView::mousePressEvent(QMouseEvent* event)
3584-{
3585- thereWasAnEvent(); // Refresh screen ASAP
3586- QGraphicsView::mousePressEvent(event);
3587-}
3588-
3589-void StelMainView::mouseReleaseEvent(QMouseEvent* event)
3590-{
3591- thereWasAnEvent(); // Refresh screen ASAP
3592- QGraphicsView::mouseReleaseEvent(event);
3593-}
3594-
3595-void StelMainView::wheelEvent(QWheelEvent* event)
3596-{
3597- thereWasAnEvent(); // Refresh screen ASAP
3598- QGraphicsView::wheelEvent(event);
3599+ const float timeRate = stelApp->getCore()->getTimeRate();
3600+ return (now - lastEventTimeSec < 2.5) || fabs(timeRate) > StelCore::JD_SECOND;
3601 }
3602
3603 void StelMainView::moveEvent(QMoveEvent * event)
3604@@ -1193,38 +1275,21 @@
3605 Q_UNUSED(event);
3606
3607 // We use the glWidget instead of the event, as we want the screen that shows most of the widget.
3608- StelApp::getInstance().setDevicePixelsPerPixel(glWidget->windowHandle()->devicePixelRatio());
3609+ QWindow* win = glWidget->windowHandle();
3610+ if(win)
3611+ stelApp->setDevicePixelsPerPixel(win->devicePixelRatio());
3612 }
3613
3614 void StelMainView::closeEvent(QCloseEvent* event)
3615 {
3616 Q_UNUSED(event);
3617- StelApp::getInstance().quit();
3618-}
3619-
3620-void StelMainView::keyPressEvent(QKeyEvent* event)
3621-{
3622- thereWasAnEvent(); // Refresh screen ASAP
3623- // Try to trigger a gobal shortcut.
3624- StelActionMgr* actionMgr = StelApp::getInstance().getStelActionManager();
3625- if (actionMgr->pushKey(event->key() + event->modifiers(), true)) {
3626- event->setAccepted(true);
3627- return;
3628- }
3629- QGraphicsView::keyPressEvent(event);
3630-}
3631-
3632-void StelMainView::keyReleaseEvent(QKeyEvent* event)
3633-{
3634- thereWasAnEvent(); // Refresh screen ASAP
3635- QGraphicsView::keyReleaseEvent(event);
3636-}
3637-
3638+ stelApp->quit();
3639+}
3640
3641 //! Delete openGL textures (to call before the GLContext disappears)
3642 void StelMainView::deinitGL()
3643 {
3644- StelApp::getInstance().deinit();
3645+ stelApp->deinit();
3646 delete gui;
3647 gui = NULL;
3648 }
3649@@ -1240,11 +1305,12 @@
3650 void StelMainView::doScreenshot(void)
3651 {
3652 QFileInfo shotDir;
3653-#if STEL_USE_NEW_OPENGL_WIDGETS
3654+#ifdef USE_OLD_QGLWIDGET
3655+ QImage im = glWidget->grabFrameBuffer();
3656+#else
3657 QImage im = glWidget->grabFramebuffer();
3658-#else
3659- QImage im = glWidget->grabFrameBuffer();
3660 #endif
3661+
3662 if (flagInvertScreenShotColors)
3663 im.invertPixels();
3664
3665@@ -1289,7 +1355,21 @@
3666 return glWidget->mapFromGlobal(QCursor::pos());
3667 }
3668
3669-void StelMainView::setFocusOnSky()
3670-{
3671- skyItem->setFocus();
3672+QOpenGLContext* StelMainView::glContext() const
3673+{
3674+#ifdef USE_OLD_QGLWIDGET
3675+ return glWidget->context()->contextHandle();
3676+#else
3677+ return glWidget->context();
3678+#endif
3679+}
3680+
3681+void StelMainView::glContextMakeCurrent()
3682+{
3683+ glWidget->makeCurrent();
3684+}
3685+
3686+void StelMainView::glContextDoneCurrent()
3687+{
3688+ glWidget->doneCurrent();
3689 }
3690
3691=== modified file 'src/StelMainView.hpp'
3692--- src/StelMainView.hpp 2016-12-10 10:33:35 +0000
3693+++ src/StelMainView.hpp 2017-01-12 21:08:38 +0000
3694@@ -24,19 +24,13 @@
3695 #include <QGraphicsView>
3696 #include <QEventLoop>
3697 #include <QOpenGLContext>
3698-
3699-// This define (only used here and in StelMainView.cpp) is temporarily used
3700-// to allow uncompromised compiling while the migration to the new QOpenGL... classes
3701-// has not been done. As soon as Qt5.4 is out, we should finish this migration process!
3702-#define STEL_USE_NEW_OPENGL_WIDGETS 0
3703-
3704-#if STEL_USE_NEW_OPENGL_WIDGETS
3705-class QOpenGLWidget;
3706-class StelQOpenGLWidget;
3707-#else
3708-class QGLWidget;
3709-class StelQGLWidget;
3710+#include <QTimer>
3711+#ifdef OPENGL_DEBUG_LOGGING
3712+#include <QOpenGLDebugMessage>
3713 #endif
3714+
3715+class StelGLWidget;
3716+class StelGraphicsScene;
3717 class QMoveEvent;
3718 class QResizeEvent;
3719 class StelGuiBase;
3720@@ -49,16 +43,27 @@
3721 class StelMainView : public QGraphicsView
3722 {
3723 friend class StelGuiItem;
3724- friend class StelSkyItem;
3725+ friend class StelRootItem;
3726+ friend class StelGraphicsScene;
3727+ friend class NightModeGraphicsEffect;
3728 Q_OBJECT
3729 Q_PROPERTY(bool fullScreen READ isFullScreen WRITE setFullScreen NOTIFY fullScreenChanged)
3730
3731 public:
3732- StelMainView(QWidget* parent = NULL);
3733+ //! Contains some basic info about the OpenGL context used
3734+ struct GLInfo
3735+ {
3736+ QString vendor;
3737+ QString renderer;
3738+ QOpenGLContext* mainContext;
3739+ QOpenGLFunctions* functions;
3740+ };
3741+
3742+ StelMainView(QSettings* settings);
3743 virtual ~StelMainView();
3744
3745 //! Start the main initialization of Stellarium
3746- void init(class QSettings* conf);
3747+ void init();
3748 void deinit();
3749
3750 //! Set the application title for the current language.
3751@@ -70,20 +75,33 @@
3752
3753 //! Delete openGL textures (to call before the GLContext disappears)
3754 void deinitGL();
3755- //! Return focus to the sky item. To be used when we close a dialog.
3756- void focusSky();
3757+
3758 //! Return the parent gui widget, this should be used as parent to all
3759 //! the StelDialog instances.
3760 QGraphicsWidget* getGuiWidget() const {return guiItem;}
3761 //! Return mouse position coordinates
3762 QPoint getMousePos();
3763+
3764+ //! Returns the main application OpenGL context,
3765+ //! which should be used for all drawing Stellarium does
3766+ //! @sa glContextMakeCurrent()
3767+ //! @sa glContextDoneCurrent()
3768+ QOpenGLContext* glContext() const;
3769+ //! Make the main GL context (the one returned from glContext()) current
3770+ //! on the main view surface
3771+ void glContextMakeCurrent();
3772+ //! Releases the main GL context
3773+ void glContextDoneCurrent();
3774+
3775+ //! Returns the information about the GL context, this does not require the context to be active.
3776+ GLInfo getGLInformation() const { return glInfo; }
3777 public slots:
3778
3779 //! Set whether fullscreen is activated or not
3780 void setFullScreen(bool);
3781
3782- //! Set focus on the sky
3783- void setFocusOnSky();
3784+ //! Return focus to the sky item. To be used when we close a dialog.
3785+ void focusSky();
3786
3787 ///////////////////////////////////////////////////////////////////////////
3788 // Specific methods
3789@@ -119,82 +137,86 @@
3790 //! user events for some seconds to save power. However, if can be useful to set this to a high
3791 //! value to improve playing smoothness in scripts.
3792 //! @param m the new minimum fps setting.
3793- void setMinFps(float m) {minfps=m; minFpsChanged();}
3794+ void setMinFps(float m) {minfps=m; minFpsTimer->setInterval(1000/minfps);}
3795 //! Get the current minimum frames per second.
3796 float getMinFps() {return minfps;}
3797 //! Set the maximum frames per second.
3798 //! @param m the new maximum fps setting.
3799+ //! @todo this setting currently does nothing
3800 void setMaxFps(float m) {maxfps = m;}
3801 //! Get the current maximum frames per second.
3802 float getMaxFps() {return maxfps;}
3803
3804- void maxFpsSceneUpdate();
3805- //! Updates the scene and process all events
3806- void updateScene();
3807-
3808 //! Notify that an event was handled by the program and therefore the
3809 //! FPS should be maximized for a couple of seconds.
3810 void thereWasAnEvent();
3811
3812+ //! Determines if we should render as fast as possible,
3813+ //! or limit the FPS. This depends on the time the last user event
3814+ //! happened.
3815+ bool needsMaxFPS() const;
3816+
3817 protected:
3818- virtual void mouseMoveEvent(QMouseEvent* event);
3819- virtual void mousePressEvent(QMouseEvent* event);
3820- virtual void mouseReleaseEvent(QMouseEvent* event);
3821- virtual void keyPressEvent(QKeyEvent* event);
3822- virtual void keyReleaseEvent(QKeyEvent* event);
3823- virtual void wheelEvent(QWheelEvent* wheelEvent);
3824- virtual void moveEvent(QMoveEvent* event);
3825- virtual void closeEvent(QCloseEvent* event);
3826- virtual void resizeEvent(QResizeEvent* event);
3827-
3828- //! Update the mouse pointer state and schedule next redraw.
3829- //! This method is called automatically by Qt.
3830- virtual void drawBackground(QPainter* painter, const QRectF &rect);
3831-
3832+ //! Hack to determine current monitor pixel ratio
3833+ //! @todo Find a better way to handle this
3834+ virtual void moveEvent(QMoveEvent* event) Q_DECL_OVERRIDE;
3835+ //! Handle window closed event, calling StelApp::quit()
3836+ virtual void closeEvent(QCloseEvent* event) Q_DECL_OVERRIDE;
3837+ //! Handle window resized events, and change the size of the underlying
3838+ //! QGraphicsScene to be the same
3839+ virtual void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE;
3840 signals:
3841 //! emitted when saveScreenShot is requested with saveScreenShot().
3842 //! doScreenshot() does the actual work (it has to do it in the main
3843 //! thread, where as saveScreenShot() might get called from another one.
3844+ //!
3845+ //! @remark FS: is threaded access here even a possibility anymore, or a remnant of older code?
3846 void screenshotRequested(void);
3847 void fullScreenChanged(bool b);
3848-
3849 private slots:
3850 // Do the actual screenshot generation in the main thread with this method.
3851 void doScreenshot(void);
3852- void minFpsChanged();
3853+ void minFPSUpdate();
3854+#ifdef OPENGL_DEBUG_LOGGING
3855+ void logGLMessage(const QOpenGLDebugMessage& debugMessage);
3856+ void contextDestroyed();
3857+#endif
3858 void updateNightModeProperty(bool b);
3859
3860 private:
3861- //! Start the display loop
3862- void startMainLoop();
3863-
3864+ //! The graphics scene notifies us when a draw finished, so that we can queue the next one
3865+ void drawEnded();
3866+ //! Returns the desired OpenGL format settings,
3867+ //! on desktop this corresponds to a GL 2.1 context,
3868+ //! with 32bit RGBA buffer and 24/8 depth/stencil buffer
3869+ QSurfaceFormat getDesiredGLFormat() const;
3870 //! provide extended OpenGL diagnostics in logfile.
3871 void dumpOpenGLdiagnostics() const;
3872 //! Startup diagnostics, providing test for various circumstances of bad OS/OpenGL driver combinations
3873 //! to provide feedback to the user about bad OpenGL drivers.
3874-#if STEL_USE_NEW_OPENGL_WIDGETS
3875- void processOpenGLdiagnosticsAndWarnings(QSettings *conf, StelQOpenGLWidget* glWidget) const;
3876-#else
3877- void processOpenGLdiagnosticsAndWarnings(QSettings *conf, StelQGLWidget* glWidget) const;
3878-#endif
3879+ void processOpenGLdiagnosticsAndWarnings(QSettings *conf, QOpenGLContext* context) const;
3880
3881 //! The StelMainView singleton
3882 static StelMainView* singleton;
3883
3884- QGraphicsWidget* rootItem;
3885- QGraphicsWidget* skyItem;
3886+ GLInfo glInfo;
3887+
3888+ QSettings* configuration;
3889+
3890+ class StelRootItem* rootItem;
3891 QGraphicsWidget* guiItem;
3892 QGraphicsEffect* nightModeEffect;
3893
3894- //! The openGL window
3895-#if STEL_USE_NEW_OPENGL_WIDGETS
3896- StelQOpenGLWidget* glWidget;
3897-#else
3898- StelQGLWidget* glWidget;
3899-#endif
3900+ //! The openGL viewport of the graphics scene
3901+ //! Responsible for main GL setup, rendering is done in the scene background
3902+ StelGLWidget* glWidget;
3903+ //! Custom QGraphicsScene, this renders our scene background
3904+ StelGraphicsScene* stelScene;
3905+
3906 StelGuiBase* gui;
3907 class StelApp* stelApp;
3908
3909+ bool updateQueued;
3910 bool flagInvertScreenShotColors;
3911 bool flagOverwriteScreenshots; //! if set to true, screenshot is named exactly screenShotPrefix.png and overwrites existing file
3912
3913@@ -207,12 +229,15 @@
3914
3915 double lastEventTimeSec;
3916
3917- QTimer* minFpsTimer;
3918- bool flagMaxFpsUpdatePending;
3919 //! The minimum desired frame rate in frame per second.
3920 float minfps;
3921 //! The maximum desired frame rate in frame per second.
3922 float maxfps;
3923+ QTimer* minFpsTimer;
3924+
3925+#ifdef OPENGL_DEBUG_LOGGING
3926+ QOpenGLDebugLogger* glLogger;
3927+#endif
3928 };
3929
3930
3931
3932=== modified file 'src/core/OctahedronPolygon.cpp'
3933--- src/core/OctahedronPolygon.cpp 2015-03-24 16:31:04 +0000
3934+++ src/core/OctahedronPolygon.cpp 2017-01-12 21:08:38 +0000
3935@@ -91,7 +91,7 @@
3936 }
3937 res[res.size()-1]=']';
3938 return res;
3939-};
3940+}
3941
3942 OctahedronPolygon::OctahedronPolygon(const QVector<Vec3d>& contour) : fillCachedVertexArray(StelVertexArray::Triangles), outlineCachedVertexArray(StelVertexArray::Lines)
3943 {
3944
3945=== modified file 'src/core/SpoutSender.cpp'
3946--- src/core/SpoutSender.cpp 2016-12-18 22:26:48 +0000
3947+++ src/core/SpoutSender.cpp 2017-01-12 21:08:38 +0000
3948@@ -18,7 +18,7 @@
3949 */
3950
3951 #include "SpoutSender.hpp"
3952-#include "SpoutLibrary.h"
3953+#include "../../external/SpoutLibrary.h"
3954
3955 Q_LOGGING_CATEGORY(spout,"stel.spout")
3956
3957
3958=== modified file 'src/core/StelApp.cpp'
3959--- src/core/StelApp.cpp 2017-01-09 17:24:41 +0000
3960+++ src/core/StelApp.cpp 2017-01-12 21:08:38 +0000
3961@@ -20,6 +20,7 @@
3962 #include "StelApp.hpp"
3963
3964 #include "StelCore.hpp"
3965+#include "StelMainView.hpp"
3966 #include "StelUtils.hpp"
3967 #include "StelTextureMgr.hpp"
3968 #include "StelObjectMgr.hpp"
3969@@ -202,9 +203,10 @@
3970 /*************************************************************************
3971 Create and initialize the main Stellarium application.
3972 *************************************************************************/
3973-StelApp::StelApp(QObject* parent)
3974+StelApp::StelApp(StelMainView *parent)
3975 : QObject(parent)
3976- , core(NULL)
3977+ , mainWin(parent)
3978+ , core(NULL)
3979 , moduleMgr(NULL)
3980 , localeMgr(NULL)
3981 , skyCultureMgr(NULL)
3982@@ -226,8 +228,7 @@
3983 , globalScalingRatio(1.f)
3984 , fps(0)
3985 , frame(0)
3986- , timefr(0.)
3987- , timeBase(0.)
3988+ , frameTimeAccum(0.)
3989 , flagNightVision(false)
3990 , confSettings(NULL)
3991 , initialized(false)
3992@@ -390,6 +391,7 @@
3993
3994 void StelApp::init(QSettings* conf)
3995 {
3996+ gl = QOpenGLContext::currentContext()->functions();
3997 confSettings = conf;
3998
3999 devicePixelsPerPixel = QOpenGLContext::currentContext()->screen()->devicePixelRatio();
4000@@ -632,13 +634,13 @@
4001 return;
4002
4003 ++frame;
4004- timefr+=deltaTime;
4005- if (timefr-timeBase > 1.)
4006+ frameTimeAccum+=deltaTime;
4007+ if (frameTimeAccum > 1.)
4008 {
4009 // Calc the FPS rate every seconds
4010- fps=(double)frame/(timefr-timeBase);
4011+ fps=(double)frame/frameTimeAccum;
4012 frame = 0;
4013- timeBase+=1.;
4014+ frameTimeAccum=0.;
4015 }
4016
4017 core->update(deltaTime);
4018@@ -668,11 +670,10 @@
4019 renderBuffer->bind();
4020 }
4021
4022-void StelApp::applyRenderBuffer(int drawFbo)
4023+void StelApp::applyRenderBuffer(GLuint drawFbo)
4024 {
4025 if (!renderBuffer) return;
4026- renderBuffer->release();
4027- if (drawFbo) GL(glBindFramebuffer(GL_FRAMEBUFFER, drawFbo));
4028+ GL(gl->glBindFramebuffer(GL_FRAMEBUFFER, drawFbo));
4029 viewportEffect->paintViewportBuffer(renderBuffer);
4030 }
4031
4032@@ -682,11 +683,18 @@
4033 if (!initialized)
4034 return;
4035
4036- int drawFbo;
4037- glGetIntegerv(GL_FRAMEBUFFER_BINDING, &drawFbo);
4038+ //find out which framebuffer is the current one
4039+ //this is usually NOT the "zero" FBO, but one provided by QOpenGLWidget
4040+ GLint drawFbo;
4041+ GL(gl->glGetIntegerv(GL_FRAMEBUFFER_BINDING, &drawFbo));
4042
4043 prepareRenderBuffer();
4044+ currentFbo = renderBuffer ? renderBuffer->handle() : drawFbo;
4045+
4046 core->preDraw();
4047+ // Clear areas not redrawn by main viewport (i.e. fisheye square viewport)
4048+ GL(gl->glClearColor(0,0,0,0));
4049+ GL(gl->glClear(GL_COLOR_BUFFER_BIT));
4050
4051 const QList<StelModule*> modules = moduleMgr->getCallOrders(StelModule::ActionDraw);
4052 foreach(StelModule* module, modules)
4053@@ -706,23 +714,24 @@
4054 /*************************************************************************
4055 Call this when the size of the GL window has changed
4056 *************************************************************************/
4057-void StelApp::glWindowHasBeenResized(float x, float y, float w, float h)
4058+void StelApp::glWindowHasBeenResized(const QRectF& rect)
4059 {
4060 if (core)
4061- core->windowHasBeenResized(x, y, w, h);
4062+ core->windowHasBeenResized(rect.x(), rect.y(), rect.width(), rect.height());
4063 else
4064 {
4065- saveProjW = w;
4066- saveProjH = h;
4067+ saveProjW = rect.width();
4068+ saveProjH = rect.height();
4069 }
4070 if (renderBuffer)
4071 {
4072+ ensureGLContextCurrent();
4073 delete renderBuffer;
4074 renderBuffer = NULL;
4075 }
4076 #ifdef ENABLE_SPOUT
4077 if (spoutSender)
4078- spoutSender->resize(w,h);
4079+ spoutSender->resize(rect.width(),rect.height());
4080 #endif
4081 }
4082
4083@@ -788,7 +797,7 @@
4084 }
4085
4086 // Handle mouse move
4087-void StelApp::handleMove(float x, float y, Qt::MouseButtons b)
4088+bool StelApp::handleMove(float x, float y, Qt::MouseButtons b)
4089 {
4090 if (viewportEffect)
4091 viewportEffect->distortXY(x, y);
4092@@ -796,8 +805,9 @@
4093 foreach (StelModule* i, moduleMgr->getCallOrders(StelModule::ActionHandleMouseMoves))
4094 {
4095 if (i->handleMouseMoves(x*devicePixelsPerPixel, y*devicePixelsPerPixel, b))
4096- return;
4097+ return true;
4098 }
4099+ return false;
4100 }
4101
4102 // Handle key press and release
4103@@ -857,6 +867,11 @@
4104 #endif
4105 }
4106
4107+void StelApp::ensureGLContextCurrent()
4108+{
4109+ mainWin->glContextMakeCurrent();
4110+}
4111+
4112 // Return the time since when stellarium is running in second.
4113 double StelApp::getTotalRunTime()
4114 {
4115@@ -907,6 +922,7 @@
4116 if (name == getViewportEffect()) return;
4117 if (renderBuffer)
4118 {
4119+ ensureGLContextCurrent();
4120 delete renderBuffer;
4121 renderBuffer = NULL;
4122 }
4123
4124=== modified file 'src/core/StelApp.hpp'
4125--- src/core/StelApp.hpp 2016-12-18 22:26:48 +0000
4126+++ src/core/StelApp.hpp 2017-01-12 21:08:38 +0000
4127@@ -30,9 +30,11 @@
4128 class StelObjectMgr;
4129 class StelLocaleMgr;
4130 class StelModuleMgr;
4131+class StelMainView;
4132 class StelSkyCultureMgr;
4133 class StelViewportEffect;
4134 class QOpenGLFramebufferObject;
4135+class QOpenGLFunctions;
4136 class QSettings;
4137 class QNetworkAccessManager;
4138 class QNetworkReply;
4139@@ -70,14 +72,14 @@
4140
4141 public:
4142 friend class StelAppGraphicsWidget;
4143- friend class StelSkyItem;
4144+ friend class StelRootItem;
4145
4146 //! Create and initialize the main Stellarium application.
4147 //! @param parent the QObject parent
4148 //! The configFile will be search for in the search path by the StelFileMgr,
4149 //! it is therefor possible to specify either just a file name or path within the
4150 //! search path, or use a full path or even a relative path to an existing file
4151- StelApp(QObject* parent=NULL);
4152+ StelApp(StelMainView* parent);
4153
4154 //! Deinitialize and destroy the main Stellarium application.
4155 virtual ~StelApp();
4156@@ -160,9 +162,6 @@
4157 // @return the max squared distance in pixels that any object has travelled since the last update.
4158 void draw();
4159
4160- //! Call this when the size of the GL window has changed.
4161- void glWindowHasBeenResized(float x, float y, float w, float h);
4162-
4163 //! Get the ratio between real device pixel and "Device Independent Pixel".
4164 //! Usually this value is 1, but for a mac with retina screen this will be value 2.
4165 float getDevicePixelsPerPixel() const {return devicePixelsPerPixel;}
4166@@ -212,6 +211,8 @@
4167 ///////////////////////////////////////////////////////////////////////////
4168 // Scriptable methods
4169 public slots:
4170+ //! Call this when the size of the GL window has changed.
4171+ void glWindowHasBeenResized(const QRectF &rect);
4172
4173 //! Set flag for activating night vision mode.
4174 void setVisionModeNight(bool);
4175@@ -240,6 +241,17 @@
4176 //! @return the FPS averaged on the last second
4177 float getFps() const {return fps;}
4178
4179+ //! Returns the default FBO handle, to be used when StelModule instances want to release their own FBOs.
4180+ //! Note that this is usually not the same as QOpenGLContext::defaultFramebufferObject(),
4181+ //! so use this call instead of the Qt version!
4182+ //! Valid through a StelModule::draw() call, do not use elsewhere.
4183+ quint32 getDefaultFBO() const { return currentFbo; }
4184+
4185+ //! Makes sure the correct GL context used for main drawing is made current.
4186+ //! This is always the case during init() and draw() calls, but if OpenGL access is required elsewhere,
4187+ //! this MUST be called before using any GL functions.
4188+ void ensureGLContextCurrent();
4189+
4190 //! Return the time since when stellarium is running in second.
4191 static double getTotalRunTime();
4192
4193@@ -263,7 +275,6 @@
4194 void progressBarRemoved(const StelProgressController*);
4195 //! Called just before we exit Qt mainloop.
4196 void aboutToQuit();
4197-
4198 private:
4199
4200 //! Handle mouse clics.
4201@@ -271,7 +282,7 @@
4202 //! Handle mouse wheel.
4203 void handleWheel(class QWheelEvent* event);
4204 //! Handle mouse move.
4205- void handleMove(float x, float y, Qt::MouseButtons b);
4206+ bool handleMove(float x, float y, Qt::MouseButtons b);
4207 //! Handle key press and release.
4208 void handleKeys(class QKeyEvent* event);
4209 //! Handle pinch on multi touch devices.
4210@@ -281,11 +292,14 @@
4211 void prepareRenderBuffer();
4212 //! Used internally to set the viewport effects.
4213 //! @param drawFbo the OpenGL fbo we need to render into.
4214- void applyRenderBuffer(int drawFbo=0);
4215+ void applyRenderBuffer(quint32 drawFbo=0);
4216
4217 // The StelApp singleton
4218 static StelApp* singleton;
4219
4220+ //! The main window which is the parent of this object
4221+ StelMainView* mainWin;
4222+
4223 // The associated StelCore instance
4224 StelCore* core;
4225
4226@@ -354,7 +368,7 @@
4227
4228 float fps;
4229 int frame;
4230- double timefr, timeBase; // Used for fps counter
4231+ double frameTimeAccum; // Used for fps counter
4232
4233 //! Define whether we are in night vision mode
4234 bool flagNightVision;
4235@@ -388,8 +402,8 @@
4236
4237 // Framebuffer object used for viewport effects.
4238 QOpenGLFramebufferObject* renderBuffer;
4239-
4240 StelViewportEffect* viewportEffect;
4241+ QOpenGLFunctions* gl;
4242
4243 bool flagShowDecimalDegrees;
4244 // flag to indicate we want calculate azimuth from south towards west (as in old astronomical literature)
4245@@ -398,6 +412,9 @@
4246 SpoutSender* spoutSender;
4247 #endif
4248
4249+ // The current main FBO/render target handle, without requiring GL queries. Valid through a draw() call
4250+ quint32 currentFbo;
4251+
4252 };
4253
4254 #endif // _STELAPP_HPP_
4255
4256=== modified file 'src/core/StelCore.cpp'
4257--- src/core/StelCore.cpp 2017-01-06 13:26:03 +0000
4258+++ src/core/StelCore.cpp 2017-01-12 21:08:38 +0000
4259@@ -244,6 +244,9 @@
4260 setCurrentProjectionTypeKey(getDefaultProjectionTypeKey());
4261 updateMaximumFov();
4262
4263+ // activate DE430/431
4264+ initEphemeridesFunctions();
4265+
4266 // Register all the core actions.
4267 QString timeGroup = N_("Date and Time");
4268 QString movementGroup = N_("Movement and Selection");
4269@@ -503,10 +506,6 @@
4270 currentProjectorParams.zFar = 500.;
4271
4272 skyDrawer->preDraw();
4273-
4274- // Clear areas not redrawn by main viewport (i.e. fisheye square viewport)
4275- glClearColor(0,0,0,0);
4276- glClear(GL_COLOR_BUFFER_BIT);
4277 }
4278
4279
4280
4281=== modified file 'src/core/StelOpenGL.cpp'
4282--- src/core/StelOpenGL.cpp 2014-06-11 15:48:31 +0000
4283+++ src/core/StelOpenGL.cpp 2017-01-12 21:08:38 +0000
4284@@ -16,10 +16,12 @@
4285 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
4286 */
4287
4288-#include <cstdio>
4289 #include "StelOpenGL.hpp"
4290-
4291-const char* getGLErrorText(int code) {
4292+#include <QDebug>
4293+
4294+QOpenGLContext* StelOpenGL::mainContext = NULL;
4295+
4296+const char* StelOpenGL::getGLErrorText(GLenum code) {
4297 switch (code) {
4298 case GL_INVALID_ENUM:
4299 return "GL_INVALID_ENUM";
4300@@ -32,20 +34,18 @@
4301 case GL_OUT_OF_MEMORY:
4302 return "GL_OUT_OF_MEMORY";
4303 default:
4304- return "undefined error";
4305+ return "unknown GL error type";
4306 }
4307 }
4308
4309-int checkGLErrors(const char *file, int line)
4310+int StelOpenGL::checkGLErrors(const char *file, int line)
4311 {
4312 int errors = 0;
4313- while (true)
4314+ for(GLenum x; (x=mainContext->functions()->glGetError())!=GL_NO_ERROR; )
4315 {
4316- GLenum x = glGetError();
4317- if (x == GL_NO_ERROR)
4318- return errors;
4319- printf("%s:%d: OpenGL error: %d (%s)\n",
4320- file, line, x, getGLErrorText(x));
4321- errors++;
4322+ ++errors;
4323+ qCritical("%s:%d: OpenGL error: %d (%s)\n",
4324+ file, line, x, getGLErrorText(x));
4325 }
4326+ return errors;
4327 }
4328
4329=== modified file 'src/core/StelOpenGL.hpp'
4330--- src/core/StelOpenGL.hpp 2016-12-10 10:33:35 +0000
4331+++ src/core/StelOpenGL.hpp 2017-01-12 21:08:38 +0000
4332@@ -1,6 +1,7 @@
4333 /*
4334 * Stellarium
4335 * Copyright (C) 2014 Fabien Chereau
4336+ * Copyright (C) 2016 Florian Schaukowitsch
4337 *
4338 * This program is free software; you can redistribute it and/or
4339 * modify it under the terms of the GNU General Public License
4340@@ -20,185 +21,29 @@
4341 #ifndef _STELOPENGL_HPP_
4342 #define _STELOPENGL_HPP_
4343
4344-#define GL_GLEXT_PROTOTYPES
4345-#include <qopengl.h>
4346-
4347 #include <QOpenGLFunctions>
4348
4349-// On windows without ANGLE support, we should not directly call some
4350-// of the OpenGL functions, instead we have to use QOpenGLFunctions.
4351-//
4352-// Here we replace the functions with a macro that will invoke the proper
4353-// calls.
4354-#if defined(Q_OS_WIN) && !defined(Q_NO_OPENGL)
4355-# define GLFUNC_(x) QOpenGLContext::currentContext()->functions()->x
4356-#else
4357-# define GLFUNC_(x) x
4358-#endif
4359-
4360-#define glActiveTexture(...) GLFUNC_(glActiveTexture(__VA_ARGS__))
4361-#define glAttachShader(...) GLFUNC_(glAttachShader(__VA_ARGS__))
4362-#define glBindAttribLocation(...) GLFUNC_(glBindAttribLocation(__VA_ARGS__))
4363-#define glBindBuffer(...) GLFUNC_(glBindBuffer(__VA_ARGS__))
4364-#define glBindFramebuffer(...) GLFUNC_(glBindFramebuffer(__VA_ARGS__))
4365-#define glBindRenderbuffer(...) GLFUNC_(glBindRenderbuffer(__VA_ARGS__))
4366-#define glBlendColor(...) GLFUNC_(glBlendColor(__VA_ARGS__))
4367-#define glBlendEquation(...) GLFUNC_(glBlendEquation(__VA_ARGS__))
4368-#define glBlendEquationSeparate(...) GLFUNC_(glBlendEquationSeparate(__VA_ARGS__))
4369-#define glBlendFuncSeparate(...) GLFUNC_(glBlendFuncSeparate(__VA_ARGS__))
4370-#define glBufferData(...) GLFUNC_(glBufferData(__VA_ARGS__))
4371-#define glBufferSubData(...) GLFUNC_(glBufferSubData(__VA_ARGS__))
4372-#define glCheckFramebufferStatus(...) GLFUNC_(glCheckFramebufferStatus(__VA_ARGS__))
4373-#define glClearDepthf(...) GLFUNC_(glClearDepthf(__VA_ARGS__))
4374-#define glCompileShader(...) GLFUNC_(glCompileShader(__VA_ARGS__))
4375-#define glCompressedTexImage2D(...) GLFUNC_(glCompressedTexImage2D(__VA_ARGS__))
4376-#define glCompressedTexSubImage2D(...) GLFUNC_(glCompressedTexSubImage2D(__VA_ARGS__))
4377-#define glCopyTexSubImage2D(...) GLFUNC_(glCopyTexSubImage2D(__VA_ARGS__)) // new for spout
4378-#define glCreateProgram(...) GLFUNC_(glCreateProgram(__VA_ARGS__))
4379-#define glCreateShader(...) GLFUNC_(glCreateShader(__VA_ARGS__))
4380-#define glDeleteBuffers(...) GLFUNC_(glDeleteBuffers(__VA_ARGS__))
4381-#define glDeleteFramebuffers(...) GLFUNC_(glDeleteFramebuffers(__VA_ARGS__))
4382-#define glDeleteProgram(...) GLFUNC_(glDeleteProgram(__VA_ARGS__))
4383-#define glDeleteRenderbuffers(...) GLFUNC_(glDeleteRenderbuffers(__VA_ARGS__))
4384-#define glDeleteShader(...) GLFUNC_(glDeleteShader(__VA_ARGS__))
4385-#define glDepthRangef(...) GLFUNC_(glDepthRangef(__VA_ARGS__))
4386-#define glDetachShader(...) GLFUNC_(glDetachShader(__VA_ARGS__))
4387-#define glDisableVertexAttribArray(...) GLFUNC_(glDisableVertexAttribArray(__VA_ARGS__))
4388-#define glEnableVertexAttribArray(...) GLFUNC_(glEnableVertexAttribArray(__VA_ARGS__))
4389-#define glFramebufferRenderbuffer(...) GLFUNC_(glFramebufferRenderbuffer(__VA_ARGS__))
4390-#define glFramebufferTexture2D(...) GLFUNC_(glFramebufferTexture2D(__VA_ARGS__))
4391-#define glGenBuffers(...) GLFUNC_(glGenBuffers(__VA_ARGS__))
4392-#define glGenerateMipmap(...) GLFUNC_(glGenerateMipmap(__VA_ARGS__))
4393-#define glGenFramebuffers(...) GLFUNC_(glGenFramebuffers(__VA_ARGS__))
4394-#define glGenRenderbuffers(...) GLFUNC_(glGenRenderbuffers(__VA_ARGS__))
4395-#define glGetActiveAttrib(...) GLFUNC_(glGetActiveAttrib(__VA_ARGS__))
4396-#define glGetActiveUniform(...) GLFUNC_(glGetActiveUniform(__VA_ARGS__))
4397-#define glGetAttachedShaders(...) GLFUNC_(glGetAttachedShaders(__VA_ARGS__))
4398-#define glGetAttribLocation(...) GLFUNC_(glGetAttribLocation(__VA_ARGS__))
4399-#define glGetBufferParameteriv(...) GLFUNC_(glGetBufferParameteriv(__VA_ARGS__))
4400-#define glGetFramebufferAttachmentParameteriv(...) GLFUNC_(glGetFramebufferAttachmentParameteriv(__VA_ARGS__))
4401-#define glGetProgramiv(...) GLFUNC_(glGetProgramiv(__VA_ARGS__))
4402-#define glGetProgramInfoLog(...) GLFUNC_(glGetProgramInfoLog(__VA_ARGS__))
4403-#define glGetRenderbufferParameteriv(...) GLFUNC_(glGetRenderbufferParameteriv(__VA_ARGS__))
4404-#define glGetShaderiv(...) GLFUNC_(glGetShaderiv(__VA_ARGS__))
4405-#define glGetShaderInfoLog(...) GLFUNC_(glGetShaderInfoLog(__VA_ARGS__))
4406-#define glGetShaderPrecisionFormat(...) GLFUNC_(glGetShaderPrecisionFormat(__VA_ARGS__))
4407-#define glGetShaderSource(...) GLFUNC_(glGetShaderSource(__VA_ARGS__))
4408-#define glGetUniformfv(...) GLFUNC_(glGetUniformfv(__VA_ARGS__))
4409-#define glGetUniformiv(...) GLFUNC_(glGetUniformiv(__VA_ARGS__))
4410-#define glGetUniformLocation(...) GLFUNC_(glGetUniformLocation(__VA_ARGS__))
4411-#define glGetVertexAttribfv(...) GLFUNC_(glGetVertexAttribfv(__VA_ARGS__))
4412-#define glGetVertexAttribiv(...) GLFUNC_(glGetVertexAttribiv(__VA_ARGS__))
4413-#define glGetVertexAttribPointerv(...) GLFUNC_(glGetVertexAttribPointerv(__VA_ARGS__))
4414-#define glIsBuffer(...) GLFUNC_(glIsBuffer(__VA_ARGS__))
4415-#define glIsFramebuffer(...) GLFUNC_(glIsFramebuffer(__VA_ARGS__))
4416-#define glIsProgram(...) GLFUNC_(glIsProgram(__VA_ARGS__))
4417-#define glIsRenderbuffer(...) GLFUNC_(glIsRenderbuffer(__VA_ARGS__))
4418-#define glIsShader(...) GLFUNC_(glIsShader(__VA_ARGS__))
4419-#define glLinkProgram(...) GLFUNC_(glLinkProgram(__VA_ARGS__))
4420-#define glProgramParameteri(...) GLFUNC_(glProgramParameteri(__VA_ARGS__)) // GZ TRIAL
4421-#define glProgramParameteriEXT(...) GLFUNC_(glProgramParameteriEXT(__VA_ARGS__)) // GZ TRIAL
4422-#define glReleaseShaderCompiler(...) GLFUNC_(glReleaseShaderCompiler(__VA_ARGS__))
4423-#define glRenderbufferStorage(...) GLFUNC_(glRenderbufferStorage(__VA_ARGS__))
4424-#define glSampleCoverage(...) GLFUNC_(glSampleCoverage(__VA_ARGS__))
4425-#define glShaderBinary(...) GLFUNC_(glShaderBinary(__VA_ARGS__))
4426-#define glShaderSource(...) GLFUNC_(glShaderSource(__VA_ARGS__))
4427-#define glStencilFuncSeparate(...) GLFUNC_(glStencilFuncSeparate(__VA_ARGS__))
4428-#define glStencilMaskSeparate(...) GLFUNC_(glStencilMaskSeparate(__VA_ARGS__))
4429-#define glStencilOpSeparate(...) GLFUNC_(glStencilOpSeparate(__VA_ARGS__))
4430-#define glUniform1f(...) GLFUNC_(glUniform1f(__VA_ARGS__))
4431-#define glUniform1fv(...) GLFUNC_(glUniform1fv(__VA_ARGS__))
4432-#define glUniform1i(...) GLFUNC_(glUniform1i(__VA_ARGS__))
4433-#define glUniform1iv(...) GLFUNC_(glUniform1iv(__VA_ARGS__))
4434-#define glUniform2f(...) GLFUNC_(glUniform2f(__VA_ARGS__))
4435-#define glUniform2fv(...) GLFUNC_(glUniform2fv(__VA_ARGS__))
4436-#define glUniform2i(...) GLFUNC_(glUniform2i(__VA_ARGS__))
4437-#define glUniform2iv(...) GLFUNC_(glUniform2iv(__VA_ARGS__))
4438-#define glUniform3f(...) GLFUNC_(glUniform3f(__VA_ARGS__))
4439-#define glUniform3fv(...) GLFUNC_(glUniform3fv(__VA_ARGS__))
4440-#define glUniform3i(...) GLFUNC_(glUniform3i(__VA_ARGS__))
4441-#define glUniform3iv(...) GLFUNC_(glUniform3iv(__VA_ARGS__))
4442-#define glUniform4f(...) GLFUNC_(glUniform4f(__VA_ARGS__))
4443-#define glUniform4fv(...) GLFUNC_(glUniform4fv(__VA_ARGS__))
4444-#define glUniform4i(...) GLFUNC_(glUniform4i(__VA_ARGS__))
4445-#define glUniform4iv(...) GLFUNC_(glUniform4iv(__VA_ARGS__))
4446-#define glUniformMatrix2fv(...) GLFUNC_(glUniformMatrix2fv(__VA_ARGS__))
4447-#define glUniformMatrix3fv(...) GLFUNC_(glUniformMatrix3fv(__VA_ARGS__))
4448-#define glUniformMatrix4fv(...) GLFUNC_(glUniformMatrix4fv(__VA_ARGS__))
4449-#define glUseProgram(...) GLFUNC_(glUseProgram(__VA_ARGS__))
4450-#define glValidateProgram(...) GLFUNC_(glValidateProgram(__VA_ARGS__))
4451-#define glVertexAttrib1f(...) GLFUNC_(glVertexAttrib1f(__VA_ARGS__))
4452-#define glVertexAttrib1fv(...) GLFUNC_(glVertexAttrib1fv(__VA_ARGS__))
4453-#define glVertexAttrib2f(...) GLFUNC_(glVertexAttrib2f(__VA_ARGS__))
4454-#define glVertexAttrib2fv(...) GLFUNC_(glVertexAttrib2fv(__VA_ARGS__))
4455-#define glVertexAttrib3f(...) GLFUNC_(glVertexAttrib3f(__VA_ARGS__))
4456-#define glVertexAttrib3fv(...) GLFUNC_(glVertexAttrib3fv(__VA_ARGS__))
4457-#define glVertexAttrib4f(...) GLFUNC_(glVertexAttrib4f(__VA_ARGS__))
4458-#define glVertexAttrib4fv(...) GLFUNC_(glVertexAttrib4fv(__VA_ARGS__))
4459-#define glVertexAttribPointer(...) GLFUNC_(glVertexAttribPointer(__VA_ARGS__))
4460-
4461-#if QT_VERSION >= QT_VERSION_CHECK(5, 3, 0)
4462-#define glGetString(...) GLFUNC_(glGetString(__VA_ARGS__))
4463-#endif
4464-
4465-#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
4466-#define glBindTexture(...) GLFUNC_(glBindTexture(__VA_ARGS__))
4467-#define glBlendFunc(...) GLFUNC_(glBlendFunc(__VA_ARGS__))
4468-#define glClear(...) GLFUNC_(glClear(__VA_ARGS__))
4469-#define glClearColor(...) GLFUNC_(glClearColor(__VA_ARGS__))
4470-#define glCullFace(...) GLFUNC_(glCullFace(__VA_ARGS__))
4471-#define glDeleteTextures(...) GLFUNC_(glDeleteTextures(__VA_ARGS__))
4472-#define glDepthMask(...) GLFUNC_(glDepthMask(__VA_ARGS__))
4473-#define glDisable(...) GLFUNC_(glDisable(__VA_ARGS__))
4474-#define glDrawArrays(...) GLFUNC_(glDrawArrays(__VA_ARGS__))
4475-#define glDrawElements(...) GLFUNC_(glDrawElements(__VA_ARGS__))
4476-#define glEnable(...) GLFUNC_(glEnable(__VA_ARGS__))
4477-#define glGenTextures(...) GLFUNC_(glGenTextures(__VA_ARGS__))
4478-#define glGetError(...) GLFUNC_(glGetError(__VA_ARGS__))
4479-#define glGetIntegerv(...) GLFUNC_(glGetIntegerv(__VA_ARGS__))
4480-#define glFrontFace(...) GLFUNC_(glFrontFace(__VA_ARGS__))
4481-#define glIsEnabled(...) GLFUNC_(glIsEnabled(__VA_ARGS__))
4482-#define glIsTexture(...) GLFUNC_(glIsTexture(__VA_ARGS__))
4483-#define glLineWidth(...) GLFUNC_(glLineWidth(__VA_ARGS__))
4484-#define glPixelStorei(...) GLFUNC_(glPixelStorei(__VA_ARGS__))
4485-#define glPolygonOffset(...) GLFUNC_(glPolygonOffset(__VA_ARGS__))
4486-#define glStencilMask(...) GLFUNC_(glStencilMask(__VA_ARGS__))
4487-#define glTexImage2D(...) GLFUNC_(glTexImage2D(__VA_ARGS__))
4488-#define glTexParameterf(...) GLFUNC_(glTexParameterf(__VA_ARGS__))
4489-#define glTexParameterfv(...) GLFUNC_(glTexParameterfv(__VA_ARGS__))
4490-#define glTexParameteri(...) GLFUNC_(glTexParameteri(__VA_ARGS__))
4491-#define glTexParameteriv(...) GLFUNC_(glTexParameteriv(__VA_ARGS__))
4492-#define glViewport(...) GLFUNC_(glViewport(__VA_ARGS__))
4493-#endif
4494-
4495-#ifndef NDEBUG
4496+#ifndef QT_NO_DEBUG
4497 # define GL(line) do { \
4498+ /*for debugging, we make sure we use our main context*/\
4499+ Q_ASSERT(StelOpenGL::mainContext == QOpenGLContext::currentContext());\
4500 line;\
4501- if (checkGLErrors(__FILE__, __LINE__))\
4502- exit(-1);\
4503+ Q_ASSERT_X(!StelOpenGL::checkGLErrors(__FILE__, __LINE__), "GL macro", "OpenGL errors encountered");\
4504 } while(0)
4505 #else
4506 # define GL(line) line
4507 #endif
4508
4509-// In ANGLE and other OpenGL ES systems, GL_LINE_SMOOTH is undefined.
4510-// We can define it here to not break compilation, but must test for real OpenGL context before calling.
4511-# ifndef GL_LINE_SMOOTH
4512-# define GL_LINE_SMOOTH 0x0B20
4513-# endif
4514-
4515-const char* getGLErrorText(int code);
4516-int checkGLErrors(const char *file, int line);
4517-
4518-// To build on arm platforms we need to re-introduce the Qt 5.4 removed
4519-// typedefs and defines of GLdouble/GL_DOUBLE, which are not present in GLES
4520-#if defined(QT_OPENGL_ES_2)
4521-# ifndef GL_DOUBLE
4522-# define GL_DOUBLE GL_FLOAT
4523-# endif
4524-# ifndef GLdouble
4525-typedef double GLdouble;
4526-# endif
4527-#endif
4528+//! Namespace containing some OpenGL helpers
4529+namespace StelOpenGL
4530+{
4531+ //! The main context as created by the StelMainView (only used for debugging)
4532+ extern QOpenGLContext* mainContext;
4533+
4534+ //! Converts a GLenum from glGetError to a string
4535+ const char* getGLErrorText(GLenum code);
4536+ //! Retrieves and prints all current OpenGL errors to console (glGetError in a loop)
4537+ int checkGLErrors(const char *file, int line);
4538+}
4539
4540 #endif // _STELOPENGL_HPP_
4541
4542=== modified file 'src/core/StelPainter.cpp'
4543--- src/core/StelPainter.cpp 2017-01-06 16:52:05 +0000
4544+++ src/core/StelPainter.cpp 2017-01-12 21:08:38 +0000
4545@@ -55,26 +55,50 @@
4546 StelPainter::BasicShaderVars StelPainter::colorShaderVars;
4547 StelPainter::TexturesColorShaderVars StelPainter::texturesColorShaderVars;
4548
4549-StelPainter::GLState::GLState()
4550-{
4551- blend = glIsEnabled(GL_BLEND);
4552- glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRGB);
4553- glGetIntegerv(GL_BLEND_DST_RGB, &blendDstRGB);
4554- glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha);
4555- glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDstAlpha);
4556-}
4557-
4558-StelPainter::GLState::~GLState()
4559-{
4560- if (blend)
4561- {
4562- glEnable(GL_BLEND);
4563- glBlendFuncSeparate(blendSrcRGB, blendDstRGB, blendSrcAlpha, blendDstAlpha);
4564- }
4565- else
4566- {
4567- glDisable(GL_BLEND);
4568- }
4569+StelPainter::GLState::GLState(QOpenGLFunctions* gl)
4570+ : blend(false),
4571+ blendSrc(GL_SRC_ALPHA), blendDst(GL_ONE_MINUS_SRC_ALPHA),
4572+ depthTest(false),
4573+ depthMask(false),
4574+ cullFace(false),
4575+ lineSmooth(false),
4576+ lineWidth(1.0f),
4577+ gl(gl)
4578+{
4579+
4580+}
4581+
4582+void StelPainter::GLState::apply()
4583+{
4584+ if(blend)
4585+ gl->glEnable(GL_BLEND);
4586+ else
4587+ gl->glDisable(GL_BLEND);
4588+ gl->glBlendFunc(blendSrc,blendDst);
4589+ if(depthTest)
4590+ gl->glEnable(GL_DEPTH_TEST);
4591+ else
4592+ gl->glDisable(GL_DEPTH_TEST);
4593+ gl->glDepthMask(depthMask);
4594+ if(cullFace)
4595+ gl->glEnable(GL_CULL_FACE);
4596+ else
4597+ gl->glDisable(GL_CULL_FACE);
4598+#ifdef GL_LINE_SMOOTH
4599+ if(!QOpenGLContext::currentContext()->isOpenGLES())
4600+ {
4601+ if (lineSmooth)
4602+ gl->glEnable(GL_LINE_SMOOTH);
4603+ else
4604+ gl->glDisable(GL_LINE_SMOOTH);
4605+ }
4606+#endif
4607+}
4608+
4609+void StelPainter::GLState::reset()
4610+{
4611+ *this = GLState(gl);
4612+ apply();
4613 }
4614
4615 bool StelPainter::linkProg(QOpenGLShaderProgram* prog, const QString& name)
4616@@ -85,7 +109,7 @@
4617 return ret;
4618 }
4619
4620-StelPainter::StelPainter(const StelProjectorP& proj) : prj(proj)
4621+StelPainter::StelPainter(const StelProjectorP& proj) : QOpenGLFunctions(QOpenGLContext::currentContext()), glState(this)
4622 {
4623 Q_ASSERT(proj);
4624
4625@@ -106,13 +130,10 @@
4626 }
4627 #endif
4628
4629- glDisable(GL_DEPTH_TEST);
4630- glDisable(GL_CULL_FACE);
4631+ //TODO: is this still required, and is there some Qt way to fix it? 0x11111111 is a bit peculiar, how was it chosen?
4632 // Fix some problem when using Qt OpenGL2 engine
4633 glStencilMask(0x11111111);
4634- // Deactivate drawing in depth buffer by default
4635- glDepthMask(GL_FALSE);
4636- enableTexture2d(false);
4637+ glState.apply(); //apply default OpenGL state
4638 setProjector(proj);
4639 }
4640
4641@@ -126,6 +147,9 @@
4642
4643 StelPainter::~StelPainter()
4644 {
4645+ //reset opengl state
4646+ glState.reset();
4647+
4648 #ifndef NDEBUG
4649 GLenum er = glGetError();
4650 if (er!=GL_NO_ERROR)
4651@@ -160,6 +184,87 @@
4652 return QFontMetrics(currentFont);
4653 }
4654
4655+void StelPainter::setBlending(bool enableBlending, GLenum blendSrc, GLenum blendDst)
4656+{
4657+ if(enableBlending != glState.blend)
4658+ {
4659+ glState.blend = enableBlending;
4660+ if(enableBlending)
4661+ glEnable(GL_BLEND);
4662+ else
4663+ glDisable(GL_BLEND);
4664+ }
4665+ if(enableBlending)
4666+ {
4667+ if(blendSrc!=glState.blendSrc||blendDst!=glState.blendDst)
4668+ {
4669+ glState.blendSrc = blendSrc;
4670+ glState.blendDst = blendDst;
4671+ glBlendFunc(blendSrc,blendDst);
4672+ }
4673+ }
4674+}
4675+
4676+void StelPainter::setDepthTest(bool enable)
4677+{
4678+ if(glState.depthTest != enable)
4679+ {
4680+ glState.depthTest = enable;
4681+ if(enable)
4682+ glEnable(GL_DEPTH_TEST);
4683+ else
4684+ glDisable(GL_DEPTH_TEST);
4685+ }
4686+}
4687+
4688+void StelPainter::setDepthMask(bool enable)
4689+{
4690+ if(glState.depthMask != enable)
4691+ {
4692+ glState.depthMask = enable;
4693+ if(enable)
4694+ glDepthMask(GL_TRUE);
4695+ else
4696+ glDepthMask(GL_FALSE);
4697+ }
4698+}
4699+
4700+void StelPainter::setCullFace(bool enable)
4701+{
4702+ if(glState.cullFace!=enable)
4703+ {
4704+ glState.cullFace = enable;
4705+ if(enable)
4706+ glEnable(GL_CULL_FACE);
4707+ else
4708+ glDisable(GL_CULL_FACE);
4709+ }
4710+}
4711+
4712+void StelPainter::setLineSmooth(bool enable)
4713+{
4714+#ifdef GL_LINE_SMOOTH
4715+ if (!QOpenGLContext::currentContext()->isOpenGLES() && enable!=glState.lineSmooth)
4716+ {
4717+ glState.lineSmooth = enable;
4718+ if(enable)
4719+ glEnable(GL_LINE_SMOOTH);
4720+ else
4721+ glDisable(GL_LINE_SMOOTH);
4722+ }
4723+#else
4724+ Q_UNUSED(enable); //noop
4725+#endif
4726+}
4727+
4728+void StelPainter::setLineWidth(float width)
4729+{
4730+ if(glState.lineWidth != width)
4731+ {
4732+ glState.lineWidth = width;
4733+ glLineWidth(width);
4734+ }
4735+}
4736
4737 ///////////////////////////////////////////////////////////////////////////
4738 // Standard methods for drawing primitives
4739@@ -170,6 +275,7 @@
4740 if (prj->maskType != StelProjector::MaskDisk)
4741 return;
4742
4743+ bool oldBlendState = glState.blend;
4744 glDisable(GL_BLEND);
4745 setColor(0.f,0.f,0.f);
4746
4747@@ -219,6 +325,8 @@
4748 }
4749 drawFromArray(TriangleStrip, (slices+1)*2, 0, false);
4750 enableClientStates(false);
4751+ if(oldBlendState)
4752+ glEnable(GL_BLEND);
4753 }
4754
4755 void StelPainter::computeFanDisk(float radius, int innerFanSlices, int level, QVector<double>& vertexArr, QVector<float>& texCoordArr)
4756@@ -530,7 +638,6 @@
4757
4758 void StelPainter::drawText(float x, float y, const QString& str, float angleDeg, float xshift, float yshift, bool noGravity)
4759 {
4760- //StelPainter::GLState state; // Will restore the opengl state at the end of the function.
4761 if (prj->gravityLabels && !noGravity)
4762 {
4763 drawTextGravity180(x, y, str, xshift, yshift);
4764@@ -545,7 +652,6 @@
4765 angleDeg += prj->defaultAngleForGravityText;
4766 tex->texture->bind();
4767
4768- enableTexture2d(true);
4769 static float vertexData[8];
4770 // compute the vertex coordinates applying the translation and the rotation
4771 static const float vertexBase[] = {0., 0., 1., 0., 0., 1., 1., 1.};
4772@@ -579,11 +685,15 @@
4773 texCoords[i*2+1] = tex->getTexSize().height() * (1 - i / 2);
4774 }
4775 setTexCoordPointer(2, GL_FLOAT, texCoords);
4776- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
4777- glEnable(GL_BLEND);
4778+
4779+ //text drawing requires blending, but we reset GL state afterwards if necessary
4780+ bool oldBlending = glState.blend;
4781+ GLenum oldSrc = glState.blendSrc, oldDst = glState.blendDst;
4782+ setBlending(true);
4783 enableClientStates(true, true);
4784 setVertexPointer(2, GL_FLOAT, vertexData);
4785 drawFromArray(TriangleStrip, 4, 0, false);
4786+ setBlending(oldBlending, oldSrc, oldDst);
4787 enableClientStates(false, false);
4788 tex->texture->release();
4789 delete[] texCoords;
4790@@ -598,7 +708,6 @@
4791 // painter.setFont(currentFont);
4792
4793 QPainter painter(&device);
4794- painter.beginNativePainting();
4795
4796 QFont tmpFont = currentFont;
4797 tmpFont.setPixelSize(currentFont.pixelSize()*prj->getDevicePixelsPerPixel()*StelApp::getInstance().getGlobalScalingRatio());
4798@@ -629,7 +738,11 @@
4799 painter.drawText(x+xshift, y+yshift, str);
4800 }
4801
4802- painter.endNativePainting();
4803+ //important to call this before GL state restore
4804+ painter.end();
4805+
4806+ //QPainter messes up some GL state, begin/endNativePainting or save/restore does not help
4807+ glState.apply();
4808 }
4809 }
4810
4811@@ -1462,6 +1575,8 @@
4812 if (!prj->getBoundingCap().intersects(poly->getBoundingCap()))
4813 return;
4814
4815+ bool oldCullFace = glState.cullFace;
4816+
4817 switch (drawMode)
4818 {
4819 case SphericalPolygonDrawModeBoundary:
4820@@ -1473,7 +1588,7 @@
4821 case SphericalPolygonDrawModeFill:
4822 case SphericalPolygonDrawModeTextureFill:
4823 case SphericalPolygonDrawModeTextureFillColormodulated:
4824- glEnable(GL_CULL_FACE);
4825+ setCullFace(true);
4826 // The polygon is already tesselated as triangles
4827 if (doSubDivise || prj->intersectViewportDiscontinuity(poly->getBoundingCap()))
4828 // flag for color-modulated textured mode (e.g. for Milky Way/extincted)
4829@@ -1481,7 +1596,7 @@
4830 else
4831 drawStelVertexArray(poly->getFillVertexArray(), false);
4832
4833- glDisable(GL_CULL_FACE);
4834+ setCullFace(oldCullFace);
4835 break;
4836 default:
4837 Q_ASSERT(0);
4838@@ -1822,11 +1937,6 @@
4839 glCullFace(GL_BACK);
4840 }
4841
4842-void StelPainter::enableTexture2d(bool b)
4843-{
4844- texture2dEnabled = b;
4845-}
4846-
4847 void StelPainter::initGLShaders()
4848 {
4849 qDebug() << "Initializing basic GL shaders... ";
4850
4851=== modified file 'src/core/StelPainter.hpp'
4852--- src/core/StelPainter.hpp 2016-05-01 05:52:39 +0000
4853+++ src/core/StelPainter.hpp 2017-01-12 21:08:38 +0000
4854@@ -1,4 +1,4 @@
4855-/*
4856+/*
4857 * Stellarium
4858 * Copyright (C) 2008 Fabien Chereau
4859 *
4860@@ -37,7 +37,7 @@
4861 //! Because openGL is not thread safe, only one instance of StelPainter can exist at a time, enforcing thread safety.
4862 //! As a coding rule, no openGL calls should be performed when no instance of StelPainter exist.
4863 //! Typical usage is to create a local instance of StelPainter where drawing operations are needed.
4864-class StelPainter
4865+class StelPainter : protected QOpenGLFunctions
4866 {
4867 public:
4868 friend class VertexArrayProjector;
4869@@ -66,6 +66,11 @@
4870 explicit StelPainter(const StelProjectorP& prj);
4871 ~StelPainter();
4872
4873+ //! Returns a QOpenGLFunctions object suitable for drawing directly with OpenGL while this StelPainter is active.
4874+ //! This is recommended to be used instead of QOpenGLContext::currentContext()->functions() when a StelPainter is available,
4875+ //! and you only need to call a few GL functions directly.
4876+ inline QOpenGLFunctions* glFuncs() { return this; }
4877+
4878 //! Return the instance of projector associated to this painter
4879 const StelProjectorP& getProjector() const {return prj;}
4880 void setProjector(const StelProjectorP& p);
4881@@ -227,6 +232,25 @@
4882 //! Get the font metrics for the current font.
4883 QFontMetrics getFontMetrics() const;
4884
4885+ //! Enable OpenGL blending. By default, blending is disabled.
4886+ //! The additional parameters specify the blending mode, the default parameters are suitable for
4887+ //! "normal" blending operations that you want in most cases. Blending will be automatically disabled when
4888+ //! the StelPainter is destroyed.
4889+ void setBlending(bool enableBlending, GLenum blendSrc = GL_SRC_ALPHA, GLenum blendDst = GL_ONE_MINUS_SRC_ALPHA);
4890+
4891+ void setDepthTest(bool enable);
4892+
4893+ void setDepthMask(bool enable);
4894+
4895+ //! Set the OpenGL GL_CULL_FACE state, by default face culling is disabled
4896+ void setCullFace(bool enable);
4897+
4898+ //! Enables/disables line smoothing. By default, smoothing is disabled.
4899+ void setLineSmooth(bool enable);
4900+
4901+ //! Sets the line width. Default is 1.0f.
4902+ void setLineWidth(float width);
4903+
4904 //! Create the OpenGL shaders programs used by the StelPainter.
4905 //! This method needs to be called once at init.
4906 static void initGLShaders();
4907@@ -235,9 +259,6 @@
4908 //! This method needs to be called once before exit.
4909 static void deinitGLShaders();
4910
4911- //! Set whether texturing is enabled.
4912- void enableTexture2d(bool b);
4913-
4914 // Thoses methods should eventually be replaced by a single setVertexArray
4915 //! use instead of glVertexPointer
4916 void setVertexPointer(int size, int type, const void* pointer) {
4917@@ -262,7 +283,7 @@
4918 normalArray.size = 3; normalArray.type = type; normalArray.pointer = pointer;
4919 }
4920
4921- //! use instead of glEnableClient
4922+ //! Simulates glEnableClientState, basically you describe what data the ::drawFromArray call has available
4923 void enableClientStates(bool vertex, bool texture=false, bool color=false, bool normal=false);
4924
4925 //! convenience method that enable and set all the given arrays.
4926@@ -290,17 +311,27 @@
4927 friend class StelTextureMgr;
4928 friend class StelTexture;
4929
4930- //! RAII class used to store and restore the opengl state.
4931- //! to use it we just need to instanciate it at the beginning of a method that might change the state.
4932- class GLState
4933+ //! Helper struct to track the GL state and restore it to canonical values on StelPainter creation/destruction
4934+ struct GLState
4935 {
4936- public:
4937- GLState();
4938- ~GLState();
4939+ GLState(QOpenGLFunctions *gl);
4940+
4941+ bool blend;
4942+ GLenum blendSrc, blendDst;
4943+ bool depthTest;
4944+ bool depthMask;
4945+ bool cullFace;
4946+ bool lineSmooth;
4947+ GLfloat lineWidth;
4948+
4949+ //! Applies the values stored here to set the GL state
4950+ void apply();
4951+ //! Resets the state to the default values (like a GLState was newly constructed)
4952+ //! and calls apply()
4953+ void reset();
4954 private:
4955- bool blend;
4956- int blendSrcRGB, blendDstRGB, blendSrcAlpha, blendDstAlpha;
4957- };
4958+ QOpenGLFunctions* gl;
4959+ } glState;
4960
4961 // From text-use-opengl-buffer
4962 static QCache<QByteArray, struct StringTexture> texCache;
4963@@ -352,7 +383,6 @@
4964 QFont currentFont;
4965
4966 Vec4f currentColor;
4967- bool texture2dEnabled;
4968
4969 static QOpenGLShaderProgram* basicShaderProgram;
4970 struct BasicShaderVars {
4971
4972=== modified file 'src/core/StelSkyDrawer.cpp'
4973--- src/core/StelSkyDrawer.cpp 2017-01-06 02:19:00 +0000
4974+++ src/core/StelSkyDrawer.cpp 2017-01-12 21:08:38 +0000
4975@@ -17,12 +17,6 @@
4976 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
4977 */
4978
4979-#ifndef GL_POINT_SPRITE
4980- #define GL_POINT_SPRITE 0x8861
4981-#endif
4982-#ifndef GL_VERTEX_PROGRAM_POINT_SIZE
4983- #define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
4984-#endif
4985
4986 #include "StelSkyDrawer.hpp"
4987 #include "StelProjector.hpp"
4988@@ -156,6 +150,8 @@
4989 // Init parameters from config file
4990 void StelSkyDrawer::init()
4991 {
4992+ initializeOpenGLFunctions();
4993+
4994 // Load star texture no mipmap:
4995 texHalo = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/star16x16.png");
4996 texBigHalo = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/haloLune.png");
4997@@ -382,9 +378,7 @@
4998
4999 // Blending is really important. Otherwise faint stars in the vicinity of
5000 // bright star will cause tiny black squares on the bright star, e.g. see Procyon.
The diff has been truncated for viewing.