changeset 23987:9ea121c8e2df

Handle case where get_image is called twice without a draw_image in-between (-vc ffmpeg12 seems to do this sometimes).
author reimar
date Fri, 03 Aug 2007 18:29:54 +0000
parents 82903387bbf4
children 3b830c7e0eb2
files libvo/vo_gl.c
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/vo_gl.c	Fri Aug 03 17:22:31 2007 +0000
+++ b/libvo/vo_gl.c	Fri Aug 03 18:29:54 2007 +0000
@@ -88,6 +88,7 @@
 static GLenum gl_type;
 static GLuint gl_buffer;
 static int gl_buffersize;
+static void *gl_bufferptr;
 static GLuint fragprog;
 static GLuint default_texs[22];
 static char *custom_prog;
@@ -371,6 +372,7 @@
   if (DeleteBuffers && gl_buffer)
     DeleteBuffers(1, &gl_buffer);
   gl_buffer = 0; gl_buffersize = 0;
+  gl_bufferptr = NULL;
   err_shown = 0;
 }
 
@@ -677,7 +679,9 @@
                NULL, GL_DYNAMIC_DRAW);
     gl_buffersize = mpi->stride[0] * mpi->h;
   }
-  mpi->planes[0] = MapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
+  if (!gl_bufferptr)
+    gl_bufferptr = MapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
+  mpi->planes[0] = gl_bufferptr;
   BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
   if (mpi->planes[0] == NULL) {
     if (!err_shown)
@@ -715,6 +719,7 @@
     planes[2] -= base;
     BindBuffer(GL_PIXEL_UNPACK_BUFFER, gl_buffer);
     UnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
+    gl_bufferptr = NULL;
     slice = 0; // always "upload" full texture
   }
   glUploadTex(gl_target, gl_format, gl_type, planes[0], stride[0],