summaryrefslogtreecommitdiff
path: root/src/wx
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
parentd618ea99fcf29a1d7384819eb92e865ea69fd3a2 (diff)
Move some more GL setup into GLView.
Diffstat (limited to 'src/wx')
-rw-r--r--src/wx/gl_video_view.cc30
-rw-r--r--src/wx/gl_video_view.h1
-rw-r--r--src/wx/gl_view.cc43
-rw-r--r--src/wx/gl_view.h3
4 files changed, 47 insertions, 30 deletions
diff --git a/src/wx/gl_video_view.cc b/src/wx/gl_video_view.cc
index dc3846e80..c24736570 100644
--- a/src/wx/gl_video_view.cc
+++ b/src/wx/gl_video_view.cc
@@ -119,15 +119,7 @@ GLVideoView::check_for_butler_errors()
void
GLVideoView::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();
+ GLView::update();
#ifdef DCPOMATIC_OSX
/* macOS gives errors if we don't do this (and therefore [NSOpenGLContext setView:]) from the main thread */
@@ -136,12 +128,6 @@ GLVideoView::update()
_setup_shaders_done = true;
}
#endif
-
- start_thread_if_required();
-
- request_one_shot();
-
- rethrow();
}
@@ -292,20 +278,6 @@ enum class FragmentType
};
-void
-GLVideoView::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));
- }
- }
-}
-
-
/* Offset and number of indices for the things in the indices array below */
static constexpr int indices_video_texture_offset = 0;
static constexpr int indices_video_texture_number = 6;
diff --git a/src/wx/gl_video_view.h b/src/wx/gl_video_view.h
index a3bbe716f..a69b97f8e 100644
--- a/src/wx/gl_video_view.h
+++ b/src/wx/gl_video_view.h
@@ -92,7 +92,6 @@ private:
void set_image(std::shared_ptr<const PlayerVideo> pv);
void check_for_butler_errors();
- void ensure_context();
void setup_shaders();
void set_outline_content_colour(GLuint program);
void set_crop_guess_colour(GLuint program);
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
diff --git a/src/wx/gl_view.h b/src/wx/gl_view.h
index c5f056cb5..f20d5962a 100644
--- a/src/wx/gl_view.h
+++ b/src/wx/gl_view.h
@@ -45,6 +45,8 @@ public:
GLView(wxWindow* parent);
virtual ~GLView();
+ virtual void update();
+
wxWindow* canvas() const {
return _canvas;
}
@@ -64,6 +66,7 @@ protected:
void start();
void stop();
void request_one_shot();
+ void ensure_context();
wxGLCanvas* _canvas;
boost::atomic<wxSize> _canvas_size;