void GLAPIENTRY gluBeginTrim(GLUnurbsObj * nobj) { #if 0 nurbs_trim *ptr; #endif if (nobj->nurbs_type != GLU_NURBS_TRIM_DONE) if (nobj->nurbs_type != GLU_NURBS_NO_TRIM) { call_user_error(nobj, GLU_NURBS_ERROR15); return; } nobj->nurbs_type = GLU_NURBS_TRIM; fprintf(stderr, "NURBS - trimming not supported yet\n"); #if 0 if ((ptr = (nurbs_trim *) malloc(sizeof(nurbs_trim))) == NULL) { call_user_error(nobj, GLU_OUT_OF_MEMORY); return; } if (nobj->trim) { nurbs_trim *tmp_ptr; for (tmp_ptr = nobj->trim; tmp_ptr->next; tmp_ptr = tmp_ptr->next); tmp_ptr->next = ptr; } else nobj->trim = ptr; ptr->trim_loop = NULL; ptr->segments = NULL; ptr->next = NULL; #endif }
void GLAPIENTRY gluEndCurve(GLUnurbsObj * nobj) { if (nobj->nurbs_type == GLU_NURBS_NONE) { call_user_error(nobj, GLU_NURBS_ERROR7); return; } if (nobj->curve.geom.type == GLU_INVALID_ENUM) { call_user_error(nobj, GLU_NURBS_ERROR8); nobj->nurbs_type = GLU_NURBS_NONE; return; } glPushAttrib((GLbitfield) (GL_EVAL_BIT | GL_ENABLE_BIT)); glDisable(GL_MAP1_VERTEX_3); glDisable(GL_MAP1_VERTEX_4); glDisable(GL_MAP1_INDEX); glDisable(GL_MAP1_COLOR_4); glDisable(GL_MAP1_NORMAL); glDisable(GL_MAP1_TEXTURE_COORD_1); glDisable(GL_MAP1_TEXTURE_COORD_2); glDisable(GL_MAP1_TEXTURE_COORD_3); glDisable(GL_MAP1_TEXTURE_COORD_4); glDisable(GL_MAP2_VERTEX_3); glDisable(GL_MAP2_VERTEX_4); glDisable(GL_MAP2_INDEX); glDisable(GL_MAP2_COLOR_4); glDisable(GL_MAP2_NORMAL); glDisable(GL_MAP2_TEXTURE_COORD_1); glDisable(GL_MAP2_TEXTURE_COORD_2); glDisable(GL_MAP2_TEXTURE_COORD_3); glDisable(GL_MAP2_TEXTURE_COORD_4); do_nurbs_curve(nobj); glPopAttrib(); nobj->nurbs_type = GLU_NURBS_NONE; }
static GLenum test_nurbs_surface(GLUnurbsObj *nobj, surface_attribs *attrib) { GLenum err; GLint tmp_int; if(attrib->sorder < 0 || attrib->torder < 0) { call_user_error(nobj,GLU_INVALID_VALUE); return GLU_ERROR; } glGetIntegerv(GL_MAX_EVAL_ORDER,&tmp_int); if(attrib->sorder > tmp_int || attrib->sorder < 2) { call_user_error(nobj,GLU_NURBS_ERROR1); return GLU_ERROR; } if(attrib->torder > tmp_int || attrib->torder < 2) { call_user_error(nobj,GLU_NURBS_ERROR1); return GLU_ERROR; } if(attrib->sknot_count < attrib->sorder +2) { call_user_error(nobj,GLU_NURBS_ERROR2); return GLU_ERROR; } if(attrib->tknot_count < attrib->torder +2) { call_user_error(nobj,GLU_NURBS_ERROR2); return GLU_ERROR; } if(attrib->s_stride < 0 || attrib->t_stride < 0) { call_user_error(nobj,GLU_NURBS_ERROR34); return GLU_ERROR; } if(attrib->sknot==NULL || attrib->tknot==NULL || attrib->ctrlarray==NULL) { call_user_error(nobj,GLU_NURBS_ERROR36); return GLU_ERROR; } if((err=test_knot(attrib->tknot_count,attrib->tknot,attrib->torder)) !=GLU_NO_ERROR) { call_user_error(nobj,err); return GLU_ERROR; } if((err=test_knot(attrib->sknot_count,attrib->sknot,attrib->sorder)) !=GLU_NO_ERROR) { call_user_error(nobj,err); return GLU_ERROR; } return GLU_NO_ERROR; }
void GLAPIENTRY gluPwlCurve(GLUnurbsObj * nobj, GLint count, GLfloat * array, GLint stride, GLenum type) { #if 0 nurbs_trim *ptr1; trim_list *ptr2; #endif if (nobj->nurbs_type == GLU_NURBS_CURVE) { call_user_error(nobj, GLU_NURBS_ERROR9); return; } if (nobj->nurbs_type == GLU_NURBS_NONE) { call_user_error(nobj, GLU_NURBS_ERROR19); return; } if (type != GLU_MAP1_TRIM_2 && type != GLU_MAP1_TRIM_3) { call_user_error(nobj, GLU_NURBS_ERROR14); return; } #if 0 for (ptr1 = nobj->trim; ptr1->next; ptr1 = ptr1->next); if (ptr1->trim_loop) { for (ptr2 = ptr1->trim_loop; ptr2->next; ptr2 = ptr2->next); if ((ptr2->next = (trim_list *) malloc(sizeof(trim_list))) == NULL) { call_user_error(nobj, GLU_OUT_OF_MEMORY); return; } ptr2 = ptr2->next; } else { if ((ptr2 = (trim_list *) malloc(sizeof(trim_list))) == NULL) { call_user_error(nobj, GLU_OUT_OF_MEMORY); return; } ptr1->trim_loop = ptr2; } ptr2->trim_type = GLU_TRIM_PWL; ptr2->curve.pwl_curve.pt_count = count; ptr2->curve.pwl_curve.ctrlarray = array; ptr2->curve.pwl_curve.stride = stride; ptr2->curve.pwl_curve.dim = (type == GLU_MAP1_TRIM_2 ? 2 : 3); ptr2->curve.pwl_curve.type = type; ptr2->next = NULL; #endif }
void GLAPIENTRY gluNurbsCallback(GLUnurbsObj * nobj, GLenum which, void (GLCALLBACK * fn) ()) { nobj->error_callback = (void (GLCALLBACKPCAST) (GLenum)) fn; if (which != GLU_ERROR) call_user_error(nobj, GLU_INVALID_ENUM); }
void GLAPIENTRY gluEndSurface(GLUnurbsObj * nobj) { switch (nobj->nurbs_type) { case GLU_NURBS_NONE: call_user_error(nobj, GLU_NURBS_ERROR13); break; case GLU_NURBS_TRIM: call_user_error(nobj, GLU_NURBS_ERROR12); break; case GLU_NURBS_TRIM_DONE: /* if(nobj->trim->trim_loop==NULL) { call_user_error(nobj,GLU_NURBS_ERROR18); return; }*/ /* no break - fallthrough */ case GLU_NURBS_NO_TRIM: glPushAttrib((GLbitfield) (GL_EVAL_BIT | GL_ENABLE_BIT | GL_POLYGON_BIT)); glDisable(GL_MAP2_VERTEX_3); glDisable(GL_MAP2_VERTEX_4); glDisable(GL_MAP2_INDEX); glDisable(GL_MAP2_COLOR_4); glDisable(GL_MAP2_NORMAL); glDisable(GL_MAP2_TEXTURE_COORD_1); glDisable(GL_MAP2_TEXTURE_COORD_2); glDisable(GL_MAP2_TEXTURE_COORD_3); glDisable(GL_MAP2_TEXTURE_COORD_4); /* glDisable(GL_MAP1_VERTEX_3); glDisable(GL_MAP1_VERTEX_4); glDisable(GL_MAP1_INDEX); glDisable(GL_MAP1_COLOR_4); glDisable(GL_MAP1_NORMAL); glDisable(GL_MAP1_TEXTURE_COORD_1); glDisable(GL_MAP1_TEXTURE_COORD_2); glDisable(GL_MAP1_TEXTURE_COORD_3); glDisable(GL_MAP1_TEXTURE_COORD_4);*/ do_nurbs_surface(nobj); glPopAttrib(); break; default: call_user_error(nobj, GLU_NURBS_ERROR8); } nobj->nurbs_type = GLU_NURBS_NONE; }
void GLAPIENTRY gluEndTrim(GLUnurbsObj * nobj) { if (nobj->nurbs_type != GLU_NURBS_TRIM) { call_user_error(nobj, GLU_NURBS_ERROR17); return; } nobj->nurbs_type = GLU_NURBS_TRIM_DONE; }
void GLAPIENTRY gluBeginCurve(GLUnurbsObj * nobj) { if (nobj->nurbs_type == GLU_NURBS_CURVE) { call_user_error(nobj, GLU_NURBS_ERROR6); return; } nobj->nurbs_type = GLU_NURBS_CURVE; nobj->curve.geom.type = GLU_INVALID_ENUM; nobj->curve.color.type = GLU_INVALID_ENUM; nobj->curve.texture.type = GLU_INVALID_ENUM; nobj->curve.normal.type = GLU_INVALID_ENUM; }
void GLAPIENTRY gluBeginSurface(GLUnurbsObj * nobj) { switch (nobj->nurbs_type) { case GLU_NURBS_NONE: nobj->nurbs_type = GLU_NURBS_SURFACE; nobj->surface.geom.type = GLU_INVALID_ENUM; nobj->surface.color.type = GLU_INVALID_ENUM; nobj->surface.texture.type = GLU_INVALID_ENUM; nobj->surface.normal.type = GLU_INVALID_ENUM; break; case GLU_NURBS_TRIM: call_user_error(nobj, GLU_NURBS_ERROR16); break; case GLU_NURBS_SURFACE: case GLU_NURBS_NO_TRIM: case GLU_NURBS_TRIM_DONE: call_user_error(nobj, GLU_NURBS_ERROR27); break; case GLU_NURBS_CURVE: call_user_error(nobj, GLU_NURBS_ERROR6); break; } }
void GLAPIENTRY gluGetNurbsProperty(GLUnurbsObj * nobj, GLenum property, GLfloat * value) { switch (property) { case GLU_SAMPLING_TOLERANCE: *value = nobj->sampling_tolerance; break; case GLU_DISPLAY_MODE: *value = (GLfloat) (GLint) nobj->display_mode; break; case GLU_CULLING: *value = nobj->culling ? 1.0 : 0.0; break; case GLU_AUTO_LOAD_MATRIX: *value = nobj->auto_load_matrix ? 1.0 : 0.0; break; default: call_user_error(nobj, GLU_INVALID_ENUM); } }
/* sequence of adjacent Bezier patches */ static GLenum convert_surfs(GLUnurbsObj *nobj, new_ctrl_type *new_ctrl) { knot_str_type geom_s_knot,color_s_knot,normal_s_knot,texture_s_knot; knot_str_type geom_t_knot,color_t_knot,normal_t_knot,texture_t_knot; GLenum err; if((err=fill_knot_structures(nobj,&geom_s_knot,&geom_t_knot, &color_s_knot,&color_t_knot,&normal_s_knot,&normal_t_knot, &texture_s_knot,&texture_t_knot)) !=GLU_NO_ERROR) { return err; } /* unify knots - all knots should have the same working range */ if((err=select_knot_working_range(nobj,&geom_s_knot,&color_s_knot, &normal_s_knot,&texture_s_knot)) !=GLU_NO_ERROR) { call_user_error(nobj,err); return err; } if((err=select_knot_working_range(nobj,&geom_t_knot,&color_t_knot, &normal_t_knot,&texture_t_knot)) !=GLU_NO_ERROR) { free_unified_knots(&geom_s_knot,&color_s_knot,&normal_s_knot, &texture_s_knot); call_user_error(nobj,err); return err; } /* convert the geometry surface */ nobj->surface.geom.dim=get_surface_dim(nobj->surface.geom.type); if((err=convert_surf(&geom_s_knot,&geom_t_knot,&(nobj->surface.geom), &(new_ctrl->geom_ctrl),&(new_ctrl->geom_s_pt_cnt), &(new_ctrl->geom_t_pt_cnt)))!=GLU_NO_ERROR) { free_unified_knots(&geom_s_knot,&color_s_knot,&normal_s_knot, &texture_s_knot); free_unified_knots(&geom_t_knot,&color_t_knot,&normal_t_knot, &texture_t_knot); call_user_error(nobj,err); return err; } /* if additional attributive surfaces are given convert them as well */ if(color_s_knot.unified_knot) { nobj->surface.color.dim=get_surface_dim(nobj->surface.color.type); if((err=convert_surf(&color_s_knot,&color_t_knot,&(nobj->surface.color), &(new_ctrl->color_ctrl),&(new_ctrl->color_s_pt_cnt), &(new_ctrl->color_t_pt_cnt)))!=GLU_NO_ERROR) { free_unified_knots(&color_s_knot,&color_s_knot,&normal_s_knot, &texture_s_knot); free_unified_knots(&color_t_knot,&color_t_knot,&normal_t_knot, &texture_t_knot); free_new_ctrl(new_ctrl); call_user_error(nobj,err); return err; } } if(normal_s_knot.unified_knot) { nobj->surface.normal.dim=get_surface_dim(nobj->surface.normal.type); if((err=convert_surf(&normal_s_knot,&normal_t_knot, &(nobj->surface.normal), &(new_ctrl->normal_ctrl),&(new_ctrl->normal_s_pt_cnt), &(new_ctrl->normal_t_pt_cnt)))!=GLU_NO_ERROR) { free_unified_knots(&normal_s_knot,&normal_s_knot,&normal_s_knot, &texture_s_knot); free_unified_knots(&normal_t_knot,&normal_t_knot,&normal_t_knot, &texture_t_knot); free_new_ctrl(new_ctrl); call_user_error(nobj,err); return err; } } if(texture_s_knot.unified_knot) { nobj->surface.texture.dim=get_surface_dim(nobj->surface.texture.type); if((err=convert_surf(&texture_s_knot,&texture_t_knot, &(nobj->surface.texture), &(new_ctrl->texture_ctrl),&(new_ctrl->texture_s_pt_cnt), &(new_ctrl->texture_t_pt_cnt)))!=GLU_NO_ERROR) { free_unified_knots(&texture_s_knot,&texture_s_knot,&texture_s_knot, &texture_s_knot); free_unified_knots(&texture_t_knot,&texture_t_knot,&texture_t_knot, &texture_t_knot); free_new_ctrl(new_ctrl); call_user_error(nobj,err); return err; } } return GLU_NO_ERROR; }
/* prepare the knot information structures */ static GLenum fill_knot_structures(GLUnurbsObj *nobj, knot_str_type *geom_s_knot, knot_str_type *geom_t_knot, knot_str_type *color_s_knot, knot_str_type *color_t_knot, knot_str_type *normal_s_knot, knot_str_type *normal_t_knot, knot_str_type *texture_s_knot, knot_str_type *texture_t_knot) { GLint order; GLfloat *knot; GLint nknots; GLint t_min,t_max; geom_s_knot->unified_knot=NULL; knot=geom_s_knot->knot=nobj->surface.geom.sknot; nknots=geom_s_knot->nknots=nobj->surface.geom.sknot_count; order=geom_s_knot->order=nobj->surface.geom.sorder; geom_s_knot->delta_nknots=0; t_min=geom_s_knot->t_min=order-1; t_max=geom_s_knot->t_max=nknots-order; if(fabs(knot[t_min]-knot[t_max])<EPSILON) { call_user_error(nobj,GLU_NURBS_ERROR3); return GLU_ERROR; } if(fabs(knot[0]-knot[t_min])<EPSILON) { /* knot open at beggining */ geom_s_knot->open_at_begin=GL_TRUE; } else geom_s_knot->open_at_begin=GL_FALSE; if(fabs(knot[t_max]-knot[nknots-1])<EPSILON) { /* knot open at end */ geom_s_knot->open_at_end=GL_TRUE; } else geom_s_knot->open_at_end=GL_FALSE; geom_t_knot->unified_knot=NULL; knot=geom_t_knot->knot=nobj->surface.geom.tknot; nknots=geom_t_knot->nknots=nobj->surface.geom.tknot_count; order=geom_t_knot->order=nobj->surface.geom.torder; geom_t_knot->delta_nknots=0; t_min=geom_t_knot->t_min=order-1; t_max=geom_t_knot->t_max=nknots-order; if(fabs(knot[t_min]-knot[t_max])<EPSILON) { call_user_error(nobj,GLU_NURBS_ERROR3); return GLU_ERROR; } if(fabs(knot[0]-knot[t_min])<EPSILON) { /* knot open at beggining */ geom_t_knot->open_at_begin=GL_TRUE; } else geom_t_knot->open_at_begin=GL_FALSE; if(fabs(knot[t_max]-knot[nknots-1])<EPSILON) { /* knot open at end */ geom_t_knot->open_at_end=GL_TRUE; } else geom_t_knot->open_at_end=GL_FALSE; if(nobj->surface.color.type!=GLU_INVALID_ENUM) { color_s_knot->unified_knot=(GLfloat *)1; knot=color_s_knot->knot=nobj->surface.color.sknot; nknots=color_s_knot->nknots=nobj->surface.color.sknot_count; order=color_s_knot->order=nobj->surface.color.sorder; color_s_knot->delta_nknots=0; t_min=color_s_knot->t_min=order-1; t_max=color_s_knot->t_max=nknots-order; if(fabs(knot[t_min]-knot[t_max])<EPSILON) { call_user_error(nobj,GLU_NURBS_ERROR3); return GLU_ERROR; } if(fabs(knot[0]-knot[t_min])<EPSILON) { /* knot open at beggining */ color_s_knot->open_at_begin=GL_TRUE; } else color_s_knot->open_at_begin=GL_FALSE; if(fabs(knot[t_max]-knot[nknots-1])<EPSILON) { /* knot open at end */ color_s_knot->open_at_end=GL_TRUE; } else color_s_knot->open_at_end=GL_FALSE; color_t_knot->unified_knot=(GLfloat *)1; knot=color_t_knot->knot=nobj->surface.color.tknot; nknots=color_t_knot->nknots=nobj->surface.color.tknot_count; order=color_t_knot->order=nobj->surface.color.torder; color_t_knot->delta_nknots=0; t_min=color_t_knot->t_min=order-1; t_max=color_t_knot->t_max=nknots-order; if(fabs(knot[t_min]-knot[t_max])<EPSILON) { call_user_error(nobj,GLU_NURBS_ERROR3); return GLU_ERROR; } if(fabs(knot[0]-knot[t_min])<EPSILON) { /* knot open at beggining */ color_t_knot->open_at_begin=GL_TRUE; } else color_t_knot->open_at_begin=GL_FALSE; if(fabs(knot[t_max]-knot[nknots-1])<EPSILON) { /* knot open at end */ color_t_knot->open_at_end=GL_TRUE; } else color_t_knot->open_at_end=GL_FALSE; } else { color_s_knot->unified_knot=NULL; color_t_knot->unified_knot=NULL; } if(nobj->surface.normal.type!=GLU_INVALID_ENUM) { normal_s_knot->unified_knot=(GLfloat *)1; knot=normal_s_knot->knot=nobj->surface.normal.sknot; nknots=normal_s_knot->nknots=nobj->surface.normal.sknot_count; order=normal_s_knot->order=nobj->surface.normal.sorder; normal_s_knot->delta_nknots=0; t_min=normal_s_knot->t_min=order-1; t_max=normal_s_knot->t_max=nknots-order; if(fabs(knot[t_min]-knot[t_max])<EPSILON) { call_user_error(nobj,GLU_NURBS_ERROR3); return GLU_ERROR; } if(fabs(knot[0]-knot[t_min])<EPSILON) { /* knot open at beggining */ normal_s_knot->open_at_begin=GL_TRUE; } else normal_s_knot->open_at_begin=GL_FALSE; if(fabs(knot[t_max]-knot[nknots-1])<EPSILON) { /* knot open at end */ normal_s_knot->open_at_end=GL_TRUE; } else normal_s_knot->open_at_end=GL_FALSE; normal_t_knot->unified_knot=(GLfloat *)1; knot=normal_t_knot->knot=nobj->surface.normal.tknot; nknots=normal_t_knot->nknots=nobj->surface.normal.tknot_count; order=normal_t_knot->order=nobj->surface.normal.torder; normal_t_knot->delta_nknots=0; t_min=normal_t_knot->t_min=order-1; t_max=normal_t_knot->t_max=nknots-order; if(fabs(knot[t_min]-knot[t_max])<EPSILON) { call_user_error(nobj,GLU_NURBS_ERROR3); return GLU_ERROR; } if(fabs(knot[0]-knot[t_min])<EPSILON) { /* knot open at beggining */ normal_t_knot->open_at_begin=GL_TRUE; } else normal_t_knot->open_at_begin=GL_FALSE; if(fabs(knot[t_max]-knot[nknots-1])<EPSILON) { /* knot open at end */ normal_t_knot->open_at_end=GL_TRUE; } else normal_t_knot->open_at_end=GL_FALSE; } else { normal_s_knot->unified_knot=NULL; normal_t_knot->unified_knot=NULL; } if(nobj->surface.texture.type!=GLU_INVALID_ENUM) { texture_s_knot->unified_knot=(GLfloat *)1; knot=texture_s_knot->knot=nobj->surface.texture.sknot; nknots=texture_s_knot->nknots=nobj->surface.texture.sknot_count; order=texture_s_knot->order=nobj->surface.texture.sorder; texture_s_knot->delta_nknots=0; t_min=texture_s_knot->t_min=order-1; t_max=texture_s_knot->t_max=nknots-order; if(fabs(knot[t_min]-knot[t_max])<EPSILON) { call_user_error(nobj,GLU_NURBS_ERROR3); return GLU_ERROR; } if(fabs(knot[0]-knot[t_min])<EPSILON) { /* knot open at beggining */ texture_s_knot->open_at_begin=GL_TRUE; } else texture_s_knot->open_at_begin=GL_FALSE; if(fabs(knot[t_max]-knot[nknots-1])<EPSILON) { /* knot open at end */ texture_s_knot->open_at_end=GL_TRUE; } else texture_s_knot->open_at_end=GL_FALSE; texture_t_knot->unified_knot=(GLfloat *)1; knot=texture_t_knot->knot=nobj->surface.texture.tknot; nknots=texture_t_knot->nknots=nobj->surface.texture.tknot_count; order=texture_t_knot->order=nobj->surface.texture.torder; texture_t_knot->delta_nknots=0; t_min=texture_t_knot->t_min=order-1; t_max=texture_t_knot->t_max=nknots-order; if(fabs(knot[t_min]-knot[t_max])<EPSILON) { call_user_error(nobj,GLU_NURBS_ERROR3); return GLU_ERROR; } if(fabs(knot[0]-knot[t_min])<EPSILON) { /* knot open at beggining */ texture_t_knot->open_at_begin=GL_TRUE; } else texture_t_knot->open_at_begin=GL_FALSE; if(fabs(knot[t_max]-knot[nknots-1])<EPSILON) { /* knot open at end */ texture_t_knot->open_at_end=GL_TRUE; } else texture_t_knot->open_at_end=GL_FALSE; } else { texture_s_knot->unified_knot=NULL; texture_t_knot->unified_knot=NULL; } return GLU_NO_ERROR; }
GLenum augment_new_ctrl(GLUnurbsObj *nobj, new_ctrl_type *p) { GLsizei offset_size; GLint i,j; p->s_bezier_cnt=(p->geom_s_pt_cnt)/(nobj->surface.geom.sorder); p->t_bezier_cnt=(p->geom_t_pt_cnt)/(nobj->surface.geom.torder); offset_size=(p->s_bezier_cnt)*(p->t_bezier_cnt); p->geom_t_stride=nobj->surface.geom.dim; p->geom_s_stride=(p->geom_t_pt_cnt)*(nobj->surface.geom.dim); p->color_t_stride=nobj->surface.color.dim; p->color_s_stride=(p->color_t_pt_cnt)*(nobj->surface.color.dim); p->normal_t_stride=nobj->surface.normal.dim; p->normal_s_stride=(p->normal_t_pt_cnt)*(nobj->surface.normal.dim); p->texture_t_stride=nobj->surface.texture.dim; p->texture_s_stride=(p->texture_t_pt_cnt)*(nobj->surface.texture.dim); if((p->geom_offsets=(GLfloat **)malloc(sizeof(GLfloat *)*offset_size))==NULL) { call_user_error(nobj,GLU_OUT_OF_MEMORY); return GLU_ERROR; } if(p->color_ctrl) if((p->color_offsets=(GLfloat **)malloc(sizeof(GLfloat *)*offset_size))==NULL) { free_new_ctrl(p); call_user_error(nobj,GLU_OUT_OF_MEMORY); return GLU_ERROR; } if(p->normal_ctrl) if((p->normal_offsets=(GLfloat **)malloc(sizeof(GLfloat *)*offset_size))==NULL) { free_new_ctrl(p); call_user_error(nobj,GLU_OUT_OF_MEMORY); return GLU_ERROR; } if(p->texture_ctrl) if((p->texture_offsets=(GLfloat **)malloc(sizeof(GLfloat *)*offset_size))==NULL) { free_new_ctrl(p); call_user_error(nobj,GLU_OUT_OF_MEMORY); return GLU_ERROR; } for(i=0;i<p->s_bezier_cnt;i++) for(j=0;j<p->t_bezier_cnt;j++) *(p->geom_offsets + i*(p->t_bezier_cnt) + j) = p->geom_ctrl + i*(nobj->surface.geom.sorder)* (nobj->surface.geom.dim)*(p->geom_t_pt_cnt) + j*(nobj->surface.geom.dim)*(nobj->surface.geom.torder); if(p->color_ctrl) for(i=0;i<p->s_bezier_cnt;i++) for(j=0;j<p->t_bezier_cnt;j++) *(p->color_offsets + i*(p->t_bezier_cnt) + j) = p->color_ctrl + i*(nobj->surface.color.sorder)* (nobj->surface.color.dim)*(p->color_t_pt_cnt) + j*(nobj->surface.color.dim)*(nobj->surface.color.torder); if(p->normal_ctrl) for(i=0;i<p->s_bezier_cnt;i++) for(j=0;j<p->t_bezier_cnt;j++) *(p->normal_offsets + i*(p->t_bezier_cnt) + j) = p->normal_ctrl + i*(nobj->surface.normal.sorder)* (nobj->surface.normal.dim)*(p->normal_t_pt_cnt) + j*(nobj->surface.normal.dim)*(nobj->surface.normal.torder); if(p->texture_ctrl) for(i=0;i<p->s_bezier_cnt;i++) for(j=0;j<p->t_bezier_cnt;j++) *(p->texture_offsets + i*(p->t_bezier_cnt) + j) = p->texture_ctrl + i*(nobj->surface.texture.sorder)* (nobj->surface.texture.dim)*(p->texture_t_pt_cnt) + j*(nobj->surface.texture.dim)*(nobj->surface.texture.torder); return GLU_NO_ERROR; }
void GLAPIENTRY gluNurbsSurface(GLUnurbsObj * nobj, GLint sknot_count, GLfloat * sknot, GLint tknot_count, GLfloat * tknot, GLint s_stride, GLint t_stride, GLfloat * ctrlarray, GLint sorder, GLint torder, GLenum type) { if (nobj->nurbs_type == GLU_NURBS_NO_TRIM || nobj->nurbs_type == GLU_NURBS_TRIM || nobj->nurbs_type == GLU_NURBS_TRIM_DONE) { if (type == GL_MAP2_VERTEX_3 || type == GL_MAP2_VERTEX_4) { call_user_error(nobj, GLU_NURBS_ERROR8); return; } } else if (nobj->nurbs_type != GLU_NURBS_SURFACE) { call_user_error(nobj, GLU_NURBS_ERROR11); return; } switch (type) { case GL_MAP2_VERTEX_3: case GL_MAP2_VERTEX_4: nobj->surface.geom.sknot_count = sknot_count; nobj->surface.geom.sknot = sknot; nobj->surface.geom.tknot_count = tknot_count; nobj->surface.geom.tknot = tknot; nobj->surface.geom.s_stride = s_stride; nobj->surface.geom.t_stride = t_stride; nobj->surface.geom.ctrlarray = ctrlarray; nobj->surface.geom.sorder = sorder; nobj->surface.geom.torder = torder; nobj->surface.geom.type = type; nobj->nurbs_type = GLU_NURBS_NO_TRIM; break; case GL_MAP2_INDEX: case GL_MAP2_COLOR_4: nobj->surface.color.sknot_count = sknot_count; nobj->surface.color.sknot = sknot; nobj->surface.color.tknot_count = tknot_count; nobj->surface.color.tknot = tknot; nobj->surface.color.s_stride = s_stride; nobj->surface.color.t_stride = t_stride; nobj->surface.color.ctrlarray = ctrlarray; nobj->surface.color.sorder = sorder; nobj->surface.color.torder = torder; nobj->surface.color.type = type; break; case GL_MAP2_NORMAL: nobj->surface.normal.sknot_count = sknot_count; nobj->surface.normal.sknot = sknot; nobj->surface.normal.tknot_count = tknot_count; nobj->surface.normal.tknot = tknot; nobj->surface.normal.s_stride = s_stride; nobj->surface.normal.t_stride = t_stride; nobj->surface.normal.ctrlarray = ctrlarray; nobj->surface.normal.sorder = sorder; nobj->surface.normal.torder = torder; nobj->surface.normal.type = type; break; case GL_MAP2_TEXTURE_COORD_1: case GL_MAP2_TEXTURE_COORD_2: case GL_MAP2_TEXTURE_COORD_3: case GL_MAP2_TEXTURE_COORD_4: nobj->surface.texture.sknot_count = sknot_count; nobj->surface.texture.sknot = sknot; nobj->surface.texture.tknot_count = tknot_count; nobj->surface.texture.tknot = tknot; nobj->surface.texture.s_stride = s_stride; nobj->surface.texture.t_stride = t_stride; nobj->surface.texture.ctrlarray = ctrlarray; nobj->surface.texture.sorder = sorder; nobj->surface.texture.torder = torder; nobj->surface.texture.type = type; break; default: call_user_error(nobj, GLU_INVALID_ENUM); } }
void GLAPIENTRY gluNurbsCurve(GLUnurbsObj * nobj, GLint nknots, GLfloat * knot, GLint stride, GLfloat * ctlarray, GLint order, GLenum type) { if (nobj->nurbs_type == GLU_NURBS_TRIM) { #if 0 /* TODO: NOT IMPLEMENTED YET */ nurbs_trim *ptr1; trim_list *ptr2; if (type != GLU_MAP1_TRIM_2 && type != GLU_MAP1_TRIM_3) { call_user_error(nobj, GLU_NURBS_ERROR14); return; } for (ptr1 = nobj->trim; ptr1->next; ptr1 = ptr1->next); if (ptr1->trim_loop) { for (ptr2 = ptr1->trim_loop; ptr2->next; ptr2 = ptr2->next); if ((ptr2->next = (trim_list *) malloc(sizeof(trim_list))) == NULL) { call_user_error(nobj, GLU_OUT_OF_MEMORY); return; } ptr2 = ptr2->next; } else { if ((ptr2 = (trim_list *) malloc(sizeof(trim_list))) == NULL) { call_user_error(nobj, GLU_OUT_OF_MEMORY); return; } ptr1->trim_loop = ptr2; } ptr2->trim_type = GLU_TRIM_NURBS; ptr2->curve.nurbs_curve.knot_count = nknots; ptr2->curve.nurbs_curve.knot = knot; ptr2->curve.nurbs_curve.stride = stride; ptr2->curve.nurbs_curve.ctrlarray = ctlarray; ptr2->curve.nurbs_curve.order = order; ptr2->curve.nurbs_curve.dim = (type == GLU_MAP1_TRIM_2 ? 2 : 3); ptr2->curve.nurbs_curve.type = type; ptr2->next = NULL; #endif } else { if (type == GLU_MAP1_TRIM_2 || type == GLU_MAP1_TRIM_3) { call_user_error(nobj, GLU_NURBS_ERROR22); return; } if (nobj->nurbs_type != GLU_NURBS_CURVE) { call_user_error(nobj, GLU_NURBS_ERROR10); return; } switch (type) { case GL_MAP1_VERTEX_3: case GL_MAP1_VERTEX_4: if (nobj->curve.geom.type != GLU_INVALID_ENUM) { call_user_error(nobj, GLU_NURBS_ERROR8); return; } nobj->curve.geom.type = type; nobj->curve.geom.knot_count = nknots; nobj->curve.geom.knot = knot; nobj->curve.geom.stride = stride; nobj->curve.geom.ctrlarray = ctlarray; nobj->curve.geom.order = order; break; case GL_MAP1_INDEX: case GL_MAP1_COLOR_4: nobj->curve.color.type = type; nobj->curve.color.knot_count = nknots; nobj->curve.color.knot = knot; nobj->curve.color.stride = stride; nobj->curve.color.ctrlarray = ctlarray; nobj->curve.color.order = order; break; case GL_MAP1_NORMAL: nobj->curve.normal.type = type; nobj->curve.normal.knot_count = nknots; nobj->curve.normal.knot = knot; nobj->curve.normal.stride = stride; nobj->curve.normal.ctrlarray = ctlarray; nobj->curve.normal.order = order; break; case GL_MAP1_TEXTURE_COORD_1: case GL_MAP1_TEXTURE_COORD_2: case GL_MAP1_TEXTURE_COORD_3: case GL_MAP1_TEXTURE_COORD_4: nobj->curve.texture.type = type; nobj->curve.texture.knot_count = nknots; nobj->curve.texture.knot = knot; nobj->curve.texture.stride = stride; nobj->curve.texture.ctrlarray = ctlarray; nobj->curve.texture.order = order; break; default: call_user_error(nobj, GLU_INVALID_ENUM); } } }
void GLAPIENTRY gluNurbsProperty(GLUnurbsObj * nobj, GLenum property, GLfloat value) { GLenum val; switch (property) { case GLU_SAMPLING_TOLERANCE: if (value <= 0.0) { call_user_error(nobj, GLU_INVALID_VALUE); return; } nobj->sampling_tolerance = value; break; case GLU_PARAMETRIC_TOLERANCE: if (value <= 0.0) { call_user_error(nobj, GLU_INVALID_VALUE); return; } nobj->parametric_tolerance = value; break; case GLU_U_STEP: if (value <= 0.0) { call_user_error(nobj, GLU_INVALID_VALUE); return; } nobj->u_step = (GLint) value; break; case GLU_V_STEP: if (value <= 0.0) { call_user_error(nobj, GLU_INVALID_VALUE); return; } nobj->v_step = (GLint) value; break; case GLU_SAMPLING_METHOD: val = (GLenum) value; if (val != GLU_PATH_LENGTH && val != GLU_PARAMETRIC_ERROR && val != GLU_DOMAIN_DISTANCE) { call_user_error(nobj, GLU_INVALID_ENUM); return; } nobj->sampling_method = val; break; case GLU_DISPLAY_MODE: val = (GLenum) value; if (val != GLU_FILL && val != GLU_OUTLINE_POLYGON && val != GLU_OUTLINE_PATCH) { call_user_error(nobj, GLU_INVALID_ENUM); return; } if (nobj->nurbs_type == GLU_NURBS_CURVE) { call_user_error(nobj, GLU_NURBS_ERROR26); return; } nobj->display_mode = val; if (val == GLU_OUTLINE_PATCH) fprintf(stderr, "NURBS, for the moment, can display only in POLYGON mode\n"); break; case GLU_CULLING: val = (GLenum) value; if (val != GL_TRUE && val != GL_FALSE) { call_user_error(nobj, GLU_INVALID_ENUM); return; } nobj->culling = (GLboolean) value; break; case GLU_AUTO_LOAD_MATRIX: val = (GLenum) value; if (val != GL_TRUE && val != GL_FALSE) { call_user_error(nobj, GLU_INVALID_ENUM); return; } nobj->auto_load_matrix = (GLboolean) value; break; default: call_user_error(nobj, GLU_NURBS_ERROR26); } }