7 * Mesa 3-D graphics library
10 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
26 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42 * Check if given blend source factor is legal.
43 * \return GL_TRUE if legal, GL_FALSE otherwise.
46 legal_src_factor(const struct gl_context
*ctx
, GLenum factor
)
50 case GL_ONE_MINUS_SRC_COLOR
:
51 return ctx
->Extensions
.NV_blend_square
;
55 case GL_ONE_MINUS_DST_COLOR
:
57 case GL_ONE_MINUS_SRC_ALPHA
:
59 case GL_ONE_MINUS_DST_ALPHA
:
60 case GL_SRC_ALPHA_SATURATE
:
61 case GL_CONSTANT_COLOR
:
62 case GL_ONE_MINUS_CONSTANT_COLOR
:
63 case GL_CONSTANT_ALPHA
:
64 case GL_ONE_MINUS_CONSTANT_ALPHA
:
73 * Check if given blend destination factor is legal.
74 * \return GL_TRUE if legal, GL_FALSE otherwise.
77 legal_dst_factor(const struct gl_context
*ctx
, GLenum factor
)
81 case GL_ONE_MINUS_DST_COLOR
:
82 return ctx
->Extensions
.NV_blend_square
;
86 case GL_ONE_MINUS_SRC_COLOR
:
88 case GL_ONE_MINUS_SRC_ALPHA
:
90 case GL_ONE_MINUS_DST_ALPHA
:
91 case GL_CONSTANT_COLOR
:
92 case GL_ONE_MINUS_CONSTANT_COLOR
:
93 case GL_CONSTANT_ALPHA
:
94 case GL_ONE_MINUS_CONSTANT_ALPHA
:
103 * Check if src/dest RGB/A blend factors are legal. If not generate
105 * \return GL_TRUE if factors are legal, GL_FALSE otherwise.
108 validate_blend_factors(struct gl_context
*ctx
, const char *func
,
109 GLenum sfactorRGB
, GLenum dfactorRGB
,
110 GLenum sfactorA
, GLenum dfactorA
)
112 if (!legal_src_factor(ctx
, sfactorRGB
)) {
113 _mesa_error(ctx
, GL_INVALID_ENUM
,
114 "%s(sfactorRGB = %s)", func
,
115 _mesa_lookup_enum_by_nr(sfactorRGB
));
119 if (!legal_dst_factor(ctx
, dfactorRGB
)) {
120 _mesa_error(ctx
, GL_INVALID_ENUM
,
121 "%s(dfactorRGB = %s)", func
,
122 _mesa_lookup_enum_by_nr(dfactorRGB
));
126 if (sfactorA
!= sfactorRGB
&& !legal_src_factor(ctx
, sfactorA
)) {
127 _mesa_error(ctx
, GL_INVALID_ENUM
,
128 "%s(sfactorA = %s)", func
,
129 _mesa_lookup_enum_by_nr(sfactorA
));
133 if (dfactorA
!= dfactorRGB
&& !legal_dst_factor(ctx
, dfactorA
)) {
134 _mesa_error(ctx
, GL_INVALID_ENUM
,
135 "%s(dfactorA = %s)", func
,
136 _mesa_lookup_enum_by_nr(dfactorA
));
145 * Specify the blending operation.
147 * \param sfactor source factor operator.
148 * \param dfactor destination factor operator.
150 * \sa glBlendFunc, glBlendFuncSeparateEXT
153 _mesa_BlendFunc( GLenum sfactor
, GLenum dfactor
)
155 _mesa_BlendFuncSeparateEXT(sfactor
, dfactor
, sfactor
, dfactor
);
160 * Set the separate blend source/dest factors for all draw buffers.
162 * \param sfactorRGB RGB source factor operator.
163 * \param dfactorRGB RGB destination factor operator.
164 * \param sfactorA alpha source factor operator.
165 * \param dfactorA alpha destination factor operator.
168 _mesa_BlendFuncSeparateEXT( GLenum sfactorRGB
, GLenum dfactorRGB
,
169 GLenum sfactorA
, GLenum dfactorA
)
171 GLuint buf
, numBuffers
;
173 GET_CURRENT_CONTEXT(ctx
);
174 ASSERT_OUTSIDE_BEGIN_END(ctx
);
176 if (MESA_VERBOSE
& VERBOSE_API
)
177 _mesa_debug(ctx
, "glBlendFuncSeparate %s %s %s %s\n",
178 _mesa_lookup_enum_by_nr(sfactorRGB
),
179 _mesa_lookup_enum_by_nr(dfactorRGB
),
180 _mesa_lookup_enum_by_nr(sfactorA
),
181 _mesa_lookup_enum_by_nr(dfactorA
));
183 if (!validate_blend_factors(ctx
, "glBlendFuncSeparate",
184 sfactorRGB
, dfactorRGB
,
185 sfactorA
, dfactorA
)) {
189 numBuffers
= ctx
->Extensions
.ARB_draw_buffers_blend
190 ? ctx
->Const
.MaxDrawBuffers
: 1;
193 for (buf
= 0; buf
< numBuffers
; buf
++) {
194 if (ctx
->Color
.Blend
[buf
].SrcRGB
!= sfactorRGB
||
195 ctx
->Color
.Blend
[buf
].DstRGB
!= dfactorRGB
||
196 ctx
->Color
.Blend
[buf
].SrcA
!= sfactorA
||
197 ctx
->Color
.Blend
[buf
].DstA
!= dfactorA
) {
205 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
207 for (buf
= 0; buf
< numBuffers
; buf
++) {
208 ctx
->Color
.Blend
[buf
].SrcRGB
= sfactorRGB
;
209 ctx
->Color
.Blend
[buf
].DstRGB
= dfactorRGB
;
210 ctx
->Color
.Blend
[buf
].SrcA
= sfactorA
;
211 ctx
->Color
.Blend
[buf
].DstA
= dfactorA
;
213 ctx
->Color
._BlendFuncPerBuffer
= GL_FALSE
;
215 if (ctx
->Driver
.BlendFuncSeparate
) {
216 ctx
->Driver
.BlendFuncSeparate(ctx
, sfactorRGB
, dfactorRGB
,
226 * Set blend source/dest factors for one color buffer/target.
229 _mesa_BlendFunci(GLuint buf
, GLenum sfactor
, GLenum dfactor
)
231 _mesa_BlendFuncSeparatei(buf
, sfactor
, dfactor
, sfactor
, dfactor
);
236 * Set separate blend source/dest factors for one color buffer/target.
239 _mesa_BlendFuncSeparatei(GLuint buf
, GLenum sfactorRGB
, GLenum dfactorRGB
,
240 GLenum sfactorA
, GLenum dfactorA
)
242 GET_CURRENT_CONTEXT(ctx
);
243 ASSERT_OUTSIDE_BEGIN_END(ctx
);
245 if (!ctx
->Extensions
.ARB_draw_buffers_blend
) {
246 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glBlendFunc[Separate]i()");
250 if (buf
>= ctx
->Const
.MaxDrawBuffers
) {
251 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBlendFuncSeparatei(buffer=%u)",
256 if (!validate_blend_factors(ctx
, "glBlendFuncSeparatei",
257 sfactorRGB
, dfactorRGB
,
258 sfactorA
, dfactorA
)) {
262 if (ctx
->Color
.Blend
[buf
].SrcRGB
== sfactorRGB
&&
263 ctx
->Color
.Blend
[buf
].DstRGB
== dfactorRGB
&&
264 ctx
->Color
.Blend
[buf
].SrcA
== sfactorA
&&
265 ctx
->Color
.Blend
[buf
].DstA
== dfactorA
)
266 return; /* no change */
268 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
270 ctx
->Color
.Blend
[buf
].SrcRGB
= sfactorRGB
;
271 ctx
->Color
.Blend
[buf
].DstRGB
= dfactorRGB
;
272 ctx
->Color
.Blend
[buf
].SrcA
= sfactorA
;
273 ctx
->Color
.Blend
[buf
].DstA
= dfactorA
;
274 ctx
->Color
._BlendFuncPerBuffer
= GL_TRUE
;
276 if (ctx
->Driver
.BlendFuncSeparatei
) {
277 ctx
->Driver
.BlendFuncSeparatei(ctx
, buf
, sfactorRGB
, dfactorRGB
,
284 * Check if given blend equation is legal.
285 * \return GL_TRUE if legal, GL_FALSE otherwise.
288 legal_blend_equation(const struct gl_context
*ctx
,
289 GLenum mode
, GLboolean is_separate
)
296 return ctx
->Extensions
.EXT_blend_minmax
;
298 /* glBlendEquationSeparate cannot take GL_LOGIC_OP as a parameter.
300 return ctx
->Extensions
.EXT_blend_logic_op
&& !is_separate
;
301 case GL_FUNC_SUBTRACT
:
302 case GL_FUNC_REVERSE_SUBTRACT
:
303 return ctx
->Extensions
.EXT_blend_subtract
;
310 /* This is really an extension function! */
312 _mesa_BlendEquation( GLenum mode
)
314 GLuint buf
, numBuffers
;
316 GET_CURRENT_CONTEXT(ctx
);
317 ASSERT_OUTSIDE_BEGIN_END(ctx
);
319 if (MESA_VERBOSE
& VERBOSE_API
)
320 _mesa_debug(ctx
, "glBlendEquation(%s)\n",
321 _mesa_lookup_enum_by_nr(mode
));
323 if (!legal_blend_equation(ctx
, mode
, GL_FALSE
)) {
324 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBlendEquation");
328 numBuffers
= ctx
->Extensions
.ARB_draw_buffers_blend
329 ? ctx
->Const
.MaxDrawBuffers
: 1;
332 for (buf
= 0; buf
< numBuffers
; buf
++) {
333 if (ctx
->Color
.Blend
[buf
].EquationRGB
!= mode
||
334 ctx
->Color
.Blend
[buf
].EquationA
!= mode
) {
342 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
343 for (buf
= 0; buf
< numBuffers
; buf
++) {
344 ctx
->Color
.Blend
[buf
].EquationRGB
= mode
;
345 ctx
->Color
.Blend
[buf
].EquationA
= mode
;
347 ctx
->Color
._BlendEquationPerBuffer
= GL_FALSE
;
349 if (ctx
->Driver
.BlendEquationSeparate
)
350 (*ctx
->Driver
.BlendEquationSeparate
)( ctx
, mode
, mode
);
355 * Set blend equation for one color buffer/target.
358 _mesa_BlendEquationi(GLuint buf
, GLenum mode
)
360 GET_CURRENT_CONTEXT(ctx
);
361 ASSERT_OUTSIDE_BEGIN_END(ctx
);
363 if (MESA_VERBOSE
& VERBOSE_API
)
364 _mesa_debug(ctx
, "glBlendEquationi(%u, %s)\n",
365 buf
, _mesa_lookup_enum_by_nr(mode
));
367 if (buf
>= ctx
->Const
.MaxDrawBuffers
) {
368 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBlendFuncSeparatei(buffer=%u)",
373 if (!legal_blend_equation(ctx
, mode
, GL_FALSE
)) {
374 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBlendEquationi");
378 if (ctx
->Color
.Blend
[buf
].EquationRGB
== mode
&&
379 ctx
->Color
.Blend
[buf
].EquationA
== mode
)
380 return; /* no change */
382 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
383 ctx
->Color
.Blend
[buf
].EquationRGB
= mode
;
384 ctx
->Color
.Blend
[buf
].EquationA
= mode
;
385 ctx
->Color
._BlendEquationPerBuffer
= GL_TRUE
;
387 if (ctx
->Driver
.BlendEquationSeparatei
)
388 ctx
->Driver
.BlendEquationSeparatei(ctx
, buf
, mode
, mode
);
393 _mesa_BlendEquationSeparateEXT( GLenum modeRGB
, GLenum modeA
)
395 GLuint buf
, numBuffers
;
397 GET_CURRENT_CONTEXT(ctx
);
398 ASSERT_OUTSIDE_BEGIN_END(ctx
);
400 if (MESA_VERBOSE
& VERBOSE_API
)
401 _mesa_debug(ctx
, "glBlendEquationSeparateEXT(%s %s)\n",
402 _mesa_lookup_enum_by_nr(modeRGB
),
403 _mesa_lookup_enum_by_nr(modeA
));
405 if ( (modeRGB
!= modeA
) && !ctx
->Extensions
.EXT_blend_equation_separate
) {
406 _mesa_error(ctx
, GL_INVALID_OPERATION
,
407 "glBlendEquationSeparateEXT not supported by driver");
411 if (!legal_blend_equation(ctx
, modeRGB
, GL_TRUE
)) {
412 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBlendEquationSeparateEXT(modeRGB)");
416 if (!legal_blend_equation(ctx
, modeA
, GL_TRUE
)) {
417 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBlendEquationSeparateEXT(modeA)");
421 numBuffers
= ctx
->Extensions
.ARB_draw_buffers_blend
422 ? ctx
->Const
.MaxDrawBuffers
: 1;
425 for (buf
= 0; buf
< numBuffers
; buf
++) {
426 if (ctx
->Color
.Blend
[buf
].EquationRGB
!= modeRGB
||
427 ctx
->Color
.Blend
[buf
].EquationA
!= modeA
) {
435 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
436 for (buf
= 0; buf
< numBuffers
; buf
++) {
437 ctx
->Color
.Blend
[buf
].EquationRGB
= modeRGB
;
438 ctx
->Color
.Blend
[buf
].EquationA
= modeA
;
440 ctx
->Color
._BlendEquationPerBuffer
= GL_FALSE
;
442 if (ctx
->Driver
.BlendEquationSeparate
)
443 ctx
->Driver
.BlendEquationSeparate(ctx
, modeRGB
, modeA
);
448 * Set separate blend equations for one color buffer/target.
451 _mesa_BlendEquationSeparatei(GLuint buf
, GLenum modeRGB
, GLenum modeA
)
453 GET_CURRENT_CONTEXT(ctx
);
454 ASSERT_OUTSIDE_BEGIN_END(ctx
);
456 if (MESA_VERBOSE
& VERBOSE_API
)
457 _mesa_debug(ctx
, "glBlendEquationSeparatei(%u, %s %s)\n", buf
,
458 _mesa_lookup_enum_by_nr(modeRGB
),
459 _mesa_lookup_enum_by_nr(modeA
));
461 if (buf
>= ctx
->Const
.MaxDrawBuffers
) {
462 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBlendEquationSeparatei(buffer=%u)",
467 if (!legal_blend_equation(ctx
, modeRGB
, GL_TRUE
)) {
468 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBlendEquationSeparatei(modeRGB)");
472 if (!legal_blend_equation(ctx
, modeA
, GL_TRUE
)) {
473 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBlendEquationSeparatei(modeA)");
477 if (ctx
->Color
.Blend
[buf
].EquationRGB
== modeRGB
&&
478 ctx
->Color
.Blend
[buf
].EquationA
== modeA
)
479 return; /* no change */
481 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
482 ctx
->Color
.Blend
[buf
].EquationRGB
= modeRGB
;
483 ctx
->Color
.Blend
[buf
].EquationA
= modeA
;
484 ctx
->Color
._BlendEquationPerBuffer
= GL_TRUE
;
486 if (ctx
->Driver
.BlendEquationSeparatei
)
487 ctx
->Driver
.BlendEquationSeparatei(ctx
, buf
, modeRGB
, modeA
);
492 #endif /* _HAVE_FULL_GL */
496 * Set the blending color.
498 * \param red red color component.
499 * \param green green color component.
500 * \param blue blue color component.
501 * \param alpha alpha color component.
503 * \sa glBlendColor().
505 * Clamps the parameters and updates gl_colorbuffer_attrib::BlendColor. On a
506 * change, flushes the vertices and notifies the driver via
507 * dd_function_table::BlendColor callback.
510 _mesa_BlendColor( GLclampf red
, GLclampf green
, GLclampf blue
, GLclampf alpha
)
513 GET_CURRENT_CONTEXT(ctx
);
514 ASSERT_OUTSIDE_BEGIN_END(ctx
);
521 if (TEST_EQ_4V(tmp
, ctx
->Color
.BlendColorUnclamped
))
524 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
525 COPY_4FV( ctx
->Color
.BlendColorUnclamped
, tmp
);
527 ctx
->Color
.BlendColor
[0] = CLAMP(tmp
[0], 0.0F
, 1.0F
);
528 ctx
->Color
.BlendColor
[1] = CLAMP(tmp
[1], 0.0F
, 1.0F
);
529 ctx
->Color
.BlendColor
[2] = CLAMP(tmp
[2], 0.0F
, 1.0F
);
530 ctx
->Color
.BlendColor
[3] = CLAMP(tmp
[3], 0.0F
, 1.0F
);
532 if (ctx
->Driver
.BlendColor
)
533 (*ctx
->Driver
.BlendColor
)(ctx
, ctx
->Color
.BlendColor
);
538 * Specify the alpha test function.
540 * \param func alpha comparison function.
541 * \param ref reference value.
543 * Verifies the parameters and updates gl_colorbuffer_attrib.
544 * On a change, flushes the vertices and notifies the driver via
545 * dd_function_table::AlphaFunc callback.
548 _mesa_AlphaFunc( GLenum func
, GLclampf ref
)
550 GET_CURRENT_CONTEXT(ctx
);
551 ASSERT_OUTSIDE_BEGIN_END(ctx
);
553 if (MESA_VERBOSE
& VERBOSE_API
)
554 _mesa_debug(ctx
, "glAlphaFunc(%s, %f)\n",
555 _mesa_lookup_enum_by_nr(func
), ref
);
566 if (ctx
->Color
.AlphaFunc
== func
&& ctx
->Color
.AlphaRefUnclamped
== ref
)
567 return; /* no change */
569 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
570 ctx
->Color
.AlphaFunc
= func
;
571 ctx
->Color
.AlphaRefUnclamped
= ref
;
572 ctx
->Color
.AlphaRef
= CLAMP(ref
, 0.0F
, 1.0F
);
574 if (ctx
->Driver
.AlphaFunc
)
575 ctx
->Driver
.AlphaFunc(ctx
, func
, ctx
->Color
.AlphaRef
);
579 _mesa_error( ctx
, GL_INVALID_ENUM
, "glAlphaFunc(func)" );
586 * Specify a logic pixel operation for color index rendering.
588 * \param opcode operation.
590 * Verifies that \p opcode is a valid enum and updates
591 gl_colorbuffer_attrib::LogicOp.
592 * On a change, flushes the vertices and notifies the driver via the
593 * dd_function_table::LogicOpcode callback.
596 _mesa_LogicOp( GLenum opcode
)
598 GET_CURRENT_CONTEXT(ctx
);
599 ASSERT_OUTSIDE_BEGIN_END(ctx
);
601 if (MESA_VERBOSE
& VERBOSE_API
)
602 _mesa_debug(ctx
, "glLogicOp(%s)\n", _mesa_lookup_enum_by_nr(opcode
));
608 case GL_COPY_INVERTED
:
618 case GL_AND_INVERTED
:
623 _mesa_error( ctx
, GL_INVALID_ENUM
, "glLogicOp" );
627 if (ctx
->Color
.LogicOp
== opcode
)
630 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
631 ctx
->Color
.LogicOp
= opcode
;
633 if (ctx
->Driver
.LogicOpcode
)
634 ctx
->Driver
.LogicOpcode( ctx
, opcode
);
639 _mesa_IndexMask( GLuint mask
)
641 GET_CURRENT_CONTEXT(ctx
);
642 ASSERT_OUTSIDE_BEGIN_END(ctx
);
644 if (ctx
->Color
.IndexMask
== mask
)
647 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
648 ctx
->Color
.IndexMask
= mask
;
654 * Enable or disable writing of frame buffer color components.
656 * \param red whether to mask writing of the red color component.
657 * \param green whether to mask writing of the green color component.
658 * \param blue whether to mask writing of the blue color component.
659 * \param alpha whether to mask writing of the alpha color component.
663 * Sets the appropriate value of gl_colorbuffer_attrib::ColorMask. On a
664 * change, flushes the vertices and notifies the driver via the
665 * dd_function_table::ColorMask callback.
668 _mesa_ColorMask( GLboolean red
, GLboolean green
,
669 GLboolean blue
, GLboolean alpha
)
671 GET_CURRENT_CONTEXT(ctx
);
675 ASSERT_OUTSIDE_BEGIN_END(ctx
);
677 if (MESA_VERBOSE
& VERBOSE_API
)
678 _mesa_debug(ctx
, "glColorMask(%d, %d, %d, %d)\n",
679 red
, green
, blue
, alpha
);
681 /* Shouldn't have any information about channel depth in core mesa
682 * -- should probably store these as the native booleans:
684 tmp
[RCOMP
] = red
? 0xff : 0x0;
685 tmp
[GCOMP
] = green
? 0xff : 0x0;
686 tmp
[BCOMP
] = blue
? 0xff : 0x0;
687 tmp
[ACOMP
] = alpha
? 0xff : 0x0;
690 for (i
= 0; i
< ctx
->Const
.MaxDrawBuffers
; i
++) {
691 if (!TEST_EQ_4V(tmp
, ctx
->Color
.ColorMask
[i
])) {
693 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
696 COPY_4UBV(ctx
->Color
.ColorMask
[i
], tmp
);
700 if (ctx
->Driver
.ColorMask
)
701 ctx
->Driver
.ColorMask( ctx
, red
, green
, blue
, alpha
);
706 * For GL_EXT_draw_buffers2 and GL3
709 _mesa_ColorMaskIndexed( GLuint buf
, GLboolean red
, GLboolean green
,
710 GLboolean blue
, GLboolean alpha
)
713 GET_CURRENT_CONTEXT(ctx
);
714 ASSERT_OUTSIDE_BEGIN_END(ctx
);
716 if (MESA_VERBOSE
& VERBOSE_API
)
717 _mesa_debug(ctx
, "glColorMaskIndexed %u %d %d %d %d\n",
718 buf
, red
, green
, blue
, alpha
);
720 if (buf
>= ctx
->Const
.MaxDrawBuffers
) {
721 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorMaskIndexed(buf=%u)", buf
);
725 /* Shouldn't have any information about channel depth in core mesa
726 * -- should probably store these as the native booleans:
728 tmp
[RCOMP
] = red
? 0xff : 0x0;
729 tmp
[GCOMP
] = green
? 0xff : 0x0;
730 tmp
[BCOMP
] = blue
? 0xff : 0x0;
731 tmp
[ACOMP
] = alpha
? 0xff : 0x0;
733 if (TEST_EQ_4V(tmp
, ctx
->Color
.ColorMask
[buf
]))
736 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
737 COPY_4UBV(ctx
->Color
.ColorMask
[buf
], tmp
);
739 if (ctx
->Driver
.ColorMaskIndexed
)
740 ctx
->Driver
.ColorMaskIndexed(ctx
, buf
, red
, green
, blue
, alpha
);
745 _mesa_ClampColorARB(GLenum target
, GLenum clamp
)
747 GET_CURRENT_CONTEXT(ctx
);
749 ASSERT_OUTSIDE_BEGIN_END(ctx
);
751 if (clamp
!= GL_TRUE
&& clamp
!= GL_FALSE
&& clamp
!= GL_FIXED_ONLY_ARB
) {
752 _mesa_error(ctx
, GL_INVALID_ENUM
, "glClampColorARB(clamp)");
757 case GL_CLAMP_VERTEX_COLOR_ARB
:
758 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
759 ctx
->Light
.ClampVertexColor
= clamp
;
761 case GL_CLAMP_FRAGMENT_COLOR_ARB
:
762 FLUSH_VERTICES(ctx
, _NEW_FRAG_CLAMP
);
763 ctx
->Color
.ClampFragmentColor
= clamp
;
765 case GL_CLAMP_READ_COLOR_ARB
:
766 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
767 ctx
->Color
.ClampReadColor
= clamp
;
770 _mesa_error(ctx
, GL_INVALID_ENUM
, "glClampColorARB(target)");
778 /**********************************************************************/
779 /** \name Initialization */
783 * Initialization of the context's Color attribute group.
785 * \param ctx GL context.
787 * Initializes the related fields in the context color attribute group,
788 * __struct gl_contextRec::Color.
790 void _mesa_init_color( struct gl_context
* ctx
)
794 /* Color buffer group */
795 ctx
->Color
.IndexMask
= ~0u;
796 memset(ctx
->Color
.ColorMask
, 0xff, sizeof(ctx
->Color
.ColorMask
));
797 ctx
->Color
.ClearIndex
= 0;
798 ASSIGN_4V( ctx
->Color
.ClearColor
, 0, 0, 0, 0 );
799 ASSIGN_4V( ctx
->Color
.ClearColorUnclamped
, 0, 0, 0, 0 );
800 ctx
->Color
.AlphaEnabled
= GL_FALSE
;
801 ctx
->Color
.AlphaFunc
= GL_ALWAYS
;
802 ctx
->Color
.AlphaRef
= 0;
803 ctx
->Color
.BlendEnabled
= 0x0;
804 for (i
= 0; i
< Elements(ctx
->Color
.Blend
); i
++) {
805 ctx
->Color
.Blend
[i
].SrcRGB
= GL_ONE
;
806 ctx
->Color
.Blend
[i
].DstRGB
= GL_ZERO
;
807 ctx
->Color
.Blend
[i
].SrcA
= GL_ONE
;
808 ctx
->Color
.Blend
[i
].DstA
= GL_ZERO
;
809 ctx
->Color
.Blend
[i
].EquationRGB
= GL_FUNC_ADD
;
810 ctx
->Color
.Blend
[i
].EquationA
= GL_FUNC_ADD
;
812 ASSIGN_4V( ctx
->Color
.BlendColor
, 0.0, 0.0, 0.0, 0.0 );
813 ASSIGN_4V( ctx
->Color
.BlendColorUnclamped
, 0.0, 0.0, 0.0, 0.0 );
814 ctx
->Color
.IndexLogicOpEnabled
= GL_FALSE
;
815 ctx
->Color
.ColorLogicOpEnabled
= GL_FALSE
;
816 ctx
->Color
._LogicOpEnabled
= GL_FALSE
;
817 ctx
->Color
.LogicOp
= GL_COPY
;
818 ctx
->Color
.DitherFlag
= GL_TRUE
;
820 if (ctx
->Visual
.doubleBufferMode
) {
821 ctx
->Color
.DrawBuffer
[0] = GL_BACK
;
824 ctx
->Color
.DrawBuffer
[0] = GL_FRONT
;
827 ctx
->Color
.ClampFragmentColor
= GL_FIXED_ONLY_ARB
;
828 ctx
->Color
._ClampFragmentColor
= GL_TRUE
;
829 ctx
->Color
.ClampReadColor
= GL_FIXED_ONLY_ARB
;
830 ctx
->Color
._ClampReadColor
= GL_TRUE
;