Skip to content
Snippets Groups Projects
Commit 1be3c2f2 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

simpler solution to 2D primitive sorting problem
parent 7f66652b
No related branches found
No related tags found
No related merge requests found
// $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 // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
// //
...@@ -47,12 +47,6 @@ void Draw3d(void) ...@@ -47,12 +47,6 @@ void Draw3d(void)
glPopMatrix(); 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) void Draw2d(void)
{ {
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
...@@ -61,19 +55,12 @@ void Draw2d(void) ...@@ -61,19 +55,12 @@ void Draw2d(void)
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); 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], 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); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
// make sure that all the 2D stuff gets printed in front
glTranslated(0.0, 0.0, 0.9*clip);
glPushMatrix(); glPushMatrix();
Draw_Graph2D(); Draw_Graph2D();
Draw_Text2D(); Draw_Text2D();
...@@ -156,7 +143,9 @@ void Orthogonalize(int x, int y) ...@@ -156,7 +143,9 @@ void Orthogonalize(int x, int y)
// Mesa on Linux; with hardware acceleration or on Windows // Mesa on Linux; with hardware acceleration or on Windows
// everyhting seems to be fine). // everyhting seems to be fine).
if(CTX.ortho) { 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); glOrtho(CTX.vxmin, CTX.vxmax, CTX.vymin, CTX.vymax, -clip, clip);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment