Use checker backdrop for footage with alpha channel in clip editor

Also use glaDrawPixelsAuto as a fallback method. Hopefully it'll
make using 2D textures for frames higher resolution than
GL_MAX_TEXTURE_SIZE.
This commit is contained in:
Sergey Sharybin 2013-03-19 08:53:01 +00:00
parent fbbbb90af3
commit 4e93ac546f
2 changed files with 16 additions and 1 deletions

@ -269,8 +269,18 @@ static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar,
if (display_buffer) {
int need_fallback = 1;
/* checkerboard for case alpha */
if (ibuf->planes == 32) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
fdrawcheckerboard(x, y, x + zoomx * ibuf->x, y + zoomy * ibuf->y);
}
if (ED_space_clip_texture_buffer_supported(sc)) {
if (ED_space_clip_load_movieclip_buffer(sc, ibuf, display_buffer)) {
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glPushMatrix();
glTranslatef(x, y, 0.0f);
glScalef(zoomx, zoomy, 1.0f);
@ -296,11 +306,14 @@ static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar,
/* set zoom */
glPixelZoom(zoomx * width / ibuf->x, zoomy * height / ibuf->y);
glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);
glaDrawPixelsAuto(x, y, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, GL_NEAREST, display_buffer);
/* reset zoom */
glPixelZoom(1.0f, 1.0f);
}
if (ibuf->planes == 32)
glDisable(GL_BLEND);
}
IMB_display_buffer_release(cache_handle);

@ -617,6 +617,8 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf, const unsign
context->last_texture = glaGetOneInteger(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
/* image texture need to be rebinded if displaying another image buffer
* assuming displaying happens of footage frames only on which painting doesn't happen.
* so not changed image buffer pointer means unchanged image content */