diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-09-13 01:13:30 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-09-27 13:41:46 +0200 |
| commit | 56e0452ce0f436e7c54a49c68b272797f92a7ffe (patch) | |
| tree | 0977a9668bf338583d0ff2e552952551991897da /src | |
| parent | f802565830bed9ec9e7ad6c16ccaa7b0700625d9 (diff) | |
Add basic Texture wrapper for a GL texture.
Diffstat (limited to 'src')
| -rw-r--r-- | src/wx/gl_video_view.cc | 30 | ||||
| -rw-r--r-- | src/wx/gl_video_view.h | 19 |
2 files changed, 41 insertions, 8 deletions
diff --git a/src/wx/gl_video_view.cc b/src/wx/gl_video_view.cc index 035d337e5..7fb387f53 100644 --- a/src/wx/gl_video_view.cc +++ b/src/wx/gl_video_view.cc @@ -114,8 +114,6 @@ GLVideoView::~GLVideoView () _thread.interrupt (); _thread.join (); } catch (...) {} - - glDeleteTextures (1, &_video_texture); } void @@ -464,7 +462,6 @@ GLVideoView::draw (Position<int>, dcp::Size) glViewport (0, 0, width, height); check_gl_error ("glViewport"); - glBindTexture(GL_TEXTURE_2D, _video_texture); glBindVertexArray(_vao); check_gl_error ("glBindVertexArray"); glUniform1i(_fragment_type, _optimise_for_j2k ? 1 : 2); @@ -668,10 +665,8 @@ try _vsync_enabled = true; #endif - glGenTextures (1, &_video_texture); - check_gl_error ("glGenTextures"); - glBindTexture (GL_TEXTURE_2D, _video_texture); - check_gl_error ("glBindTexture"); + _video_texture.reset(new Texture()); + _video_texture->bind(); while (true) { boost::mutex::scoped_lock lm (_playing_mutex); @@ -718,3 +713,24 @@ GLVideoView::request_one_shot () _thread_work_condition.notify_all (); } + +Texture::Texture () +{ + glGenTextures (1, &_name); + check_gl_error ("glGenTextures"); +} + + +Texture::~Texture () +{ + glDeleteTextures (1, &_name); +} + + +void +Texture::bind () +{ + glBindTexture(GL_TEXTURE_2D, _name); + check_gl_error ("glBindTexture"); +} + diff --git a/src/wx/gl_video_view.h b/src/wx/gl_video_view.h index 8f3f2dcb4..272198591 100644 --- a/src/wx/gl_video_view.h +++ b/src/wx/gl_video_view.h @@ -34,6 +34,23 @@ DCPOMATIC_ENABLE_WARNINGS #undef Success #undef Status + +class Texture +{ +public: + Texture (); + ~Texture (); + + Texture (Texture const&) = delete; + Texture& operator= (Texture const&) = delete; + + void bind (); + +private: + GLuint _name; +}; + + class GLVideoView : public VideoView { public: @@ -74,7 +91,7 @@ private: wxGLContext* _context; boost::atomic<wxSize> _canvas_size; - GLuint _video_texture; + std::unique_ptr<Texture> _video_texture; boost::optional<dcp::Size> _video_size; bool _have_storage; bool _vsync_enabled; |
