VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_buffer.c@ 16969

Last change on this file since 16969 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: 17.0 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 "state.h"
9#include "state/cr_statetypes.h"
10#include "state_internals.h"
11
12void crStateBufferInit (CRContext *ctx)
13{
14 CRBufferState *b = &ctx->buffer;
15 CRStateBits *sb = GetCurrentBits();
16 CRBufferBits *bb = &(sb->buffer);
17 GLcolorf zero_colorf = {0.0f, 0.0f, 0.0f, 0.0f};
18
19 b->depthTest = GL_FALSE;
20 b->blend = GL_FALSE;
21 b->alphaTest = GL_FALSE;
22 b->dither = GL_TRUE;
23 RESET(bb->enable, ctx->bitid);
24
25 b->logicOp = GL_FALSE;
26 RESET(bb->logicOp, ctx->bitid);
27 b->indexLogicOp = GL_FALSE;
28 RESET(bb->indexLogicOp, ctx->bitid);
29 b->depthMask = GL_TRUE;
30 RESET(bb->depthMask, ctx->bitid);
31
32 b->alphaTestFunc = GL_ALWAYS;
33 b->alphaTestRef = 0;
34 RESET(bb->alphaFunc, ctx->bitid);
35 b->depthFunc = GL_LESS;
36 RESET(bb->depthFunc, ctx->bitid);
37 b->blendSrcRGB = GL_ONE;
38 b->blendDstRGB = GL_ZERO;
39 RESET(bb->blendFunc, ctx->bitid);
40#ifdef CR_EXT_blend_func_separate
41 b->blendSrcA = GL_ONE;
42 b->blendDstA = GL_ZERO;
43 RESET(bb->blendFuncSeparate, ctx->bitid);
44#endif
45 b->logicOpMode = GL_COPY;
46 b->drawBuffer = GL_BACK;
47 RESET(bb->drawBuffer, ctx->bitid);
48 b->readBuffer = GL_BACK;
49 RESET(bb->readBuffer, ctx->bitid);
50 b->indexWriteMask = 0xffffffff;
51 RESET(bb->indexMask, ctx->bitid);
52 b->colorWriteMask.r = GL_TRUE;
53 b->colorWriteMask.g = GL_TRUE;
54 b->colorWriteMask.b = GL_TRUE;
55 b->colorWriteMask.a = GL_TRUE;
56 RESET(bb->colorWriteMask, ctx->bitid);
57 b->colorClearValue = zero_colorf;
58 RESET(bb->clearColor, ctx->bitid);
59 b->indexClearValue = 0;
60 RESET(bb->clearIndex, ctx->bitid);
61 b->depthClearValue = (GLdefault) 1.0;
62 RESET(bb->clearDepth, ctx->bitid);
63 b->accumClearValue = zero_colorf;
64 RESET(bb->clearAccum, ctx->bitid);
65
66#ifdef CR_EXT_blend_color
67 b->blendColor = zero_colorf;
68 RESET(bb->blendColor, ctx->bitid);
69#endif
70#if defined(CR_EXT_blend_minmax) || defined(CR_EXT_blend_subtract) || defined(CR_EXT_blend_logic_op)
71 b->blendEquation = GL_FUNC_ADD_EXT;
72 RESET(bb->blendEquation, ctx->bitid);
73#endif
74
75 RESET(bb->dirty, ctx->bitid);
76}
77
78void STATE_APIENTRY crStateAlphaFunc (GLenum func, GLclampf ref)
79{
80 CRContext *g = GetCurrentContext();
81 CRBufferState *b = &(g->buffer);
82 CRStateBits *sb = GetCurrentBits();
83 CRBufferBits *bb = &(sb->buffer);
84
85 if (g->current.inBeginEnd)
86 {
87 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glAlphaFunc called in begin/end");
88 return;
89 }
90
91 FLUSH();
92
93 switch (func)
94 {
95 case GL_NEVER:
96 case GL_LESS:
97 case GL_EQUAL:
98 case GL_LEQUAL:
99 case GL_GREATER:
100 case GL_GEQUAL:
101 case GL_NOTEQUAL:
102 case GL_ALWAYS:
103 break;
104 default:
105 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glAlphaFunc: Invalid func: %d", func);
106 return;
107 }
108
109 if (ref < 0.0f) ref = 0.0f;
110 if (ref > 1.0f) ref = 1.0f;
111
112 b->alphaTestFunc = func;
113 b->alphaTestRef = ref;
114 DIRTY(bb->dirty, g->neg_bitid);
115 DIRTY(bb->alphaFunc, g->neg_bitid);
116}
117
118void STATE_APIENTRY crStateDepthFunc (GLenum func)
119{
120 CRContext *g = GetCurrentContext();
121 CRBufferState *b = &(g->buffer);
122 CRStateBits *sb = GetCurrentBits();
123 CRBufferBits *bb = &(sb->buffer);
124
125 if (g->current.inBeginEnd)
126 {
127 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glDepthFunc called in begin/end");
128 return;
129 }
130
131 FLUSH();
132
133 switch (func)
134 {
135 case GL_NEVER:
136 case GL_LESS:
137 case GL_EQUAL:
138 case GL_LEQUAL:
139 case GL_GREATER:
140 case GL_NOTEQUAL:
141 case GL_GEQUAL:
142 case GL_ALWAYS:
143 break;
144 default:
145 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glDepthFunc: Invalid func: %d", func);
146 return;
147 }
148
149
150 b->depthFunc = func;
151 DIRTY(bb->dirty, g->neg_bitid);
152 DIRTY(bb->depthFunc, g->neg_bitid);
153}
154
155void STATE_APIENTRY crStateBlendFunc (GLenum sfactor, GLenum dfactor)
156{
157 CRContext *g = GetCurrentContext();
158 CRBufferState *b = &(g->buffer);
159 CRStateBits *sb = GetCurrentBits();
160 CRBufferBits *bb = &(sb->buffer);
161
162 if (g->current.inBeginEnd)
163 {
164 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glBlendFunc called in begin/end");
165 return;
166 }
167
168 FLUSH();
169
170 switch (sfactor)
171 {
172 case GL_ZERO:
173 case GL_ONE:
174 case GL_DST_COLOR:
175 case GL_ONE_MINUS_DST_COLOR:
176 case GL_SRC_ALPHA:
177 case GL_ONE_MINUS_SRC_ALPHA:
178 case GL_DST_ALPHA:
179 case GL_ONE_MINUS_DST_ALPHA:
180 case GL_SRC_ALPHA_SATURATE:
181 break; /* OK */
182#ifdef CR_EXT_blend_color
183 case GL_CONSTANT_COLOR_EXT:
184 case GL_ONE_MINUS_CONSTANT_COLOR_EXT:
185 case GL_CONSTANT_ALPHA_EXT:
186 case GL_ONE_MINUS_CONSTANT_ALPHA_EXT:
187 if (g->extensions.EXT_blend_color)
188 break; /* OK */
189#endif
190 default:
191 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid sfactor passed to glBlendFunc: %d", sfactor);
192 return;
193 }
194
195 switch (dfactor)
196 {
197 case GL_ZERO:
198 case GL_ONE:
199 case GL_SRC_COLOR:
200 case GL_ONE_MINUS_SRC_COLOR:
201 case GL_SRC_ALPHA:
202 case GL_ONE_MINUS_SRC_ALPHA:
203 case GL_DST_ALPHA:
204 case GL_ONE_MINUS_DST_ALPHA:
205 break; /* OK */
206#ifdef CR_EXT_blend_color
207 case GL_CONSTANT_COLOR_EXT:
208 case GL_ONE_MINUS_CONSTANT_COLOR_EXT:
209 case GL_CONSTANT_ALPHA_EXT:
210 case GL_ONE_MINUS_CONSTANT_ALPHA_EXT:
211 if (g->extensions.EXT_blend_color)
212 break; /* OK */
213#endif
214 default:
215 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid dfactor passed to glBlendFunc: %d", dfactor);
216 return;
217 }
218
219 b->blendSrcRGB = sfactor;
220 b->blendDstRGB = dfactor;
221 b->blendSrcA = sfactor;
222 b->blendDstA = dfactor;
223 DIRTY(bb->dirty, g->neg_bitid);
224 DIRTY(bb->blendFunc, g->neg_bitid);
225}
226
227void STATE_APIENTRY crStateBlendColorEXT( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha )
228{
229 CRContext *g = GetCurrentContext();
230 CRBufferState *b = &(g->buffer);
231 CRStateBits *sb = GetCurrentBits();
232 CRBufferBits *bb = &(sb->buffer);
233
234 if (g->current.inBeginEnd)
235 {
236 crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, "BlendColorEXT called inside a Begin/End" );
237 return;
238 }
239
240 b->blendColor.r = red;
241 b->blendColor.g = green;
242 b->blendColor.b = blue;
243 b->blendColor.a = alpha;
244 DIRTY(bb->blendColor, g->neg_bitid);
245 DIRTY(bb->dirty, g->neg_bitid);
246}
247
248#ifdef CR_EXT_blend_func_separate
249void STATE_APIENTRY crStateBlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorA, GLenum dfactorA )
250{
251 CRContext *g = GetCurrentContext();
252 CRBufferState *b = &(g->buffer);
253 CRStateBits *sb = GetCurrentBits();
254 CRBufferBits *bb = &(sb->buffer);
255
256 if (g->current.inBeginEnd)
257 {
258 crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, "BlendFuncSeparateEXT called inside a Begin/End" );
259 return;
260 }
261
262 FLUSH();
263
264 switch (sfactorRGB)
265 {
266 case GL_ZERO:
267 case GL_ONE:
268 case GL_DST_COLOR:
269 case GL_ONE_MINUS_DST_COLOR:
270 case GL_SRC_ALPHA:
271 case GL_ONE_MINUS_SRC_ALPHA:
272 case GL_DST_ALPHA:
273 case GL_ONE_MINUS_DST_ALPHA:
274 case GL_SRC_ALPHA_SATURATE:
275 break; /* OK */
276#ifdef CR_EXT_blend_color
277 case GL_CONSTANT_COLOR_EXT:
278 case GL_ONE_MINUS_CONSTANT_COLOR_EXT:
279 case GL_CONSTANT_ALPHA_EXT:
280 case GL_ONE_MINUS_CONSTANT_ALPHA_EXT:
281 if (g->extensions.EXT_blend_color)
282 break; /* OK */
283#endif
284 default:
285 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid sfactorRGB passed to glBlendFuncSeparateEXT: %d", sfactorRGB);
286 return;
287 }
288
289 switch (sfactorA)
290 {
291 case GL_ZERO:
292 case GL_ONE:
293 case GL_DST_COLOR:
294 case GL_ONE_MINUS_DST_COLOR:
295 case GL_SRC_ALPHA:
296 case GL_ONE_MINUS_SRC_ALPHA:
297 case GL_DST_ALPHA:
298 case GL_ONE_MINUS_DST_ALPHA:
299 case GL_SRC_ALPHA_SATURATE:
300 break; /* OK */
301#ifdef CR_EXT_blend_color
302 case GL_CONSTANT_COLOR_EXT:
303 case GL_ONE_MINUS_CONSTANT_COLOR_EXT:
304 case GL_CONSTANT_ALPHA_EXT:
305 case GL_ONE_MINUS_CONSTANT_ALPHA_EXT:
306 if (g->extensions.EXT_blend_color)
307 break; /* OK */
308#endif
309 default:
310 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid sfactorA passed to glBlendFuncSeparateEXT: %d", sfactorA);
311 return;
312 }
313
314 switch (dfactorRGB)
315 {
316 case GL_ZERO:
317 case GL_ONE:
318 case GL_SRC_COLOR:
319 case GL_DST_COLOR:
320 case GL_ONE_MINUS_DST_COLOR:
321 case GL_ONE_MINUS_SRC_COLOR:
322 case GL_SRC_ALPHA:
323 case GL_ONE_MINUS_SRC_ALPHA:
324 case GL_DST_ALPHA:
325 case GL_ONE_MINUS_DST_ALPHA:
326 case GL_SRC_ALPHA_SATURATE:
327 break; /* OK */
328#ifdef CR_EXT_blend_color
329 case GL_CONSTANT_COLOR_EXT:
330 case GL_ONE_MINUS_CONSTANT_COLOR_EXT:
331 case GL_CONSTANT_ALPHA_EXT:
332 case GL_ONE_MINUS_CONSTANT_ALPHA_EXT:
333 if (g->extensions.EXT_blend_color)
334 break; /* OK */
335#endif
336 default:
337 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid dfactorRGB passed to glBlendFuncSeparateEXT: %d", dfactorRGB);
338 return;
339 }
340
341 switch (dfactorA)
342 {
343 case GL_ZERO:
344 case GL_ONE:
345 case GL_DST_COLOR:
346 case GL_SRC_COLOR:
347 case GL_ONE_MINUS_SRC_COLOR:
348 case GL_ONE_MINUS_DST_COLOR:
349 case GL_SRC_ALPHA:
350 case GL_ONE_MINUS_SRC_ALPHA:
351 case GL_DST_ALPHA:
352 case GL_ONE_MINUS_DST_ALPHA:
353 case GL_SRC_ALPHA_SATURATE:
354 break; /* OK */
355#ifdef CR_EXT_blend_color
356 case GL_CONSTANT_COLOR_EXT:
357 case GL_ONE_MINUS_CONSTANT_COLOR_EXT:
358 case GL_CONSTANT_ALPHA_EXT:
359 case GL_ONE_MINUS_CONSTANT_ALPHA_EXT:
360 if (g->extensions.EXT_blend_color)
361 break; /* OK */
362#endif
363 default:
364 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid dfactorA passed to glBlendFuncSeparateEXT: %d", dfactorA);
365 return;
366 }
367
368 b->blendSrcRGB = sfactorRGB;
369 b->blendDstRGB = dfactorRGB;
370 b->blendSrcA = sfactorA;
371 b->blendDstA = dfactorA;
372 DIRTY(bb->dirty, g->neg_bitid);
373 DIRTY(bb->blendFuncSeparate, g->neg_bitid);
374}
375#endif
376
377void STATE_APIENTRY crStateBlendEquationEXT( GLenum mode )
378{
379 CRContext *g = GetCurrentContext();
380 CRBufferState *b = &(g->buffer);
381 CRStateBits *sb = GetCurrentBits();
382 CRBufferBits *bb = &(sb->buffer);
383
384 if( g->current.inBeginEnd )
385 {
386 crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, "BlendEquationEXT called inside a Begin/End" );
387 return;
388 }
389 switch( mode )
390 {
391#if defined(CR_EXT_blend_minmax) || defined(CR_EXT_blend_subtract) || defined(CR_EXT_blend_logic_op)
392 case GL_FUNC_ADD_EXT:
393#ifdef CR_EXT_blend_subtract
394 case GL_FUNC_SUBTRACT_EXT:
395 case GL_FUNC_REVERSE_SUBTRACT_EXT:
396#endif /* CR_EXT_blend_subtract */
397#ifdef CR_EXT_blend_minmax
398 case GL_MIN_EXT:
399 case GL_MAX_EXT:
400#endif /* CR_EXT_blend_minmax */
401#ifdef CR_EXT_blend_logic_op
402 case GL_LOGIC_OP:
403#endif /* CR_EXT_blend_logic_op */
404 b->blendEquation = mode;
405 break;
406#endif /* defined(CR_EXT_blend_minmax) || defined(CR_EXT_blend_subtract) || defined(CR_EXT_blend_logic_op) */
407 default:
408 crStateError( __LINE__, __FILE__, GL_INVALID_ENUM,
409 "BlendEquationEXT: mode called with illegal parameter: 0x%x", (GLenum) mode );
410 return;
411 }
412 DIRTY(bb->blendEquation, g->neg_bitid);
413 DIRTY(bb->dirty, g->neg_bitid);
414}
415
416void STATE_APIENTRY crStateLogicOp (GLenum opcode)
417{
418 CRContext *g = GetCurrentContext();
419 CRBufferState *b = &(g->buffer);
420 CRStateBits *sb = GetCurrentBits();
421 CRBufferBits *bb = &(sb->buffer);
422
423 if (g->current.inBeginEnd)
424 {
425 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glLogicOp called in begin/end");
426 return;
427 }
428
429 FLUSH();
430
431 switch (opcode)
432 {
433 case GL_CLEAR:
434 case GL_SET:
435 case GL_COPY:
436 case GL_COPY_INVERTED:
437 case GL_NOOP:
438 case GL_INVERT:
439 case GL_AND:
440 case GL_NAND:
441 case GL_OR:
442 case GL_NOR:
443 case GL_XOR:
444 case GL_EQUIV:
445 case GL_AND_REVERSE:
446 case GL_AND_INVERTED:
447 case GL_OR_REVERSE:
448 case GL_OR_INVERTED:
449 break;
450 default:
451 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glLogicOp called with bogus opcode: %d", opcode);
452 return;
453 }
454
455 b->logicOpMode = opcode;
456 DIRTY(bb->dirty, g->neg_bitid);
457 DIRTY(bb->logicOp, g->neg_bitid);
458 DIRTY(bb->indexLogicOp, g->neg_bitid);
459}
460
461void STATE_APIENTRY crStateDrawBuffer (GLenum mode)
462{
463 CRContext *g = GetCurrentContext();
464 CRBufferState *b = &(g->buffer);
465 CRStateBits *sb = GetCurrentBits();
466 CRBufferBits *bb = &(sb->buffer);
467
468 if (g->current.inBeginEnd)
469 {
470 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glDrawBuffer called in begin/end");
471 return;
472 }
473
474 FLUSH();
475
476 switch (mode)
477 {
478 case GL_NONE:
479 case GL_FRONT_LEFT:
480 case GL_FRONT_RIGHT:
481 case GL_BACK_LEFT:
482 case GL_BACK_RIGHT:
483 case GL_FRONT:
484 case GL_BACK:
485 case GL_LEFT:
486 case GL_RIGHT:
487 case GL_FRONT_AND_BACK:
488 case GL_AUX0:
489 case GL_AUX1:
490 case GL_AUX2:
491 case GL_AUX3:
492 break;
493 default:
494 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glDrawBuffer called with bogus mode: %d", mode);
495 return;
496 }
497
498 b->drawBuffer = mode;
499 DIRTY(bb->dirty, g->neg_bitid);
500 DIRTY(bb->drawBuffer, g->neg_bitid);
501}
502
503void STATE_APIENTRY crStateReadBuffer (GLenum mode)
504{
505 CRContext *g = GetCurrentContext();
506 CRBufferState *b = &(g->buffer);
507 CRStateBits *sb = GetCurrentBits();
508 CRBufferBits *bb = &(sb->buffer);
509
510 if (g->current.inBeginEnd)
511 {
512 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glReadBuffer called in begin/end");
513 return;
514 }
515
516 FLUSH();
517
518 switch (mode)
519 {
520 case GL_NONE:
521 case GL_FRONT_LEFT:
522 case GL_FRONT_RIGHT:
523 case GL_BACK_LEFT:
524 case GL_BACK_RIGHT:
525 case GL_FRONT:
526 case GL_BACK:
527 case GL_LEFT:
528 case GL_RIGHT:
529 case GL_FRONT_AND_BACK:
530 case GL_AUX0:
531 case GL_AUX1:
532 case GL_AUX2:
533 case GL_AUX3:
534 break;
535 default:
536 crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glReadBuffer called with bogus mode: %d", mode);
537 return;
538 }
539
540 b->readBuffer = mode;
541 DIRTY(bb->dirty, g->neg_bitid);
542 DIRTY(bb->readBuffer, g->neg_bitid);
543}
544
545void STATE_APIENTRY crStateIndexMask (GLuint mask)
546{
547 CRContext *g = GetCurrentContext();
548 CRBufferState *b = &(g->buffer);
549 CRStateBits *sp = GetCurrentBits();
550 CRBufferBits *bb = &(sp->buffer);
551
552 if (g->current.inBeginEnd)
553 {
554 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glReadBuffer called in begin/end");
555 return;
556 }
557
558 FLUSH();
559
560 b->indexWriteMask = mask;
561 DIRTY(bb->dirty, g->neg_bitid);
562 DIRTY(bb->indexMask, g->neg_bitid);
563}
564
565void STATE_APIENTRY crStateColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
566{
567 CRContext *g = GetCurrentContext();
568 CRBufferState *b = &(g->buffer);
569 CRStateBits *sp = GetCurrentBits();
570 CRBufferBits *bb = &(sp->buffer);
571
572 if (g->current.inBeginEnd)
573 {
574 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glReadBuffer called in begin/end");
575 return;
576 }
577
578 FLUSH();
579
580 b->colorWriteMask.r = red;
581 b->colorWriteMask.g = green;
582 b->colorWriteMask.b = blue;
583 b->colorWriteMask.a = alpha;
584 DIRTY(bb->dirty, g->neg_bitid);
585 DIRTY(bb->colorWriteMask, g->neg_bitid);
586}
587
588void STATE_APIENTRY crStateClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
589{
590 CRContext *g = GetCurrentContext();
591 CRBufferState *b = &(g->buffer);
592 CRStateBits *sp = GetCurrentBits();
593 CRBufferBits *bb = &(sp->buffer);
594
595 if (g->current.inBeginEnd)
596 {
597 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glClearColor called in begin/end");
598 return;
599 }
600
601 FLUSH();
602
603 if (red < 0.0f) red = 0.0f;
604 if (red > 1.0f) red = 1.0f;
605 if (green < 0.0f) green = 0.0f;
606 if (green > 1.0f) green = 1.0f;
607 if (blue < 0.0f) blue = 0.0f;
608 if (blue > 1.0f) blue = 1.0f;
609 if (alpha < 0.0f) alpha = 0.0f;
610 if (alpha > 1.0f) alpha = 1.0f;
611
612 b->colorClearValue.r = red;
613 b->colorClearValue.g = green;
614 b->colorClearValue.b = blue;
615 b->colorClearValue.a = alpha;
616 DIRTY(bb->dirty, g->neg_bitid);
617 DIRTY(bb->clearColor, g->neg_bitid);
618}
619
620void STATE_APIENTRY crStateClearIndex (GLfloat c)
621{
622 CRContext *g = GetCurrentContext();
623 CRBufferState *b = &(g->buffer);
624 CRStateBits *sp = GetCurrentBits();
625 CRBufferBits *bb = &(sp->buffer);
626
627 if (g->current.inBeginEnd)
628 {
629 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glClearIndex called in begin/end");
630 return;
631 }
632
633 b->indexClearValue = c;
634 DIRTY(bb->dirty, g->neg_bitid);
635 DIRTY(bb->clearIndex, g->neg_bitid);
636}
637
638void STATE_APIENTRY crStateClearDepth (GLclampd depth)
639{
640 CRContext *g = GetCurrentContext();
641 CRBufferState *b = &(g->buffer);
642 CRStateBits *sp = GetCurrentBits();
643 CRBufferBits *bb = &(sp->buffer);
644
645 if (g->current.inBeginEnd)
646 {
647 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glClearDepth called in begin/end");
648 return;
649 }
650
651 FLUSH();
652
653 if (depth < 0.0) depth = 0.0;
654 if (depth > 1.0) depth = 1.0;
655
656 b->depthClearValue = (GLdefault) depth;
657 DIRTY(bb->dirty, g->neg_bitid);
658 DIRTY(bb->clearDepth, g->neg_bitid);
659}
660
661void STATE_APIENTRY crStateClearAccum (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
662{
663 CRContext *g = GetCurrentContext();
664 CRBufferState *b = &(g->buffer);
665 CRStateBits *sp = GetCurrentBits();
666 CRBufferBits *bb = &(sp->buffer);
667
668 if (g->current.inBeginEnd)
669 {
670 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glClearAccum called in begin/end");
671 return;
672 }
673
674 FLUSH();
675
676 if (red < -1.0f) red = 0.0f;
677 if (red > 1.0f) red = 1.0f;
678 if (green < -1.0f) green = 0.0f;
679 if (green > 1.0f) green = 1.0f;
680 if (blue < -1.0f) blue = 0.0f;
681 if (blue > 1.0f) blue = 1.0f;
682 if (alpha < -1.0f) alpha = 0.0f;
683 if (alpha > 1.0f) alpha = 1.0f;
684
685 b->accumClearValue.r = red;
686 b->accumClearValue.g = green;
687 b->accumClearValue.b = blue;
688 b->accumClearValue.a = alpha;
689 DIRTY(bb->dirty, g->neg_bitid);
690 DIRTY(bb->clearAccum, g->neg_bitid);
691}
692
693void STATE_APIENTRY crStateDepthMask (GLboolean b)
694{
695 CRContext *g = GetCurrentContext();
696 CRBufferState *bs = &(g->buffer);
697 CRStateBits *sp = GetCurrentBits();
698 CRBufferBits *bb = &(sp->buffer);
699
700 if (g->current.inBeginEnd)
701 {
702 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "DepthMask called in begin/end");
703 return;
704 }
705
706 FLUSH();
707
708 bs->depthMask = b;
709 DIRTY(bb->dirty, g->neg_bitid);
710 DIRTY(bb->depthMask, g->neg_bitid);
711}
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