Merge remote branch 'nouveau/gallium-0.1' into gallium-0.2
[mesa.git] / src / glu / sgi / libnurbs / interface / bezierPatchMesh.h
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 "bezierPatch.h"
37
38 typedef struct bezierPatchMesh{
39 bezierPatch *bpatch; /*vertex*/
40 bezierPatch *bpatch_normal;
41 bezierPatch *bpatch_texcoord; /*s,t,r,q*/
42 bezierPatch *bpatch_color; /*RGBA*/
43
44 float *UVarray; /*all UV components of all vertices of all strips*/
45 int *length_array; /*[i] is the number of vertices in the ith strip*/
46 GLenum *type_array; /*[i] is the type of the ith primitive*/
47
48 /*to support dynamic insertion*/
49 int size_UVarray;
50 int index_UVarray;
51 int size_length_array;
52 int index_length_array;
53
54 int counter; /*track the current strip size*/
55 GLenum type; /*track the current type: 0: GL_TRIANGLES, 1: GL_TRIANGLE_STRIP*/
56
57 /*we eventually want to evaluate from (u,v) to (x,y,z) and draw them*/
58 float *vertex_array; /*each vertex contains three components*/
59 float *normal_array; /*each normal contains three components*/
60 float *color_array;
61 float *texcoord_array;
62
63 /*in case we need a linked list*/
64 struct bezierPatchMesh *next;
65 } bezierPatchMesh;
66
67 #ifdef __cplusplus
68 extern "C" {
69 #endif
70
71
72
73 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);
74
75 /*initilize patches to be null*/
76 bezierPatchMesh *bezierPatchMeshMake2(int size_UVarray, int size_length_array);
77
78 void bezierPatchMeshPutPatch(bezierPatchMesh *bpm, int maptype, float umin, float umax, int ustride, int uorder, float vmin, float vmax, int vstride, int vorder, float *ctlpoints);
79
80 void bezierPatchMeshDelete(bezierPatchMesh *bpm);
81
82 void bezierPatchMeshBeginStrip(bezierPatchMesh *bpm, GLenum type);
83
84 void bezierPatchMeshEndStrip(bezierPatchMesh *bpm);
85
86 void bezierPatchMeshInsertUV(bezierPatchMesh *bpm, float u, float v);
87
88 void bezierPatchMeshPrint(bezierPatchMesh *bpm);
89
90 bezierPatchMesh* bezierPatchMeshListInsert(bezierPatchMesh* list, bezierPatchMesh* bpm);
91
92 void bezierPatchMeshListPrint(bezierPatchMesh* list);
93
94 int bezierPatchMeshListTotalStrips(bezierPatchMesh* list);
95
96 int bezierPatchMeshListTotalVert(bezierPatchMesh* list);
97 int bezierPatchMeshNumTriangles(bezierPatchMesh* bpm);
98 int bezierPatchMeshListNumTriangles(bezierPatchMesh* list);
99
100 void bezierPatchMeshDelDeg(bezierPatchMesh* bpm);
101
102
103 void bezierPatchMeshEval(bezierPatchMesh* bpm);
104
105 void bezierPatchMeshDraw(bezierPatchMesh* bpm);
106
107 void bezierPatchMeshListDraw(bezierPatchMesh* list);
108 void bezierPatchMeshListEval(bezierPatchMesh* list);
109 void bezierPatchMeshListCollect(bezierPatchMesh* list, float **vertex_array, float **normal_array, int **length_array, GLenum **type_array, int *num_strips);
110
111 void bezierPatchMeshListDelDeg(bezierPatchMesh* list);
112 void bezierPatchMeshListDelete(bezierPatchMesh *list);
113 bezierPatchMesh* bezierPatchMeshListReverse(bezierPatchMesh* list);
114 void drawStrips(float *vertex_array, float *normal_array, int *length_array, GLenum *type_array, int num_strips);
115
116 #ifdef __cplusplus
117 }
118 #endif
119
120 #endif