1 /* 2 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) 3 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice including the dates of first publication and 13 * either this permission notice or a reference to 14 * http://oss.sgi.com/projects/FreeB/ 15 * shall be included in all copies or substantial portions of the Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 22 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 * SOFTWARE. 24 * 25 * Except as contained in this notice, the name of Silicon Graphics, Inc. 26 * shall not be used in advertising or otherwise to promote the sale, use or 27 * other dealings in this Software without prior written authorization from 28 * Silicon Graphics, Inc. 29 */ 30 /* 31 */ 32 33 #ifndef _BEZIERPATCHMESH_H 34 #define _BEZIERPATCHMESH_H 35 36 #include <GL/gl.h> 37 #include "bezierPatch.h" 38 39 typedef struct bezierPatchMesh{ 40 bezierPatch *bpatch; /*vertex*/ 41 bezierPatch *bpatch_normal; 42 bezierPatch *bpatch_texcoord; /*s,t,r,q*/ 43 bezierPatch *bpatch_color; /*RGBA*/ 44 45 float *UVarray; /*all UV components of all vertices of all strips*/ 46 int *length_array; /*[i] is the number of vertices in the ith strip*/ 47 GLenum *type_array; /*[i] is the type of the ith primitive*/ 48 49 /*to support dynamic insertion*/ 50 int size_UVarray; 51 int index_UVarray; 52 int size_length_array; 53 int index_length_array; 54 55 int counter; /*track the current strip size*/ 56 GLenum type; /*track the current type: 0: GL_TRIANGLES, 1: GL_TRIANGLE_STRIP*/ 57 58 /*we eventually want to evaluate from (u,v) to (x,y,z) and draw them*/ 59 float *vertex_array; /*each vertex contains three components*/ 60 float *normal_array; /*each normal contains three components*/ 61 float *color_array; 62 float *texcoord_array; 63 64 /*in case we need a linked list*/ 65 struct bezierPatchMesh *next; 66 } bezierPatchMesh; 67 68 #ifdef __cplusplus 69 extern "C" { 70 #endif 71 72 73 74 bezierPatchMesh *bezierPatchMeshMake(int maptype, float umin, float umax, int ustride, int uorder, float vmin, float vmax, int vstride, int vorder, float *ctlpoints, int size_UVarray, int size_length_array); 75 76 /*initilize patches to be null*/ 77 bezierPatchMesh *bezierPatchMeshMake2(int size_UVarray, int size_length_array); 78 79 void bezierPatchMeshPutPatch(bezierPatchMesh *bpm, int maptype, float umin, float umax, int ustride, int uorder, float vmin, float vmax, int vstride, int vorder, float *ctlpoints); 80 81 void bezierPatchMeshDelete(bezierPatchMesh *bpm); 82 83 void bezierPatchMeshBeginStrip(bezierPatchMesh *bpm, GLenum type); 84 85 void bezierPatchMeshEndStrip(bezierPatchMesh *bpm); 86 87 void bezierPatchMeshInsertUV(bezierPatchMesh *bpm, float u, float v); 88 89 void bezierPatchMeshPrint(bezierPatchMesh *bpm); 90 91 bezierPatchMesh* bezierPatchMeshListInsert(bezierPatchMesh* list, bezierPatchMesh* bpm); 92 93 void bezierPatchMeshListPrint(bezierPatchMesh* list); 94 95 int bezierPatchMeshListTotalStrips(bezierPatchMesh* list); 96 97 int bezierPatchMeshListTotalVert(bezierPatchMesh* list); 98 int bezierPatchMeshNumTriangles(bezierPatchMesh* bpm); 99 int bezierPatchMeshListNumTriangles(bezierPatchMesh* list); 100 101 void bezierPatchMeshDelDeg(bezierPatchMesh* bpm); 102 103 104 void bezierPatchMeshEval(bezierPatchMesh* bpm); 105 106 void bezierPatchMeshDraw(bezierPatchMesh* bpm); 107 108 void bezierPatchMeshListDraw(bezierPatchMesh* list); 109 void bezierPatchMeshListEval(bezierPatchMesh* list); 110 void bezierPatchMeshListCollect(bezierPatchMesh* list, float **vertex_array, float **normal_array, int **length_array, GLenum **type_array, int *num_strips); 111 112 void bezierPatchMeshListDelDeg(bezierPatchMesh* list); 113 void bezierPatchMeshListDelete(bezierPatchMesh *list); 114 bezierPatchMesh* bezierPatchMeshListReverse(bezierPatchMesh* list); 115 void drawStrips(float *vertex_array, float *normal_array, int *length_array, GLenum *type_array, int num_strips); 116 117 #ifdef __cplusplus 118 } 119 #endif 120 121 #endif 122