VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_pixel.c@ 39290

Last change on this file since 39290 was 27091, checked in by vboxsync, 15 years ago

crOpenGL: add GL_ARB_pixel_buffer_object support

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 26.6 KB
Line 
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 <stdio.h>
8#include "cr_mem.h"
9#include "state.h"
10#include "state/cr_statetypes.h"
11#include "state_internals.h"
12
13void crStatePixelInit(CRContext *ctx)
14{
15 CRPixelState *p = &ctx->pixel;
16 CRStateBits *sb = GetCurrentBits();
17 CRPixelBits *pb = &(sb->pixel);
18 GLcolorf zero_color = {0.0f, 0.0f, 0.0f, 0.0f};
19 GLcolorf one_color = {1.0f, 1.0f, 1.0f, 1.0f};
20
21 p->mapColor = GL_FALSE;
22 p->mapStencil = GL_FALSE;
23 p->indexShift = 0;
24 p->indexOffset = 0;
25 p->scale = one_color;
26 p->depthScale = 1.0f;
27 p->bias = zero_color;
28 p->depthBias = 0.0f;
29 p->xZoom = 1.0f;
30 p->yZoom = 1.0f;
31 RESET(pb->transfer, ctx->bitid);
32 RESET(pb->zoom, ctx->bitid);
33
34 p->mapStoS[0] = 0;
35 p->mapItoI[0] = 0;
36 p->mapItoR[0] = 0.0;
37 p->mapItoG[0] = 0.0;
38 p->mapItoB[0] = 0.0;
39 p->mapItoA[0] = 0.0;
40 p->mapRtoR[0] = 0.0;
41 p->mapGtoG[0] = 0.0;
42 p->mapBtoB[0] = 0.0;
43 p->mapAtoA[0] = 0.0;
44
45 p->mapItoIsize = 1;
46 p->mapStoSsize = 1;
47 p->mapItoRsize = 1;
48 p->mapItoGsize = 1;
49 p->mapItoBsize = 1;
50 p->mapItoAsize = 1;
51 p->mapRtoRsize = 1;
52 p->mapGtoGsize = 1;
53 p->mapBtoBsize = 1;
54 p->mapAtoAsize = 1;
55 RESET(pb->maps, ctx->bitid);
56
57 RESET(pb->dirty, ctx->bitid);
58}
59
60void STATE_APIENTRY crStatePixelTransferi (GLenum pname, GLint param)
61{
62 crStatePixelTransferf( pname, (GLfloat) param );
63}
64
65void STATE_APIENTRY crStatePixelTransferf (GLenum pname, GLfloat param)
66{
67 CRContext *g = GetCurrentContext();
68 CRPixelState *p = &(g->pixel);
69 CRStateBits *sb = GetCurrentBits();
70 CRPixelBits *pb = &(sb->pixel);
71
72 if (g->current.inBeginEnd)
73 {
74 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "PixelTransfer{if} called in Begin/End");
75 return;
76 }
77
78 FLUSH();
79
80 switch( pname )
81 {
82 case GL_MAP_COLOR:
83 p->mapColor = (GLboolean) ((param == 0.0f) ? GL_FALSE : GL_TRUE);
84 break;
85 case GL_MAP_STENCIL:
86 p->mapStencil = (GLboolean) ((param == 0.0f) ? GL_FALSE : GL_TRUE);
87 break;
88 case GL_INDEX_SHIFT:
89 p->indexShift = (GLint) param;
90 break;
91 case GL_INDEX_OFFSET:
92 p->indexOffset = (GLint) param;
93 break;
94 case GL_RED_SCALE:
95 p->scale.r = param;
96 break;
97 case GL_GREEN_SCALE:
98 p->scale.g = param;
99 break;
100 case GL_BLUE_SCALE:
101 p->scale.b = param;
102 break;
103 case GL_ALPHA_SCALE:
104 p->scale.a = param;
105 break;
106 case GL_DEPTH_SCALE:
107 p->depthScale = param;
108 break;
109 case GL_RED_BIAS:
110 p->bias.r = param;
111 break;
112 case GL_GREEN_BIAS:
113 p->bias.g = param;
114 break;
115 case GL_BLUE_BIAS:
116 p->bias.b = param;
117 break;
118 case GL_ALPHA_BIAS:
119 p->bias.a = param;
120 break;
121 case GL_DEPTH_BIAS:
122 p->depthBias = param;
123 break;
124 default:
125 crStateError( __LINE__, __FILE__, GL_INVALID_VALUE, "Unknown glPixelTransfer pname: %d", pname );
126 return;
127 }
128 DIRTY(pb->transfer, g->neg_bitid);
129 DIRTY(pb->dirty, g->neg_bitid);
130}
131
132void STATE_APIENTRY crStatePixelZoom (GLfloat xfactor, GLfloat yfactor)
133{
134 CRContext *g = GetCurrentContext();
135 CRPixelState *p = &(g->pixel);
136 CRStateBits *sb = GetCurrentBits();
137 CRPixelBits *pb = &(sb->pixel);
138
139 if (g->current.inBeginEnd)
140 {
141 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "PixelZoom called in Begin/End");
142 return;
143 }
144
145 FLUSH();
146
147 p->xZoom = xfactor;
148 p->yZoom = yfactor;
149 DIRTY(pb->zoom, g->neg_bitid);
150 DIRTY(pb->dirty, g->neg_bitid);
151}
152
153
154void STATE_APIENTRY crStateBitmap( GLsizei width, GLsizei height,
155 GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove,
156 const GLubyte *bitmap)
157{
158 CRContext *g = GetCurrentContext();
159 CRCurrentState *c = &(g->current);
160 CRStateBits *sb = GetCurrentBits();
161 CRCurrentBits *cb = &(sb->current);
162
163 (void) xorig;
164 (void) yorig;
165 (void) bitmap;
166
167 if (g->lists.mode == GL_COMPILE)
168 return;
169
170 if (g->current.inBeginEnd)
171 {
172 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
173 "Bitmap called in begin/end");
174 return;
175 }
176
177 if (width < 0 || height < 0)
178 {
179 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE,
180 "Bitmap called with neg dims: %dx%d", width, height);
181 return;
182 }
183
184 if (!c->rasterValid)
185 {
186 return;
187 }
188
189 c->rasterAttrib[VERT_ATTRIB_POS][0] += xmove;
190 c->rasterAttrib[VERT_ATTRIB_POS][1] += ymove;
191 DIRTY(cb->rasterPos, g->neg_bitid);
192 DIRTY(cb->dirty, g->neg_bitid);
193
194 c->rasterAttribPre[VERT_ATTRIB_POS][0] += xmove;
195 c->rasterAttribPre[VERT_ATTRIB_POS][1] += ymove;
196}
197
198
199#define UNUSED(x) ((void)(x))
200
201#define CLAMP(x, min, max) ((x) < (min) ? (min) : ((x) > (max) ? (max) : (x)))
202
203void STATE_APIENTRY crStatePixelMapfv (GLenum map, GLint mapsize, const GLfloat * values)
204{
205 CRContext *g = GetCurrentContext();
206 CRPixelState *p = &(g->pixel);
207 CRStateBits *sb = GetCurrentBits();
208 CRPixelBits *pb = &(sb->pixel);
209 GLint i;
210 GLboolean unpackbuffer = crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB);
211
212 if (g->current.inBeginEnd) {
213 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "PixelMap called in Begin/End");
214 return;
215 }
216
217 FLUSH();
218
219 if (mapsize < 0 || mapsize > CR_MAX_PIXEL_MAP_TABLE) {
220 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "PixelMap(mapsize)");
221 return;
222 }
223
224 if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) {
225 /* XXX check that mapsize is a power of two */
226 }
227
228 switch (map) {
229 case GL_PIXEL_MAP_S_TO_S:
230 p->mapStoSsize = mapsize;
231 if (!unpackbuffer)
232 for (i=0;i<mapsize;i++) {
233 p->mapStoS[i] = (GLint) values[i];
234 }
235 break;
236 case GL_PIXEL_MAP_I_TO_I:
237 p->mapItoIsize = mapsize;
238 if (!unpackbuffer)
239 for (i=0;i<mapsize;i++) {
240 p->mapItoI[i] = (GLint) values[i];
241 }
242 break;
243 case GL_PIXEL_MAP_I_TO_R:
244 p->mapItoRsize = mapsize;
245 if (!unpackbuffer)
246 for (i=0;i<mapsize;i++) {
247 GLfloat val = CLAMP( values[i], 0.0F, 1.0F );
248 p->mapItoR[i] = val;
249 }
250 break;
251 case GL_PIXEL_MAP_I_TO_G:
252 p->mapItoGsize = mapsize;
253 if (!unpackbuffer)
254 for (i=0;i<mapsize;i++) {
255 GLfloat val = CLAMP( values[i], 0.0F, 1.0F );
256 p->mapItoG[i] = val;
257 }
258 break;
259 case GL_PIXEL_MAP_I_TO_B:
260 p->mapItoBsize = mapsize;
261 if (!unpackbuffer)
262 for (i=0;i<mapsize;i++) {
263 GLfloat val = CLAMP( values[i], 0.0F, 1.0F );
264 p->mapItoB[i] = val;
265 }
266 break;
267 case GL_PIXEL_MAP_I_TO_A:
268 p->mapItoAsize = mapsize;
269 if (!unpackbuffer)
270 for (i=0;i<mapsize;i++) {
271 GLfloat val = CLAMP( values[i], 0.0F, 1.0F );
272 p->mapItoA[i] = val;
273 }
274 break;
275 case GL_PIXEL_MAP_R_TO_R:
276 p->mapRtoRsize = mapsize;
277 if (!unpackbuffer)
278 for (i=0;i<mapsize;i++) {
279 p->mapRtoR[i] = CLAMP( values[i], 0.0F, 1.0F );
280 }
281 break;
282 case GL_PIXEL_MAP_G_TO_G:
283 p->mapGtoGsize = mapsize;
284 if (!unpackbuffer)
285 for (i=0;i<mapsize;i++) {
286 p->mapGtoG[i] = CLAMP( values[i], 0.0F, 1.0F );
287 }
288 break;
289 case GL_PIXEL_MAP_B_TO_B:
290 p->mapBtoBsize = mapsize;
291 if (!unpackbuffer)
292 for (i=0;i<mapsize;i++) {
293 p->mapBtoB[i] = CLAMP( values[i], 0.0F, 1.0F );
294 }
295 break;
296 case GL_PIXEL_MAP_A_TO_A:
297 p->mapAtoAsize = mapsize;
298 if (!unpackbuffer)
299 for (i=0;i<mapsize;i++) {
300 p->mapAtoA[i] = CLAMP( values[i], 0.0F, 1.0F );
301 }
302 break;
303 default:
304 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "PixelMap(map)");
305 return;
306 }
307
308 DIRTY(pb->maps, g->neg_bitid);
309 DIRTY(pb->dirty, g->neg_bitid);
310}
311
312void STATE_APIENTRY crStatePixelMapuiv (GLenum map, GLint mapsize, const GLuint * values)
313{
314 GLfloat fvalues[CR_MAX_PIXEL_MAP_TABLE];
315 GLint i;
316
317 if (!crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
318 {
319 if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) {
320 for (i=0;i<mapsize;i++) {
321 fvalues[i] = (GLfloat) values[i];
322 }
323 }
324 else {
325 for (i=0;i<mapsize;i++) {
326 fvalues[i] = values[i] / 4294967295.0F;
327 }
328 }
329 crStatePixelMapfv(map, mapsize, fvalues);
330 }
331 else
332 {
333 crStatePixelMapfv(map, mapsize, (const GLfloat*) values);
334 }
335}
336
337void STATE_APIENTRY crStatePixelMapusv (GLenum map, GLint mapsize, const GLushort * values)
338{
339 GLfloat fvalues[CR_MAX_PIXEL_MAP_TABLE];
340 GLint i;
341
342 if (!crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
343 {
344 if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) {
345 for (i=0;i<mapsize;i++) {
346 fvalues[i] = (GLfloat) values[i];
347 }
348 }
349 else {
350 for (i=0;i<mapsize;i++) {
351 fvalues[i] = values[i] / 65535.0F;
352 }
353 }
354 crStatePixelMapfv(map, mapsize, fvalues);
355 }
356 else
357 {
358 crStatePixelMapfv(map, mapsize, (const GLfloat*) values);
359 }
360}
361
362
363void STATE_APIENTRY crStateGetPixelMapfv (GLenum map, GLfloat * values)
364{
365 CRContext *g = GetCurrentContext();
366 CRPixelState *p = &(g->pixel);
367 GLint i;
368
369 if (g->current.inBeginEnd) {
370 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
371 "GetPixelMapfv called in Begin/End");
372 return;
373 }
374
375 switch (map) {
376 case GL_PIXEL_MAP_S_TO_S:
377 for (i = 0; i < p->mapStoSsize; i++) {
378 values[i] = (GLfloat) p->mapStoS[i];
379 }
380 break;
381 case GL_PIXEL_MAP_I_TO_I:
382 for (i = 0; i < p->mapItoIsize; i++) {
383 values[i] = (GLfloat) p->mapItoI[i];
384 }
385 break;
386 case GL_PIXEL_MAP_I_TO_R:
387 crMemcpy(values, p->mapItoR, p->mapItoRsize * sizeof(GLfloat));
388 break;
389 case GL_PIXEL_MAP_I_TO_G:
390 crMemcpy(values, p->mapItoG, p->mapItoGsize * sizeof(GLfloat));
391 break;
392 case GL_PIXEL_MAP_I_TO_B:
393 crMemcpy(values, p->mapItoB, p->mapItoBsize * sizeof(GLfloat));
394 break;
395 case GL_PIXEL_MAP_I_TO_A:
396 crMemcpy(values, p->mapItoA, p->mapItoAsize * sizeof(GLfloat));
397 break;
398 case GL_PIXEL_MAP_R_TO_R:
399 crMemcpy(values, p->mapRtoR, p->mapRtoRsize * sizeof(GLfloat));
400 break;
401 case GL_PIXEL_MAP_G_TO_G:
402 crMemcpy(values, p->mapGtoG, p->mapGtoGsize * sizeof(GLfloat));
403 break;
404 case GL_PIXEL_MAP_B_TO_B:
405 crMemcpy(values, p->mapBtoB, p->mapBtoBsize * sizeof(GLfloat));
406 break;
407 case GL_PIXEL_MAP_A_TO_A:
408 crMemcpy(values, p->mapAtoA, p->mapAtoAsize * sizeof(GLfloat));
409 break;
410 default:
411 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "GetPixelMap(map)");
412 return;
413 }
414}
415
416void STATE_APIENTRY crStateGetPixelMapuiv (GLenum map, GLuint * values)
417{
418 CRContext *g = GetCurrentContext();
419 const GLfloat maxUint = 4294967295.0F;
420 CRPixelState *p = &(g->pixel);
421 GLint i;
422
423 if (g->current.inBeginEnd) {
424 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
425 "GetPixelMapuiv called in Begin/End");
426 return;
427 }
428
429 switch (map) {
430 case GL_PIXEL_MAP_S_TO_S:
431 for (i = 0; i < p->mapStoSsize; i++) {
432 values[i] = p->mapStoS[i];
433 }
434 break;
435 case GL_PIXEL_MAP_I_TO_I:
436 for (i = 0; i < p->mapItoIsize; i++) {
437 values[i] = p->mapItoI[i];
438 }
439 break;
440 case GL_PIXEL_MAP_I_TO_R:
441 for (i = 0; i < p->mapItoRsize; i++) {
442 values[i] = (GLuint) (p->mapItoR[i] * maxUint);
443 }
444 break;
445 case GL_PIXEL_MAP_I_TO_G:
446 for (i = 0; i < p->mapItoGsize; i++) {
447 values[i] = (GLuint) (p->mapItoG[i] * maxUint);
448 }
449 break;
450 case GL_PIXEL_MAP_I_TO_B:
451 for (i = 0; i < p->mapItoBsize; i++) {
452 values[i] = (GLuint) (p->mapItoB[i] * maxUint);
453 }
454 break;
455 case GL_PIXEL_MAP_I_TO_A:
456 for (i = 0; i < p->mapItoAsize; i++) {
457 values[i] = (GLuint) (p->mapItoA[i] * maxUint);
458 }
459 break;
460 case GL_PIXEL_MAP_R_TO_R:
461 for (i = 0; i < p->mapRtoRsize; i++) {
462 values[i] = (GLuint) (p->mapRtoR[i] * maxUint);
463 }
464 break;
465 case GL_PIXEL_MAP_G_TO_G:
466 for (i = 0; i < p->mapGtoGsize; i++) {
467 values[i] = (GLuint) (p->mapGtoG[i] * maxUint);
468 }
469 break;
470 case GL_PIXEL_MAP_B_TO_B:
471 for (i = 0; i < p->mapBtoBsize; i++) {
472 values[i] = (GLuint) (p->mapBtoB[i] * maxUint);
473 }
474 break;
475 case GL_PIXEL_MAP_A_TO_A:
476 for (i = 0; i < p->mapAtoAsize; i++) {
477 values[i] = (GLuint) (p->mapAtoA[i] * maxUint);
478 }
479 break;
480 default:
481 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "GetPixelMapuiv(map)");
482 return;
483 }
484}
485
486void STATE_APIENTRY crStateGetPixelMapusv (GLenum map, GLushort * values)
487{
488 CRContext *g = GetCurrentContext();
489 const GLfloat maxUshort = 65535.0F;
490 CRPixelState *p = &(g->pixel);
491 GLint i;
492
493 if (g->current.inBeginEnd) {
494 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
495 "GetPixelMapusv called in Begin/End");
496 return;
497 }
498
499 switch (map) {
500 case GL_PIXEL_MAP_S_TO_S:
501 for (i = 0; i < p->mapStoSsize; i++) {
502 values[i] = p->mapStoS[i];
503 }
504 break;
505 case GL_PIXEL_MAP_I_TO_I:
506 for (i = 0; i < p->mapItoIsize; i++) {
507 values[i] = p->mapItoI[i];
508 }
509 break;
510 case GL_PIXEL_MAP_I_TO_R:
511 for (i = 0; i < p->mapItoRsize; i++) {
512 values[i] = (GLushort) (p->mapItoR[i] * maxUshort);
513 }
514 break;
515 case GL_PIXEL_MAP_I_TO_G:
516 for (i = 0; i < p->mapItoGsize; i++) {
517 values[i] = (GLushort) (p->mapItoG[i] * maxUshort);
518 }
519 break;
520 case GL_PIXEL_MAP_I_TO_B:
521 for (i = 0; i < p->mapItoBsize; i++) {
522 values[i] = (GLushort) (p->mapItoB[i] * maxUshort);
523 }
524 break;
525 case GL_PIXEL_MAP_I_TO_A:
526 for (i = 0; i < p->mapItoAsize; i++) {
527 values[i] = (GLushort) (p->mapItoA[i] * maxUshort);
528 }
529 break;
530 case GL_PIXEL_MAP_R_TO_R:
531 for (i = 0; i < p->mapRtoRsize; i++) {
532 values[i] = (GLushort) (p->mapRtoR[i] * maxUshort);
533 }
534 break;
535 case GL_PIXEL_MAP_G_TO_G:
536 for (i = 0; i < p->mapGtoGsize; i++) {
537 values[i] = (GLushort) (p->mapGtoG[i] * maxUshort);
538 }
539 break;
540 case GL_PIXEL_MAP_B_TO_B:
541 for (i = 0; i < p->mapBtoBsize; i++) {
542 values[i] = (GLushort) (p->mapBtoB[i] * maxUshort);
543 }
544 break;
545 case GL_PIXEL_MAP_A_TO_A:
546 for (i = 0; i < p->mapAtoAsize; i++) {
547 values[i] = (GLushort) (p->mapAtoA[i] * maxUshort);
548 }
549 break;
550 default:
551 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "GetPixelMapusv(map)");
552 return;
553 }
554}
555
556void crStatePixelDiff(CRPixelBits *b, CRbitvalue *bitID,
557 CRContext *fromCtx, CRContext *toCtx)
558{
559 CRPixelState *from = &(fromCtx->pixel);
560 CRPixelState *to = &(toCtx->pixel);
561 int j, i;
562 CRbitvalue nbitID[CR_MAX_BITARRAY];
563 for (j=0;j<CR_MAX_BITARRAY;j++)
564 nbitID[j] = ~bitID[j];
565 i = 0; /* silence compiler */
566 if (CHECKDIRTY(b->transfer, bitID))
567 {
568 if (from->mapColor != to->mapColor)
569 {
570 diff_api.PixelTransferi (GL_MAP_COLOR, to->mapColor);
571 from->mapColor = to->mapColor;
572 }
573 if (from->mapStencil != to->mapStencil)
574 {
575 diff_api.PixelTransferi (GL_MAP_STENCIL, to->mapStencil);
576 from->mapStencil = to->mapStencil;
577 }
578 if (from->indexOffset != to->indexOffset)
579 {
580 diff_api.PixelTransferi (GL_INDEX_OFFSET, to->indexOffset);
581 from->indexOffset = to->indexOffset;
582 }
583 if (from->indexShift != to->indexShift)
584 {
585 diff_api.PixelTransferi (GL_INDEX_SHIFT, to->indexShift);
586 from->indexShift = to->indexShift;
587 }
588 if (from->scale.r != to->scale.r)
589 {
590 diff_api.PixelTransferf (GL_RED_SCALE, to->scale.r);
591 from->scale.r = to->scale.r;
592 }
593 if (from->scale.g != to->scale.g)
594 {
595 diff_api.PixelTransferf (GL_GREEN_SCALE, to->scale.g);
596 from->scale.g = to->scale.g;
597 }
598 if (from->scale.b != to->scale.b)
599 {
600 diff_api.PixelTransferf (GL_BLUE_SCALE, to->scale.b);
601 from->scale.b = to->scale.b;
602 }
603 if (from->scale.a != to->scale.a)
604 {
605 diff_api.PixelTransferf (GL_ALPHA_SCALE, to->scale.a);
606 from->scale.a = to->scale.a;
607 }
608 if (from->bias.r != to->bias.r)
609 {
610 diff_api.PixelTransferf (GL_RED_BIAS, to->bias.r);
611 from->bias.r = to->bias.r;
612 }
613 if (from->bias.g != to->bias.g)
614 {
615 diff_api.PixelTransferf (GL_GREEN_BIAS, to->bias.g);
616 from->bias.g = to->bias.g;
617 }
618 if (from->bias.b != to->bias.b)
619 {
620 diff_api.PixelTransferf (GL_BLUE_BIAS, to->bias.b);
621 from->bias.b = to->bias.b;
622 }
623 if (from->bias.a != to->bias.a)
624 {
625 diff_api.PixelTransferf (GL_ALPHA_BIAS, to->bias.a);
626 from->bias.a = to->bias.a;
627 }
628 if (from->depthScale != to->depthScale)
629 {
630 diff_api.PixelTransferf (GL_DEPTH_SCALE, to->depthScale);
631 from->depthScale = to->depthScale;
632 }
633 if (from->depthBias != to->depthBias)
634 {
635 diff_api.PixelTransferf (GL_DEPTH_BIAS, to->depthBias);
636 from->depthBias = to->depthBias;
637 }
638 CLEARDIRTY(b->transfer, nbitID);
639 }
640 if (CHECKDIRTY(b->zoom, bitID))
641 {
642 if (from->xZoom != to->xZoom ||
643 from->yZoom != to->yZoom)
644 {
645 diff_api.PixelZoom (to->xZoom,
646 to->yZoom);
647 from->xZoom = to->xZoom;
648 from->yZoom = to->yZoom;
649 }
650 CLEARDIRTY(b->zoom, nbitID);
651 }
652 if (CHECKDIRTY(b->maps, bitID))
653 {
654 if (crMemcmp(to->mapStoS, from->mapStoS, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
655 diff_api.PixelMapfv(GL_PIXEL_MAP_S_TO_S,to->mapStoSsize,(GLfloat*)to->mapStoS);
656 if (crMemcmp(to->mapItoI, from->mapItoI, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
657 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_I,to->mapItoIsize,(GLfloat*)to->mapItoI);
658 if (crMemcmp(to->mapItoR, from->mapItoR, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
659 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_R,to->mapItoRsize,(GLfloat*)to->mapItoR);
660 if (crMemcmp(to->mapItoG, from->mapItoG, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
661 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_G,to->mapItoGsize,(GLfloat*)to->mapItoG);
662 if (crMemcmp(to->mapItoB, from->mapItoB, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
663 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_B,to->mapItoBsize,(GLfloat*)to->mapItoB);
664 if (crMemcmp(to->mapItoA, from->mapItoA, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
665 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_A,to->mapItoAsize,(GLfloat*)to->mapItoA);
666 if (crMemcmp(to->mapRtoR, from->mapRtoR, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
667 diff_api.PixelMapfv(GL_PIXEL_MAP_R_TO_R,to->mapRtoRsize,(GLfloat*)to->mapRtoR);
668 if (crMemcmp(to->mapGtoG, from->mapGtoG, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
669 diff_api.PixelMapfv(GL_PIXEL_MAP_G_TO_G,to->mapGtoGsize,(GLfloat*)to->mapGtoG);
670 if (crMemcmp(to->mapBtoB, from->mapBtoB, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
671 diff_api.PixelMapfv(GL_PIXEL_MAP_B_TO_B,to->mapBtoBsize,(GLfloat*)to->mapBtoB);
672 if (crMemcmp(to->mapAtoA, from->mapAtoA, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
673 diff_api.PixelMapfv(GL_PIXEL_MAP_A_TO_A,to->mapAtoAsize,(GLfloat*)to->mapAtoA);
674 CLEARDIRTY(b->maps, nbitID);
675 }
676 CLEARDIRTY(b->dirty, nbitID);
677}
678
679void crStatePixelSwitch(CRPixelBits *b, CRbitvalue *bitID,
680 CRContext *fromCtx, CRContext *toCtx)
681{
682 CRPixelState *from = &(fromCtx->pixel);
683 CRPixelState *to = &(toCtx->pixel);
684 int j, i;
685 CRbitvalue nbitID[CR_MAX_BITARRAY];
686 for (j=0;j<CR_MAX_BITARRAY;j++)
687 nbitID[j] = ~bitID[j];
688 i = 0; /* silence compiler */
689 if (CHECKDIRTY(b->transfer, bitID))
690 {
691 if (from->mapColor != to->mapColor)
692 {
693 diff_api.PixelTransferi (GL_MAP_COLOR, to->mapColor);
694 FILLDIRTY(b->transfer);
695 FILLDIRTY(b->dirty);
696 }
697 if (from->mapStencil != to->mapStencil)
698 {
699 diff_api.PixelTransferi (GL_MAP_STENCIL, to->mapStencil);
700 FILLDIRTY(b->transfer);
701 FILLDIRTY(b->dirty);
702 }
703 if (from->indexOffset != to->indexOffset)
704 {
705 diff_api.PixelTransferi (GL_INDEX_OFFSET, to->indexOffset);
706 FILLDIRTY(b->transfer);
707 FILLDIRTY(b->dirty);
708 }
709 if (from->indexShift != to->indexShift)
710 {
711 diff_api.PixelTransferi (GL_INDEX_SHIFT, to->indexShift);
712 FILLDIRTY(b->transfer);
713 FILLDIRTY(b->dirty);
714 }
715 if (from->scale.r != to->scale.r)
716 {
717 diff_api.PixelTransferf (GL_RED_SCALE, to->scale.r);
718 FILLDIRTY(b->transfer);
719 FILLDIRTY(b->dirty);
720 }
721 if (from->scale.g != to->scale.g)
722 {
723 diff_api.PixelTransferf (GL_GREEN_SCALE, to->scale.g);
724 FILLDIRTY(b->transfer);
725 FILLDIRTY(b->dirty);
726 }
727 if (from->scale.b != to->scale.b)
728 {
729 diff_api.PixelTransferf (GL_BLUE_SCALE, to->scale.b);
730 FILLDIRTY(b->transfer);
731 FILLDIRTY(b->dirty);
732 }
733 if (from->scale.a != to->scale.a)
734 {
735 diff_api.PixelTransferf (GL_ALPHA_SCALE, to->scale.a);
736 FILLDIRTY(b->transfer);
737 FILLDIRTY(b->dirty);
738 }
739 if (from->bias.r != to->bias.r)
740 {
741 diff_api.PixelTransferf (GL_RED_BIAS, to->bias.r);
742 FILLDIRTY(b->transfer);
743 FILLDIRTY(b->dirty);
744 }
745 if (from->bias.g != to->bias.g)
746 {
747 diff_api.PixelTransferf (GL_GREEN_BIAS, to->bias.g);
748 FILLDIRTY(b->transfer);
749 FILLDIRTY(b->dirty);
750 }
751 if (from->bias.b != to->bias.b)
752 {
753 diff_api.PixelTransferf (GL_BLUE_BIAS, to->bias.b);
754 FILLDIRTY(b->transfer);
755 FILLDIRTY(b->dirty);
756 }
757 if (from->bias.a != to->bias.a)
758 {
759 diff_api.PixelTransferf (GL_ALPHA_BIAS, to->bias.a);
760 FILLDIRTY(b->transfer);
761 FILLDIRTY(b->dirty);
762 }
763 if (from->depthScale != to->depthScale)
764 {
765 diff_api.PixelTransferf (GL_DEPTH_SCALE, to->depthScale);
766 FILLDIRTY(b->transfer);
767 FILLDIRTY(b->dirty);
768 }
769 if (from->depthBias != to->depthBias)
770 {
771 diff_api.PixelTransferf (GL_DEPTH_BIAS, to->depthBias);
772 FILLDIRTY(b->transfer);
773 FILLDIRTY(b->dirty);
774 }
775 CLEARDIRTY(b->transfer, nbitID);
776 }
777 if (CHECKDIRTY(b->zoom, bitID))
778 {
779 if (from->xZoom != to->xZoom ||
780 from->yZoom != to->yZoom)
781 {
782 diff_api.PixelZoom (to->xZoom,
783 to->yZoom);
784 FILLDIRTY(b->zoom);
785 FILLDIRTY(b->dirty);
786 }
787 CLEARDIRTY(b->zoom, nbitID);
788 }
789 if (CHECKDIRTY(b->maps, bitID))
790 {
791 if (crMemcmp(to->mapStoS, from->mapStoS, CR_MAX_PIXEL_MAP_TABLE)) {
792 diff_api.PixelMapfv(GL_PIXEL_MAP_S_TO_S,to->mapStoSsize,(GLfloat*)to->mapStoS);
793 FILLDIRTY(b->maps);
794 FILLDIRTY(b->dirty);
795 }
796 if (crMemcmp(to->mapItoI, from->mapItoI, CR_MAX_PIXEL_MAP_TABLE)) {
797 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_I,to->mapItoIsize,(GLfloat*)to->mapItoI);
798 FILLDIRTY(b->maps);
799 FILLDIRTY(b->dirty);
800 }
801 if (crMemcmp(to->mapItoR, from->mapItoR, CR_MAX_PIXEL_MAP_TABLE)) {
802 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_R,to->mapItoRsize,(GLfloat*)to->mapItoR);
803 FILLDIRTY(b->maps);
804 FILLDIRTY(b->dirty);
805 }
806 if (crMemcmp(to->mapItoG, from->mapItoG, CR_MAX_PIXEL_MAP_TABLE)) {
807 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_G,to->mapItoGsize,(GLfloat*)to->mapItoG);
808 FILLDIRTY(b->maps);
809 FILLDIRTY(b->dirty);
810 }
811 if (crMemcmp(to->mapItoB, from->mapItoB, CR_MAX_PIXEL_MAP_TABLE)) {
812 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_B,to->mapItoBsize,(GLfloat*)to->mapItoB);
813 FILLDIRTY(b->maps);
814 FILLDIRTY(b->dirty);
815 }
816 if (crMemcmp(to->mapItoA, from->mapItoA, CR_MAX_PIXEL_MAP_TABLE)) {
817 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_A,to->mapItoAsize,(GLfloat*)to->mapItoA);
818 FILLDIRTY(b->maps);
819 FILLDIRTY(b->dirty);
820 }
821 if (crMemcmp(to->mapRtoR, from->mapRtoR, CR_MAX_PIXEL_MAP_TABLE)) {
822 diff_api.PixelMapfv(GL_PIXEL_MAP_R_TO_R,to->mapRtoRsize,(GLfloat*)to->mapRtoR);
823 FILLDIRTY(b->maps);
824 FILLDIRTY(b->dirty);
825 }
826 if (crMemcmp(to->mapGtoG, from->mapGtoG, CR_MAX_PIXEL_MAP_TABLE)) {
827 diff_api.PixelMapfv(GL_PIXEL_MAP_G_TO_G,to->mapGtoGsize,(GLfloat*)to->mapGtoG);
828 FILLDIRTY(b->maps);
829 FILLDIRTY(b->dirty);
830 }
831 if (crMemcmp(to->mapBtoB, from->mapBtoB, CR_MAX_PIXEL_MAP_TABLE)) {
832 diff_api.PixelMapfv(GL_PIXEL_MAP_B_TO_B,to->mapBtoBsize,(GLfloat*)to->mapBtoB);
833 FILLDIRTY(b->maps);
834 FILLDIRTY(b->dirty);
835 }
836 if (crMemcmp(to->mapAtoA, from->mapAtoA, CR_MAX_PIXEL_MAP_TABLE)) {
837 diff_api.PixelMapfv(GL_PIXEL_MAP_A_TO_A,to->mapAtoAsize,(GLfloat*)to->mapAtoA);
838 FILLDIRTY(b->maps);
839 FILLDIRTY(b->dirty);
840 }
841 CLEARDIRTY(b->maps, nbitID);
842 }
843 CLEARDIRTY(b->dirty, nbitID);
844}
845
Note: See TracBrowser for help on using the repository browser.

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