PDA

View Full Version : NURBS surface not displayed properly inside lists



martiniinthemorning
02-22-2010, 09:15 PM
Hi, had somebody encountered a similar problem where NURBS surfaces were not rendered properly when drawn inside display lists? I have this custom NURBS class that initializes its Control Points and Knots Array at the constructor, something like this...


memset(this->m_aCtlPoints, 0, sizeof(GLfloat) * 48);
memcpy(this->m_aCtlPoints, aCtlPts, sizeof(GLfloat) * 48);
this->m_aKnots = aKnots;

...and somewhere after the constructor call a function called Init from this NURBS class is called...


this->m_pcNURBSObj = gluNewNurbsRenderer();
gluNurbsProperty(this->m_pcNURBSObj, GLU_SAMPLING_TOLERANCE, 25.0);
// mesh types are, GLU_OUTLINE_POLYGON and GLU_FILL
gluNurbsProperty(this->m_pcNURBSObj, GLU_DISPLAY_MODE, flMeshType);
m_iList = glGenLists(1);
glNewList(m_iList, GL_COMPILE);
if (pcColor)
{
glColor3f(pcColor->m_flR, pcColor->m_flG, pcColor->m_flB);
}
glTranslatef(m_flX, m_flY, m_flZ);
gluBeginSurface(this->m_pcNURBSObj);
gluNurbsSurface(this->m_pcNURBSObj, 8, this->m_aKnots, 8, this->m_aKnots, 4 * 3, 3, &(this->m_aCtlPoints[0][0][0]), 4, 4, GL_MAP2_VERTEX_3);
gluEndSurface(this->m_pcNURBSObj);
glEndList();

...and again somewhere from an external code, which is actually where all of the code above where also called the NURBS class's list member variable is called to draw the NURBS...


glCallList(m_pcNurb0->m_iList);

The observed problem is that, when setting GLU_OUTLINE_POLYGON for the NURBS, it renders an outlined NURBS with a zigzag line in it. But when drawing it directly outside display lists, it draws an outlined NURBS with equal number of rows and columns not a zigzag line(which is correct).

Please help. I hope I can post the image of the zigzagged NURBS here.