Beispiel #1
0
ON_BOOL32 myInitGL( const ON_Viewport& viewport, GLUnurbsObj*& nobj )
{
  // set the model view transform
  SetGLModelViewMatrix( viewport );

  // this stuff works with MSVC 4.2's Open GL. Changes may be needed for other
  // GLs.
  //ON_Color background_color(0,128,128);
  ON_Color background_color(0,63,127);
  //background_color = glb_model->m_settings.m_RenderSettings.m_background_color;
  glClearColor( (float)background_color.FractionRed(), 
                (float)background_color.FractionGreen(), 
                (float)background_color.FractionBlue(), 
                1.0f
                );

  glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE );
  glDisable( GL_CULL_FACE );
  
  // Rhino viewports have camera "Z" pointing at the camera in a right
  // handed coordinate system.
  glClearDepth( 0.0f );
  glEnable( GL_DEPTH_TEST );
  glDepthFunc( GL_GEQUAL );

  glEnable( GL_LIGHTING );
  glEnable( GL_DITHER );
  //glEnable( GL_AUTO_NORMAL );
  //glEnable( GL_NORMALIZE );

  // default material
  ON_GL( (ON_Material*)NULL );


  // GL rendering of NURBS objects requires a GLUnurbsObj.
  nobj = gluNewNurbsRenderer();
  if ( !nobj )
    return false;
  
  gluNurbsProperty( nobj, GLU_SAMPLING_TOLERANCE,   20.0f );
  gluNurbsProperty( nobj, GLU_PARAMETRIC_TOLERANCE, 0.5f );
  gluNurbsProperty( nobj, GLU_DISPLAY_MODE,         (GLfloat)GLU_FILL );
  //gluNurbsProperty( nobj, GLU_DISPLAY_MODE,         GLU_OUTLINE_POLYGON );
  //gluNurbsProperty( nobj, GLU_DISPLAY_MODE,         GLU_OUTLINE_PATCH );
  gluNurbsProperty( nobj, GLU_SAMPLING_METHOD,      (GLfloat)GLU_PATH_LENGTH );
  //gluNurbsProperty( nobj, GLU_SAMPLING_METHOD,      GLU_PARAMETRIC_ERROR );
  //gluNurbsProperty( nobj, GLU_SAMPLING_METHOD,      GLU_DOMAIN_DISTANCE );
  gluNurbsProperty( nobj, GLU_CULLING,              (GLfloat)GL_FALSE );

  // register GL NURBS error callback
  {
    // hack to get around C vs C++ type checking trauma
    RHINO_GL_NURBS_ERROR fn;
    fn = (RHINO_GL_NURBS_ERROR)myNurbsErrorCallback;
    gluNurbsCallback( nobj, GLU_ERROR, fn );
  }

  return true;
}
Beispiel #2
0
void nurbsInit(void)
{
    theNurbs = gluNewNurbsRenderer();
    gluNurbsCallback(theNurbs, GLU_ERROR, ErrorCallback);
    gluNurbsProperty(theNurbs,GLU_NURBS_MODE,GLU_NURBS_TESSELLATOR);
    gluNurbsCallback(theNurbs,GLU_NURBS_BEGIN,beginCallback);
    gluNurbsCallback(theNurbs,GLU_NURBS_END,endCallback);
    gluNurbsCallback(theNurbs,GLU_NURBS_VERTEX,vertexCallback);
    gluNurbsProperty(theNurbs, GLU_SAMPLING_TOLERANCE, 15.0);
    gluNurbsProperty(theNurbs, GLU_DISPLAY_MODE, GLU_OUTLINE_PATCH);
    expectedError = GLU_INVALID_ENUM;
    gluNurbsProperty(theNurbs, ~0, 15.0);
    expectedError = GLU_NURBS_ERROR13;
    gluEndSurface(theNurbs);
    expectedError = 0;

}
Beispiel #3
0
void init(void)
{
	glClearColor (0.0, 0.0, 0.0, 0.0);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	theNurb = gluNewNurbsRenderer();
	gluNurbsProperty (theNurb, GLU_SAMPLING_TOLERANCE, 10.0);
	gluNurbsCallback(theNurb, GLU_ERROR, (GLvoid (*)()) nurbsError);
	setup();
}
Beispiel #4
0
void init(void)
{
  if (!pNurb2)
  {
    pNurb2 = gluNewNurbsRenderer();
    gluNurbsProperty(pNurb2, GLU_SAMPLING_TOLERANCE, 5.0f);
    gluNurbsProperty(pNurb2, GLU_DISPLAY_MODE, GLU_OUTLINE_POLYGON);
/*     gluNurbsProperty(pNurb2, GLU_DISPLAY_MODE, GLU_FILL); */
    gluNurbsCallback(pNurb2, GLU_ERROR, (GLvoid (*) ()) nurbsError);
  }
  glClearColor(1.0, 1.0, 1.0, 0.0);
  glShadeModel(GL_SMOOTH);
  glLineWidth(7.0);
  glTranslatef(0., 0., -1.5);
}
Beispiel #5
0
static void Init(void)
{

    theNurbs = gluNewNurbsRenderer();
    gluNurbsCallback(theNurbs, GLU_ERROR, ErrorCallback);

    gluNurbsProperty(theNurbs, GLU_SAMPLING_TOLERANCE, 15.0);
    gluNurbsProperty(theNurbs, GLU_DISPLAY_MODE, GLU_OUTLINE_PATCH);

    expectedError = GLU_INVALID_ENUM;
    gluNurbsProperty(theNurbs, ~0, 15.0);
    expectedError = GLU_NURBS_ERROR13;
    gluEndSurface(theNurbs);
    expectedError = 0;

    glColor3f(1.0, 1.0, 1.0);
}
Beispiel #6
0
    void draw_local()
    {
        int i,j;
        GLfloat knots[8] = {0,1,2,3,4,5,6,7};

        GLfloat mat_diffuse[] = { 0.7, 0.7, 0.7, 1.0 };
        GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
        GLfloat mat_shininess[] = { 100.0 };

        glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
        glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
        glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);

        theNurb = gluNewNurbsRenderer();
        gluNurbsProperty(theNurb, GLU_SAMPLING_TOLERANCE, 25.0);
        gluNurbsProperty(theNurb, GLU_DISPLAY_MODE, GLU_FILL);
        gluNurbsCallback(theNurb, GLU_ERROR, (GLvoid (*)()) nurbsError);

        gluBeginSurface(theNurb);
        gluNurbsSurface(theNurb,
                        8, knots, 8, knots,
                        3*6, 3, &ctlpoints[0][0][0],
                        2, 2, GL_MAP2_VERTEX_3);
        gluEndSurface(theNurb);

        if (showPoints) {
            glPointSize(5.0);
            glDisable(GL_LIGHTING);
            glColor3f(1.0, 1.0, 0.0);
            glBegin(GL_POINTS);

            for (i=0; i<6; i++) {
                for (j=0; j<6; j++) {
                    glVertex3f(ctlpoints[i][j][0],
                               ctlpoints[i][j][1],
                               ctlpoints[i][j][2]);
                }
            }
            glEnd();
            glEnable(GL_LIGHTING);
        }

        gluDeleteNurbsRenderer(theNurb);
    }
Beispiel #7
0
void init(void)
{
    GLfloat mat_diffuse[] = { 0.7, 0.7, 0.7, 1.0 };
    GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
    GLfloat mat_shininess[] = { 100.0 };
    glClearColor(0.0, 0.0, 0.0, 0.0);
    glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
    glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
    glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_AUTO_NORMAL);
    glEnable(GL_NORMALIZE);
    init_surface();
    theNurb = gluNewNurbsRenderer();
    gluNurbsProperty(theNurb, GLU_SAMPLING_TOLERANCE, 25.0);
    gluNurbsProperty(theNurb, GLU_DISPLAY_MODE, GLU_FILL);
    gluNurbsCallback(theNurb, GLU_ERROR, nurbsError);
}
Beispiel #8
0
/* nurb:NurbsCallback(which, func) -> nurb */
static int luaglu_nurbs_callback(lua_State *L) 
{
  LuaGLUnurb *lnurb=luaglu_checknurb(L,1);
  GLenum e;

  e = luaglu_get_gl_enum(L, 2);

  if (!(lua_isfunction(L,3) || lua_isnil(L,3)))
    luaL_argerror(L, 3, "invalid callback");

  lua_rawgeti(L,LUA_REGISTRYINDEX,lnurb->ref_cb);/* get callback table */

  /* set C callback */
  switch(e) 
  {
  case GLU_NURBS_BEGIN : 
    gluNurbsCallback(lnurb->nurb,GLU_NURBS_BEGIN_DATA,nurbBeginDataCB);
    lua_pushstring(L,"BeginCB");lua_pushvalue(L,3);lua_settable(L,-3);
    break;
  case GLU_NURBS_VERTEX : 
    gluNurbsCallback(lnurb->nurb,GLU_NURBS_VERTEX_DATA,nurbVertexDataCB);
    lua_pushstring(L,"VertexCB");lua_pushvalue(L,3);lua_settable(L,-3);
    break;
  case GLU_NURBS_NORMAL : 
    gluNurbsCallback(lnurb->nurb,GLU_NURBS_NORMAL_DATA,nurbNormalDataCB);
    lua_pushstring(L,"NormalCB");lua_pushvalue(L,3);lua_settable(L,-3);
    break;
  case GLU_NURBS_COLOR : 
    gluNurbsCallback(lnurb->nurb,GLU_NURBS_COLOR_DATA,nurbColorDataCB);
    lua_pushstring(L,"ColorCB");lua_pushvalue(L,3);lua_settable(L,-3);
    break;
  case GLU_NURBS_TEXTURE_COORD : 
    gluNurbsCallback(lnurb->nurb,GLU_NURBS_TEXTURE_COORD_DATA,nurbTexCoordDataCB);
    lua_pushstring(L,"TexCoordCB");lua_pushvalue(L,3);lua_settable(L,-3);
    break;
  case GLU_NURBS_END : 
    gluNurbsCallback(lnurb->nurb,GLU_NURBS_END_DATA,nurbEndDataCB);
    lua_pushstring(L,"EndCB");lua_pushvalue(L,3);lua_settable(L,-3);
    break;
  default : 
    luaL_argerror(L, 2, "invalid or unnown enumeration");
  }
  
  lua_pushvalue(L,1);
  return 1;
}
/***************************************************************************
 DrawTrace
 ****************************************************************************/
static void DrawTrace(int snum){
    int i = 0;
    float comx = 0.0,
	comy = 0.0,
	comz = 0.0;
    
    struct coord *c = state->coords[snum];
    
    for (i=0; i<c->size; i++){
        comx += c->rp_ca[i].x;
        comy += c->rp_ca[i].y;
        comz += c->rp_ca[i].z;
    }
    comx /= c->size;
    comy /= c->size;
    comz /= c->size;
    
    GLUnurbsObj *nurbs = gluNewNurbsRenderer();
    
    GLfloat* ctrlpts = E_MALLOC(12*sizeof(GLfloat)*c->size);
    for(i=0; i < c->size*12; i+=12){
        
        ctrlpts[i]   = c->rp_n[i/12].x - comx;
        ctrlpts[i+1] = c->rp_n[i/12].y - comy;
        ctrlpts[i+2] = c->rp_n[i/12].z - comz;
        
        ctrlpts[i+3] = 1.0;
        
        ctrlpts[i+4] = c->rp_ca[i/12].x - comx;
        ctrlpts[i+5] = c->rp_ca[i/12].y - comy;
        ctrlpts[i+6] = c->rp_ca[i/12].z - comz;
		
        ctrlpts[i+7] = 1.0;
        
        ctrlpts[i+8] = c->rp_c[i/12].x - comx;
        ctrlpts[i+9] = c->rp_c[i/12].y - comy;
        ctrlpts[i+10] = c->rp_c[i/12].z - comz;
		
        ctrlpts[i+11] = 1.0;
		
    }
    
    GLfloat* knots = E_MALLOC(sizeof(GLfloat)*(c->size*3+4));
    
    for(i=0; i < c->size*3+4; i++){
		
        if(i>c->size*3+2){
            knots[i]=knots[c->size*3+2];
        }
        else{
            knots[i]=i/1.0-i%1; 
        }
    }
    
    glColor3f(0.0, 0.0, 1.0);
    if(snum%3 == 1){
        glColor3f(1.0, 0.0, 0.0);
    }
    else if(snum%3 == 2){
        glColor3f(0.0, 1.0, 0.0);
        
    }
    else{
        glColor3f(0.0, 1.0, 0.0);
    }
    
    
    glLineWidth(2);
    
    glPushMatrix();
    
    gluNurbsCallback(nurbs, GLU_ERROR, (GLvoid(*)())nurbsError);
    
    gluBeginCurve(nurbs);
	
    gluNurbsCurve(nurbs,              //context object
                  c->size*3+4,          //number of knots
                  knots,              //knot pointer
                  4,                  //width of control points
                  ctrlpts,  //control point pointer
                  4,                  //order of the curve (degree+1)
                  GL_MAP1_VERTEX_4    //type
				  );
	
    gluEndCurve(nurbs);
    
    glPopMatrix();
}
/***************************************************************************
 Draw3dRibbon
 ****************************************************************************/
static void Draw3dRibbon(int snum){
    int i = 0;
    float comx = 0.0,
	comy = 0.0,
	comz = 0.0;
    float *cp = E_MALLOC(3*sizeof(float));
    float *inA = E_MALLOC(3*sizeof(float));
    float *inB = E_MALLOC(3*sizeof(float));
    float *inC = E_MALLOC(3*sizeof(float));
    float *out = E_MALLOC(3*sizeof(float));
	
    struct coord *c = state->coords[snum];
	
    for (i=0; i<c->size; i++){
        comx += c->rp_ca[i].x;
        comy += c->rp_ca[i].y;
        comz += c->rp_ca[i].z;
    }
    comx /= c->size;
    comy /= c->size;
    comz /= c->size;
    
    GLUnurbsObj *nurbs = gluNewNurbsRenderer();
    
    GLfloat* ctrlpts = E_MALLOC(12*sizeof(GLfloat)*(c->size-1));
    
    GLfloat* tracepts = E_MALLOC(3*sizeof(GLfloat)*c->size-1);
    
    for(i=0; i < c->size-1; i++){
        if((i) %2){
            ctrlpts[i*12]   = c->rp_c[i].x - comx;
            ctrlpts[i*12+1] = c->rp_c[i].y - comy;
            ctrlpts[i*12+2] = c->rp_c[i].z - comz;
        }
        else{
            ctrlpts[i*12]   = c->rp_o[i].x - comx;
            ctrlpts[i*12+1] = c->rp_o[i].y - comy;
            ctrlpts[i*12+2] = c->rp_o[i].z - comz;
        }
        
        inA[0] = c->rp_c[i].x - c->rp_ca[i].x;
        inA[1] = c->rp_c[i].y - c->rp_ca[i].y;
        inA[2] = c->rp_c[i].z - c->rp_ca[i].z;
        inB[0] = c->rp_c[i].x - c->rp_o[i].x;
        inB[1] = c->rp_c[i].y - c->rp_o[i].y;
        inB[2] = c->rp_c[i].z - c->rp_o[i].z;
        
        cross(cp, inA, inB);
        normalize(cp);
        
        inC[0] = ((c->rp_c[i].x + c->rp_ca[i].x) / 2) - comx;
        inC[1] = ((c->rp_c[i].y + c->rp_ca[i].y) / 2) - comy;
        inC[2] = ((c->rp_c[i].z + c->rp_ca[i].z) / 2) - comz;
        
        //cross(out, cp, inC);
        //normalize(out);
		
        ctrlpts[i*12+3] = inC[0] + cp[0];
        ctrlpts[i*12+4] = inC[1] + cp[1];
        ctrlpts[i*12+5] = inC[2] + cp[2];
        
        if((i) %2){
            ctrlpts[i*12+6] = c->rp_o[i].x - comx;
            ctrlpts[i*12+7] = c->rp_o[i].y - comy;
            ctrlpts[i*12+8] = c->rp_o[i].z - comz;
        }
        else{
            ctrlpts[i*12+6]   = c->rp_c[i].x - comx;
            ctrlpts[i*12+7] = c->rp_c[i].y - comy;
            ctrlpts[i*12+8] = c->rp_c[i].z - comz;
        }
        
        
		ctrlpts[i*12+9]  = inC[0] - cp[0];
		ctrlpts[i*12+10] = inC[1] - cp[1];
		ctrlpts[i*12+11] = inC[2] - cp[2];
		
		tracepts[i] = inC[0];
		tracepts[i+1] = inC[1];
		tracepts[i+2] = inC[2];
		
		//                printf("[%f, %f, %f], [%f, %f, %f] \n", 
		//                       cp[0], cp[1], cp[2],
		//                       inC[0], inC[1], inC[2]);
        
		//        printf("[%f, %f, %f], [%f, %f, %f], [%f, %f, %f], [%f, %f, %f] \n",
		//               ctrlpts[i], ctrlpts[i+1] ,ctrlpts[i+2], ctrlpts[i+3], ctrlpts[i+4],
		//               ctrlpts[i+5], ctrlpts[i+6], ctrlpts[i+7], ctrlpts[i+8], ctrlpts[i+9], 
		//               ctrlpts[i+10], ctrlpts[i+11]);
        
    }
	
    free(cp);
    free(inA);
    free(inB);
    free(inC);
    free(out);
    
	GLfloat* uknots = E_MALLOC(sizeof(GLfloat)*(c->size+3));
	
	for(i=0; i < c->size+3; i++){
		if(i<c->size+1 && i>2){
			uknots[i] = uknots[i-1]+1.0;
		}
		else if(i<3){
			uknots[i] = 0.0;
		}
		else{
			uknots[i] = uknots[i-1]; 
		}
	}
	
	
	GLfloat vknots[8] = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0};
	
	GLfloat* knots = E_MALLOC(sizeof(GLfloat)*(c->size+4));
	
	for(i=0; i < c->size+4; i++){
		
		if(i>c->size+2){
			knots[i]=knots[c->size+2];
		}
		else{
			knots[i]=i/1.0-i%1; 
		}
	}
	
	
	
	glColor3f(0.0, 0.0, 1.0);
	glEnable(GL_AUTO_NORMAL);
	glShadeModel(GL_SMOOTH);
	
	glPushMatrix();
	
	gluNurbsCallback(nurbs, GLU_ERROR, (GLvoid(*)())nurbsError);
	gluNurbsProperty(nurbs, GLU_V_STEP, 4);
	gluNurbsProperty(nurbs, GLU_U_STEP, 4);
	gluNurbsProperty(nurbs, GLU_CULLING, GL_TRUE);
	gluNurbsProperty(nurbs, GLU_SAMPLING_METHOD, GLU_DOMAIN_DISTANCE);
	
	glShadeModel(GL_SMOOTH);
	
	gluBeginSurface(nurbs);
	
	gluNurbsSurface(nurbs,              //context object
					c->size+3,          //number of u-knots
					uknots,             //u-knot pointer
					8,                  //number of v-knots
					vknots,             //v-knot ptr
					3,                  //width of u-control points (u-stride)
					3,                  //width of v-control points (v-stride)
					ctrlpts,            //control point pointer
					4,                  // u-order of the curve (degree+1)
					4,                  // v-order of the curve (degree+1)
					GL_MAP2_TEXTURE_COORD_2    //type
					);
	
	gluNurbsSurface(nurbs,              //context object
					c->size+3,          //number of u-knots
					uknots,             //u-knot pointer
					8,                  //number of v-knots
					vknots,             //v-knot ptr
					3,                  //width of u-control points (u-stride)
					3,                  //width of v-control points (v-stride)
					ctrlpts,            //control point pointer
					4,                  // u-order of the curve (degree+1)
					4,                  // v-order of the curve (degree+1)
					GL_MAP2_NORMAL      //type
					);
	
	
	gluNurbsSurface(nurbs,              //context object
					c->size+3,          //number of u-knots
					uknots,             //u-knot pointer
					8,                  //number of v-knots
					vknots,             //v-knot ptr
					3,                  //width of u-control points (u-stride)
					3,                  //width of v-control points (v-stride)
					ctrlpts,            //control point pointer
					4,                  // u-order of the curve (degree+1)
					4,                  // v-order of the curve (degree+1)
					GL_MAP2_VERTEX_3    //type
					);
	
	
	gluEndSurface(nurbs);
	/*
	 gluBeginCurve(nurbs);
	 gluNurbsCurve(nurbs,              //context object
	 c->size+4,          //number of knots
	 knots,              //knot pointer
	 3,                  //width of control points
	 tracepts,  //control point pointer
	 4,                  //order of the curve (degree+1)
	 GL_MAP1_VERTEX_3    //type
	 );
	 
	 gluEndCurve(nurbs);
	 */
	glPopMatrix();
}
/***************************************************************************
 DrawRibbon
 ****************************************************************************/
static void DrawRibbon(int snum){
    int i = 0;
    float comx = 0.0,
	comy = 0.0,
	comz = 0.0;
    struct coord *c = state->coords[snum];
	
    for (i=0; i<c->size; i++){
        comx += c->rp_ca[i].x;
        comy += c->rp_ca[i].y;
        comz += c->rp_ca[i].z;
    }
    comx /= c->size;
    comy /= c->size;
    comz /= c->size;
    
    GLUnurbsObj *nurbs = gluNewNurbsRenderer();
    
    GLfloat* ctrlpts = E_MALLOC(6*sizeof(GLfloat)*c->size);
    for(i=0; i < c->size*6; i+=6){
        
		ctrlpts[i]   = c->rp_n[i/6].x - comx;
		ctrlpts[i+1] = c->rp_n[i/6].y - comy;
		ctrlpts[i+2] = c->rp_n[i/6].z - comz;
        
		ctrlpts[i+3] = c->rp_c[i/6].x - comx;
		ctrlpts[i+4] = c->rp_c[i/6].y - comy;
		ctrlpts[i+5] = c->rp_c[i/6].z - comz;
		
    }
    
    GLfloat* uknots = E_MALLOC(sizeof(GLfloat)*(2*c->size+4));
    
    for(i=0; i < 2*c->size+4; i++){
        if(i>c->size*2+3){
            uknots[i]=uknots[c->size*2+3];
        }
        else{
            uknots[i]=i/1.0; 
        }
    }
	
	GLfloat vknots[8] = {0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0};
	
	glColor3f(0.0, 0.0, 1.0);
	glLineWidth(2);
	glEnable(GL_AUTO_NORMAL);
	glShadeModel(GL_SMOOTH);
	
	glPushMatrix();
	
	gluNurbsCallback(nurbs, GLU_ERROR, (GLvoid(*)())nurbsError);
	gluNurbsProperty(nurbs, GLU_V_STEP, 4);
	gluNurbsProperty(nurbs, GLU_U_STEP, 4);
	gluNurbsProperty(nurbs, GLU_CULLING, GL_TRUE);
	gluNurbsProperty(nurbs, GLU_SAMPLING_METHOD, GLU_DOMAIN_DISTANCE);
	
	glShadeModel(GL_SMOOTH);
	
	gluBeginSurface(nurbs);
	
	
	if(snum%3 == 1){
		glColor3f(1.0, 0.0, 0.0);
	}
	else if(snum%3 == 2){
		glColor3f(0.0, 1.0, 0.0);
		
	}
	else{
		glColor3f(0.0, 1.0, 0.0);
	}
	
	gluNurbsSurface(nurbs,              //context object
					c->size*2+4,          //number of u-knots
					uknots,                //u-knot pointer
					8,                  //number of v-knots
					vknots,               //v-knot ptr
					3,                  //width of u-control points (u-stride)
					3,                  //width of v-control points (v-stride)
					ctrlpts,  //control point pointer
					4,                  // u-order of the curve (degree+1)
					4,                  // v-order of the curve (degree+1)
					GL_MAP2_TEXTURE_COORD_2    //type
					);
	
	gluNurbsSurface(nurbs,              //context object
					c->size*2+4,          //number of u-knots
					uknots,                //u-knot pointer
					8,                  //number of v-knots
					vknots,               //v-knot ptr
					3,                  //width of u-control points (u-stride)
					3,                  //width of v-control points (v-stride)
					ctrlpts,  //control point pointer
					4,                  // u-order of the curve (degree+1)
					4,                  // v-order of the curve (degree+1)
					GL_MAP2_VERTEX_3    //type
					);
	
	gluEndSurface(nurbs);
	
	glPopMatrix();
}