X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Fwx%2Fgl_video_view.cc;h=b3f036ded57d30a3949724c447f5e399c7ecf4f0;hp=ce17c03297c14b6c694a6232e17a95077a79da61;hb=e153d7f5dc128d97160e41bdda3c4e4a05c7140b;hpb=a8e31120a793f09ab56cc2847d76944ba698ba95 diff --git a/src/wx/gl_video_view.cc b/src/wx/gl_video_view.cc index ce17c0329..b3f036ded 100644 --- a/src/wx/gl_video_view.cc +++ b/src/wx/gl_video_view.cc @@ -35,12 +35,14 @@ using std::cout; using boost::shared_ptr; +using boost::optional; GLVideoView::GLVideoView (wxWindow *parent) { _canvas = new wxGLCanvas (parent, wxID_ANY, 0, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE); _context = new wxGLContext (_canvas); - _canvas->Bind (wxEVT_PAINT, boost::bind(&GLVideoView::paint, this, _1)); + _canvas->Bind (wxEVT_PAINT, boost::bind(&GLVideoView::paint, this)); + _canvas->Bind (wxEVT_SIZE, boost::bind(boost::ref(Sized))); glGenTextures (1, &_id); glBindTexture (GL_TEXTURE_2D, _id); @@ -51,7 +53,6 @@ GLVideoView::~GLVideoView () { glDeleteTextures (1, &_id); delete _context; - delete _canvas; } static void @@ -64,10 +65,26 @@ check_gl_error (char const * last) } void -GLVideoView::paint (wxPaintEvent &) +GLVideoView::paint () { _canvas->SetCurrent (*_context); wxPaintDC dc (_canvas); + draw (); +} + +void +GLVideoView::update () +{ + if (!_canvas->IsShownOnScreen()) { + return; + } + wxClientDC dc (_canvas); + draw (); +} + +void +GLVideoView::draw () +{ glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); check_gl_error ("glClear"); @@ -115,8 +132,10 @@ GLVideoView::paint (wxPaintEvent &) void GLVideoView::set_image (shared_ptr image) { - /* XXX: put this somewhere sensible */ - cout << glGetString (GL_VERSION) << "\n"; + if (!image) { + _size = optional(); + return; + } DCPOMATIC_ASSERT (image->pixel_format() == AV_PIX_FMT_RGB24); DCPOMATIC_ASSERT (!image->aligned()); @@ -133,6 +152,4 @@ GLVideoView::set_image (shared_ptr image) glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); check_gl_error ("glTexParameterf"); - - _canvas->Refresh (); }