Fix #36826: make screencast with quicktime output gave black flickering areas.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 27 Sep 2013 20:29:07 +0000 (20:29 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 27 Sep 2013 20:29:07 +0000 (20:29 +0000)
Problem was OpenGL buffer alpha channel, it's not used in most places and so
not set to any meaningful value while drawing.

source/blender/editors/screen/screendump.c

index 584d4cef1334ffab28dffb9b61ac236867ebff22..40447a0106ab165d6cc3e3da59ae9bacdbc12c91 100644 (file)
@@ -77,6 +77,18 @@ typedef struct ScreenshotData {
        ImageFormatData im_format;
 } ScreenshotData;
 
+static void screenshot_read_pixels(int x, int y, int w, int h, unsigned char *rect)
+{
+       int i;
+
+       glReadPixels(x, y, w, h, GL_RGBA, GL_UNSIGNED_BYTE, rect);
+       glFinish();
+
+       /* clear alpha, it is not set to a meaningful value in opengl */
+       for (i = 0, rect += 3; i < w*h; i++, rect += 4)
+               *rect = 255;
+}
+
 /* get shot from frontbuffer */
 static unsigned int *screenshot(bContext *C, int *dumpsx, int *dumpsy)
 {
@@ -93,8 +105,7 @@ static unsigned int *screenshot(bContext *C, int *dumpsx, int *dumpsy)
                
                dumprect = MEM_mallocN(sizeof(int) * (*dumpsx) * (*dumpsy), "dumprect");
                glReadBuffer(GL_FRONT);
-               glReadPixels(x, y, *dumpsx, *dumpsy, GL_RGBA, GL_UNSIGNED_BYTE, dumprect);
-               glFinish();
+               screenshot_read_pixels(x, y, *dumpsx, *dumpsy, (unsigned char*)dumprect);
                glReadBuffer(GL_BACK);
        }
 
@@ -316,8 +327,7 @@ static void screenshot_updatejob(void *sjv)
        
        if (sj->dumprect == NULL) {
                dumprect = MEM_mallocN(sizeof(int) * sj->dumpsx * sj->dumpsy, "dumprect");
-               glReadPixels(sj->x, sj->y, sj->dumpsx, sj->dumpsy, GL_RGBA, GL_UNSIGNED_BYTE, dumprect);
-               glFinish();
+               screenshot_read_pixels(sj->x, sj->y, sj->dumpsx, sj->dumpsy, (unsigned char*)dumprect);
                
                sj->dumprect = dumprect;
        }