diff options
Diffstat (limited to 'generic/tkZinc.c')
-rw-r--r-- | generic/tkZinc.c | 62 |
1 files changed, 54 insertions, 8 deletions
diff --git a/generic/tkZinc.c b/generic/tkZinc.c index f9e9193..d6e5215 100644 --- a/generic/tkZinc.c +++ b/generic/tkZinc.c @@ -422,7 +422,7 @@ static Tk_ConfigSpec config_specs[] = { "0", Tk_Offset(ZnWInfo, screen_rotation), 0, NULL}, #endif /* Use damage option (only used if -render is set to 1 ie if we use GL */ - {TK_CONFIG_BOOLEAN, "-usedamage", "useDamage", "UseDamage", + {TK_CONFIG_INT, "-usedamage", "useDamage", "UseDamage", "0", Tk_Offset(ZnWInfo, usedamage), 0, NULL}, {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL} }; @@ -539,7 +539,7 @@ static Tk_OptionSpec option_specs[] = { "0", -1, Tk_Offset(ZnWInfo, screen_rotation), 0, NULL, CONFIG_ROTATION}, #endif /* Use damage option (only used if -render is set to 1 ie if we use GL */ - {TK_OPTION_BOOLEAN, "-usedamage", "useDamage", "UseDamage", + {TK_OPTION_INT, "-usedamage", "useDamage", "UseDamage", "0", -1, Tk_Offset(ZnWInfo, usedamage), 0, NULL, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0} }; @@ -8867,17 +8867,47 @@ Repair(ZnWInfo *wi) // // glViewport and glOrtho must always be used together with // matching parameters to keep the mapping straight (no distorsion). - glViewport(darea_x1, wi->height - darea_y2, darea_x2 - darea_x1, darea_y2 - darea_y1); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(darea_x1, darea_x2, darea_y2, darea_y1, -1.0, 1.0); - glMatrixMode(GL_MODELVIEW); + if (wi->usedamage == 2) { + // usedamage == 2 + glViewport(0, 0, wi->width, wi->height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, wi->width, wi->height, 0, -1.0, 1.0); + glMatrixMode(GL_MODELVIEW); + } + else { + glViewport(darea_x1, wi->height - darea_y2, darea_x2 - darea_x1, darea_y2 - darea_y1); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(darea_x1, darea_x2, darea_y2, darea_y1, -1.0, 1.0); + glMatrixMode(GL_MODELVIEW); + } + /* * Clear the GL buffers. */ glClear(GL_STENCIL_BUFFER_BIT); /* + * Use clipping if needed (optimization for non-Nvidia cards) + */ + if (wi->usedamage == 2) { + // Clip the damaged region + // This point array will contain our damage mask coordinates + ZnPoint _ptClip [ 2 ]; + // This triangle strip will contain our specific damage clipping zone. + ZnTriStrip tristripClip; + _ptClip [0].x = darea_x1; + _ptClip [0].y = darea_y1; + _ptClip [1].x = darea_x2; + _ptClip [1].y = darea_y2; + + ZnTriStrip1(&tristripClip, _ptClip, 2, False); + ZnPushClip(wi, &tristripClip, True, True); + } + + + /* * Setup the background tile or the background color. */ if (wi->tile != ZnUnspecifiedImage) { @@ -8901,6 +8931,15 @@ Repair(ZnWInfo *wi) wi->top_group->class->Render(wi->top_group); + + /* + * Stop clipping if needed (optimizations for non-Nvidia cards) + */ + if (wi->usedamage == 2) { + // Stop clipping ! + ZnPopClip(wi, True); + } + #if defined(GL) && defined(ROTATION) if (wi->enable_rotation) { FinalizeRotation(wi); @@ -8911,7 +8950,14 @@ Repair(ZnWInfo *wi) unsigned short alpha; /* Test if we are using damage or not */ - if (wi->usedamage) { + if (wi->usedamage == 2) { + glViewport(0, 0, wi->width, wi->height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0.0, wi->width, wi->height, 0.0, -1.0, 1.0); + glMatrixMode(GL_MODELVIEW); + } + else { glViewport(0, 0, wi->opt_width, wi->opt_height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); |