From 1be3c2f2601397426af275897f1a1ee8c1876f08 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Wed, 29 Dec 2004 22:30:09 +0000 Subject: [PATCH] simpler solution to 2D primitive sorting problem --- Graphics/Draw.cpp | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/Graphics/Draw.cpp b/Graphics/Draw.cpp index 48e4612de2..8e174a6759 100644 --- a/Graphics/Draw.cpp +++ b/Graphics/Draw.cpp @@ -1,4 +1,4 @@ -// $Id: Draw.cpp,v 1.68 2004-12-29 22:03:05 geuzaine Exp $ +// $Id: Draw.cpp,v 1.69 2004-12-29 22:30:09 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -47,12 +47,6 @@ void Draw3d(void) glPopMatrix(); } -double GetClip(){ - double maxz = MAX(fabs(CTX.min[2]), fabs(CTX.max[2])); - if(maxz < CTX.lc) maxz = CTX.lc; - return maxz * CTX.s[2] * CTX.clip_factor; -} - void Draw2d(void) { glDisable(GL_DEPTH_TEST); @@ -61,19 +55,12 @@ void Draw2d(void) glMatrixMode(GL_PROJECTION); glLoadIdentity(); - // draw directly in screen coords. The special near and far clipping - // planes and the translation are there for GL2PS: without this, - // GL2PS has no way to know that the 2D primitives should be drawn - // "in front" of the scene. It's a hack, but it's the only way if we - // don't want special GL2PS commands to tell that some special - // primitives should be sorted in a non-standard way. - double clip = GetClip(); glOrtho((double)CTX.viewport[0], (double)CTX.viewport[2], - (double)CTX.viewport[1], (double)CTX.viewport[3], -clip, clip); + (double)CTX.viewport[1], (double)CTX.viewport[3], -1., 1.); + // hack to make the 2D primitives appear "in front" in GL2PS + glTranslated(0.0, 0.0, CTX.clip_factor ? 1./CTX.clip_factor : 0.); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - // make sure that all the 2D stuff gets printed in front - glTranslated(0.0, 0.0, 0.9*clip); glPushMatrix(); Draw_Graph2D(); Draw_Text2D(); @@ -156,7 +143,9 @@ void Orthogonalize(int x, int y) // Mesa on Linux; with hardware acceleration or on Windows // everyhting seems to be fine). if(CTX.ortho) { - double clip = GetClip(); + double maxz = MAX(fabs(CTX.min[2]), fabs(CTX.max[2])); + if(maxz < CTX.lc) maxz = CTX.lc; + double clip = maxz * CTX.s[2] * CTX.clip_factor; glOrtho(CTX.vxmin, CTX.vxmax, CTX.vymin, CTX.vymax, -clip, clip); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); -- GitLab