File tree 2 files changed +30
-0
lines changed
2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -210,6 +210,24 @@ void ProjectLoader::timerEvent(QTimerEvent *event)
210
210
return ;
211
211
212
212
if (m_engine) {
213
+ QOpenGLContext *oldCtx = QOpenGLContext::currentContext ();
214
+ QSurface *oldSurface = nullptr ;
215
+
216
+ if (!m_glCtx)
217
+ m_glCtx = oldCtx;
218
+
219
+ if (m_glCtx) {
220
+ if (!m_surface)
221
+ m_surface = m_glCtx->surface ();
222
+
223
+ oldSurface = oldCtx->surface ();
224
+
225
+ if (oldCtx != m_glCtx) {
226
+ oldCtx->doneCurrent ();
227
+ m_glCtx->makeCurrent (m_surface);
228
+ }
229
+ }
230
+
213
231
for (Monitor *monitor : m_unpositionedMonitors)
214
232
monitor->autoPosition (m_engine->monitors ());
215
233
@@ -230,6 +248,13 @@ void ProjectLoader::timerEvent(QTimerEvent *event)
230
248
m_renderTimer.restart ();
231
249
} else
232
250
m_renderFpsCounter++;
251
+
252
+ if (m_glCtx) {
253
+ if (oldCtx != m_glCtx) {
254
+ m_glCtx->doneCurrent ();
255
+ oldCtx->makeCurrent (oldSurface);
256
+ }
257
+ }
233
258
}
234
259
235
260
event->accept ();
Original file line number Diff line number Diff line change 12
12
Q_MOC_INCLUDE (" spritemodel.h" );
13
13
Q_MOC_INCLUDE (" monitormodel.h" );
14
14
15
+ class QSurface ;
16
+ class QOpenGLContext ;
17
+
15
18
namespace scratchcpprender
16
19
{
17
20
@@ -185,6 +188,8 @@ class ProjectLoader : public QObject
185
188
std::atomic<unsigned int > m_downloadedAssets = 0 ;
186
189
std::atomic<unsigned int > m_assetCount = 0 ;
187
190
std::atomic<bool > m_stopLoading = false ;
191
+ QOpenGLContext *m_glCtx = nullptr ;
192
+ QSurface *m_surface = nullptr ;
188
193
};
189
194
190
195
} // namespace scratchcpprender
You can’t perform that action at this time.
0 commit comments