Update to SGI FreeB 2.0.
[mesa.git] / src / glu / sgi / libnurbs / interface / glrenderer.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 * glrenderer.h
33 *
34 * $Date: 2004/02/26 14:58:11 $ $Revision: 1.4 $
35 * $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/interface/glrenderer.h,v 1.4 2004/02/26 14:58:11 brianp Exp $
36 */
37
38 #ifndef __gluglrenderer_h_
39 #define __gluglrenderer_h_
40
41 #include <GL/gl.h>
42 #include <GL/glu.h>
43 #include "nurbstess.h"
44 #include "glsurfeval.h"
45 #include "glcurveval.h"
46
47 extern "C" {
48 typedef void (APIENTRY *errorCallbackType)( GLenum );
49 }
50
51 class GLUnurbs : public NurbsTessellator {
52
53 public:
54 GLUnurbs( void );
55 void loadGLMatrices( void );
56 void useGLMatrices( const GLfloat modelMatrix[16],
57 const GLfloat projMatrix[16],
58 const GLint viewport[4] );
59 void setSamplingMatrixIdentity( void );
60
61 void errorHandler( int );
62 void bgnrender( void );
63 void endrender( void );
64 void setautoloadmode( INREAL value )
65 {
66
67 if (value) autoloadmode = GL_TRUE;
68 else autoloadmode = GL_FALSE;
69
70 }
71 GLboolean getautoloadmode( void ) { return autoloadmode; }
72
73 errorCallbackType errorCallback;
74 void postError( int which )
75 { if (errorCallback) (errorCallback)( (GLenum)which ); }
76 #ifdef _WIN32
77 void putSurfCallBack(GLenum which, void (GLAPIENTRY *fn)() )
78 #else
79 void putSurfCallBack(GLenum which, _GLUfuncptr fn )
80 #endif
81 {
82 curveEvaluator.putCallBack(which, fn);
83 surfaceEvaluator.putCallBack(which, fn);
84 }
85
86 int get_vertices_call_back()
87 {
88 return surfaceEvaluator.get_vertices_call_back();
89 }
90
91 void put_vertices_call_back(int flag)
92 {
93 surfaceEvaluator.put_vertices_call_back(flag);
94 }
95
96 int get_callback_auto_normal()
97 {
98 return surfaceEvaluator.get_callback_auto_normal();
99 }
100
101 void put_callback_auto_normal(int flag)
102 {
103 surfaceEvaluator.put_callback_auto_normal(flag);
104 }
105
106 void setNurbsCallbackData(void* userData)
107 {
108 curveEvaluator.set_callback_userData(userData);
109 surfaceEvaluator.set_callback_userData(userData);
110 }
111
112
113 //for LOD
114 void LOD_eval_list(int level)
115 {
116 surfaceEvaluator.LOD_eval_list(level);
117 }
118
119 //NEWCALLBACK
120 int is_callback()
121 {
122 return callbackFlag;
123 }
124 void put_callbackFlag(int flag)
125 {
126 callbackFlag = flag;
127 surfaceEvaluator.put_vertices_call_back(flag);
128 curveEvaluator.put_vertices_call_back(flag);
129 }
130
131 private:
132 GLboolean autoloadmode;
133 OpenGLSurfaceEvaluator surfaceEvaluator;
134 OpenGLCurveEvaluator curveEvaluator;
135
136 void loadSamplingMatrix( const GLfloat vmat[4][4],
137 const GLint viewport[4] );
138 void loadCullingMatrix( GLfloat vmat[4][4] );
139 static void grabGLMatrix( GLfloat vmat[4][4] );
140 static void transform4d( GLfloat A[4], GLfloat B[4],
141 GLfloat mat[4][4] );
142 static void multmatrix4d( GLfloat n[4][4], const GLfloat left[4][4],
143 const GLfloat right[4][4] );
144
145 int callbackFlag;
146 };
147
148 #endif /* __gluglrenderer_h_ */