summaryrefslogtreecommitdiff
path: root/src/wx/gl_view.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-04-19 22:05:26 +0200
committerCarl Hetherington <cth@carlh.net>2025-04-20 21:18:19 +0200
commit7274fa9a628508c451713b724c54dbef9f1d199d (patch)
tree86d0ff8eaac0f4207c1a1a306ef6113860e64bb5 /src/wx/gl_view.cc
parented16bb805a162b05eb7c44d93d9f556d230ca8db (diff)
Extract some parts of GLVideoView to GLView.
Diffstat (limited to 'src/wx/gl_view.cc')
-rw-r--r--src/wx/gl_view.cc63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/wx/gl_view.cc b/src/wx/gl_view.cc
new file mode 100644
index 000000000..567057e96
--- /dev/null
+++ b/src/wx/gl_view.cc
@@ -0,0 +1,63 @@
+/*
+ Copyright (C) 2025 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include "lib/dcpomatic_log.h"
+#include "gl_view.h"
+#include <wx/wx.h>
+
+#if BOOST_VERSION >= 106100
+using namespace boost::placeholders;
+#endif
+
+
+/* This will only build on an new-enough wxWidgets: see the comment in gl_view.h */
+#if wxCHECK_VERSION(3,1,0)
+
+
+GLView::GLView(wxWindow* parent)
+ : _context(nullptr)
+{
+ wxGLAttributes attributes;
+ /* We don't need a depth buffer, and indeed there is apparently a bug with Windows/Intel HD 630
+ * which puts green lines over the OpenGL display if you have a non-zero depth buffer size.
+ * https://community.intel.com/t5/Graphics/Request-for-details-on-Intel-HD-630-green-lines-in-OpenGL-apps/m-p/1202179
+ */
+ attributes.PlatformDefaults().MinRGBA(8, 8, 8, 8).DoubleBuffer().Depth(0).EndList();
+ _canvas = new wxGLCanvas(
+ parent, attributes, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE
+ );
+ _canvas->Bind(wxEVT_SIZE, boost::bind(&GLView::size_changed, this, _1));
+}
+
+
+void
+GLView::size_changed(wxSizeEvent const& ev)
+{
+ auto const scale = _canvas->GetDPIScaleFactor();
+ int const width = std::round(ev.GetSize().GetWidth() * scale);
+ int const height = std::round(ev.GetSize().GetHeight() * scale);
+ _canvas_size = { width, height };
+ LOG_GENERAL("GLView canvas size changed to %1x%2", width, height);
+}
+
+
+#endif
+