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