File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 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)
210210 return ;
211211
212212 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+
213231 for (Monitor *monitor : m_unpositionedMonitors)
214232 monitor->autoPosition (m_engine->monitors ());
215233
@@ -230,6 +248,13 @@ void ProjectLoader::timerEvent(QTimerEvent *event)
230248 m_renderTimer.restart ();
231249 } else
232250 m_renderFpsCounter++;
251+
252+ if (m_glCtx) {
253+ if (oldCtx != m_glCtx) {
254+ m_glCtx->doneCurrent ();
255+ oldCtx->makeCurrent (oldSurface);
256+ }
257+ }
233258 }
234259
235260 event->accept ();
Original file line number Diff line number Diff line change 1212Q_MOC_INCLUDE (" spritemodel.h" );
1313Q_MOC_INCLUDE (" monitormodel.h" );
1414
15+ class QSurface ;
16+ class QOpenGLContext ;
17+
1518namespace scratchcpprender
1619{
1720
@@ -185,6 +188,8 @@ class ProjectLoader : public QObject
185188 std::atomic<unsigned int > m_downloadedAssets = 0 ;
186189 std::atomic<unsigned int > m_assetCount = 0 ;
187190 std::atomic<bool > m_stopLoading = false ;
191+ QOpenGLContext *m_glCtx = nullptr ;
192+ QSurface *m_surface = nullptr ;
188193};
189194
190195} // namespace scratchcpprender
You can’t perform that action at this time.
0 commit comments