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