Fix update on drag with GL canvas.
[dcpomatic.git] / src / wx / gl_video_view.cc
index f75d50f9dc8fd9716881458ee6cd8c0440fe66c1..b3f036ded57d30a3949724c447f5e399c7ecf4f0 100644 (file)
@@ -41,7 +41,7 @@ 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);
@@ -65,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");