VirtualBox

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

最後變更 在這個檔案從76792是 76792,由 vboxsync 提交於 6 年 前

3D: GetMap(dfi)v code cleanup, bugref:9327

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id Revision
檔案大小: 6.9 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
40static GLuint __evaluator_dimension( GLenum target )
41{
42 switch( target )
43 {
44 case GL_MAP1_COLOR_4:
45 case GL_MAP1_INDEX:
46 case GL_MAP1_NORMAL:
47 case GL_MAP1_TEXTURE_COORD_1:
48 case GL_MAP1_TEXTURE_COORD_2:
49 case GL_MAP1_TEXTURE_COORD_3:
50 case GL_MAP1_TEXTURE_COORD_4:
51 case GL_MAP1_VERTEX_3:
52 case GL_MAP1_VERTEX_4:
53 return 1;
54
55 case GL_MAP2_COLOR_4:
56 case GL_MAP2_INDEX:
57 case GL_MAP2_NORMAL:
58 case GL_MAP2_TEXTURE_COORD_1:
59 case GL_MAP2_TEXTURE_COORD_2:
60 case GL_MAP2_TEXTURE_COORD_3:
61 case GL_MAP2_TEXTURE_COORD_4:
62 case GL_MAP2_VERTEX_3:
63 case GL_MAP2_VERTEX_4:
64 return 2;
65
66 default:
67 return 0;
68 }
69}
70
71void SERVER_DISPATCH_APIENTRY crServerDispatchGetMapdv( GLenum target, GLenum query, GLdouble *v )
72{
73 GLdouble *coeffs = NULL;
74 GLdouble *retptr = NULL;
75 GLdouble order[2] = {0};
76 GLdouble domain[4] = {0};
77 GLint tempOrder[2] = {0};
78 int dimension, evalcomp;
79 unsigned int size = sizeof(GLdouble);
80 (void) v;
81
82 evalcomp = __evaluator_components(target);
83 dimension = __evaluator_dimension(target);
84
85 if (evalcomp == 0 || dimension == 0)
86 {
87 crError( "Bad target in crServerDispatchGetMapdv: %d", target );
88 return;
89 }
90
91 switch(query)
92 {
93 case GL_ORDER:
94 cr_server.head_spu->dispatch_table.GetMapdv( target, query, order );
95 retptr = &(order[0]);
96 size *= dimension;
97 break;
98 case GL_DOMAIN:
99 cr_server.head_spu->dispatch_table.GetMapdv( target, query, domain );
100 retptr = &(domain[0]);
101 size *= dimension * 2;
102 break;
103 case GL_COEFF:
104 cr_server.head_spu->dispatch_table.GetMapiv( target, GL_ORDER, tempOrder );
105 size *= evalcomp * tempOrder[0];
106 if (dimension == 2)
107 size *= tempOrder[1];
108
109 if (size)
110 coeffs = (GLdouble *) crCalloc( size );
111
112 if (coeffs)
113 {
114 cr_server.head_spu->dispatch_table.GetMapdv( target, query, coeffs );
115 retptr = coeffs;
116 }
117 break;
118 default:
119 crError( "Bad query in crServerDispatchGetMapdv: %d", query );
120 return;
121 }
122
123 crServerReturnValue( retptr, size );
124 if (coeffs)
125 {
126 crFree(coeffs);
127 }
128}
129
130void SERVER_DISPATCH_APIENTRY crServerDispatchGetMapfv( GLenum target, GLenum query, GLfloat *v )
131{
132 GLfloat *coeffs = NULL;
133 GLfloat *retptr = NULL;
134 GLfloat order[2] = {0};
135 GLfloat domain[4] = {0};
136 GLint tempOrder[2] = {0};
137 int dimension, evalcomp;
138 unsigned int size = sizeof(GLfloat);
139 (void) v;
140
141 evalcomp = __evaluator_components(target);
142 dimension = __evaluator_dimension(target);
143
144 if (evalcomp == 0 || dimension == 0)
145 {
146 crError( "Bad target in crServerDispatchGetMapfv: %d", target );
147 return;
148 }
149
150 switch(query)
151 {
152 case GL_ORDER:
153 cr_server.head_spu->dispatch_table.GetMapfv( target, query, order );
154 retptr = &(order[0]);
155 size *= dimension;
156 break;
157 case GL_DOMAIN:
158 cr_server.head_spu->dispatch_table.GetMapfv( target, query, domain );
159 retptr = &(domain[0]);
160 size *= dimension * 2;
161 break;
162 case GL_COEFF:
163 cr_server.head_spu->dispatch_table.GetMapiv( target, GL_ORDER, tempOrder );
164 size *= evalcomp * tempOrder[0];
165 if (dimension == 2)
166 size *= tempOrder[1];
167
168 if (size)
169 coeffs = (GLfloat *) crCalloc( size );
170
171 if (coeffs)
172 {
173 cr_server.head_spu->dispatch_table.GetMapfv( target, query, coeffs );
174 retptr = coeffs;
175 }
176 break;
177 default:
178 crError( "Bad query in crServerDispatchGetMapfv: %d", query );
179 return;
180 }
181
182 crServerReturnValue( retptr, size );
183 if (coeffs)
184 {
185 crFree(coeffs);
186 }
187}
188
189void SERVER_DISPATCH_APIENTRY crServerDispatchGetMapiv( GLenum target, GLenum query, GLint *v )
190{
191 GLint *coeffs = NULL;
192 GLint *retptr = NULL;
193 GLint order[2] = {0};
194 GLint domain[4] = {0};
195 GLint tempOrder[2] = {0};
196 int dimension, evalcomp;
197 unsigned int size = sizeof(GLint);
198 (void) v;
199
200 evalcomp = __evaluator_components(target);
201 dimension = __evaluator_dimension(target);
202
203 if (evalcomp == 0 || dimension == 0)
204 {
205 crError( "Bad target in crServerDispatchGetMapiv: %d", target );
206 return;
207 }
208
209 switch(query)
210 {
211 case GL_ORDER:
212 cr_server.head_spu->dispatch_table.GetMapiv( target, query, order );
213 retptr = &(order[0]);
214 size *= dimension;
215 break;
216 case GL_DOMAIN:
217 cr_server.head_spu->dispatch_table.GetMapiv( target, query, domain );
218 retptr = &(domain[0]);
219 size *= dimension * 2;
220 break;
221 case GL_COEFF:
222 cr_server.head_spu->dispatch_table.GetMapiv( target, GL_ORDER, tempOrder );
223 size *= evalcomp * tempOrder[0];
224 if (dimension == 2)
225 size *= tempOrder[1];
226
227 if (size)
228 coeffs = (GLint *) crCalloc( size );
229
230 if (coeffs)
231 {
232 cr_server.head_spu->dispatch_table.GetMapiv( target, query, coeffs );
233 retptr = coeffs;
234 }
235 break;
236 default:
237 crError( "Bad query in crServerDispatchGetMapiv: %d", query );
238 break;
239 }
240
241 crServerReturnValue( retptr, size );
242 if (coeffs)
243 {
244 crFree(coeffs);
245 }
246}
247
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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