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

fixes for windows/cygwin (cannot use glVertex2d when there is a transfo along z)

parent d654aa8f
No related branches found
No related tags found
No related merge requests found
// $Id: Draw.cpp,v 1.86 2005-12-18 23:45:01 geuzaine Exp $ // $Id: Draw.cpp,v 1.87 2005-12-19 02:24:56 geuzaine Exp $
// //
// Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle
// //
...@@ -176,24 +176,24 @@ void InitProjection(int x, int y) ...@@ -176,24 +176,24 @@ void InitProjection(int x, int y)
// we should generalize the following for cases when the object is // we should generalize the following for cases when the object is
// located far from the z=0 plane // located far from the z=0 plane
double gradient_zdist, gradient_xyfact; double grad_z, grad_xy;
if(CTX.ortho) { if(CTX.ortho) {
// setting up the near and far clipping planes so that the box is // setting up the near and far clipping planes so that the box is
// large enough to manipulate the model and zoom, but not too big // large enough to manipulate the model and zoom, but not too big
// (the z-buffer resolution, e.g., on software Mesa can become // (the z-buffer resolution, e.g., on software Mesa can become
// insufficient) // insufficient)
double maxz = MAX(fabs(CTX.min[2]), fabs(CTX.max[2])); double zmax = MAX(fabs(CTX.min[2]), fabs(CTX.max[2]));
if(maxz < CTX.lc) maxz = CTX.lc; if(zmax < CTX.lc) zmax = CTX.lc;
double clip = maxz * CTX.s[2] * CTX.clip_factor; double clip = zmax * 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();
gradient_zdist = 0.99 * clip; grad_z = 0.99 * clip;
gradient_xyfact = 1.; grad_xy = 1.;
} }
else { else {
double near = 0.75 * CTX.clip_factor * CTX.lc; double znear = 0.75 * CTX.clip_factor * CTX.lc;
double far = 75. * CTX.clip_factor * CTX.lc; double zfar = 75. * CTX.clip_factor * CTX.lc;
// recenter the model such that the perspective is always at the // recenter the model such that the perspective is always at the
// center of gravity (we should maybe add an option to choose // center of gravity (we should maybe add an option to choose
// this, as we do for the rotation center) // this, as we do for the rotation center)
...@@ -203,37 +203,36 @@ void InitProjection(int x, int y) ...@@ -203,37 +203,36 @@ void InitProjection(int x, int y)
CTX.vxmax -= CTX.t_init[0]; CTX.vxmax -= CTX.t_init[0];
CTX.vymin -= CTX.t_init[1]; CTX.vymin -= CTX.t_init[1];
CTX.vymax -= CTX.t_init[1]; CTX.vymax -= CTX.t_init[1];
glFrustum(CTX.vxmin, CTX.vxmax, CTX.vymin, CTX.vymax, near, far); glFrustum(CTX.vxmin, CTX.vxmax, CTX.vymin, CTX.vymax, znear, zfar);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
glTranslated(-10 * CTX.t_init[0], -10 * CTX.t_init[1], -10 * near); glTranslated(-10 * CTX.t_init[0], -10 * CTX.t_init[1], -10 * znear);
glScaled(10., 10., 10.); glScaled(10., 10., 10.);
gradient_zdist = 0.99 * far; grad_z = 0.99 * zfar;
gradient_xyfact = far / near; grad_xy = zfar / znear;
} }
// draw background gradient // draw background gradient
if(CTX.render_mode != GMSH_SELECT && CTX.bg_gradient){ if(CTX.render_mode != GMSH_SELECT && CTX.bg_gradient){
glPushMatrix(); glPushMatrix();
glLoadIdentity(); glLoadIdentity();
glTranslated(0., 0., -gradient_zdist); glTranslated(0., 0., -grad_z);
glShadeModel(GL_SMOOTH);
glBegin(GL_QUADS); glBegin(GL_QUADS);
if(CTX.bg_gradient == 1){ if(CTX.bg_gradient == 1){
glColor4ubv((GLubyte *) & CTX.color.bg); glColor4ubv((GLubyte *) & CTX.color.bg);
glVertex2d(gradient_xyfact * CTX.vxmin, gradient_xyfact * CTX.vymin); glVertex3d(grad_xy * CTX.vxmin, grad_xy * CTX.vymin, 0.);
glVertex2d(gradient_xyfact * CTX.vxmax, gradient_xyfact * CTX.vymin); glVertex3d(grad_xy * CTX.vxmax, grad_xy * CTX.vymin, 0.);
glColor4ubv((GLubyte *) & CTX.color.bg_grad); glColor4ubv((GLubyte *) & CTX.color.bg_grad);
glVertex2d(gradient_xyfact * CTX.vxmax, gradient_xyfact * CTX.vymax); glVertex3d(grad_xy * CTX.vxmax, grad_xy * CTX.vymax, 0.);
glVertex2d(gradient_xyfact * CTX.vxmin, gradient_xyfact * CTX.vymax); glVertex3d(grad_xy * CTX.vxmin, grad_xy * CTX.vymax, 0.);
} }
else{ else{
glColor4ubv((GLubyte *) & CTX.color.bg); glColor4ubv((GLubyte *) & CTX.color.bg);
glVertex2d(gradient_xyfact * CTX.vxmax, gradient_xyfact * CTX.vymin); glVertex3d(grad_xy * CTX.vxmax, grad_xy * CTX.vymin, 0.);
glVertex2d(gradient_xyfact * CTX.vxmax, gradient_xyfact * CTX.vymax); glVertex3d(grad_xy * CTX.vxmax, grad_xy * CTX.vymax, 0.);
glColor4ubv((GLubyte *) & CTX.color.bg_grad); glColor4ubv((GLubyte *) & CTX.color.bg_grad);
glVertex2d(gradient_xyfact * CTX.vxmin, gradient_xyfact * CTX.vymax); glVertex3d(grad_xy * CTX.vxmin, grad_xy * CTX.vymax, 0.);
glVertex2d(gradient_xyfact * CTX.vxmin, gradient_xyfact * CTX.vymin); glVertex3d(grad_xy * CTX.vxmin, grad_xy * CTX.vymin, 0.);
} }
glEnd(); glEnd();
glPopMatrix(); glPopMatrix();
...@@ -288,6 +287,7 @@ void InitRenderModel(void) ...@@ -288,6 +287,7 @@ void InitRenderModel(void)
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, CTX.shine_exponent); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, CTX.shine_exponent);
glShadeModel(GL_SMOOTH); glShadeModel(GL_SMOOTH);
// Normalize the normals automatically. We could use the more // Normalize the normals automatically. We could use the more
// efficient glEnable(GL_RESCALE_NORMAL) instead (since we initially // efficient glEnable(GL_RESCALE_NORMAL) instead (since we initially
// specify unit normals), but GL_RESCALE_NORMAL does only work with // specify unit normals), but GL_RESCALE_NORMAL does only work with
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment