ReactOS 0.4.16-dev-91-g764881a
glrenderer.cc
Go to the documentation of this file.
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*/
37
38#include "gluos.h"
39//#include "glimports.h"
40#include "glrenderer.h"
41
43 : NurbsTessellator(curveEvaluator, surfaceEvaluator)
44{
64
69
74
79
84
85 //added for optimizing untrimmed case
87
92
93 //added for optimizing untrimmed case
95 set_is_domain_distance_sampling(0); //since the default is path_length
96
97 //default autoloadmode is true
98 autoloadmode = 1;
99
100 //default callbackFlag is 0
101 callbackFlag = 0;
102
104}
105
106void
108{
109 if (autoloadmode) {
111 }
112}
113
114void
116{
117}
118
119void
121{
122 int gluError;
123
124 gluError = i + (GLU_NURBS_ERROR1 - 1);
125 postError( gluError );
126}
127
128void
130{
131 GLfloat vmat[4][4];
132 GLint viewport[4];
133
134 grabGLMatrix((GLfloat (*)[4]) vmat);
135 loadCullingMatrix((GLfloat (*)[4]) vmat);
136 ::glGetIntegerv((GLenum) GL_VIEWPORT, (GLint *) viewport);
137 loadSamplingMatrix((const GLfloat (*)[4]) vmat, (const GLint *) viewport);
138}
139
140void
141GLUnurbs::useGLMatrices(const GLfloat modelMatrix[16],
142 const GLfloat projMatrix[16],
143 const GLint viewport[4])
144{
145 GLfloat vmat[4][4];
146
147 multmatrix4d(vmat, (const GLfloat (*)[4]) modelMatrix,
148 (const GLfloat (*)[4]) projMatrix);
149 loadCullingMatrix((GLfloat (*)[4]) vmat);
150 loadSamplingMatrix((const GLfloat (*)[4]) vmat, (const GLint *) viewport);
151}
152
153/*--------------------------------------------------------------------------
154 * grabGLMatrix
155 *--------------------------------------------------------------------------
156 */
157
158void
160{
161 GLfloat m1[4][4], m2[4][4];
162
165 multmatrix4d((GLfloat (*)[4]) vmat,
166 (const GLfloat (*)[4]) m1, (const GLfloat (*)[4]) m2);
167}
168
169//for object space tesselation: view independent
170void
172{
173 INREAL smat[4][4] = {
174 {1,0,0,0},
175 {0,1,0,0},
176 {0,0,1,0},
177 {0,0,0,1}
178 };
179 const long rstride = sizeof(smat[0]) / sizeof(smat[0][0]);
180 const long cstride = 1;
181
183 cstride);
185 cstride);
187 cstride);
189 cstride);
190}
191
192
193void
195 const GLint viewport[4])
196{
197
198 /* rescale the mapping to correspond to pixels in x/y */
199 REAL xsize = 0.5 * (REAL) (viewport[2]);
200 REAL ysize = 0.5 * (REAL) (viewport[3]);
201
202 INREAL smat[4][4];
203 smat[0][0] = vmat[0][0] * xsize;
204 smat[1][0] = vmat[1][0] * xsize;
205 smat[2][0] = vmat[2][0] * xsize;
206 smat[3][0] = vmat[3][0] * xsize;
207
208 smat[0][1] = vmat[0][1] * ysize;
209 smat[1][1] = vmat[1][1] * ysize;
210 smat[2][1] = vmat[2][1] * ysize;
211 smat[3][1] = vmat[3][1] * ysize;
212
213 smat[0][2] = 0.0;
214 smat[1][2] = 0.0;
215 smat[2][2] = 0.0;
216 smat[3][2] = 0.0;
217
218 smat[0][3] = vmat[0][3];
219 smat[1][3] = vmat[1][3];
220 smat[2][3] = vmat[2][3];
221 smat[3][3] = vmat[3][3];
222
223 const long rstride = sizeof(smat[0]) / sizeof(smat[0][0]);
224 const long cstride = 1;
225
227 cstride);
229 cstride);
231 cstride);
233 cstride);
234}
235
236void
238{
239 INREAL cmat[4][4];
240
241 cmat[0][0] = vmat[0][0];
242 cmat[0][1] = vmat[0][1];
243 cmat[0][2] = vmat[0][2];
244 cmat[0][3] = vmat[0][3];
245
246 cmat[1][0] = vmat[1][0];
247 cmat[1][1] = vmat[1][1];
248 cmat[1][2] = vmat[1][2];
249 cmat[1][3] = vmat[1][3];
250
251 cmat[2][0] = vmat[2][0];
252 cmat[2][1] = vmat[2][1];
253 cmat[2][2] = vmat[2][2];
254 cmat[2][3] = vmat[2][3];
255
256 cmat[3][0] = vmat[3][0];
257 cmat[3][1] = vmat[3][1];
258 cmat[3][2] = vmat[3][2];
259 cmat[3][3] = vmat[3][3];
260
261 const long rstride = sizeof(cmat[0]) / sizeof(cmat[0][0]);
262 const long cstride = 1;
263
265 cstride);
267 cstride);
268 //added for curves by zl
270 cstride);
272 cstride);
273}
274
275/*---------------------------------------------------------------------
276 * A = B * MAT ; transform a 4d vector through a 4x4 matrix
277 *---------------------------------------------------------------------
278 */
279void
281{
282
283 A[0] = B[0]*mat[0][0] + B[1]*mat[1][0] + B[2]*mat[2][0] + B[3]*mat[3][0];
284 A[1] = B[0]*mat[0][1] + B[1]*mat[1][1] + B[2]*mat[2][1] + B[3]*mat[3][1];
285 A[2] = B[0]*mat[0][2] + B[1]*mat[1][2] + B[2]*mat[2][2] + B[3]*mat[3][2];
286 A[3] = B[0]*mat[0][3] + B[1]*mat[1][3] + B[2]*mat[2][3] + B[3]*mat[3][3];
287}
288
289/*---------------------------------------------------------------------
290 * new = [left][right] ; multiply two matrices together
291 *---------------------------------------------------------------------
292 */
293void
295 const GLfloat right[4][4])
296{
297 transform4d ((GLfloat *) n[0],(GLfloat *) left[0],(GLfloat (*)[4]) right);
298 transform4d ((GLfloat *) n[1],(GLfloat *) left[1],(GLfloat (*)[4]) right);
299 transform4d ((GLfloat *) n[2],(GLfloat *) left[2],(GLfloat (*)[4]) right);
300 transform4d ((GLfloat *) n[3],(GLfloat *) left[3],(GLfloat (*)[4]) right);
301}
Definition: ehthrow.cxx:93
Definition: ehthrow.cxx:54
static void multmatrix4d(GLfloat n[4][4], const GLfloat left[4][4], const GLfloat right[4][4])
Definition: glrenderer.cc:294
void setSamplingMatrixIdentity(void)
Definition: glrenderer.cc:171
void loadCullingMatrix(GLfloat vmat[4][4])
Definition: glrenderer.cc:237
errorCallbackType errorCallback
Definition: glrenderer.h:71
void useGLMatrices(const GLfloat modelMatrix[16], const GLfloat projMatrix[16], const GLint viewport[4])
Definition: glrenderer.cc:141
GLboolean autoloadmode
Definition: glrenderer.h:130
void errorHandler(int)
Definition: glrenderer.cc:120
GLUnurbs(void)
Definition: glrenderer.cc:42
static void grabGLMatrix(GLfloat vmat[4][4])
Definition: glrenderer.cc:159
int callbackFlag
Definition: glrenderer.h:143
void postError(int which)
Definition: glrenderer.h:72
void bgnrender(void)
Definition: glrenderer.cc:107
void endrender(void)
Definition: glrenderer.cc:115
void loadGLMatrices(void)
Definition: glrenderer.cc:129
static void transform4d(GLfloat A[4], GLfloat B[4], GLfloat mat[4][4])
Definition: glrenderer.cc:280
void loadSamplingMatrix(const GLfloat vmat[4][4], const GLint viewport[4])
Definition: glrenderer.cc:194
void set_domain_distance_v_rate(REAL v_rate)
Definition: nurbstess.cc:59
void set_is_domain_distance_sampling(int flag)
Definition: nurbstess.cc:65
void redefineMaps(void)
void set_domain_distance_u_rate(REAL u_rate)
Definition: nurbstess.cc:53
void defineMap(long, long, long)
void setnurbsproperty(long, INREAL)
#define NULL
Definition: types.h:112
#define GLU_NURBS_ERROR1
Definition: glu.h:128
#define INREAL
Definition: types.h:40
float REAL
Definition: types.h:41
#define GL_MAP2_NORMAL
Definition: gl.h:562
#define GL_MAP1_TEXTURE_COORD_3
Definition: gl.h:556
#define GL_MAP2_INDEX
Definition: gl.h:561
#define GL_MAP2_TEXTURE_COORD_2
Definition: gl.h:564
#define GL_MAP1_VERTEX_3
Definition: gl.h:558
float GLfloat
Definition: gl.h:161
#define GL_MAP1_TEXTURE_COORD_2
Definition: gl.h:555
#define GL_MAP2_TEXTURE_COORD_4
Definition: gl.h:566
unsigned int GLenum
Definition: gl.h:150
#define GL_VIEWPORT
Definition: gl.h:547
#define GL_MAP2_COLOR_4
Definition: gl.h:560
#define GL_PROJECTION_MATRIX
Definition: gl.h:541
#define GL_MAP1_TEXTURE_COORD_1
Definition: gl.h:554
#define GL_MAP2_VERTEX_4
Definition: gl.h:568
#define GL_MODELVIEW_MATRIX
Definition: gl.h:538
#define GL_MAP1_INDEX
Definition: gl.h:552
#define GL_MAP2_VERTEX_3
Definition: gl.h:567
#define GL_MAP1_TEXTURE_COORD_4
Definition: gl.h:557
#define GL_MAP1_COLOR_4
Definition: gl.h:551
#define GL_MAP2_TEXTURE_COORD_1
Definition: gl.h:563
#define GL_MAP2_TEXTURE_COORD_3
Definition: gl.h:565
#define GL_MAP1_NORMAL
Definition: gl.h:553
int GLint
Definition: gl.h:156
GLAPI void GLAPIENTRY glGetFloatv(GLenum pname, GLfloat *params)
GLAPI void GLAPIENTRY glGetIntegerv(GLenum pname, GLint *params)
#define GL_MAP1_VERTEX_4
Definition: gl.h:559
GLdouble n
Definition: glext.h:7729
GLdouble GLdouble right
Definition: glext.h:10859
GLint left
Definition: glext.h:7726
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static const MAT2 mat
Definition: font.c:66
#define N_SAMPLINGMATRIX
Definition: nurbsconsts.h:106
#define N_PATHLENGTH
Definition: nurbsconsts.h:59
#define N_S_STEPS
Definition: nurbsconsts.h:99
#define N_T_STEPS
Definition: nurbsconsts.h:100
#define N_PIXEL_TOLERANCE
Definition: nurbsconsts.h:89
#define N_CULLINGMATRIX
Definition: nurbsconsts.h:105
#define N_ERROR_TOLERANCE
Definition: nurbsconsts.h:90
#define N_SAMPLINGMETHOD
Definition: nurbsconsts.h:54