summaryrefslogtreecommitdiff
path: root/beryl-plugins/src/blurfx.c
diff options
context:
space:
mode:
authoronestone <onestone@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2007-01-23 18:15:52 +0000
committeronestone <onestone@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2007-01-23 18:15:52 +0000
commitfb3580f35f8ef1790ad6a6daff6f829153d7afff (patch)
treecb118142f469be8625e189311b73760d65f5834e /beryl-plugins/src/blurfx.c
parent1e04919c7f3cae77d34cbace95b99fbd6457493a (diff)
downloadmarex-dev-fb3580f35f8ef1790ad6a6daff6f829153d7afff.tar.gz
marex-dev-fb3580f35f8ef1790ad6a6daff6f829153d7afff.tar.bz2
beryl-plugins: blurfx: fixed rendering if framebuffer attach fails
git-svn-id: file:///beryl/trunk@3055 d7aaf104-2d23-0410-ae22-9d23157bf5a3
Diffstat (limited to 'beryl-plugins/src/blurfx.c')
-rw-r--r--beryl-plugins/src/blurfx.c283
1 files changed, 157 insertions, 126 deletions
diff --git a/beryl-plugins/src/blurfx.c b/beryl-plugins/src/blurfx.c
index a38ca3e..65b6ddb 100644
--- a/beryl-plugins/src/blurfx.c
+++ b/beryl-plugins/src/blurfx.c
@@ -1245,7 +1245,7 @@ blurfxPaintScreen(CompScreen * s, const ScreenPaintAttrib * sa,
// redirect all drawing operations into background texture
- bindFbo(s, bs->backTex);
+ Bool fbo_ok = bindFbo(s, bs->backTex);
glMatrixMode(GL_PROJECTION);
glLoadMatrixf(bs->pm);
@@ -1259,155 +1259,158 @@ blurfxPaintScreen(CompScreen * s, const ScreenPaintAttrib * sa,
unbindFbo(s);
- if (bs->motion_blur_active && bs->mb_mode == 2
- && output + 1 == s->nOutputDev)
+ if (fbo_ok)
{
- // blend actual screen into motion blur texture
- if (glIsEnabled(GL_SCISSOR_TEST))
- {
- glDisable(GL_SCISSOR_TEST);
- enable_scissor = TRUE;
- }
- glPushAttrib(GL_COLOR_BUFFER_BIT | GL_TEXTURE_BIT);
- GLERR;
- bindFbo(s, bs->motionTex);
- glPushMatrix();
- glLoadIdentity();
- glViewport(0, 0, s->width, s->height);
- glTranslatef(-0.5f, -0.5f, -DEFAULT_Z_CAMERA);
- glScalef(1.0f / s->width, -1.0f / s->height, 1.0f);
- glTranslatef(0.0f, -s->height, 0.0f);
-
- if (bs->mb_update)
+ if (bs->motion_blur_active && bs->mb_mode == 2
+ && output + 1 == s->nOutputDev)
{
- glClearColor(1.0, 1.0, 1.0, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
- glDisable(GL_BLEND);
- }
- else
- glEnable(GL_BLEND);
-
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- bs->mb_alpha =
- (bs->mb_timer / 500.0) * bs->mb_alpha + (1.0 -
- (bs->
- mb_timer
- / 500.0)) * 0.5;
- bs->mb_alpha = MIN(1.0, bs->mb_alpha);
- glColor4f(1, 1, 1, (bs->mb_update) ? 1.0 : bs->mb_alpha);
- enableBlurfxTexture(&bs->backTex, COMP_TEXTURE_FILTER_FAST);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
+ // blend actual screen into motion blur texture
+ if (glIsEnabled(GL_SCISSOR_TEST))
+ {
+ glDisable(GL_SCISSOR_TEST);
+ enable_scissor = TRUE;
+ }
+ glPushAttrib(GL_COLOR_BUFFER_BIT | GL_TEXTURE_BIT);
+ GLERR;
+ bindFbo(s, bs->motionTex);
+ glPushMatrix();
+ glLoadIdentity();
+ glViewport(0, 0, s->width, s->height);
+ glTranslatef(-0.5f, -0.5f, -DEFAULT_Z_CAMERA);
+ glScalef(1.0f / s->width, -1.0f / s->height, 1.0f);
+ glTranslatef(0.0f, -s->height, 0.0f);
+
+ if (bs->mb_update)
+ {
+ glClearColor(1.0, 1.0, 1.0, 1.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+ glDisable(GL_BLEND);
+ }
+ else
+ glEnable(GL_BLEND);
+
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ bs->mb_alpha =
+ (bs->mb_timer / 500.0) * bs->mb_alpha + (1.0 -
+ (bs->
+ mb_timer
+ / 500.0)) * 0.5;
+ bs->mb_alpha = MIN(1.0, bs->mb_alpha);
+ glColor4f(1, 1, 1, (bs->mb_update) ? 1.0 : bs->mb_alpha);
+ enableBlurfxTexture(&bs->backTex, COMP_TEXTURE_FILTER_FAST);
+
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
+
+ glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
+ glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR);
+ glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
+
+ glBegin(GL_QUADS);
+ glTexCoord2f(0, bs->backTex.height);
+ glVertex2f(0, 0);
+ glTexCoord2f(0, 0);
+ glVertex2f(0, bs->backTex.height);
+ glTexCoord2f(bs->backTex.width, 0);
+ glVertex2f(bs->backTex.width, bs->backTex.height);
+ glTexCoord2f(bs->backTex.width, bs->backTex.height);
+ glVertex2f(bs->backTex.width, 0);
+
+ glEnd();
- glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
- glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
- glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR);
- glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
+ glDisable(GL_BLEND);
- glBegin(GL_QUADS);
- glTexCoord2f(0, bs->backTex.height);
- glVertex2f(0, 0);
- glTexCoord2f(0, 0);
- glVertex2f(0, bs->backTex.height);
- glTexCoord2f(bs->backTex.width, 0);
- glVertex2f(bs->backTex.width, bs->backTex.height);
- glTexCoord2f(bs->backTex.width, bs->backTex.height);
- glVertex2f(bs->backTex.width, 0);
+ glPopMatrix();
+ unbindFbo(s);
- glEnd();
+ // paint motion blur texture
+ glPushMatrix();
+ glLoadIdentity();
+ glViewport(0, 0, s->width, s->height);
+ glTranslatef(-0.5f, -0.5f, -DEFAULT_Z_CAMERA);
+ glScalef(1.0f / s->width, -1.0f / s->height, 1.0f);
+ glTranslatef(0.0f, -s->height, 0.0f);
- glDisable(GL_BLEND);
+ glColor4f(1.0, 1.0, 1.0, 1.0);
- glPopMatrix();
- unbindFbo(s);
+ switchBlurfxTexture(&bs->backTex, &bs->motionTex,
+ COMP_TEXTURE_FILTER_FAST);
- // paint motion blur texture
- glPushMatrix();
- glLoadIdentity();
- glViewport(0, 0, s->width, s->height);
- glTranslatef(-0.5f, -0.5f, -DEFAULT_Z_CAMERA);
- glScalef(1.0f / s->width, -1.0f / s->height, 1.0f);
- glTranslatef(0.0f, -s->height, 0.0f);
+ glBegin(GL_QUADS);
+ glTexCoord2f(0, bs->backTex.height);
+ glVertex2f(0, 0);
+ glTexCoord2f(0, 0);
+ glVertex2f(0, bs->backTex.height);
+ glTexCoord2f(bs->backTex.width, 0);
+ glVertex2f(bs->backTex.width, bs->backTex.height);
+ glTexCoord2f(bs->backTex.width, bs->backTex.height);
+ glVertex2f(bs->backTex.width, 0);
- glColor4f(1.0, 1.0, 1.0, 1.0);
+ glEnd();
- switchBlurfxTexture(&bs->backTex, &bs->motionTex,
- COMP_TEXTURE_FILTER_FAST);
+ disableBlurfxTexture(&bs->motionTex);
- glBegin(GL_QUADS);
- glTexCoord2f(0, bs->backTex.height);
- glVertex2f(0, 0);
- glTexCoord2f(0, 0);
- glVertex2f(0, bs->backTex.height);
- glTexCoord2f(bs->backTex.width, 0);
- glVertex2f(bs->backTex.width, bs->backTex.height);
- glTexCoord2f(bs->backTex.width, bs->backTex.height);
- glVertex2f(bs->backTex.width, 0);
-
- glEnd();
-
- disableBlurfxTexture(&bs->motionTex);
+ glPopMatrix();
+ glViewport(s->outputDev[bs->output].region.extents.
+ x1,
+ s->height -
+ s->outputDev[bs->output].region.extents.
+ y2, s->outputDev[bs->output].width,
+ s->outputDev[bs->output].height);
+
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
+ glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_PREVIOUS);
+
+ glPopAttrib();
+ GLERR;
- glPopMatrix();
- glViewport(s->outputDev[bs->output].region.extents.
- x1,
- s->height -
- s->outputDev[bs->output].region.extents.
- y2, s->outputDev[bs->output].width,
- s->outputDev[bs->output].height);
+ bs->mb_update = FALSE;
+ damageScreen(s);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
- glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
- glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_PREVIOUS);
-
- glPopAttrib();
- GLERR;
+ }
+ else
+ {
- bs->mb_update = FALSE;
- damageScreen(s);
+ glPushMatrix();
+ glLoadIdentity();
+ prepareXCoords(s, output, -DEFAULT_Z_CAMERA);
- }
- else
- {
+ // draw background texture
+ int stride;
+ CompMatrix mat;
- glPushMatrix();
- glLoadIdentity();
- prepareXCoords(s, output, -DEFAULT_Z_CAMERA);
+ mat.xx = 1.0;
+ mat.yx = 0.0;
+ mat.xy = 0.0;
+ mat.yy = -1.0;
+ mat.x0 = 0;
+ mat.y0 = s->height;
- // draw background texture
- int stride;
- CompMatrix mat;
+ stride = 4 * sizeof(GLfloat);
+ genGeometry(&bs->vertArray, mat, 0,
+ &s->outputDev[bs->output].region);
+ glVertexPointer(2, GL_FLOAT, stride, bs->vertArray.vertices + 2);
+ glTexCoordPointer(2, GL_FLOAT, stride, bs->vertArray.vertices);
+ glColor4f(1.0, 1.0, 1.0, 1.0);
- mat.xx = 1.0;
- mat.yx = 0.0;
- mat.xy = 0.0;
- mat.yy = -1.0;
- mat.x0 = 0;
- mat.y0 = s->height;
+ enableBlurfxTexture(&bs->backTex, COMP_TEXTURE_FILTER_FAST);
- stride = 4 * sizeof(GLfloat);
- genGeometry(&bs->vertArray, mat, 0,
- &s->outputDev[bs->output].region);
- glVertexPointer(2, GL_FLOAT, stride, bs->vertArray.vertices + 2);
- glTexCoordPointer(2, GL_FLOAT, stride, bs->vertArray.vertices);
- glColor4f(1.0, 1.0, 1.0, 1.0);
+ glDrawArrays(GL_QUADS, 0, bs->vertArray.vCount);
- enableBlurfxTexture(&bs->backTex, COMP_TEXTURE_FILTER_FAST);
+ disableBlurfxTexture(&bs->backTex);
- glDrawArrays(GL_QUADS, 0, bs->vertArray.vCount);
-
- disableBlurfxTexture(&bs->backTex);
-
- glPopMatrix();
+ glPopMatrix();
+ }
}
-
}
else
{
@@ -4438,6 +4441,30 @@ static Bool bindFbo(CompScreen * s, BlurTexture tex)
printf("Framebuffer attach failed\n");
bs->fboStatus = 0;
bs->fboActive = FALSE;
+
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+ glDepthRange(0, 1);
+ glViewport(-1, -1, 2, 2);
+ glRasterPos2f(0, 0);
+ s->rasterX = s->rasterY = 0;
+ glViewport(s->outputDev[bs->output].region.extents.x1,
+ s->height - s->outputDev[bs->output].region.extents.y2,
+ s->outputDev[bs->output].width,
+ s->outputDev[bs->output].height);
+
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+
+ glDrawBuffer(GL_BACK);
+ glReadBuffer(GL_BACK);
+
return FALSE;
}
}
@@ -4472,6 +4499,10 @@ static void unbindFbo(CompScreen * s)
{
BLURFX_SCREEN(s);
+
+ if (!bs->fboActive)
+ return;
+
GLERR;
// unbind fbo
(*s->bindFramebuffer) (GL_FRAMEBUFFER_EXT, 0);