VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getmap.c@ 45248

最後變更 在這個檔案從45248是 15532,由 vboxsync 提交於 16 年 前

crOpenGL: export to OSE

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id
檔案大小: 6.5 KB
 
1/* Copyright (c) 2001, Stanford University
2 * All rights reserved
3 *
4 * See the file LICENSE.txt for information on redistributing this software.
5 */
6
7#include "cr_spu.h"
8#include "chromium.h"
9#include "cr_error.h"
10#include "cr_mem.h"
11#include "cr_net.h"
12#include "server_dispatch.h"
13#include "server.h"
14
15static GLuint __evaluator_components( GLenum target )
16{
17 switch (target) {
18 case GL_MAP1_VERTEX_3: return 3;
19 case GL_MAP1_VERTEX_4: return 4;
20 case GL_MAP1_INDEX: return 1;
21 case GL_MAP1_COLOR_4: return 4;
22 case GL_MAP1_NORMAL: return 3;
23 case GL_MAP1_TEXTURE_COORD_1: return 1;
24 case GL_MAP1_TEXTURE_COORD_2: return 2;
25 case GL_MAP1_TEXTURE_COORD_3: return 3;
26 case GL_MAP1_TEXTURE_COORD_4: return 4;
27 case GL_MAP2_VERTEX_3: return 3;
28 case GL_MAP2_VERTEX_4: return 4;
29 case GL_MAP2_INDEX: return 1;
30 case GL_MAP2_COLOR_4: return 4;
31 case GL_MAP2_NORMAL: return 3;
32 case GL_MAP2_TEXTURE_COORD_1: return 1;
33 case GL_MAP2_TEXTURE_COORD_2: return 2;
34 case GL_MAP2_TEXTURE_COORD_3: return 3;
35 case GL_MAP2_TEXTURE_COORD_4: return 4;
36 default: return 0;
37 }
38}
39
40void SERVER_DISPATCH_APIENTRY crServerDispatchGetMapdv( GLenum target, GLenum query, GLdouble *v )
41{
42 GLdouble *coeffs = NULL;
43 GLdouble order[2];
44 GLdouble domain[4];
45 GLdouble *retptr = NULL;
46 GLint tempOrder[2];
47 int dimension = 0;
48 unsigned int size = sizeof(GLdouble);
49 int evalcomp = __evaluator_components(target);
50
51 (void) v;
52
53 switch( target )
54 {
55 case GL_MAP1_COLOR_4:
56 case GL_MAP1_INDEX:
57 case GL_MAP1_NORMAL:
58 case GL_MAP1_TEXTURE_COORD_1:
59 case GL_MAP1_TEXTURE_COORD_2:
60 case GL_MAP1_TEXTURE_COORD_3:
61 case GL_MAP1_TEXTURE_COORD_4:
62 case GL_MAP1_VERTEX_3:
63 case GL_MAP1_VERTEX_4:
64 dimension = 1;
65 break;
66 case GL_MAP2_COLOR_4:
67 case GL_MAP2_INDEX:
68 case GL_MAP2_NORMAL:
69 case GL_MAP2_TEXTURE_COORD_1:
70 case GL_MAP2_TEXTURE_COORD_2:
71 case GL_MAP2_TEXTURE_COORD_3:
72 case GL_MAP2_TEXTURE_COORD_4:
73 case GL_MAP2_VERTEX_3:
74 case GL_MAP2_VERTEX_4:
75 dimension = 2;
76 break;
77 default:
78 crError( "Bad target in crServerDispatchGetMapdv: %d", target );
79 break;
80 }
81
82 switch(query)
83 {
84 case GL_ORDER:
85 cr_server.head_spu->dispatch_table.GetMapdv( target, query, order );
86 retptr = &(order[0]);
87 size *= dimension;
88 break;
89 case GL_DOMAIN:
90 cr_server.head_spu->dispatch_table.GetMapdv( target, query, domain );
91 retptr = &(domain[0]);
92 size *= dimension * 2;
93 break;
94 case GL_COEFF:
95 cr_server.head_spu->dispatch_table.GetMapiv( target, GL_ORDER, tempOrder );
96 size *= evalcomp * tempOrder[0];
97 if (dimension == 2)
98 size *= tempOrder[1];
99 coeffs = (GLdouble *) crAlloc( size );
100 cr_server.head_spu->dispatch_table.GetMapdv( target, query, coeffs );
101 retptr = coeffs;
102 break;
103 default:
104 crError( "Bad query in crServerDispatchGetMapdv: %d", query );
105 break;
106 }
107
108 crServerReturnValue( retptr, size );
109 if (query == GL_COEFF)
110 {
111 crFree(coeffs);
112 }
113}
114
115void SERVER_DISPATCH_APIENTRY crServerDispatchGetMapfv( GLenum target, GLenum query, GLfloat *v )
116{
117 GLfloat *coeffs = NULL;
118 GLfloat order[2];
119 GLfloat domain[4];
120 GLfloat *retptr = NULL;
121 GLint tempOrder[2];
122 int dimension = 0;
123 unsigned int size = sizeof(GLfloat);
124 int evalcomp = __evaluator_components(target);
125
126 (void) v;
127
128 switch( target )
129 {
130 case GL_MAP1_COLOR_4:
131 case GL_MAP1_INDEX:
132 case GL_MAP1_NORMAL:
133 case GL_MAP1_TEXTURE_COORD_1:
134 case GL_MAP1_TEXTURE_COORD_2:
135 case GL_MAP1_TEXTURE_COORD_3:
136 case GL_MAP1_TEXTURE_COORD_4:
137 case GL_MAP1_VERTEX_3:
138 case GL_MAP1_VERTEX_4:
139 dimension = 1;
140 break;
141 case GL_MAP2_COLOR_4:
142 case GL_MAP2_INDEX:
143 case GL_MAP2_NORMAL:
144 case GL_MAP2_TEXTURE_COORD_1:
145 case GL_MAP2_TEXTURE_COORD_2:
146 case GL_MAP2_TEXTURE_COORD_3:
147 case GL_MAP2_TEXTURE_COORD_4:
148 case GL_MAP2_VERTEX_3:
149 case GL_MAP2_VERTEX_4:
150 dimension = 2;
151 break;
152 default:
153 crError( "Bad target in crServerDispatchGetMapfv: %d", target );
154 break;
155 }
156
157 switch(query)
158 {
159 case GL_ORDER:
160 cr_server.head_spu->dispatch_table.GetMapfv( target, query, order );
161 retptr = &(order[0]);
162 size *= dimension;
163 break;
164 case GL_DOMAIN:
165 cr_server.head_spu->dispatch_table.GetMapfv( target, query, domain );
166 retptr = &(domain[0]);
167 size *= dimension * 2;
168 break;
169 case GL_COEFF:
170 cr_server.head_spu->dispatch_table.GetMapiv( target, GL_ORDER, tempOrder );
171 size *= evalcomp * tempOrder[0];
172 if (dimension == 2)
173 size *= tempOrder[1];
174 coeffs = (GLfloat *) crAlloc( size );
175 cr_server.head_spu->dispatch_table.GetMapfv( target, query, coeffs );
176 retptr = coeffs;
177 break;
178 default:
179 crError( "Bad query in crServerDispatchGetMapfv: %d", query );
180 break;
181 }
182
183 crServerReturnValue( retptr, size );
184 if (query == GL_COEFF)
185 {
186 crFree(coeffs);
187 }
188}
189
190void SERVER_DISPATCH_APIENTRY crServerDispatchGetMapiv( GLenum target, GLenum query, GLint *v )
191{
192 GLint *coeffs = NULL;
193 GLint order[2];
194 GLint domain[4];
195 GLint *retptr = NULL;
196 GLint tempOrder[2];
197 int dimension = 0;
198 unsigned int size = sizeof(GLint);
199 int evalcomp = __evaluator_components(target);
200
201 (void) v;
202
203 switch( target )
204 {
205 case GL_MAP1_COLOR_4:
206 case GL_MAP1_INDEX:
207 case GL_MAP1_NORMAL:
208 case GL_MAP1_TEXTURE_COORD_1:
209 case GL_MAP1_TEXTURE_COORD_2:
210 case GL_MAP1_TEXTURE_COORD_3:
211 case GL_MAP1_TEXTURE_COORD_4:
212 case GL_MAP1_VERTEX_3:
213 case GL_MAP1_VERTEX_4:
214 dimension = 1;
215 break;
216 case GL_MAP2_COLOR_4:
217 case GL_MAP2_INDEX:
218 case GL_MAP2_NORMAL:
219 case GL_MAP2_TEXTURE_COORD_1:
220 case GL_MAP2_TEXTURE_COORD_2:
221 case GL_MAP2_TEXTURE_COORD_3:
222 case GL_MAP2_TEXTURE_COORD_4:
223 case GL_MAP2_VERTEX_3:
224 case GL_MAP2_VERTEX_4:
225 dimension = 2;
226 break;
227 default:
228 crError( "Bad target in crServerDispatchGetMapiv: %d", target );
229 break;
230 }
231
232 switch(query)
233 {
234 case GL_ORDER:
235 cr_server.head_spu->dispatch_table.GetMapiv( target, query, order );
236 retptr = &(order[0]);
237 size *= dimension;
238 break;
239 case GL_DOMAIN:
240 cr_server.head_spu->dispatch_table.GetMapiv( target, query, domain );
241 retptr = &(domain[0]);
242 size *= dimension * 2;
243 break;
244 case GL_COEFF:
245 cr_server.head_spu->dispatch_table.GetMapiv( target, GL_ORDER, tempOrder );
246 size *= evalcomp * tempOrder[0];
247 if (dimension == 2)
248 size *= tempOrder[1];
249 coeffs = (GLint *) crAlloc( size );
250 cr_server.head_spu->dispatch_table.GetMapiv( target, query, coeffs );
251 retptr = coeffs;
252 break;
253 default:
254 crError( "Bad query in crServerDispatchGetMapiv: %d", query );
255 break;
256 }
257
258 crServerReturnValue( retptr, size );
259 if (query == GL_COEFF)
260 {
261 crFree(coeffs);
262 }
263}
264
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette