Hi there,
Sorry for sending this bug report to this mailing lits instead of
reporting it via bugzilla but I have been unable to get a password from
the bugzilla system (mail sent with password never arrived).
The bug is that the GLU nurbs renderer sometimes places invalid calls to
glMapGrid2f() with parameters 'un' and/or 'vn' of 0.
I have traced the bug to main/gfx/lib/glu/libnurbs/internals/slicer.cc
and I think I have fixed it in the patch which I attach.
The nurbs_revol.c program attached demonstrates the problem. Note that
it occurs only when using the GLU_NURBS_RENDERER, not with the
GLU_NURBS_TESSELLATOR (as it does not use GL evaluators).
If any help is needed you can contact me at my e-mail address (I'm not
member of this mailing list).
Best regards,
Diego Santa Cruz
PS: I have tried the bug and it occurs on Irix machines (with the
shipped GLU) as well as Linux/i386 ones (with the SI-GLU compiled by
me).
--
-----------------------------------------------------------------------
Diego Santa Cruz mailto:Diego.Santacruz@xxxxxxx
Signal Processing Laboratory (LTS) http://ltswww.epfl.ch/~dsanta
Swiss Federal Institute of Technology (EPFL)
EL - Ecublens - CH-1015 Lausanne - Switzerland
Office: ELE 236
Phone: +41 - 21 - 693 26 57 (Office)
+41 - 21 - 693 46 20 (LTS Lab) * *
Fax: +41 - 21 - 693 76 00 'O^-'
Mobile: +41 - 79 - 375 50 60 ( o )
-------------------------------------------------------- oOO U OOo ----/*
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation for any purpose is hereby granted without fee, provided
* that (i) the above copyright notices and this permission notice appear in
* all copies of the software and related documentation, and (ii) the name of
* Silicon Graphics may not be used in any advertising or
* publicity relating to the software without the specific, prior written
* permission of Silicon Graphics.
*
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
* ANY KIND,
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
*
* IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
/*
* Modified by Diego Santa Cruz, Fri Apr 20 CEST 2001
*
* Changed the model to the Goblet one from the Computer Science Department,
* University of Utah and added GLU 1.3 NURBS tessellator support.
*
* Copyright (c) 2001, Diego Santa Cruz
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <GL/glut.h>
#ifndef GLU_VERSION_1_1
#error Reuiqres GLU 1.1 to compile
#endif
#ifndef CALLBACK
#define CALLBACK
#endif
GLenum doubleBuffer;
GLenum expectedError;
GLint rotX = 0, rotY = 0;
GLUnurbsObj *theNurbs;
/* This model was created using the Alpha_1 geometric */
/* modeling system at the Computer Science Department, */
/* University of Utah. We would appreciate your */
/* acknowledging the source of the data in publication */
/* of work utilizing this model, or portions of it. */
GLfloat control_points[] = {
0, -.339411, 0, 1,
0, -.169706, -.169706, 1,
0, 0, -.339411, 1,
0, .169706, -.169706, 1,
0, .339411, 0, 1,
0, .169706, .169706, 1,
0, 0, .339411, 1,
0, -.169706, .169706, 1,
0, -.339411, 0, 1,
.0166667, -.339305, 0, 1,
.0166667, -.169653, -.169653, 1,
.0166667, 0, -.339305, 1,
.0166667, .169653, -.169653, 1,
.0166667, .339305, 0, 1,
.0166667, .169653, .169653, 1,
.0166667, 0, .339305, 1,
.0166667, -.169653, .169653, 1,
.0166667, -.339305, 0, 1,
.05, -.335863, 0, 1,
.05, -.167931, -.167931, 1,
.05, 0, -.335863, 1,
.05, .167931, -.167931, 1,
.05, .335863, 0, 1,
.05, .167931, .167931, 1,
.05, 0, .335863, 1,
.05, -.167931, .167931, 1,
.05, -.335863, 0, 1,
.0914931, -.299836, 0, 1,
.0914931, -.149918, -.149918, 1,
.0914931, 0, -.299836, 1,
.0914931, .149918, -.149918, 1,
.0914931, .299836, 0, 1,
.0914931, .149918, .149918, 1,
.0914931, 0, .299836, 1,
.0914931, -.149918, .149918, 1,
.0914931, -.299836, 0, 1,
.124826, -.167957, 0, 1,
.106673, -.0982697, -.0982697, .85457,
.124826, 0, -.167957, 1,
.106673, .0982697, -.0982697, .85457,
.124826, .167957, 0, 1,
.106673, .0982697, .0982697, .85457,
.124826, 0, .167957, 1,
.106673, -.0982697, .0982697, .85457,
.124826, -.167957, 0, 1,
.15816, -.0595285, 0, 1,
.111836, -.042093, -.042093, .707107,
.15816, 0, -.0595285, 1,
.111836, .042093, -.042093, .707107,
.15816, .0595285, 0, 1,
.111836, .042093, .042093, .707107,
.15816, 0, .0595285, 1,
.111836, -.042093, .042093, .707107,
.15816, -.0595285, 0, 1,
.191667, -.0401543, 0, 1,
.135529, -.0283934, -.0283934, .707107,
.191667, 0, -.0401543, 1,
.135529, .0283934, -.0283934, .707107,
.191667, .0401543, 0, 1,
.135529, .0283934, .0283934, .707107,
.191667, 0, .0401543, 1,
.135529, -.0283934, .0283934, .707107,
.191667, -.0401543, 0, 1,
.225, -.0425, 0, 1,
.159099, -.030052, -.030052, .707107,
.225, 0, -.0425, 1,
.159099, .030052, -.030052, .707107,
.225, .0425, 0, 1,
.159099, .030052, .030052, .707107,
.225, 0, .0425, 1,
.159099, -.030052, .030052, .707107,
.225, -.0425, 0, 1,
.258316, -.0714549, 0, 1,
.182657, -.0505262, -.0505262, .707107,
.258316, 0, -.0714549, 1,
.182657, .0505262, -.0505262, .707107,
.258316, .0714549, 0, 1,
.182657, .0505262, .0505262, .707107,
.258316, 0, .0714549, 1,
.182657, -.0505262, .0505262, .707107,
.258316, -.0714549, 0, 1,
.29158, -.128385, 0, 1,
.206178, -.0907821, -.0907821, .707107,
.29158, 0, -.128385, 1,
.206178, .0907821, -.0907821, .707107,
.29158, .128385, 0, 1,
.206178, .0907821, .0907821, .707107,
.29158, 0, .128385, 1,
.206178, -.0907821, .0907821, .707107,
.29158, -.128385, 0, 1,
.324271, -.154993, 0, 1,
.229294, -.109597, -.109597, .707107,
.324271, 0, -.154993, 1,
.229294, .109597, -.109597, .707107,
.324271, .154993, 0, 1,
.229294, .109597, .109597, .707107,
.324271, 0, .154993, 1,
.229294, -.109597, .109597, .707107,
.324271, -.154993, 0, 1,
.365399, -.116657, 0, 1,
.258376, -.0824886, -.0824886, .707107,
.365399, 0, -.116657, 1,
.258376, .0824886, -.0824886, .707107,
.365399, .116657, 0, 1,
.258376, .0824886, .0824886, .707107,
.365399, 0, .116657, 1,
.258376, -.0824886, .0824886, .707107,
.365399, -.116657, 0, 1,
.421858, -.0606315, 0, 1,
.298298, -.0428729, -.0428729, .707107,
.421858, 0, -.0606315, 1,
.298298, .0428729, -.0428729, .707107,
.421858, .0606315, 0, 1,
.298298, .0428729, .0428729, .707107,
.421858, 0, .0606315, 1,
.298298, -.0428729, .0428729, .707107,
.421858, -.0606315, 0, 1,
.493867, -.0511714, 0, 1,
.349217, -.0361836, -.0361836, .707107,
.493867, 0, -.0511714, 1,
.349217, .0361836, -.0361836, .707107,
.493867, .0511714, 0, 1,
.349217, .0361836, .0361836, .707107,
.493867, 0, .0511714, 1,
.349217, -.0361836, .0361836, .707107,
.493867, -.0511714, 0, 1,
.54785, -.0848609, 0, 1,
.387388, -.0600057, -.0600057, .707107,
.54785, 0, -.0848609, 1,
.387388, .0600057, -.0600057, .707107,
.54785, .0848609, 0, 1,
.387388, .0600057, .0600057, .707107,
.54785, 0, .0848609, 1,
.387388, -.0600057, .0600057, .707107,
.54785, -.0848609, 0, 1,
.589141, -.164206, 0, 1,
.416585, -.116111, -.116111, .707107,
.589141, 0, -.164206, 1,
.416585, .116111, -.116111, .707107,
.589141, .164206, 0, 1,
.416585, .116111, .116111, .707107,
.589141, 0, .164206, 1,
.416585, -.116111, .116111, .707107,
.589141, -.164206, 0, 1,
.62916, -.216905, 0, 1,
.444883, -.153375, -.153375, .707107,
.62916, 0, -.216905, 1,
.444883, .153375, -.153375, .707107,
.62916, .216905, 0, 1,
.444883, .153375, .153375, .707107,
.62916, 0, .216905, 1,
.444883, -.153375, .153375, .707107,
.62916, -.216905, 0, 1,
.70224, -.253141, 0, 1,
.496559, -.178998, -.178998, .707107,
.70224, 0, -.253141, 1,
.496559, .178998, -.178998, .707107,
.70224, .253141, 0, 1,
.496559, .178998, .178998, .707107,
.70224, 0, .253141, 1,
.496559, -.178998, .178998, .707107,
.70224, -.253141, 0, 1,
.82956, -.263243, 0, 1,
.586588, -.186141, -.186141, .707107,
.82956, 0, -.263243, 1,
.586588, .186141, -.186141, .707107,
.82956, .263243, 0, 1,
.586588, .186141, .186141, .707107,
.82956, 0, .263243, 1,
.586588, -.186141, .186141, .707107,
.82956, -.263243, 0, 1,
.93484, -.251769, 0, 1,
.661032, -.178028, -.178028, .707107,
.93484, 0, -.251769, 1,
.661032, .178028, -.178028, .707107,
.93484, .251769, 0, 1,
.661032, .178028, .178028, .707107,
.93484, 0, .251769, 1,
.661032, -.178028, .178028, .707107,
.93484, -.251769, 0, 1,
1, -.24, 0, 1,
.707107, -.169706, -.169706, .707107,
1, 0, -.24, 1,
.707107, .169706, -.169706, .707107,
1, .24, 0, 1,
.707107, .169706, .169706, .707107,
1, 0, .24, 1,
.707107, -.169706, .169706, .707107,
1, -.24, 0, 1
};
GLfloat uknots[] = {
0, 0, 0, .25, .25,
.5, .5, .75, .75, 1,
1, 1
};
GLfloat vknots[] = {
0, 0, 0, 0, .05,
.1, .124479, .15, .2, .225,
.25, .299948, .324792, .348073, .423333,
.494167, .564102, .58528, .61804, .68416,
.80452, 1, 1, 1, 1
};
#define UORDER 3
#define VORDER 4
#define NUKNOTS (sizeof(uknots)/sizeof(uknots[0]))
#define NVKNOTS (sizeof(vknots)/sizeof(vknots[0]))
#define NUPNTS (NUKNOTS-UORDER)
#define NVPNTS (NVKNOTS-VORDER)
static void CALLBACK ErrorCallback(GLenum which)
{
if (which != expectedError) {
fprintf(stderr, "Unexpected error occured (%d):\n", which);
fprintf(stderr, " %s\n", (char *) gluErrorString(which));
}
}
static void CALLBACK NurbsBegin(GLenum type)
{
glBegin(type);
}
static void CALLBACK NurbsEnd()
{
glEnd();
}
static void CALLBACK NurbsVertex(GLfloat *vertex)
{
glVertex3fv(vertex);
}
static void CALLBACK NurbsNormal(GLfloat *normal)
{
glNormal3fv(normal);
}
static void Init(void)
{
static const GLfloat material_f[4] = {0.7, 0.7, 0.7, 1.0};
static const GLfloat material_b[4] = {0.5, 0.5, 0.5, 1.0};
static const GLfloat amb_light[4] = {0.9, 0.9, 0.9, 1.0};
static const GLfloat lt0_light[] = {0.3, 0.3, 0.3, 1.0f};
theNurbs = gluNewNurbsRenderer();
#if defined(GLU_VERSION_1_3)
gluNurbsCallback(theNurbs, GLU_NURBS_ERROR, ErrorCallback);
gluNurbsCallback(theNurbs, GLU_NURBS_BEGIN, NurbsBegin);
gluNurbsCallback(theNurbs, GLU_NURBS_VERTEX, NurbsVertex);
gluNurbsCallback(theNurbs, GLU_NURBS_NORMAL, NurbsNormal);
gluNurbsCallback(theNurbs, GLU_NURBS_END, NurbsEnd);
#elif defined(GLU_VERSION_1_2)
gluNurbsCallback(theNurbs, GLU_ERROR, ErrorCallback);
#endif
gluNurbsProperty(theNurbs, GLU_DISPLAY_MODE, GLU_FILL);
/* A tolerance of 15 or less makes the sample implementation of the GLU
* (version of 2001.03.15) generate invalid calls to glMapGrid2f(), where vn
* or un are 0. Mesa's 3.4.1 GLU does not have this bug. */
gluNurbsProperty(theNurbs, GLU_SAMPLING_METHOD, GLU_PARAMETRIC_ERROR);
gluNurbsProperty(theNurbs, GLU_PARAMETRIC_TOLERANCE, 10.0);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,amb_light);
glLightfv(GL_LIGHT0,GL_DIFFUSE,lt0_light);
glLightfv(GL_LIGHT0,GL_SPECULAR,lt0_light);
glEnable(GL_AUTO_NORMAL);
glMaterialfv(GL_FRONT,GL_AMBIENT_AND_DIFFUSE,material_f);
glMaterialfv(GL_FRONT,GL_SPECULAR,material_f);
glMaterialf(GL_FRONT,GL_SHININESS,100);
glMaterialfv(GL_BACK,GL_AMBIENT_AND_DIFFUSE,material_b);
glMaterialfv(GL_BACK,GL_SPECULAR,material_b);
glMaterialf(GL_BACK,GL_SHININESS,10);
}
static void Reshape(int width, int height)
{
glViewport(0, 0, (GLint)width, (GLint)height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(35,(GLfloat)width/(GLfloat)height,0.8,5);
gluLookAt(0,0,2.718107,0,0,0,0,1,0);
glMatrixMode(GL_MODELVIEW);
}
static void Key2(int key, int x, int y)
{
switch (key) {
case GLUT_KEY_DOWN:
rotY += 5;
break;
case GLUT_KEY_UP:
rotY -= 5;
break;
case GLUT_KEY_LEFT:
rotX -= 5;
break;
case GLUT_KEY_RIGHT:
rotX += 5;
break;
default:
return;
}
glutPostRedisplay();
}
static void Key(unsigned char key, int x, int y)
{
switch (key) {
case 27:
case 'q':
case 'Q':
exit(0);
break;
#ifdef GLU_VERSION_1_3
case 'r':
case 'R':
gluNurbsProperty(theNurbs,GLU_NURBS_MODE,GLU_NURBS_RENDERER);
fprintf(stderr,"INFO: nurbs mode = GLU_NURBS_RENDERER\n");
glutPostRedisplay();
break;
#endif
case 't':
case 'T':
#ifdef GLU_VERSION_1_3
gluNurbsProperty(theNurbs,GLU_NURBS_MODE,GLU_NURBS_TESSELLATOR);
fprintf(stderr,"INFO: nurbs mode = GLU_NURBS_TESSELLATOR\n");
glutPostRedisplay();
#else
fprintf(stderr,"Compile with GLU 1.3 for GLU NURBS tessellator support.\n");
#endif
break;
}
}
static void Draw(void)
{
static const GLfloat light_pos[] = {-1,1,1,0};
GLenum errorCode;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glLightfv(GL_LIGHT0, GL_POSITION, light_pos);
glRotatef(rotY, 1, 0, 0);
glRotatef(rotX, 0, 1, 0);
glTranslatef(-0.5, 0, 0);
gluBeginSurface(theNurbs);
gluNurbsSurface(theNurbs, NUKNOTS, uknots, NVKNOTS, vknots, 4, 4*NUPNTS,
control_points, UORDER, VORDER, GL_MAP2_VERTEX_4);
gluEndSurface(theNurbs);
glPopMatrix();
glFlush();
if (doubleBuffer) {
glutSwapBuffers();
}
while ((errorCode = glGetError()) != GL_NO_ERROR) {
fprintf(stderr,"GL error: %s\n",(const char *)gluErrorString(errorCode));
}
}
static GLenum Args(int argc, char **argv)
{
GLint i;
doubleBuffer = GL_FALSE;
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-sb") == 0) {
doubleBuffer = GL_FALSE;
} else if (strcmp(argv[i], "-db") == 0) {
doubleBuffer = GL_TRUE;
} else {
printf("%s (Bad option).\n", argv[i]);
return GL_FALSE;
}
}
return GL_TRUE;
}
int main(int argc, char **argv)
{
GLenum type;
glutInit(&argc, argv);
if (Args(argc, argv) == GL_FALSE) {
exit(1);
}
glutInitWindowPosition(0, 0); glutInitWindowSize( 500, 500);
type = GLUT_RGB|GLUT_DEPTH;
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
glutInitDisplayMode(type);
if (glutCreateWindow("NURBS Test") == GL_FALSE) {
exit(1);
}
Init();
glutReshapeFunc(Reshape);
glutKeyboardFunc(Key);
glutSpecialFunc(Key2);
glutDisplayFunc(Draw);
glutMainLoop();
return 0;
}
--- main/gfx/lib/glu/libnurbs/internals/slicer.cc Wed Apr 5 08:43:40 2000
+++ main-fixed/gfx/lib/glu/libnurbs/internals/slicer.cc Fri Apr 20 18:19:16 2001
@@ -575,11 +575,11 @@
TrimVertex trimVert;
trimVert.nuid = 0;//????
- backend.surfgrid(u_val[0], u_val[n_ulines-1], n_ulines-1,
- v_val[n_vlines-1], v_val[0], n_vlines-1);
-
- if(n_ulines>1 && n_vlines>1)
+ if(n_ulines>1 && n_vlines>1) {
+ backend.surfgrid(u_val[0], u_val[n_ulines-1], n_ulines-1,
+ v_val[n_vlines-1], v_val[0], n_vlines-1);
backend.surfmesh(0,0,n_ulines-1,n_vlines-1);
+ }
return;
|