summaryrefslogtreecommitdiff
path: root/src/wx/gl_view.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-04-19 23:30:46 +0200
committerCarl Hetherington <cth@carlh.net>2025-04-20 21:18:19 +0200
commitd921f2dae281aa6a787e693aea9d6446b6122295 (patch)
tree07697d11e884d6ea0968f026ef4efbafec8646c9 /src/wx/gl_view.cc
parentd618ea99fcf29a1d7384819eb92e865ea69fd3a2 (diff)
Move some more GL setup into GLView.
Diffstat (limited to 'src/wx/gl_view.cc')
-rw-r--r--src/wx/gl_view.cc43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/wx/gl_view.cc b/src/wx/gl_view.cc
index f97797c40..2c7424a29 100644
--- a/src/wx/gl_view.cc
+++ b/src/wx/gl_view.cc
@@ -21,6 +21,7 @@
#include "lib/cross.h"
#include "lib/dcpomatic_log.h"
+#include "lib/exceptions.h"
#include "gl_view.h"
#include <wx/wx.h>
@@ -171,5 +172,47 @@ GLView::request_one_shot()
}
+void
+GLView::update()
+{
+ if (!_canvas->IsShownOnScreen()) {
+ return;
+ }
+
+ /* It appears important to do this from the GUI thread; if we do it from the GL thread
+ * on Linux we get strange failures to create the context for any version of GL higher
+ * than 3.2.
+ */
+ ensure_context();
+
+#ifdef DCPOMATIC_OSX
+ /* macOS gives errors if we don't do this (and therefore [NSOpenGLContext setView:]) from the main thread */
+ if (!_setup_shaders_done) {
+ setup_shaders();
+ _setup_shaders_done = true;
+ }
+#endif
+
+ start_thread_if_required();
+ request_one_shot();
+ rethrow();
+}
+
+
+void
+GLView::ensure_context()
+{
+ if (!_context) {
+ wxGLContextAttrs attrs;
+ attrs.PlatformDefaults().CoreProfile().OGLVersion(4, 1).EndList();
+ _context = new wxGLContext(_canvas, nullptr, &attrs);
+ if (!_context->IsOK()) {
+ boost::throw_exception(GLError("Making GL context", -1));
+ }
+ }
+}
+
+
+
#endif