mesa: implement GL_ARB_texture_buffer_range
[mesa.git] / src / mesa / main / pixel.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 7.1
4 *
5 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25
26 /**
27 * \file pixel.c
28 * Pixel transfer functions (glPixelZoom, glPixelMap, glPixelTransfer)
29 */
30
31 #include "glheader.h"
32 #include "bufferobj.h"
33 #include "colormac.h"
34 #include "context.h"
35 #include "macros.h"
36 #include "mfeatures.h"
37 #include "pixel.h"
38 #include "pbo.h"
39 #include "mtypes.h"
40 #include "main/dispatch.h"
41
42
43 /**********************************************************************/
44 /***** glPixelZoom *****/
45 /**********************************************************************/
46
47 void GLAPIENTRY
48 _mesa_PixelZoom( GLfloat xfactor, GLfloat yfactor )
49 {
50 GET_CURRENT_CONTEXT(ctx);
51
52 if (ctx->Pixel.ZoomX == xfactor &&
53 ctx->Pixel.ZoomY == yfactor)
54 return;
55
56 FLUSH_VERTICES(ctx, _NEW_PIXEL);
57 ctx->Pixel.ZoomX = xfactor;
58 ctx->Pixel.ZoomY = yfactor;
59 }
60
61
62
63 /**********************************************************************/
64 /***** glPixelMap *****/
65 /**********************************************************************/
66
67 /**
68 * Return pointer to a pixelmap by name.
69 */
70 static struct gl_pixelmap *
71 get_pixelmap(struct gl_context *ctx, GLenum map)
72 {
73 switch (map) {
74 case GL_PIXEL_MAP_I_TO_I:
75 return &ctx->PixelMaps.ItoI;
76 case GL_PIXEL_MAP_S_TO_S:
77 return &ctx->PixelMaps.StoS;
78 case GL_PIXEL_MAP_I_TO_R:
79 return &ctx->PixelMaps.ItoR;
80 case GL_PIXEL_MAP_I_TO_G:
81 return &ctx->PixelMaps.ItoG;
82 case GL_PIXEL_MAP_I_TO_B:
83 return &ctx->PixelMaps.ItoB;
84 case GL_PIXEL_MAP_I_TO_A:
85 return &ctx->PixelMaps.ItoA;
86 case GL_PIXEL_MAP_R_TO_R:
87 return &ctx->PixelMaps.RtoR;
88 case GL_PIXEL_MAP_G_TO_G:
89 return &ctx->PixelMaps.GtoG;
90 case GL_PIXEL_MAP_B_TO_B:
91 return &ctx->PixelMaps.BtoB;
92 case GL_PIXEL_MAP_A_TO_A:
93 return &ctx->PixelMaps.AtoA;
94 default:
95 return NULL;
96 }
97 }
98
99
100 /**
101 * Helper routine used by the other _mesa_PixelMap() functions.
102 */
103 static void
104 store_pixelmap(struct gl_context *ctx, GLenum map, GLsizei mapsize,
105 const GLfloat *values)
106 {
107 GLint i;
108 struct gl_pixelmap *pm = get_pixelmap(ctx, map);
109 if (!pm) {
110 _mesa_error(ctx, GL_INVALID_ENUM, "glPixelMap(map)");
111 return;
112 }
113
114 switch (map) {
115 case GL_PIXEL_MAP_S_TO_S:
116 /* special case */
117 ctx->PixelMaps.StoS.Size = mapsize;
118 for (i = 0; i < mapsize; i++) {
119 ctx->PixelMaps.StoS.Map[i] = (GLfloat)IROUND(values[i]);
120 }
121 break;
122 case GL_PIXEL_MAP_I_TO_I:
123 /* special case */
124 ctx->PixelMaps.ItoI.Size = mapsize;
125 for (i = 0; i < mapsize; i++) {
126 ctx->PixelMaps.ItoI.Map[i] = values[i];
127 }
128 break;
129 default:
130 /* general case */
131 pm->Size = mapsize;
132 for (i = 0; i < mapsize; i++) {
133 GLfloat val = CLAMP(values[i], 0.0F, 1.0F);
134 pm->Map[i] = val;
135 }
136 }
137 }
138
139
140 /**
141 * Convenience wrapper for _mesa_validate_pbo_access() for gl[Get]PixelMap().
142 */
143 static GLboolean
144 validate_pbo_access(struct gl_context *ctx,
145 struct gl_pixelstore_attrib *pack, GLsizei mapsize,
146 GLenum format, GLenum type, GLsizei clientMemSize,
147 const GLvoid *ptr)
148 {
149 GLboolean ok;
150
151 /* Note, need to use DefaultPacking and Unpack's buffer object */
152 _mesa_reference_buffer_object(ctx,
153 &ctx->DefaultPacking.BufferObj,
154 pack->BufferObj);
155
156 ok = _mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1,
157 format, type, clientMemSize, ptr);
158
159 /* restore */
160 _mesa_reference_buffer_object(ctx,
161 &ctx->DefaultPacking.BufferObj,
162 ctx->Shared->NullBufferObj);
163
164 if (!ok) {
165 if (_mesa_is_bufferobj(pack->BufferObj)) {
166 _mesa_error(ctx, GL_INVALID_OPERATION,
167 "gl[Get]PixelMap*v(out of bounds PBO access)");
168 } else {
169 _mesa_error(ctx, GL_INVALID_OPERATION,
170 "glGetnPixelMap*vARB(out of bounds access:"
171 " bufSize (%d) is too small)", clientMemSize);
172 }
173 }
174 return ok;
175 }
176
177
178 void GLAPIENTRY
179 _mesa_PixelMapfv( GLenum map, GLsizei mapsize, const GLfloat *values )
180 {
181 GET_CURRENT_CONTEXT(ctx);
182
183 /* XXX someday, test against ctx->Const.MaxPixelMapTableSize */
184 if (mapsize < 1 || mapsize > MAX_PIXEL_MAP_TABLE) {
185 _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapfv(mapsize)" );
186 return;
187 }
188
189 if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) {
190 /* test that mapsize is a power of two */
191 if (!_mesa_is_pow_two(mapsize)) {
192 _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapfv(mapsize)" );
193 return;
194 }
195 }
196
197 FLUSH_VERTICES(ctx, _NEW_PIXEL);
198
199 if (!validate_pbo_access(ctx, &ctx->Unpack, mapsize, GL_INTENSITY,
200 GL_FLOAT, INT_MAX, values)) {
201 return;
202 }
203
204 values = (const GLfloat *) _mesa_map_pbo_source(ctx, &ctx->Unpack, values);
205 if (!values) {
206 if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) {
207 _mesa_error(ctx, GL_INVALID_OPERATION,
208 "glPixelMapfv(PBO is mapped)");
209 }
210 return;
211 }
212
213 store_pixelmap(ctx, map, mapsize, values);
214
215 _mesa_unmap_pbo_source(ctx, &ctx->Unpack);
216 }
217
218
219 void GLAPIENTRY
220 _mesa_PixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values )
221 {
222 GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
223 GET_CURRENT_CONTEXT(ctx);
224
225 if (mapsize < 1 || mapsize > MAX_PIXEL_MAP_TABLE) {
226 _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapuiv(mapsize)" );
227 return;
228 }
229
230 if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) {
231 /* test that mapsize is a power of two */
232 if (!_mesa_is_pow_two(mapsize)) {
233 _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapuiv(mapsize)" );
234 return;
235 }
236 }
237
238 FLUSH_VERTICES(ctx, _NEW_PIXEL);
239
240 if (!validate_pbo_access(ctx, &ctx->Unpack, mapsize, GL_INTENSITY,
241 GL_UNSIGNED_INT, INT_MAX, values)) {
242 return;
243 }
244
245 values = (const GLuint *) _mesa_map_pbo_source(ctx, &ctx->Unpack, values);
246 if (!values) {
247 if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) {
248 _mesa_error(ctx, GL_INVALID_OPERATION,
249 "glPixelMapuiv(PBO is mapped)");
250 }
251 return;
252 }
253
254 /* convert to floats */
255 if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) {
256 GLint i;
257 for (i = 0; i < mapsize; i++) {
258 fvalues[i] = (GLfloat) values[i];
259 }
260 }
261 else {
262 GLint i;
263 for (i = 0; i < mapsize; i++) {
264 fvalues[i] = UINT_TO_FLOAT( values[i] );
265 }
266 }
267
268 _mesa_unmap_pbo_source(ctx, &ctx->Unpack);
269
270 store_pixelmap(ctx, map, mapsize, fvalues);
271 }
272
273
274 void GLAPIENTRY
275 _mesa_PixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values )
276 {
277 GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
278 GET_CURRENT_CONTEXT(ctx);
279
280 if (mapsize < 1 || mapsize > MAX_PIXEL_MAP_TABLE) {
281 _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapusv(mapsize)" );
282 return;
283 }
284
285 if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) {
286 /* test that mapsize is a power of two */
287 if (!_mesa_is_pow_two(mapsize)) {
288 _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapuiv(mapsize)" );
289 return;
290 }
291 }
292
293 FLUSH_VERTICES(ctx, _NEW_PIXEL);
294
295 if (!validate_pbo_access(ctx, &ctx->Unpack, mapsize, GL_INTENSITY,
296 GL_UNSIGNED_SHORT, INT_MAX, values)) {
297 return;
298 }
299
300 values = (const GLushort *) _mesa_map_pbo_source(ctx, &ctx->Unpack, values);
301 if (!values) {
302 if (_mesa_is_bufferobj(ctx->Unpack.BufferObj)) {
303 _mesa_error(ctx, GL_INVALID_OPERATION,
304 "glPixelMapusv(PBO is mapped)");
305 }
306 return;
307 }
308
309 /* convert to floats */
310 if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) {
311 GLint i;
312 for (i = 0; i < mapsize; i++) {
313 fvalues[i] = (GLfloat) values[i];
314 }
315 }
316 else {
317 GLint i;
318 for (i = 0; i < mapsize; i++) {
319 fvalues[i] = USHORT_TO_FLOAT( values[i] );
320 }
321 }
322
323 _mesa_unmap_pbo_source(ctx, &ctx->Unpack);
324
325 store_pixelmap(ctx, map, mapsize, fvalues);
326 }
327
328
329 void GLAPIENTRY
330 _mesa_GetnPixelMapfvARB( GLenum map, GLsizei bufSize, GLfloat *values )
331 {
332 GET_CURRENT_CONTEXT(ctx);
333 GLint mapsize, i;
334 const struct gl_pixelmap *pm;
335
336 pm = get_pixelmap(ctx, map);
337 if (!pm) {
338 _mesa_error(ctx, GL_INVALID_ENUM, "glGetPixelMapfv(map)");
339 return;
340 }
341
342 mapsize = pm->Size;
343
344 if (!validate_pbo_access(ctx, &ctx->Pack, mapsize, GL_INTENSITY,
345 GL_FLOAT, bufSize, values)) {
346 return;
347 }
348
349 values = (GLfloat *) _mesa_map_pbo_dest(ctx, &ctx->Pack, values);
350 if (!values) {
351 if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
352 _mesa_error(ctx, GL_INVALID_OPERATION,
353 "glGetPixelMapfv(PBO is mapped)");
354 }
355 return;
356 }
357
358 if (map == GL_PIXEL_MAP_S_TO_S) {
359 /* special case */
360 for (i = 0; i < mapsize; i++) {
361 values[i] = (GLfloat) ctx->PixelMaps.StoS.Map[i];
362 }
363 }
364 else {
365 memcpy(values, pm->Map, mapsize * sizeof(GLfloat));
366 }
367
368 _mesa_unmap_pbo_dest(ctx, &ctx->Pack);
369 }
370
371
372 void GLAPIENTRY
373 _mesa_GetPixelMapfv( GLenum map, GLfloat *values )
374 {
375 _mesa_GetnPixelMapfvARB(map, INT_MAX, values);
376 }
377
378 void GLAPIENTRY
379 _mesa_GetnPixelMapuivARB( GLenum map, GLsizei bufSize, GLuint *values )
380 {
381 GET_CURRENT_CONTEXT(ctx);
382 GLint mapsize, i;
383 const struct gl_pixelmap *pm;
384
385 pm = get_pixelmap(ctx, map);
386 if (!pm) {
387 _mesa_error(ctx, GL_INVALID_ENUM, "glGetPixelMapuiv(map)");
388 return;
389 }
390
391 mapsize = pm->Size;
392
393 if (!validate_pbo_access(ctx, &ctx->Pack, mapsize, GL_INTENSITY,
394 GL_UNSIGNED_INT, bufSize, values)) {
395 return;
396 }
397
398 values = (GLuint *) _mesa_map_pbo_dest(ctx, &ctx->Pack, values);
399 if (!values) {
400 if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
401 _mesa_error(ctx, GL_INVALID_OPERATION,
402 "glGetPixelMapuiv(PBO is mapped)");
403 }
404 return;
405 }
406
407 if (map == GL_PIXEL_MAP_S_TO_S) {
408 /* special case */
409 memcpy(values, ctx->PixelMaps.StoS.Map, mapsize * sizeof(GLint));
410 }
411 else {
412 for (i = 0; i < mapsize; i++) {
413 values[i] = FLOAT_TO_UINT( pm->Map[i] );
414 }
415 }
416
417 _mesa_unmap_pbo_dest(ctx, &ctx->Pack);
418 }
419
420
421 void GLAPIENTRY
422 _mesa_GetPixelMapuiv( GLenum map, GLuint *values )
423 {
424 _mesa_GetnPixelMapuivARB(map, INT_MAX, values);
425 }
426
427 void GLAPIENTRY
428 _mesa_GetnPixelMapusvARB( GLenum map, GLsizei bufSize, GLushort *values )
429 {
430 GET_CURRENT_CONTEXT(ctx);
431 GLint mapsize, i;
432 const struct gl_pixelmap *pm;
433
434 pm = get_pixelmap(ctx, map);
435 if (!pm) {
436 _mesa_error(ctx, GL_INVALID_ENUM, "glGetPixelMapusv(map)");
437 return;
438 }
439
440 mapsize = pm->Size;
441
442 if (!validate_pbo_access(ctx, &ctx->Pack, mapsize, GL_INTENSITY,
443 GL_UNSIGNED_SHORT, bufSize, values)) {
444 return;
445 }
446
447 values = (GLushort *) _mesa_map_pbo_dest(ctx, &ctx->Pack, values);
448 if (!values) {
449 if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
450 _mesa_error(ctx, GL_INVALID_OPERATION,
451 "glGetPixelMapusv(PBO is mapped)");
452 }
453 return;
454 }
455
456 switch (map) {
457 /* special cases */
458 case GL_PIXEL_MAP_I_TO_I:
459 for (i = 0; i < mapsize; i++) {
460 values[i] = (GLushort) CLAMP(ctx->PixelMaps.ItoI.Map[i], 0.0, 65535.);
461 }
462 break;
463 case GL_PIXEL_MAP_S_TO_S:
464 for (i = 0; i < mapsize; i++) {
465 values[i] = (GLushort) CLAMP(ctx->PixelMaps.StoS.Map[i], 0.0, 65535.);
466 }
467 break;
468 default:
469 for (i = 0; i < mapsize; i++) {
470 CLAMPED_FLOAT_TO_USHORT(values[i], pm->Map[i] );
471 }
472 }
473
474 _mesa_unmap_pbo_dest(ctx, &ctx->Pack);
475 }
476
477
478 void GLAPIENTRY
479 _mesa_GetPixelMapusv( GLenum map, GLushort *values )
480 {
481 _mesa_GetnPixelMapusvARB(map, INT_MAX, values);
482 }
483
484
485 /**********************************************************************/
486 /***** glPixelTransfer *****/
487 /**********************************************************************/
488
489
490 /*
491 * Implements glPixelTransfer[fi] whether called immediately or from a
492 * display list.
493 */
494 void GLAPIENTRY
495 _mesa_PixelTransferf( GLenum pname, GLfloat param )
496 {
497 GET_CURRENT_CONTEXT(ctx);
498
499 switch (pname) {
500 case GL_MAP_COLOR:
501 if (ctx->Pixel.MapColorFlag == (param ? GL_TRUE : GL_FALSE))
502 return;
503 FLUSH_VERTICES(ctx, _NEW_PIXEL);
504 ctx->Pixel.MapColorFlag = param ? GL_TRUE : GL_FALSE;
505 break;
506 case GL_MAP_STENCIL:
507 if (ctx->Pixel.MapStencilFlag == (param ? GL_TRUE : GL_FALSE))
508 return;
509 FLUSH_VERTICES(ctx, _NEW_PIXEL);
510 ctx->Pixel.MapStencilFlag = param ? GL_TRUE : GL_FALSE;
511 break;
512 case GL_INDEX_SHIFT:
513 if (ctx->Pixel.IndexShift == (GLint) param)
514 return;
515 FLUSH_VERTICES(ctx, _NEW_PIXEL);
516 ctx->Pixel.IndexShift = (GLint) param;
517 break;
518 case GL_INDEX_OFFSET:
519 if (ctx->Pixel.IndexOffset == (GLint) param)
520 return;
521 FLUSH_VERTICES(ctx, _NEW_PIXEL);
522 ctx->Pixel.IndexOffset = (GLint) param;
523 break;
524 case GL_RED_SCALE:
525 if (ctx->Pixel.RedScale == param)
526 return;
527 FLUSH_VERTICES(ctx, _NEW_PIXEL);
528 ctx->Pixel.RedScale = param;
529 break;
530 case GL_RED_BIAS:
531 if (ctx->Pixel.RedBias == param)
532 return;
533 FLUSH_VERTICES(ctx, _NEW_PIXEL);
534 ctx->Pixel.RedBias = param;
535 break;
536 case GL_GREEN_SCALE:
537 if (ctx->Pixel.GreenScale == param)
538 return;
539 FLUSH_VERTICES(ctx, _NEW_PIXEL);
540 ctx->Pixel.GreenScale = param;
541 break;
542 case GL_GREEN_BIAS:
543 if (ctx->Pixel.GreenBias == param)
544 return;
545 FLUSH_VERTICES(ctx, _NEW_PIXEL);
546 ctx->Pixel.GreenBias = param;
547 break;
548 case GL_BLUE_SCALE:
549 if (ctx->Pixel.BlueScale == param)
550 return;
551 FLUSH_VERTICES(ctx, _NEW_PIXEL);
552 ctx->Pixel.BlueScale = param;
553 break;
554 case GL_BLUE_BIAS:
555 if (ctx->Pixel.BlueBias == param)
556 return;
557 FLUSH_VERTICES(ctx, _NEW_PIXEL);
558 ctx->Pixel.BlueBias = param;
559 break;
560 case GL_ALPHA_SCALE:
561 if (ctx->Pixel.AlphaScale == param)
562 return;
563 FLUSH_VERTICES(ctx, _NEW_PIXEL);
564 ctx->Pixel.AlphaScale = param;
565 break;
566 case GL_ALPHA_BIAS:
567 if (ctx->Pixel.AlphaBias == param)
568 return;
569 FLUSH_VERTICES(ctx, _NEW_PIXEL);
570 ctx->Pixel.AlphaBias = param;
571 break;
572 case GL_DEPTH_SCALE:
573 if (ctx->Pixel.DepthScale == param)
574 return;
575 FLUSH_VERTICES(ctx, _NEW_PIXEL);
576 ctx->Pixel.DepthScale = param;
577 break;
578 case GL_DEPTH_BIAS:
579 if (ctx->Pixel.DepthBias == param)
580 return;
581 FLUSH_VERTICES(ctx, _NEW_PIXEL);
582 ctx->Pixel.DepthBias = param;
583 break;
584 default:
585 _mesa_error( ctx, GL_INVALID_ENUM, "glPixelTransfer(pname)" );
586 return;
587 }
588 }
589
590
591 void GLAPIENTRY
592 _mesa_PixelTransferi( GLenum pname, GLint param )
593 {
594 _mesa_PixelTransferf( pname, (GLfloat) param );
595 }
596
597
598
599 /**********************************************************************/
600 /***** State Management *****/
601 /**********************************************************************/
602
603 /*
604 * Return a bitmask of IMAGE_*_BIT flags which to indicate which
605 * pixel transfer operations are enabled.
606 */
607 static void
608 update_image_transfer_state(struct gl_context *ctx)
609 {
610 GLuint mask = 0;
611
612 if (ctx->Pixel.RedScale != 1.0F || ctx->Pixel.RedBias != 0.0F ||
613 ctx->Pixel.GreenScale != 1.0F || ctx->Pixel.GreenBias != 0.0F ||
614 ctx->Pixel.BlueScale != 1.0F || ctx->Pixel.BlueBias != 0.0F ||
615 ctx->Pixel.AlphaScale != 1.0F || ctx->Pixel.AlphaBias != 0.0F)
616 mask |= IMAGE_SCALE_BIAS_BIT;
617
618 if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset)
619 mask |= IMAGE_SHIFT_OFFSET_BIT;
620
621 if (ctx->Pixel.MapColorFlag)
622 mask |= IMAGE_MAP_COLOR_BIT;
623
624 ctx->_ImageTransferState = mask;
625 }
626
627
628 /**
629 * Update mesa pixel transfer derived state.
630 */
631 void _mesa_update_pixel( struct gl_context *ctx, GLuint new_state )
632 {
633 if (new_state & _NEW_PIXEL)
634 update_image_transfer_state(ctx);
635 }
636
637
638 /**********************************************************************/
639 /***** Initialization *****/
640 /**********************************************************************/
641
642 static void
643 init_pixelmap(struct gl_pixelmap *map)
644 {
645 map->Size = 1;
646 map->Map[0] = 0.0;
647 }
648
649
650 /**
651 * Initialize the context's PIXEL attribute group.
652 */
653 void
654 _mesa_init_pixel( struct gl_context *ctx )
655 {
656 /* Pixel group */
657 ctx->Pixel.RedBias = 0.0;
658 ctx->Pixel.RedScale = 1.0;
659 ctx->Pixel.GreenBias = 0.0;
660 ctx->Pixel.GreenScale = 1.0;
661 ctx->Pixel.BlueBias = 0.0;
662 ctx->Pixel.BlueScale = 1.0;
663 ctx->Pixel.AlphaBias = 0.0;
664 ctx->Pixel.AlphaScale = 1.0;
665 ctx->Pixel.DepthBias = 0.0;
666 ctx->Pixel.DepthScale = 1.0;
667 ctx->Pixel.IndexOffset = 0;
668 ctx->Pixel.IndexShift = 0;
669 ctx->Pixel.ZoomX = 1.0;
670 ctx->Pixel.ZoomY = 1.0;
671 ctx->Pixel.MapColorFlag = GL_FALSE;
672 ctx->Pixel.MapStencilFlag = GL_FALSE;
673 init_pixelmap(&ctx->PixelMaps.StoS);
674 init_pixelmap(&ctx->PixelMaps.ItoI);
675 init_pixelmap(&ctx->PixelMaps.ItoR);
676 init_pixelmap(&ctx->PixelMaps.ItoG);
677 init_pixelmap(&ctx->PixelMaps.ItoB);
678 init_pixelmap(&ctx->PixelMaps.ItoA);
679 init_pixelmap(&ctx->PixelMaps.RtoR);
680 init_pixelmap(&ctx->PixelMaps.GtoG);
681 init_pixelmap(&ctx->PixelMaps.BtoB);
682 init_pixelmap(&ctx->PixelMaps.AtoA);
683
684 if (ctx->Visual.doubleBufferMode) {
685 ctx->Pixel.ReadBuffer = GL_BACK;
686 }
687 else {
688 ctx->Pixel.ReadBuffer = GL_FRONT;
689 }
690
691 /* Miscellaneous */
692 ctx->_ImageTransferState = 0;
693 }