VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/dlm/dlm_arrays.c@ 62659

最後變更 在這個檔案從62659是 54905,由 vboxsync 提交於 10 年 前

Host 3D: Chromium server: add Expando SPU and DLM module in order to record and save OpenGL Display Lists (currently disabled).

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 11.2 KB
 
1/* $Id: dlm_arrays.c 54905 2015-03-23 11:20:58Z vboxsync $ */
2/* Copyright (c) 2001, Stanford University
3 * All rights reserved
4 *
5 * See the file LICENSE.txt for information on redistributing this software.
6 */
7
8#include <stdio.h>
9#include <stdarg.h>
10#include "chromium.h"
11#include "cr_dlm.h"
12#include "dlm.h"
13
14/*
15 * XXX this code is awfully similar to the code in arrayspu.c
16 * We should try to write something reusable.
17 */
18
19void DLM_APIENTRY crDLMCompileArrayElement (GLint index, CRClientState *c)
20{
21 unsigned char *p;
22 int unit;
23
24 if (c->array.e.enabled)
25 {
26 crDLMCompileEdgeFlagv(c->array.e.p + index*c->array.e.stride);
27 }
28 for (unit = 0; unit < CR_MAX_TEXTURE_UNITS; unit++)
29 {
30 if (c->array.t[unit].enabled)
31 {
32 p = c->array.t[unit].p + index*c->array.t[unit].stride;
33 switch (c->array.t[unit].type)
34 {
35 case GL_SHORT:
36 switch (c->array.t[c->curClientTextureUnit].size)
37 {
38 case 1: crDLMCompileMultiTexCoord1svARB(GL_TEXTURE0_ARB + unit, (GLshort *)p); break;
39 case 2: crDLMCompileMultiTexCoord2svARB(GL_TEXTURE0_ARB + unit, (GLshort *)p); break;
40 case 3: crDLMCompileMultiTexCoord3svARB(GL_TEXTURE0_ARB + unit, (GLshort *)p); break;
41 case 4: crDLMCompileMultiTexCoord4svARB(GL_TEXTURE0_ARB + unit, (GLshort *)p); break;
42 }
43 break;
44 case GL_INT:
45 switch (c->array.t[c->curClientTextureUnit].size)
46 {
47 case 1: crDLMCompileMultiTexCoord1ivARB(GL_TEXTURE0_ARB + unit, (GLint *)p); break;
48 case 2: crDLMCompileMultiTexCoord2ivARB(GL_TEXTURE0_ARB + unit, (GLint *)p); break;
49 case 3: crDLMCompileMultiTexCoord3ivARB(GL_TEXTURE0_ARB + unit, (GLint *)p); break;
50 case 4: crDLMCompileMultiTexCoord4ivARB(GL_TEXTURE0_ARB + unit, (GLint *)p); break;
51 }
52 break;
53 case GL_FLOAT:
54 switch (c->array.t[c->curClientTextureUnit].size)
55 {
56 case 1: crDLMCompileMultiTexCoord1fvARB(GL_TEXTURE0_ARB + unit, (GLfloat *)p); break;
57 case 2: crDLMCompileMultiTexCoord2fvARB(GL_TEXTURE0_ARB + unit, (GLfloat *)p); break;
58 case 3: crDLMCompileMultiTexCoord3fvARB(GL_TEXTURE0_ARB + unit, (GLfloat *)p); break;
59 case 4: crDLMCompileMultiTexCoord4fvARB(GL_TEXTURE0_ARB + unit, (GLfloat *)p); break;
60 }
61 break;
62 case GL_DOUBLE:
63 switch (c->array.t[c->curClientTextureUnit].size)
64 {
65 case 1: crDLMCompileMultiTexCoord1dvARB(GL_TEXTURE0_ARB + unit, (GLdouble *)p); break;
66 case 2: crDLMCompileMultiTexCoord2dvARB(GL_TEXTURE0_ARB + unit, (GLdouble *)p); break;
67 case 3: crDLMCompileMultiTexCoord3dvARB(GL_TEXTURE0_ARB + unit, (GLdouble *)p); break;
68 case 4: crDLMCompileMultiTexCoord4dvARB(GL_TEXTURE0_ARB + unit, (GLdouble *)p); break;
69 }
70 break;
71 }
72 }
73 } /* loop over texture units */
74
75 if (c->array.i.enabled)
76 {
77 p = c->array.i.p + index*c->array.i.stride;
78 switch (c->array.i.type)
79 {
80 case GL_SHORT: crDLMCompileIndexsv((GLshort *)p); break;
81 case GL_INT: crDLMCompileIndexiv((GLint *)p); break;
82 case GL_FLOAT: crDLMCompileIndexfv((GLfloat *)p); break;
83 case GL_DOUBLE: crDLMCompileIndexdv((GLdouble *)p); break;
84 }
85 }
86 if (c->array.c.enabled)
87 {
88 p = c->array.c.p + index*c->array.c.stride;
89 switch (c->array.c.type)
90 {
91 case GL_BYTE:
92 switch (c->array.c.size)
93 {
94 case 3: crDLMCompileColor3bv((GLbyte *)p); break;
95 case 4: crDLMCompileColor4bv((GLbyte *)p); break;
96 }
97 break;
98 case GL_UNSIGNED_BYTE:
99 switch (c->array.c.size)
100 {
101 case 3: crDLMCompileColor3ubv((GLubyte *)p); break;
102 case 4: crDLMCompileColor4ubv((GLubyte *)p); break;
103 }
104 break;
105 case GL_SHORT:
106 switch (c->array.c.size)
107 {
108 case 3: crDLMCompileColor3sv((GLshort *)p); break;
109 case 4: crDLMCompileColor4sv((GLshort *)p); break;
110 }
111 break;
112 case GL_UNSIGNED_SHORT:
113 switch (c->array.c.size)
114 {
115 case 3: crDLMCompileColor3usv((GLushort *)p); break;
116 case 4: crDLMCompileColor4usv((GLushort *)p); break;
117 }
118 break;
119 case GL_INT:
120 switch (c->array.c.size)
121 {
122 case 3: crDLMCompileColor3iv((GLint *)p); break;
123 case 4: crDLMCompileColor4iv((GLint *)p); break;
124 }
125 break;
126 case GL_UNSIGNED_INT:
127 switch (c->array.c.size)
128 {
129 case 3: crDLMCompileColor3uiv((GLuint *)p); break;
130 case 4: crDLMCompileColor4uiv((GLuint *)p); break;
131 }
132 break;
133 case GL_FLOAT:
134 switch (c->array.c.size)
135 {
136 case 3: crDLMCompileColor3fv((GLfloat *)p); break;
137 case 4: crDLMCompileColor4fv((GLfloat *)p); break;
138 }
139 break;
140 case GL_DOUBLE:
141 switch (c->array.c.size)
142 {
143 case 3: crDLMCompileColor3dv((GLdouble *)p); break;
144 case 4: crDLMCompileColor4dv((GLdouble *)p); break;
145 }
146 break;
147 }
148 }
149 if (c->array.n.enabled)
150 {
151 p = c->array.n.p + index*c->array.n.stride;
152 switch (c->array.n.type)
153 {
154 case GL_BYTE: crDLMCompileNormal3bv((GLbyte *)p); break;
155 case GL_SHORT: crDLMCompileNormal3sv((GLshort *)p); break;
156 case GL_INT: crDLMCompileNormal3iv((GLint *)p); break;
157 case GL_FLOAT: crDLMCompileNormal3fv((GLfloat *)p); break;
158 case GL_DOUBLE: crDLMCompileNormal3dv((GLdouble *)p); break;
159 }
160 }
161#ifdef CR_EXT_secondary_color
162 if (c->array.s.enabled)
163 {
164 p = c->array.s.p + index*c->array.s.stride;
165 switch (c->array.s.type)
166 {
167 case GL_BYTE:
168 crDLMCompileSecondaryColor3bvEXT((GLbyte *)p); break;
169 case GL_UNSIGNED_BYTE:
170 crDLMCompileSecondaryColor3ubvEXT((GLubyte *)p); break;
171 case GL_SHORT:
172 crDLMCompileSecondaryColor3svEXT((GLshort *)p); break;
173 case GL_UNSIGNED_SHORT:
174 crDLMCompileSecondaryColor3usvEXT((GLushort *)p); break;
175 case GL_INT:
176 crDLMCompileSecondaryColor3ivEXT((GLint *)p); break;
177 case GL_UNSIGNED_INT:
178 crDLMCompileSecondaryColor3uivEXT((GLuint *)p); break;
179 case GL_FLOAT:
180 crDLMCompileSecondaryColor3fvEXT((GLfloat *)p); break;
181 case GL_DOUBLE:
182 crDLMCompileSecondaryColor3dvEXT((GLdouble *)p); break;
183 }
184 }
185#endif
186 if (c->array.v.enabled)
187 {
188 p = c->array.v.p + (index*c->array.v.stride);
189
190 switch (c->array.v.type)
191 {
192 case GL_SHORT:
193 switch (c->array.v.size)
194 {
195 case 2: crDLMCompileVertex2sv((GLshort *)p); break;
196 case 3: crDLMCompileVertex3sv((GLshort *)p); break;
197 case 4: crDLMCompileVertex4sv((GLshort *)p); break;
198 }
199 break;
200 case GL_INT:
201 switch (c->array.v.size)
202 {
203 case 2: crDLMCompileVertex2iv((GLint *)p); break;
204 case 3: crDLMCompileVertex3iv((GLint *)p); break;
205 case 4: crDLMCompileVertex4iv((GLint *)p); break;
206 }
207 break;
208 case GL_FLOAT:
209 switch (c->array.v.size)
210 {
211 case 2: crDLMCompileVertex2fv((GLfloat *)p); break;
212 case 3: crDLMCompileVertex3fv((GLfloat *)p); break;
213 case 4: crDLMCompileVertex4fv((GLfloat *)p); break;
214 }
215 break;
216 case GL_DOUBLE:
217 switch (c->array.v.size)
218 {
219 case 2: crDLMCompileVertex2dv((GLdouble *)p); break;
220 case 3: crDLMCompileVertex3dv((GLdouble *)p); break;
221 case 4: crDLMCompileVertex4dv((GLdouble *)p); break;
222 }
223 break;
224 }
225 }
226}
227
228void DLM_APIENTRY crDLMCompileDrawArrays(GLenum mode, GLint first, GLsizei count, CRClientState *c)
229{
230 int i;
231
232 if (count < 0)
233 {
234 crdlmWarning(__LINE__, __FILE__, GL_INVALID_VALUE, "DLM DrawArrays(negative count)");
235 return;
236 }
237
238 if (mode > GL_POLYGON)
239 {
240 crdlmWarning(__LINE__, __FILE__, GL_INVALID_ENUM, "DLM DrawArrays(bad mode)");
241 return;
242 }
243
244 crDLMCompileBegin(mode);
245 for (i=0; i<count; i++)
246 {
247 crDLMCompileArrayElement(first + i, c);
248 }
249 crDLMCompileEnd();
250}
251
252void DLM_APIENTRY crDLMCompileDrawElements(GLenum mode, GLsizei count,
253 GLenum type, const GLvoid *indices, CRClientState *c)
254{
255 int i;
256 GLubyte *p = (GLubyte *)indices;
257
258 if (count < 0)
259 {
260 crdlmWarning(__LINE__, __FILE__, GL_INVALID_VALUE, "DLM DrawElements(negative count)");
261 return;
262 }
263
264 if (mode > GL_POLYGON)
265 {
266 crdlmWarning(__LINE__, __FILE__, GL_INVALID_ENUM, "DLM DrawElements(bad mode)");
267 return;
268 }
269
270 if (type != GL_UNSIGNED_BYTE && type != GL_UNSIGNED_SHORT && type != GL_UNSIGNED_INT)
271 {
272 crdlmWarning(__LINE__, __FILE__, GL_INVALID_ENUM, "DLM DrawElements(bad type)");
273 return;
274 }
275
276 crDLMCompileBegin(mode);
277 switch (type)
278 {
279 case GL_UNSIGNED_BYTE:
280 for (i=0; i<count; i++)
281 {
282 crDLMCompileArrayElement((GLint) *p++, c);
283 }
284 break;
285 case GL_UNSIGNED_SHORT:
286 for (i=0; i<count; i++)
287 {
288 crDLMCompileArrayElement((GLint) * (GLushort *) p, c);
289 p+=sizeof (GLushort);
290 }
291 break;
292 case GL_UNSIGNED_INT:
293 for (i=0; i<count; i++)
294 {
295 crDLMCompileArrayElement((GLint) * (GLuint *) p, c);
296 p+=sizeof (GLuint);
297 }
298 break;
299 default:
300 crError( "this can't happen: DLM DrawElements" );
301 break;
302 }
303 crDLMCompileEnd();
304}
305
306void DLM_APIENTRY crDLMCompileDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count,
307 GLenum type, const GLvoid *indices, CRClientState *c)
308{
309 int i;
310 GLubyte *p = (GLubyte *)indices;
311
312 (void) end;
313
314 if (count < 0)
315 {
316 crdlmWarning(__LINE__, __FILE__, GL_INVALID_VALUE, "DLM DrawRangeElements(negative count)");
317 return;
318 }
319
320 if (mode > GL_POLYGON)
321 {
322 crdlmWarning(__LINE__, __FILE__, GL_INVALID_ENUM, "DLM DrawRangeElements(bad mode)");
323 return;
324 }
325
326 if (type != GL_UNSIGNED_BYTE && type != GL_UNSIGNED_SHORT && type != GL_UNSIGNED_INT)
327 {
328 crdlmWarning(__LINE__, __FILE__, GL_INVALID_ENUM, "DLM DrawRangeElements(bad type)");
329 return;
330 }
331
332 crDLMCompileBegin(mode);
333 switch (type)
334 {
335 case GL_UNSIGNED_BYTE:
336 for (i=start; i<count; i++)
337 {
338 crDLMCompileArrayElement((GLint) *p++, c);
339 }
340 break;
341 case GL_UNSIGNED_SHORT:
342 for (i=start; i<count; i++)
343 {
344 crDLMCompileArrayElement((GLint) * (GLushort *) p, c);
345 p+=sizeof (GLushort);
346 }
347 break;
348 case GL_UNSIGNED_INT:
349 for (i=start; i<count; i++)
350 {
351 crDLMCompileArrayElement((GLint) * (GLuint *) p, c);
352 p+=sizeof (GLuint);
353 }
354 break;
355 default:
356 crError( "this can't happen: DLM DrawRangeElements" );
357 break;
358 }
359 crDLMCompileEnd();
360}
361
362#ifdef CR_EXT_multi_draw_arrays
363void DLM_APIENTRY crDLMCompileMultiDrawArraysEXT( GLenum mode, GLint *first,
364 GLsizei *count, GLsizei primcount, CRClientState *c)
365{
366 GLint i;
367
368 for (i = 0; i < primcount; i++) {
369 if (count[i] > 0) {
370 crDLMCompileDrawArrays(mode, first[i], count[i], c);
371 }
372 }
373}
374
375
376void DLM_APIENTRY crDLMCompileMultiDrawElementsEXT( GLenum mode, const GLsizei *count, GLenum type,
377 const GLvoid **indices, GLsizei primcount, CRClientState *c)
378{
379 GLint i;
380
381 for (i = 0; i < primcount; i++) {
382 if (count[i] > 0) {
383 crDLMCompileDrawElements(mode, count[i], type, indices[i], c);
384 }
385 }
386}
387#endif /* CR_EXT_multi_draw_arrays */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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