SGI SI GLU library
[mesa.git] / src / glu / sgi / libnurbs / interface / glcurveval.h
1 /*
2 ** License Applicability. Except to the extent portions of this file are
3 ** made subject to an alternative license as permitted in the SGI Free
4 ** Software License B, Version 1.1 (the "License"), the contents of this
5 ** file are subject only to the provisions of the License. You may not use
6 ** this file except in compliance with the License. You may obtain a copy
7 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
8 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
9 **
10 ** http://oss.sgi.com/projects/FreeB
11 **
12 ** Note that, as provided in the License, the Software is distributed on an
13 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
14 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
15 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
16 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
17 **
18 ** Original Code. The Original Code is: OpenGL Sample Implementation,
19 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
20 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
21 ** Copyright in any portions created by third parties is as indicated
22 ** elsewhere herein. All Rights Reserved.
23 **
24 ** Additional Notice Provisions: The application programming interfaces
25 ** established by SGI in conjunction with the Original Code are The
26 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
27 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
28 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
29 ** Window System(R) (Version 1.3), released October 19, 1998. This software
30 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
31 ** published by SGI, but has not been independently verified as being
32 ** compliant with the OpenGL(R) version 1.2.1 Specification.
33 */
34
35 /*
36 * glcurveval.h
37 *
38 * $Date: 2001/03/17 00:25:40 $ $Revision: 1.1 $
39 * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/glcurveval.h,v 1.1 2001/03/17 00:25:40 brianp Exp $
40 */
41
42 #ifndef __gluglcurveval_h_
43 #define __gluglcurveval_h_
44
45 #include "gluos.h"
46 #include <GL/gl.h>
47 #include "basiccrveval.h"
48
49 class CurveMap;
50
51 /*for internal evaluator callback stuff*/
52 #ifndef IN_MAX_BEZIER_ORDER
53 #define IN_MAX_BEZIER_ORDER 40 /*XXX should be bigger than machine order*/
54 #endif
55
56 #ifndef IN_MAX_DIMENSION
57 #define IN_MAX_DIMENSION 4
58 #endif
59
60 typedef struct curveEvalMachine{
61 REAL uprime; //cached previously evaluated uprime
62 int k; //the dimension
63 REAL u1;
64 REAL u2;
65 int ustride;
66 int uorder;
67 REAL ctlpoints[IN_MAX_BEZIER_ORDER*IN_MAX_DIMENSION];
68 REAL ucoeff[IN_MAX_BEZIER_ORDER];//cache the polynomial values
69 } curveEvalMachine;
70
71 class OpenGLCurveEvaluator : public BasicCurveEvaluator {
72 public:
73 OpenGLCurveEvaluator(void);
74 ~OpenGLCurveEvaluator(void);
75 void range1f(long, REAL *, REAL *);
76 void domain1f(REAL, REAL);
77 void addMap(CurveMap *);
78
79 void enable(long);
80 void disable(long);
81 void bgnmap1f(long);
82 void map1f(long, REAL, REAL, long, long, REAL *);
83 void mapgrid1f(long, REAL, REAL);
84 void mapmesh1f(long, long, long);
85 void evalpoint1i(long);
86 void evalcoord1f(long, REAL);
87 void endmap1f(void);
88
89 void bgnline(void);
90 void endline(void);
91
92 void put_vertices_call_back(int flag)
93 {
94 output_triangles = flag;
95 }
96 void putCallBack(GLenum which, GLvoid (GLAPIENTRY *fn)(...));
97 void set_callback_userData(void *data)
98 {
99 userData = data;
100 }
101
102 /*------------------begin for curveEvalMachine------------*/
103 curveEvalMachine em_vertex;
104 curveEvalMachine em_normal;
105 curveEvalMachine em_color;
106 curveEvalMachine em_texcoord;
107 int vertex_flag; //whether there is a vertex map or not
108 int normal_flag; //whether there is a normal map or not
109 int color_flag; //whether there is a color map or not
110 int texcoord_flag; //whether there is a texture map or not
111
112 int global_grid_u0;
113 int global_grid_u1;
114 int global_grid_nu;
115
116 void inMap1f(int which, //0: vert, 1: norm, 2: color, 3: tex
117 int dimension,
118 REAL ulower,
119 REAL uupper,
120 int ustride,
121 int uorder,
122 REAL *ctlpoints);
123
124 void inPreEvaluate(int order, REAL vprime, REAL *coeff);
125 void inDoDomain1(curveEvalMachine *em, REAL u, REAL *retPoint);
126 void inDoEvalCoord1(REAL u);
127 void inMapMesh1f(int umin, int umax);
128
129 void (GLAPIENTRY *beginCallBackN) (GLenum type);
130 void (GLAPIENTRY *endCallBackN) (void);
131 void (GLAPIENTRY *vertexCallBackN) (const GLfloat *vert);
132 void (GLAPIENTRY *normalCallBackN) (const GLfloat *normal);
133 void (GLAPIENTRY *colorCallBackN) (const GLfloat *color);
134 void (GLAPIENTRY *texcoordCallBackN) (const GLfloat *texcoord);
135
136 void (GLAPIENTRY *beginCallBackData) (GLenum type, void* data);
137 void (GLAPIENTRY *endCallBackData) (void* data);
138 void (GLAPIENTRY *vertexCallBackData) (const GLfloat *vert, void* data);
139 void (GLAPIENTRY *normalCallBackData) (const GLfloat *normal, void* data);
140 void (GLAPIENTRY *colorCallBackData) (const GLfloat *color, void* data);
141 void (GLAPIENTRY *texcoordCallBackData) (const GLfloat *texcoord, void* data);
142
143 void* userData; //the opaque pointer for Data callback functions
144 void beginCallBack(GLenum type, void* data);
145 void endCallBack(void* data);
146 void vertexCallBack(const GLfloat *vert, void *data);
147 void normalCallBack(const GLfloat *normal, void* data);
148 void colorCallBack(const GLfloat *color, void* data);
149 void texcoordCallBack(const GLfloat *texcoord, void* data);
150
151
152 /*------------------end for curveEvalMachine------------*/
153
154 private:
155 int output_triangles; //true 1; false 0
156 };
157
158 #endif /* __gluglcurveval_h_ */