VirtualBox

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

Last change on this file since 21308 was 15532, checked in by vboxsync, 16 years ago

crOpenGL: export to OSE

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 21.7 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
211 if (g->current.inBeginEnd) {
212 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "PixelMap called in Begin/End");
213 return;
214 }
215
216 FLUSH();
217
218 if (mapsize < 0 || mapsize > CR_MAX_PIXEL_MAP_TABLE) {
219 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "PixelMap(mapsize)");
220 return;
221 }
222
223 if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) {
224 /* XXX check that mapsize is a power of two */
225 }
226
227 switch (map) {
228 case GL_PIXEL_MAP_S_TO_S:
229 p->mapStoSsize = mapsize;
230 for (i=0;i<mapsize;i++) {
231 p->mapStoS[i] = (GLint) values[i];
232 }
233 break;
234 case GL_PIXEL_MAP_I_TO_I:
235 p->mapItoIsize = mapsize;
236 for (i=0;i<mapsize;i++) {
237 p->mapItoI[i] = (GLint) values[i];
238 }
239 break;
240 case GL_PIXEL_MAP_I_TO_R:
241 p->mapItoRsize = mapsize;
242 for (i=0;i<mapsize;i++) {
243 GLfloat val = CLAMP( values[i], 0.0F, 1.0F );
244 p->mapItoR[i] = val;
245 }
246 break;
247 case GL_PIXEL_MAP_I_TO_G:
248 p->mapItoGsize = mapsize;
249 for (i=0;i<mapsize;i++) {
250 GLfloat val = CLAMP( values[i], 0.0F, 1.0F );
251 p->mapItoG[i] = val;
252 }
253 break;
254 case GL_PIXEL_MAP_I_TO_B:
255 p->mapItoBsize = mapsize;
256 for (i=0;i<mapsize;i++) {
257 GLfloat val = CLAMP( values[i], 0.0F, 1.0F );
258 p->mapItoB[i] = val;
259 }
260 break;
261 case GL_PIXEL_MAP_I_TO_A:
262 p->mapItoAsize = mapsize;
263 for (i=0;i<mapsize;i++) {
264 GLfloat val = CLAMP( values[i], 0.0F, 1.0F );
265 p->mapItoA[i] = val;
266 }
267 break;
268 case GL_PIXEL_MAP_R_TO_R:
269 p->mapRtoRsize = mapsize;
270 for (i=0;i<mapsize;i++) {
271 p->mapRtoR[i] = CLAMP( values[i], 0.0F, 1.0F );
272 }
273 break;
274 case GL_PIXEL_MAP_G_TO_G:
275 p->mapGtoGsize = mapsize;
276 for (i=0;i<mapsize;i++) {
277 p->mapGtoG[i] = CLAMP( values[i], 0.0F, 1.0F );
278 }
279 break;
280 case GL_PIXEL_MAP_B_TO_B:
281 p->mapBtoBsize = mapsize;
282 for (i=0;i<mapsize;i++) {
283 p->mapBtoB[i] = CLAMP( values[i], 0.0F, 1.0F );
284 }
285 break;
286 case GL_PIXEL_MAP_A_TO_A:
287 p->mapAtoAsize = mapsize;
288 for (i=0;i<mapsize;i++) {
289 p->mapAtoA[i] = CLAMP( values[i], 0.0F, 1.0F );
290 }
291 break;
292 default:
293 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "PixelMap(map)");
294 return;
295 }
296
297 DIRTY(pb->maps, g->neg_bitid);
298 DIRTY(pb->dirty, g->neg_bitid);
299}
300
301void STATE_APIENTRY crStatePixelMapuiv (GLenum map, GLint mapsize, const GLuint * values)
302{
303 GLfloat fvalues[CR_MAX_PIXEL_MAP_TABLE];
304 GLint i;
305 if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) {
306 for (i=0;i<mapsize;i++) {
307 fvalues[i] = (GLfloat) values[i];
308 }
309 }
310 else {
311 for (i=0;i<mapsize;i++) {
312 fvalues[i] = values[i] / 4294967295.0F;
313 }
314 }
315 crStatePixelMapfv(map, mapsize, fvalues);
316}
317
318void STATE_APIENTRY crStatePixelMapusv (GLenum map, GLint mapsize, const GLushort * values)
319{
320 GLfloat fvalues[CR_MAX_PIXEL_MAP_TABLE];
321 GLint i;
322 if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) {
323 for (i=0;i<mapsize;i++) {
324 fvalues[i] = (GLfloat) values[i];
325 }
326 }
327 else {
328 for (i=0;i<mapsize;i++) {
329 fvalues[i] = values[i] / 65535.0F;
330 }
331 }
332 crStatePixelMapfv(map, mapsize, fvalues);
333}
334
335
336void STATE_APIENTRY crStateGetPixelMapfv (GLenum map, GLfloat * values)
337{
338 CRContext *g = GetCurrentContext();
339 CRPixelState *p = &(g->pixel);
340 GLint i;
341
342 if (g->current.inBeginEnd) {
343 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
344 "GetPixelMapfv called in Begin/End");
345 return;
346 }
347
348 switch (map) {
349 case GL_PIXEL_MAP_S_TO_S:
350 for (i = 0; i < p->mapStoSsize; i++) {
351 values[i] = (GLfloat) p->mapStoS[i];
352 }
353 break;
354 case GL_PIXEL_MAP_I_TO_I:
355 for (i = 0; i < p->mapItoIsize; i++) {
356 values[i] = (GLfloat) p->mapItoI[i];
357 }
358 break;
359 case GL_PIXEL_MAP_I_TO_R:
360 crMemcpy(values, p->mapItoR, p->mapItoRsize * sizeof(GLfloat));
361 break;
362 case GL_PIXEL_MAP_I_TO_G:
363 crMemcpy(values, p->mapItoG, p->mapItoGsize * sizeof(GLfloat));
364 break;
365 case GL_PIXEL_MAP_I_TO_B:
366 crMemcpy(values, p->mapItoB, p->mapItoBsize * sizeof(GLfloat));
367 break;
368 case GL_PIXEL_MAP_I_TO_A:
369 crMemcpy(values, p->mapItoA, p->mapItoAsize * sizeof(GLfloat));
370 break;
371 case GL_PIXEL_MAP_R_TO_R:
372 crMemcpy(values, p->mapRtoR, p->mapRtoRsize * sizeof(GLfloat));
373 break;
374 case GL_PIXEL_MAP_G_TO_G:
375 crMemcpy(values, p->mapGtoG, p->mapGtoGsize * sizeof(GLfloat));
376 break;
377 case GL_PIXEL_MAP_B_TO_B:
378 crMemcpy(values, p->mapBtoB, p->mapBtoBsize * sizeof(GLfloat));
379 break;
380 case GL_PIXEL_MAP_A_TO_A:
381 crMemcpy(values, p->mapAtoA, p->mapAtoAsize * sizeof(GLfloat));
382 break;
383 default:
384 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "GetPixelMap(map)");
385 return;
386 }
387}
388
389void STATE_APIENTRY crStateGetPixelMapuiv (GLenum map, GLuint * values)
390{
391 CRContext *g = GetCurrentContext();
392 const GLfloat maxUint = 4294967295.0F;
393 CRPixelState *p = &(g->pixel);
394 GLint i;
395
396 if (g->current.inBeginEnd) {
397 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
398 "GetPixelMapuiv called in Begin/End");
399 return;
400 }
401
402 switch (map) {
403 case GL_PIXEL_MAP_S_TO_S:
404 for (i = 0; i < p->mapStoSsize; i++) {
405 values[i] = p->mapStoS[i];
406 }
407 break;
408 case GL_PIXEL_MAP_I_TO_I:
409 for (i = 0; i < p->mapItoIsize; i++) {
410 values[i] = p->mapItoI[i];
411 }
412 break;
413 case GL_PIXEL_MAP_I_TO_R:
414 for (i = 0; i < p->mapItoRsize; i++) {
415 values[i] = (GLuint) (p->mapItoR[i] * maxUint);
416 }
417 break;
418 case GL_PIXEL_MAP_I_TO_G:
419 for (i = 0; i < p->mapItoGsize; i++) {
420 values[i] = (GLuint) (p->mapItoG[i] * maxUint);
421 }
422 break;
423 case GL_PIXEL_MAP_I_TO_B:
424 for (i = 0; i < p->mapItoBsize; i++) {
425 values[i] = (GLuint) (p->mapItoB[i] * maxUint);
426 }
427 break;
428 case GL_PIXEL_MAP_I_TO_A:
429 for (i = 0; i < p->mapItoAsize; i++) {
430 values[i] = (GLuint) (p->mapItoA[i] * maxUint);
431 }
432 break;
433 case GL_PIXEL_MAP_R_TO_R:
434 for (i = 0; i < p->mapRtoRsize; i++) {
435 values[i] = (GLuint) (p->mapRtoR[i] * maxUint);
436 }
437 break;
438 case GL_PIXEL_MAP_G_TO_G:
439 for (i = 0; i < p->mapGtoGsize; i++) {
440 values[i] = (GLuint) (p->mapGtoG[i] * maxUint);
441 }
442 break;
443 case GL_PIXEL_MAP_B_TO_B:
444 for (i = 0; i < p->mapBtoBsize; i++) {
445 values[i] = (GLuint) (p->mapBtoB[i] * maxUint);
446 }
447 break;
448 case GL_PIXEL_MAP_A_TO_A:
449 for (i = 0; i < p->mapAtoAsize; i++) {
450 values[i] = (GLuint) (p->mapAtoA[i] * maxUint);
451 }
452 break;
453 default:
454 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "GetPixelMapuiv(map)");
455 return;
456 }
457}
458
459void STATE_APIENTRY crStateGetPixelMapusv (GLenum map, GLushort * values)
460{
461 CRContext *g = GetCurrentContext();
462 const GLfloat maxUshort = 65535.0F;
463 CRPixelState *p = &(g->pixel);
464 GLint i;
465
466 if (g->current.inBeginEnd) {
467 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
468 "GetPixelMapusv called in Begin/End");
469 return;
470 }
471
472 switch (map) {
473 case GL_PIXEL_MAP_S_TO_S:
474 for (i = 0; i < p->mapStoSsize; i++) {
475 values[i] = p->mapStoS[i];
476 }
477 break;
478 case GL_PIXEL_MAP_I_TO_I:
479 for (i = 0; i < p->mapItoIsize; i++) {
480 values[i] = p->mapItoI[i];
481 }
482 break;
483 case GL_PIXEL_MAP_I_TO_R:
484 for (i = 0; i < p->mapItoRsize; i++) {
485 values[i] = (GLushort) (p->mapItoR[i] * maxUshort);
486 }
487 break;
488 case GL_PIXEL_MAP_I_TO_G:
489 for (i = 0; i < p->mapItoGsize; i++) {
490 values[i] = (GLushort) (p->mapItoG[i] * maxUshort);
491 }
492 break;
493 case GL_PIXEL_MAP_I_TO_B:
494 for (i = 0; i < p->mapItoBsize; i++) {
495 values[i] = (GLushort) (p->mapItoB[i] * maxUshort);
496 }
497 break;
498 case GL_PIXEL_MAP_I_TO_A:
499 for (i = 0; i < p->mapItoAsize; i++) {
500 values[i] = (GLushort) (p->mapItoA[i] * maxUshort);
501 }
502 break;
503 case GL_PIXEL_MAP_R_TO_R:
504 for (i = 0; i < p->mapRtoRsize; i++) {
505 values[i] = (GLushort) (p->mapRtoR[i] * maxUshort);
506 }
507 break;
508 case GL_PIXEL_MAP_G_TO_G:
509 for (i = 0; i < p->mapGtoGsize; i++) {
510 values[i] = (GLushort) (p->mapGtoG[i] * maxUshort);
511 }
512 break;
513 case GL_PIXEL_MAP_B_TO_B:
514 for (i = 0; i < p->mapBtoBsize; i++) {
515 values[i] = (GLushort) (p->mapBtoB[i] * maxUshort);
516 }
517 break;
518 case GL_PIXEL_MAP_A_TO_A:
519 for (i = 0; i < p->mapAtoAsize; i++) {
520 values[i] = (GLushort) (p->mapAtoA[i] * maxUshort);
521 }
522 break;
523 default:
524 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "GetPixelMapusv(map)");
525 return;
526 }
527}
528
529void crStatePixelDiff(CRPixelBits *b, CRbitvalue *bitID,
530 CRContext *fromCtx, CRContext *toCtx)
531{
532 CRPixelState *from = &(fromCtx->pixel);
533 CRPixelState *to = &(toCtx->pixel);
534 int j, i;
535 CRbitvalue nbitID[CR_MAX_BITARRAY];
536 for (j=0;j<CR_MAX_BITARRAY;j++)
537 nbitID[j] = ~bitID[j];
538 i = 0; /* silence compiler */
539 if (CHECKDIRTY(b->transfer, bitID))
540 {
541 if (from->mapColor != to->mapColor)
542 {
543 diff_api.PixelTransferi (GL_MAP_COLOR, to->mapColor);
544 from->mapColor = to->mapColor;
545 }
546 if (from->mapStencil != to->mapStencil)
547 {
548 diff_api.PixelTransferi (GL_MAP_STENCIL, to->mapStencil);
549 from->mapStencil = to->mapStencil;
550 }
551 if (from->indexOffset != to->indexOffset)
552 {
553 diff_api.PixelTransferi (GL_INDEX_OFFSET, to->indexOffset);
554 from->indexOffset = to->indexOffset;
555 }
556 if (from->indexShift != to->indexShift)
557 {
558 diff_api.PixelTransferi (GL_INDEX_SHIFT, to->indexShift);
559 from->indexShift = to->indexShift;
560 }
561 if (from->scale.r != to->scale.r)
562 {
563 diff_api.PixelTransferf (GL_RED_SCALE, to->scale.r);
564 from->scale.r = to->scale.r;
565 }
566 if (from->scale.g != to->scale.g)
567 {
568 diff_api.PixelTransferf (GL_GREEN_SCALE, to->scale.g);
569 from->scale.g = to->scale.g;
570 }
571 if (from->scale.b != to->scale.b)
572 {
573 diff_api.PixelTransferf (GL_BLUE_SCALE, to->scale.b);
574 from->scale.b = to->scale.b;
575 }
576 if (from->scale.a != to->scale.a)
577 {
578 diff_api.PixelTransferf (GL_ALPHA_SCALE, to->scale.a);
579 from->scale.a = to->scale.a;
580 }
581 if (from->bias.r != to->bias.r)
582 {
583 diff_api.PixelTransferf (GL_RED_BIAS, to->bias.r);
584 from->bias.r = to->bias.r;
585 }
586 if (from->bias.g != to->bias.g)
587 {
588 diff_api.PixelTransferf (GL_GREEN_BIAS, to->bias.g);
589 from->bias.g = to->bias.g;
590 }
591 if (from->bias.b != to->bias.b)
592 {
593 diff_api.PixelTransferf (GL_BLUE_BIAS, to->bias.b);
594 from->bias.b = to->bias.b;
595 }
596 if (from->bias.a != to->bias.a)
597 {
598 diff_api.PixelTransferf (GL_ALPHA_BIAS, to->bias.a);
599 from->bias.a = to->bias.a;
600 }
601 if (from->depthScale != to->depthScale)
602 {
603 diff_api.PixelTransferf (GL_DEPTH_SCALE, to->depthScale);
604 from->depthScale = to->depthScale;
605 }
606 if (from->depthBias != to->depthBias)
607 {
608 diff_api.PixelTransferf (GL_DEPTH_BIAS, to->depthBias);
609 from->depthBias = to->depthBias;
610 }
611 CLEARDIRTY(b->transfer, nbitID);
612 }
613 if (CHECKDIRTY(b->zoom, bitID))
614 {
615 if (from->xZoom != to->xZoom ||
616 from->yZoom != to->yZoom)
617 {
618 diff_api.PixelZoom (to->xZoom,
619 to->yZoom);
620 from->xZoom = to->xZoom;
621 from->yZoom = to->yZoom;
622 }
623 CLEARDIRTY(b->zoom, nbitID);
624 }
625 if (CHECKDIRTY(b->maps, bitID))
626 {
627 if (crMemcmp(to->mapStoS, from->mapStoS, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
628 diff_api.PixelMapfv(GL_PIXEL_MAP_S_TO_S,to->mapStoSsize,(GLfloat*)to->mapStoS);
629 if (crMemcmp(to->mapItoI, from->mapItoI, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
630 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_I,to->mapItoIsize,(GLfloat*)to->mapItoI);
631 if (crMemcmp(to->mapItoR, from->mapItoR, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
632 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_R,to->mapItoRsize,(GLfloat*)to->mapItoR);
633 if (crMemcmp(to->mapItoG, from->mapItoG, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
634 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_G,to->mapItoGsize,(GLfloat*)to->mapItoG);
635 if (crMemcmp(to->mapItoB, from->mapItoB, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
636 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_B,to->mapItoBsize,(GLfloat*)to->mapItoB);
637 if (crMemcmp(to->mapItoA, from->mapItoA, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
638 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_A,to->mapItoAsize,(GLfloat*)to->mapItoA);
639 if (crMemcmp(to->mapRtoR, from->mapRtoR, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
640 diff_api.PixelMapfv(GL_PIXEL_MAP_R_TO_R,to->mapRtoRsize,(GLfloat*)to->mapRtoR);
641 if (crMemcmp(to->mapGtoG, from->mapGtoG, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
642 diff_api.PixelMapfv(GL_PIXEL_MAP_G_TO_G,to->mapGtoGsize,(GLfloat*)to->mapGtoG);
643 if (crMemcmp(to->mapBtoB, from->mapBtoB, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
644 diff_api.PixelMapfv(GL_PIXEL_MAP_B_TO_B,to->mapBtoBsize,(GLfloat*)to->mapBtoB);
645 if (crMemcmp(to->mapAtoA, from->mapAtoA, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
646 diff_api.PixelMapfv(GL_PIXEL_MAP_A_TO_A,to->mapAtoAsize,(GLfloat*)to->mapAtoA);
647 CLEARDIRTY(b->maps, nbitID);
648 }
649 CLEARDIRTY(b->dirty, nbitID);
650}
651
652void crStatePixelSwitch(CRPixelBits *b, CRbitvalue *bitID,
653 CRContext *fromCtx, CRContext *toCtx)
654{
655 CRPixelState *from = &(fromCtx->pixel);
656 CRPixelState *to = &(toCtx->pixel);
657 int j, i;
658 CRbitvalue nbitID[CR_MAX_BITARRAY];
659 for (j=0;j<CR_MAX_BITARRAY;j++)
660 nbitID[j] = ~bitID[j];
661 i = 0; /* silence compiler */
662 if (CHECKDIRTY(b->transfer, bitID))
663 {
664 if (from->mapColor != to->mapColor)
665 {
666 diff_api.PixelTransferi (GL_MAP_COLOR, to->mapColor);
667 FILLDIRTY(b->transfer);
668 FILLDIRTY(b->dirty);
669 }
670 if (from->mapStencil != to->mapStencil)
671 {
672 diff_api.PixelTransferi (GL_MAP_STENCIL, to->mapStencil);
673 FILLDIRTY(b->transfer);
674 FILLDIRTY(b->dirty);
675 }
676 if (from->indexOffset != to->indexOffset)
677 {
678 diff_api.PixelTransferi (GL_INDEX_OFFSET, to->indexOffset);
679 FILLDIRTY(b->transfer);
680 FILLDIRTY(b->dirty);
681 }
682 if (from->indexShift != to->indexShift)
683 {
684 diff_api.PixelTransferi (GL_INDEX_SHIFT, to->indexShift);
685 FILLDIRTY(b->transfer);
686 FILLDIRTY(b->dirty);
687 }
688 if (from->scale.r != to->scale.r)
689 {
690 diff_api.PixelTransferf (GL_RED_SCALE, to->scale.r);
691 FILLDIRTY(b->transfer);
692 FILLDIRTY(b->dirty);
693 }
694 if (from->scale.g != to->scale.g)
695 {
696 diff_api.PixelTransferf (GL_GREEN_SCALE, to->scale.g);
697 FILLDIRTY(b->transfer);
698 FILLDIRTY(b->dirty);
699 }
700 if (from->scale.b != to->scale.b)
701 {
702 diff_api.PixelTransferf (GL_BLUE_SCALE, to->scale.b);
703 FILLDIRTY(b->transfer);
704 FILLDIRTY(b->dirty);
705 }
706 if (from->scale.a != to->scale.a)
707 {
708 diff_api.PixelTransferf (GL_ALPHA_SCALE, to->scale.a);
709 FILLDIRTY(b->transfer);
710 FILLDIRTY(b->dirty);
711 }
712 if (from->bias.r != to->bias.r)
713 {
714 diff_api.PixelTransferf (GL_RED_BIAS, to->bias.r);
715 FILLDIRTY(b->transfer);
716 FILLDIRTY(b->dirty);
717 }
718 if (from->bias.g != to->bias.g)
719 {
720 diff_api.PixelTransferf (GL_GREEN_BIAS, to->bias.g);
721 FILLDIRTY(b->transfer);
722 FILLDIRTY(b->dirty);
723 }
724 if (from->bias.b != to->bias.b)
725 {
726 diff_api.PixelTransferf (GL_BLUE_BIAS, to->bias.b);
727 FILLDIRTY(b->transfer);
728 FILLDIRTY(b->dirty);
729 }
730 if (from->bias.a != to->bias.a)
731 {
732 diff_api.PixelTransferf (GL_ALPHA_BIAS, to->bias.a);
733 FILLDIRTY(b->transfer);
734 FILLDIRTY(b->dirty);
735 }
736 if (from->depthScale != to->depthScale)
737 {
738 diff_api.PixelTransferf (GL_DEPTH_SCALE, to->depthScale);
739 FILLDIRTY(b->transfer);
740 FILLDIRTY(b->dirty);
741 }
742 if (from->depthBias != to->depthBias)
743 {
744 diff_api.PixelTransferf (GL_DEPTH_BIAS, to->depthBias);
745 FILLDIRTY(b->transfer);
746 FILLDIRTY(b->dirty);
747 }
748 CLEARDIRTY(b->transfer, nbitID);
749 }
750 if (CHECKDIRTY(b->zoom, bitID))
751 {
752 if (from->xZoom != to->xZoom ||
753 from->yZoom != to->yZoom)
754 {
755 diff_api.PixelZoom (to->xZoom,
756 to->yZoom);
757 FILLDIRTY(b->zoom);
758 FILLDIRTY(b->dirty);
759 }
760 CLEARDIRTY(b->zoom, nbitID);
761 }
762 if (CHECKDIRTY(b->maps, bitID))
763 {
764 if (crMemcmp(to->mapStoS, from->mapStoS, CR_MAX_PIXEL_MAP_TABLE)) {
765 diff_api.PixelMapfv(GL_PIXEL_MAP_S_TO_S,to->mapStoSsize,(GLfloat*)to->mapStoS);
766 FILLDIRTY(b->maps);
767 FILLDIRTY(b->dirty);
768 }
769 if (crMemcmp(to->mapItoI, from->mapItoI, CR_MAX_PIXEL_MAP_TABLE)) {
770 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_I,to->mapItoIsize,(GLfloat*)to->mapItoI);
771 FILLDIRTY(b->maps);
772 FILLDIRTY(b->dirty);
773 }
774 if (crMemcmp(to->mapItoR, from->mapItoR, CR_MAX_PIXEL_MAP_TABLE)) {
775 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_R,to->mapItoRsize,(GLfloat*)to->mapItoR);
776 FILLDIRTY(b->maps);
777 FILLDIRTY(b->dirty);
778 }
779 if (crMemcmp(to->mapItoG, from->mapItoG, CR_MAX_PIXEL_MAP_TABLE)) {
780 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_G,to->mapItoGsize,(GLfloat*)to->mapItoG);
781 FILLDIRTY(b->maps);
782 FILLDIRTY(b->dirty);
783 }
784 if (crMemcmp(to->mapItoB, from->mapItoB, CR_MAX_PIXEL_MAP_TABLE)) {
785 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_B,to->mapItoBsize,(GLfloat*)to->mapItoB);
786 FILLDIRTY(b->maps);
787 FILLDIRTY(b->dirty);
788 }
789 if (crMemcmp(to->mapItoA, from->mapItoA, CR_MAX_PIXEL_MAP_TABLE)) {
790 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_A,to->mapItoAsize,(GLfloat*)to->mapItoA);
791 FILLDIRTY(b->maps);
792 FILLDIRTY(b->dirty);
793 }
794 if (crMemcmp(to->mapRtoR, from->mapRtoR, CR_MAX_PIXEL_MAP_TABLE)) {
795 diff_api.PixelMapfv(GL_PIXEL_MAP_R_TO_R,to->mapRtoRsize,(GLfloat*)to->mapRtoR);
796 FILLDIRTY(b->maps);
797 FILLDIRTY(b->dirty);
798 }
799 if (crMemcmp(to->mapGtoG, from->mapGtoG, CR_MAX_PIXEL_MAP_TABLE)) {
800 diff_api.PixelMapfv(GL_PIXEL_MAP_G_TO_G,to->mapGtoGsize,(GLfloat*)to->mapGtoG);
801 FILLDIRTY(b->maps);
802 FILLDIRTY(b->dirty);
803 }
804 if (crMemcmp(to->mapBtoB, from->mapBtoB, CR_MAX_PIXEL_MAP_TABLE)) {
805 diff_api.PixelMapfv(GL_PIXEL_MAP_B_TO_B,to->mapBtoBsize,(GLfloat*)to->mapBtoB);
806 FILLDIRTY(b->maps);
807 FILLDIRTY(b->dirty);
808 }
809 if (crMemcmp(to->mapAtoA, from->mapAtoA, CR_MAX_PIXEL_MAP_TABLE)) {
810 diff_api.PixelMapfv(GL_PIXEL_MAP_A_TO_A,to->mapAtoAsize,(GLfloat*)to->mapAtoA);
811 FILLDIRTY(b->maps);
812 FILLDIRTY(b->dirty);
813 }
814 CLEARDIRTY(b->maps, nbitID);
815 }
816 CLEARDIRTY(b->dirty, nbitID);
817}
818
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