ReactOS 0.4.15-dev-8219-ge8b88cf
incurveeval.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 <stdlib.h>
39//#include <stdio.h>
40
41#include "glcurveval.h"
42
43
44/*
45 *compute the Bezier polynomials C[n,j](v) for all j at v with
46 *return values stored in coeff[], where
47 * C[n,j](v) = (n,j) * v^j * (1-v)^(n-j),
48 * j=0,1,2,...,n.
49 *order : n+1
50 *vprime: v
51 *coeff : coeff[j]=C[n,j](v), this array store the returned values.
52 *The algorithm is a recursive scheme:
53 * C[0,0]=1;
54 * C[n,j](v) = (1-v)*C[n-1,j](v) + v*C[n-1,j-1](v), n>=1
55 *This code is copied from opengl/soft/so_eval.c:PreEvaluate
56 */
58{
59 int i, j;
60 REAL oldval, temp;
61 REAL oneMinusvprime;
62
63 /*
64 * Minor optimization
65 * Compute orders 1 and 2 outright, and set coeff[0], coeff[1] to
66 * their i==1 loop values to avoid the initialization and the i==1 loop.
67 */
68 if (order == 1) {
69 coeff[0] = 1.0;
70 return;
71 }
72
73 oneMinusvprime = 1-vprime;
74 coeff[0] = oneMinusvprime;
75 coeff[1] = vprime;
76 if (order == 2) return;
77
78 for (i = 2; i < order; i++) {
79 oldval = coeff[0] * vprime;
80 coeff[0] = oneMinusvprime * coeff[0];
81 for (j = 1; j < i; j++) {
82 temp = oldval;
83 oldval = coeff[j] * vprime;
84 coeff[j] = temp + oneMinusvprime * coeff[j];
85 }
86 coeff[j] = oldval;
87 }
88}
89
90void OpenGLCurveEvaluator::inMap1f(int which, //0: vert, 1: norm, 2: color, 3: tex
91 int k, //dimension
92 REAL ulower,
93 REAL uupper,
94 int ustride,
95 int uorder,
96 REAL *ctlpoints)
97{
98 int i,x;
99 curveEvalMachine *temp_em;
100 switch(which){
101 case 0: //vertex
102 vertex_flag = 1;
103 temp_em = &em_vertex;
104 break;
105 case 1: //normal
106 normal_flag = 1;
107 temp_em = &em_normal;
108 break;
109 case 2: //color
110 color_flag = 1;
111 temp_em = &em_color;
112 break;
113 default:
114 texcoord_flag = 1;
115 temp_em = &em_texcoord;
116 break;
117 }
118
119 REAL *data = temp_em->ctlpoints;
120 temp_em->uprime = -1; //initialized
121 temp_em->k = k;
122 temp_em->u1 = ulower;
123 temp_em->u2 = uupper;
124 temp_em->ustride = ustride;
125 temp_em->uorder = uorder;
126 /*copy the control points*/
127 for(i=0; i<uorder; i++){
128 for(x=0; x<k; x++){
129 data[x] = ctlpoints[x];
130 }
131 ctlpoints += ustride;
132 data += k;
133 }
134}
135
137{
138 int j, row;
139 REAL the_uprime;
140 REAL *data;
141
142 if(em->u2 == em->u1)
143 return;
144 the_uprime = (u-em->u1) / (em->u2-em->u1);
145 /*use already cached values if possible*/
146 if(em->uprime != the_uprime){
147 inPreEvaluate(em->uorder, the_uprime, em->ucoeff);
148 em->uprime = the_uprime;
149 }
150
151 for(j=0; j<em->k; j++){
152 data = em->ctlpoints+j;
153 retPoint[j] = 0.0;
154 for(row=0; row<em->uorder; row++)
155 {
156 retPoint[j] += em->ucoeff[row] * (*data);
157 data += em->k;
158 }
159 }
160}
161
163{
164 REAL temp_vertex[4];
165 REAL temp_normal[3];
166 REAL temp_color[4];
167 REAL temp_texcoord[4];
168 if(texcoord_flag) //there is a texture map
169 {
170 inDoDomain1(&em_texcoord, u, temp_texcoord);
171 texcoordCallBack(temp_texcoord, userData);
172 }
173#ifdef DEBUG
174printf("color_flag = %i\n", color_flag);
175#endif
176 if(color_flag) //there is a color map
177 {
178 inDoDomain1(&em_color, u, temp_color);
179 colorCallBack(temp_color, userData);
180 }
181 if(normal_flag) //there is a normal map
182 {
183 inDoDomain1(&em_normal, u, temp_normal);
184 normalCallBack(temp_normal, userData);
185 }
186 if(vertex_flag)
187 {
188 inDoDomain1(&em_vertex, u, temp_vertex);
189 vertexCallBack(temp_vertex, userData);
190 }
191}
192
193void OpenGLCurveEvaluator::inMapMesh1f(int umin, int umax)
194{
195 REAL du, u;
196 int i;
197 if(global_grid_nu == 0)
198 return; //no points to output
200 bgnline();
201 for(i=umin; i<= umax; i++){
204 }
205 endline();
206}
void inDoDomain1(curveEvalMachine *em, REAL u, REAL *retPoint)
Definition: incurveeval.cc:136
curveEvalMachine em_color
Definition: glcurveval.h:104
curveEvalMachine em_texcoord
Definition: glcurveval.h:105
void normalCallBack(const GLfloat *normal, void *data)
Definition: glcurveval.cc:378
curveEvalMachine em_vertex
Definition: glcurveval.h:102
void colorCallBack(const GLfloat *color, void *data)
Definition: glcurveval.cc:387
curveEvalMachine em_normal
Definition: glcurveval.h:103
void texcoordCallBack(const GLfloat *texcoord, void *data)
Definition: glcurveval.cc:396
void inMap1f(int which, int dimension, REAL ulower, REAL uupper, int ustride, int uorder, REAL *ctlpoints)
Definition: incurveeval.cc:90
void vertexCallBack(const GLfloat *vert, void *data)
Definition: glcurveval.cc:368
void inDoEvalCoord1(REAL u)
Definition: incurveeval.cc:162
void inMapMesh1f(int umin, int umax)
Definition: incurveeval.cc:193
void inPreEvaluate(int order, REAL vprime, REAL *coeff)
Definition: incurveeval.cc:57
float REAL
Definition: types.h:41
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78
#define printf
Definition: freeldr.h:97
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLdouble GLdouble GLint ustride
Definition: glext.h:8308
GLdouble GLdouble GLint GLint uorder
Definition: glext.h:8308
GLuint GLdouble GLdouble GLint GLint order
Definition: glext.h:11194
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
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 * u
Definition: glfuncs.h:240
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 GLint GLint j
Definition: glfuncs.h:250
int k
Definition: mpi.c:3369
static calc_node_t temp
Definition: rpn_ieee.c:38
REAL ucoeff[IN_MAX_BEZIER_ORDER]
Definition: glcurveval.h:63
REAL ctlpoints[IN_MAX_BEZIER_ORDER *IN_MAX_DIMENSION]
Definition: glcurveval.h:62
static GLenum which
Definition: wgl_font.c:159