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);
{
glDeleteTextures (1, &_id);
delete _context;
- /* XXX: should we delete this? */
- delete _canvas;
}
static void
}
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");
void
GLVideoView::set_image (shared_ptr<const Image> image)
{
+ if (!image) {
+ _size = optional<dcp::Size>();
+ return;
+ }
+
DCPOMATIC_ASSERT (image->pixel_format() == AV_PIX_FMT_RGB24);
DCPOMATIC_ASSERT (!image->aligned());