From e14f136e0250caf818c2f6b9b9ac393db7c556d8 Mon Sep 17 00:00:00 2001 From: lecoanet Date: Fri, 15 Feb 2002 08:25:44 +0000 Subject: R�amenagement du code de clipping local utilisant le stencil --- generic/Draw.c | 82 ++++++++++++++-------------------------------------------- 1 file changed, 20 insertions(+), 62 deletions(-) (limited to 'generic/Draw.c') diff --git a/generic/Draw.c b/generic/Draw.c index 95a6013..b0032b3 100644 --- a/generic/Draw.c +++ b/generic/Draw.c @@ -978,16 +978,10 @@ RenderPolyline(WidgetInfo *wi, for (pass = 0; pass < 2; pass++) { if (pass == 0) { - glStencilFunc(GL_EQUAL, num_clips, 0xFF); - glStencilOp(GL_KEEP, GL_INCR, GL_INCR); - if (num_clips == 0) { - glEnable(GL_STENCIL_TEST); - } + GLX_START_CLIP(num_clips, True); } else { - glStencilFunc(GL_EQUAL, num_clips+1, 0xFF); - glStencilOp(GL_KEEP, GL_DECR, GL_DECR); - glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); + GLX_RESTORE_STENCIL(num_clips, False); } if (first_end) { GetLineEnd(&points[0], &points[1], line_width, cap_style, @@ -1028,15 +1022,10 @@ RenderPolyline(WidgetInfo *wi, } if (pass == 0) { - glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); + GLX_RENDER_CLIPPED(); } else { - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - glStencilFunc(GL_EQUAL, num_clips, 0xFF); - if (num_clips == 0) { - glDisable(GL_STENCIL_TEST); - } + GLX_END_CLIP(num_clips); return; } need_rcaps = ((line_width > 1) && (cap_style == CapRound) && !closed); @@ -1136,17 +1125,10 @@ RenderTile(struct _WidgetInfo *wi, /* * Setup the stencil buffer with the shape to be drawn. */ - if (!num_clips) { - glEnable(GL_STENCIL_TEST); - } - glStencilFunc(GL_EQUAL, num_clips, 0xFF); - glStencilOp(GL_KEEP, GL_INCR, GL_INCR); - glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); - (*cb)(closure); - - glStencilFunc(GL_EQUAL, num_clips+1, 0xFF); - glStencilOp(GL_KEEP, GL_DECR, GL_DECR); - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + GLX_START_CLIP(num_clips, False); + + (*cb)(closure); + GLX_RESTORE_STENCIL(num_clips, True); } /* @@ -1197,11 +1179,7 @@ RenderTile(struct _WidgetInfo *wi, glEnd(); if (cb) { - glStencilFunc(GL_EQUAL, num_clips, 0xFF); - glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - if (!num_clips) { - glDisable(GL_STENCIL_TEST); - } + GLX_END_CLIP(num_clips); } glDisable(GL_TEXTURE_2D); } @@ -1351,16 +1329,9 @@ RenderGradient(struct _WidgetInfo *wi, * Draw the gradient shape in the stencil using the provided * callback (clipping). */ - if (!num_clips) { - glEnable(GL_STENCIL_TEST); - } - glStencilFunc(GL_EQUAL, num_clips, 0xFF); - glStencilOp(GL_KEEP, GL_INCR, GL_INCR); - glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); + GLX_START_CLIP(num_clips, False); (*cb)(closure); - glStencilFunc(GL_EQUAL, num_clips+1, 0xFF); - glStencilOp(GL_KEEP, GL_DECR, GL_DECR); - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + GLX_RESTORE_STENCIL(num_clips, True); } if (type == ZN_AXIAL_GRADIENT) { @@ -1539,11 +1510,7 @@ RenderGradient(struct _WidgetInfo *wi, /* * Restore the previous GL state. */ - glStencilFunc(GL_EQUAL, num_clips, 0xFF); - glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - if (!num_clips) { - glDisable(GL_STENCIL_TEST); - } + GLX_END_CLIP(num_clips); } } @@ -1554,37 +1521,28 @@ RenderHollowDot(struct _WidgetInfo *wi, ZnReal size) { int num_clips = ZnListSize(wi->clip_stack); - - if (!num_clips) { - glEnable(GL_STENCIL_TEST); - } - glStencilFunc(GL_EQUAL, num_clips, 0xFF); - glStencilOp(GL_KEEP, GL_INCR, GL_INCR); - glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); + + GLX_START_CLIP(num_clips, False); + glPointSize(size-2); glBegin(GL_POINTS); glVertex2f(p->x, p->y); glEnd(); - glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + GLX_RENDER_CLIPPED(); + glPointSize(size); glBegin(GL_POINTS); glVertex2f(p->x, p->y); glEnd(); - glStencilFunc(GL_EQUAL, num_clips+1, 0xFF); - glStencilOp(GL_KEEP, GL_DECR, GL_DECR); - glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); - glPointSize(size-2); + GLX_RESTORE_STENCIL(num_clips, False); + glBegin(GL_POINTS); glVertex2f(p->x, p->y); glEnd(); - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - if (!num_clips) { - glDisable(GL_STENCIL_TEST); - } + GLX_END_CLIP(num_clips); } #endif -- cgit v1.1