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
, GLenum mode
)
295 return ctx
->Extensions
.EXT_blend_minmax
;
296 case GL_FUNC_SUBTRACT
:
297 case GL_FUNC_REVERSE_SUBTRACT
:
298 return ctx
->Extensions
.EXT_blend_subtract
;
305 /* This is really an extension function! */
307 _mesa_BlendEquation( GLenum mode
)
309 GLuint buf
, numBuffers
;
311 GET_CURRENT_CONTEXT(ctx
);
312 ASSERT_OUTSIDE_BEGIN_END(ctx
);
314 if (MESA_VERBOSE
& VERBOSE_API
)
315 _mesa_debug(ctx
, "glBlendEquation(%s)\n",
316 _mesa_lookup_enum_by_nr(mode
));
318 if (!legal_blend_equation(ctx
, mode
)) {
319 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBlendEquation");
323 numBuffers
= ctx
->Extensions
.ARB_draw_buffers_blend
324 ? ctx
->Const
.MaxDrawBuffers
: 1;
327 for (buf
= 0; buf
< numBuffers
; buf
++) {
328 if (ctx
->Color
.Blend
[buf
].EquationRGB
!= mode
||
329 ctx
->Color
.Blend
[buf
].EquationA
!= mode
) {
337 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
338 for (buf
= 0; buf
< numBuffers
; buf
++) {
339 ctx
->Color
.Blend
[buf
].EquationRGB
= mode
;
340 ctx
->Color
.Blend
[buf
].EquationA
= mode
;
342 ctx
->Color
._BlendEquationPerBuffer
= GL_FALSE
;
344 if (ctx
->Driver
.BlendEquationSeparate
)
345 (*ctx
->Driver
.BlendEquationSeparate
)( ctx
, mode
, mode
);
350 * Set blend equation for one color buffer/target.
353 _mesa_BlendEquationi(GLuint buf
, GLenum mode
)
355 GET_CURRENT_CONTEXT(ctx
);
356 ASSERT_OUTSIDE_BEGIN_END(ctx
);
358 if (MESA_VERBOSE
& VERBOSE_API
)
359 _mesa_debug(ctx
, "glBlendEquationi(%u, %s)\n",
360 buf
, _mesa_lookup_enum_by_nr(mode
));
362 if (buf
>= ctx
->Const
.MaxDrawBuffers
) {
363 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBlendFuncSeparatei(buffer=%u)",
368 if (!legal_blend_equation(ctx
, mode
)) {
369 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBlendEquationi");
373 if (ctx
->Color
.Blend
[buf
].EquationRGB
== mode
&&
374 ctx
->Color
.Blend
[buf
].EquationA
== mode
)
375 return; /* no change */
377 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
378 ctx
->Color
.Blend
[buf
].EquationRGB
= mode
;
379 ctx
->Color
.Blend
[buf
].EquationA
= mode
;
380 ctx
->Color
._BlendEquationPerBuffer
= GL_TRUE
;
382 if (ctx
->Driver
.BlendEquationSeparatei
)
383 ctx
->Driver
.BlendEquationSeparatei(ctx
, buf
, mode
, mode
);
388 _mesa_BlendEquationSeparateEXT( GLenum modeRGB
, GLenum modeA
)
390 GLuint buf
, numBuffers
;
392 GET_CURRENT_CONTEXT(ctx
);
393 ASSERT_OUTSIDE_BEGIN_END(ctx
);
395 if (MESA_VERBOSE
& VERBOSE_API
)
396 _mesa_debug(ctx
, "glBlendEquationSeparateEXT(%s %s)\n",
397 _mesa_lookup_enum_by_nr(modeRGB
),
398 _mesa_lookup_enum_by_nr(modeA
));
400 if ( (modeRGB
!= modeA
) && !ctx
->Extensions
.EXT_blend_equation_separate
) {
401 _mesa_error(ctx
, GL_INVALID_OPERATION
,
402 "glBlendEquationSeparateEXT not supported by driver");
406 if (!legal_blend_equation(ctx
, modeRGB
)) {
407 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBlendEquationSeparateEXT(modeRGB)");
411 if (!legal_blend_equation(ctx
, modeA
)) {
412 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBlendEquationSeparateEXT(modeA)");
416 numBuffers
= ctx
->Extensions
.ARB_draw_buffers_blend
417 ? ctx
->Const
.MaxDrawBuffers
: 1;
420 for (buf
= 0; buf
< numBuffers
; buf
++) {
421 if (ctx
->Color
.Blend
[buf
].EquationRGB
!= modeRGB
||
422 ctx
->Color
.Blend
[buf
].EquationA
!= modeA
) {
430 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
431 for (buf
= 0; buf
< numBuffers
; buf
++) {
432 ctx
->Color
.Blend
[buf
].EquationRGB
= modeRGB
;
433 ctx
->Color
.Blend
[buf
].EquationA
= modeA
;
435 ctx
->Color
._BlendEquationPerBuffer
= GL_FALSE
;
437 if (ctx
->Driver
.BlendEquationSeparate
)
438 ctx
->Driver
.BlendEquationSeparate(ctx
, modeRGB
, modeA
);
443 * Set separate blend equations for one color buffer/target.
446 _mesa_BlendEquationSeparatei(GLuint buf
, GLenum modeRGB
, GLenum modeA
)
448 GET_CURRENT_CONTEXT(ctx
);
449 ASSERT_OUTSIDE_BEGIN_END(ctx
);
451 if (MESA_VERBOSE
& VERBOSE_API
)
452 _mesa_debug(ctx
, "glBlendEquationSeparatei(%u, %s %s)\n", buf
,
453 _mesa_lookup_enum_by_nr(modeRGB
),
454 _mesa_lookup_enum_by_nr(modeA
));
456 if (buf
>= ctx
->Const
.MaxDrawBuffers
) {
457 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBlendEquationSeparatei(buffer=%u)",
462 if (!legal_blend_equation(ctx
, modeRGB
)) {
463 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBlendEquationSeparatei(modeRGB)");
467 if (!legal_blend_equation(ctx
, modeA
)) {
468 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBlendEquationSeparatei(modeA)");
472 if (ctx
->Color
.Blend
[buf
].EquationRGB
== modeRGB
&&
473 ctx
->Color
.Blend
[buf
].EquationA
== modeA
)
474 return; /* no change */
476 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
477 ctx
->Color
.Blend
[buf
].EquationRGB
= modeRGB
;
478 ctx
->Color
.Blend
[buf
].EquationA
= modeA
;
479 ctx
->Color
._BlendEquationPerBuffer
= GL_TRUE
;
481 if (ctx
->Driver
.BlendEquationSeparatei
)
482 ctx
->Driver
.BlendEquationSeparatei(ctx
, buf
, modeRGB
, modeA
);
487 #endif /* _HAVE_FULL_GL */
491 * Set the blending color.
493 * \param red red color component.
494 * \param green green color component.
495 * \param blue blue color component.
496 * \param alpha alpha color component.
498 * \sa glBlendColor().
500 * Clamps the parameters and updates gl_colorbuffer_attrib::BlendColor. On a
501 * change, flushes the vertices and notifies the driver via
502 * dd_function_table::BlendColor callback.
505 _mesa_BlendColor( GLclampf red
, GLclampf green
, GLclampf blue
, GLclampf alpha
)
508 GET_CURRENT_CONTEXT(ctx
);
509 ASSERT_OUTSIDE_BEGIN_END(ctx
);
516 if (TEST_EQ_4V(tmp
, ctx
->Color
.BlendColorUnclamped
))
519 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
520 COPY_4FV( ctx
->Color
.BlendColorUnclamped
, tmp
);
522 ctx
->Color
.BlendColor
[0] = CLAMP(tmp
[0], 0.0F
, 1.0F
);
523 ctx
->Color
.BlendColor
[1] = CLAMP(tmp
[1], 0.0F
, 1.0F
);
524 ctx
->Color
.BlendColor
[2] = CLAMP(tmp
[2], 0.0F
, 1.0F
);
525 ctx
->Color
.BlendColor
[3] = CLAMP(tmp
[3], 0.0F
, 1.0F
);
527 if (ctx
->Driver
.BlendColor
)
528 (*ctx
->Driver
.BlendColor
)(ctx
, ctx
->Color
.BlendColor
);
533 * Specify the alpha test function.
535 * \param func alpha comparison function.
536 * \param ref reference value.
538 * Verifies the parameters and updates gl_colorbuffer_attrib.
539 * On a change, flushes the vertices and notifies the driver via
540 * dd_function_table::AlphaFunc callback.
543 _mesa_AlphaFunc( GLenum func
, GLclampf ref
)
545 GET_CURRENT_CONTEXT(ctx
);
546 ASSERT_OUTSIDE_BEGIN_END(ctx
);
548 if (MESA_VERBOSE
& VERBOSE_API
)
549 _mesa_debug(ctx
, "glAlphaFunc(%s, %f)\n",
550 _mesa_lookup_enum_by_nr(func
), ref
);
561 if (ctx
->Color
.AlphaFunc
== func
&& ctx
->Color
.AlphaRefUnclamped
== ref
)
562 return; /* no change */
564 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
565 ctx
->Color
.AlphaFunc
= func
;
566 ctx
->Color
.AlphaRefUnclamped
= ref
;
567 ctx
->Color
.AlphaRef
= CLAMP(ref
, 0.0F
, 1.0F
);
569 if (ctx
->Driver
.AlphaFunc
)
570 ctx
->Driver
.AlphaFunc(ctx
, func
, ctx
->Color
.AlphaRef
);
574 _mesa_error( ctx
, GL_INVALID_ENUM
, "glAlphaFunc(func)" );
581 * Specify a logic pixel operation for color index rendering.
583 * \param opcode operation.
585 * Verifies that \p opcode is a valid enum and updates
586 gl_colorbuffer_attrib::LogicOp.
587 * On a change, flushes the vertices and notifies the driver via the
588 * dd_function_table::LogicOpcode callback.
591 _mesa_LogicOp( GLenum opcode
)
593 GET_CURRENT_CONTEXT(ctx
);
594 ASSERT_OUTSIDE_BEGIN_END(ctx
);
596 if (MESA_VERBOSE
& VERBOSE_API
)
597 _mesa_debug(ctx
, "glLogicOp(%s)\n", _mesa_lookup_enum_by_nr(opcode
));
603 case GL_COPY_INVERTED
:
613 case GL_AND_INVERTED
:
618 _mesa_error( ctx
, GL_INVALID_ENUM
, "glLogicOp" );
622 if (ctx
->Color
.LogicOp
== opcode
)
625 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
626 ctx
->Color
.LogicOp
= opcode
;
628 if (ctx
->Driver
.LogicOpcode
)
629 ctx
->Driver
.LogicOpcode( ctx
, opcode
);
634 _mesa_IndexMask( GLuint mask
)
636 GET_CURRENT_CONTEXT(ctx
);
637 ASSERT_OUTSIDE_BEGIN_END(ctx
);
639 if (ctx
->Color
.IndexMask
== mask
)
642 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
643 ctx
->Color
.IndexMask
= mask
;
649 * Enable or disable writing of frame buffer color components.
651 * \param red whether to mask writing of the red color component.
652 * \param green whether to mask writing of the green color component.
653 * \param blue whether to mask writing of the blue color component.
654 * \param alpha whether to mask writing of the alpha color component.
658 * Sets the appropriate value of gl_colorbuffer_attrib::ColorMask. On a
659 * change, flushes the vertices and notifies the driver via the
660 * dd_function_table::ColorMask callback.
663 _mesa_ColorMask( GLboolean red
, GLboolean green
,
664 GLboolean blue
, GLboolean alpha
)
666 GET_CURRENT_CONTEXT(ctx
);
670 ASSERT_OUTSIDE_BEGIN_END(ctx
);
672 if (MESA_VERBOSE
& VERBOSE_API
)
673 _mesa_debug(ctx
, "glColorMask(%d, %d, %d, %d)\n",
674 red
, green
, blue
, alpha
);
676 /* Shouldn't have any information about channel depth in core mesa
677 * -- should probably store these as the native booleans:
679 tmp
[RCOMP
] = red
? 0xff : 0x0;
680 tmp
[GCOMP
] = green
? 0xff : 0x0;
681 tmp
[BCOMP
] = blue
? 0xff : 0x0;
682 tmp
[ACOMP
] = alpha
? 0xff : 0x0;
685 for (i
= 0; i
< ctx
->Const
.MaxDrawBuffers
; i
++) {
686 if (!TEST_EQ_4V(tmp
, ctx
->Color
.ColorMask
[i
])) {
688 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
691 COPY_4UBV(ctx
->Color
.ColorMask
[i
], tmp
);
695 if (ctx
->Driver
.ColorMask
)
696 ctx
->Driver
.ColorMask( ctx
, red
, green
, blue
, alpha
);
701 * For GL_EXT_draw_buffers2 and GL3
704 _mesa_ColorMaskIndexed( GLuint buf
, GLboolean red
, GLboolean green
,
705 GLboolean blue
, GLboolean alpha
)
708 GET_CURRENT_CONTEXT(ctx
);
709 ASSERT_OUTSIDE_BEGIN_END(ctx
);
711 if (MESA_VERBOSE
& VERBOSE_API
)
712 _mesa_debug(ctx
, "glColorMaskIndexed %u %d %d %d %d\n",
713 buf
, red
, green
, blue
, alpha
);
715 if (buf
>= ctx
->Const
.MaxDrawBuffers
) {
716 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorMaskIndexed(buf=%u)", buf
);
720 /* Shouldn't have any information about channel depth in core mesa
721 * -- should probably store these as the native booleans:
723 tmp
[RCOMP
] = red
? 0xff : 0x0;
724 tmp
[GCOMP
] = green
? 0xff : 0x0;
725 tmp
[BCOMP
] = blue
? 0xff : 0x0;
726 tmp
[ACOMP
] = alpha
? 0xff : 0x0;
728 if (TEST_EQ_4V(tmp
, ctx
->Color
.ColorMask
[buf
]))
731 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
732 COPY_4UBV(ctx
->Color
.ColorMask
[buf
], tmp
);
734 if (ctx
->Driver
.ColorMaskIndexed
)
735 ctx
->Driver
.ColorMaskIndexed(ctx
, buf
, red
, green
, blue
, alpha
);
740 _mesa_ClampColorARB(GLenum target
, GLenum clamp
)
742 GET_CURRENT_CONTEXT(ctx
);
744 ASSERT_OUTSIDE_BEGIN_END(ctx
);
746 if (clamp
!= GL_TRUE
&& clamp
!= GL_FALSE
&& clamp
!= GL_FIXED_ONLY_ARB
) {
747 _mesa_error(ctx
, GL_INVALID_ENUM
, "glClampColorARB(clamp)");
752 case GL_CLAMP_VERTEX_COLOR_ARB
:
753 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
754 ctx
->Light
.ClampVertexColor
= clamp
;
756 case GL_CLAMP_FRAGMENT_COLOR_ARB
:
757 FLUSH_VERTICES(ctx
, _NEW_FRAG_CLAMP
);
758 ctx
->Color
.ClampFragmentColor
= clamp
;
760 case GL_CLAMP_READ_COLOR_ARB
:
761 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
762 ctx
->Color
.ClampReadColor
= clamp
;
765 _mesa_error(ctx
, GL_INVALID_ENUM
, "glClampColorARB(target)");
773 /**********************************************************************/
774 /** \name Initialization */
778 * Initialization of the context's Color attribute group.
780 * \param ctx GL context.
782 * Initializes the related fields in the context color attribute group,
783 * __struct gl_contextRec::Color.
785 void _mesa_init_color( struct gl_context
* ctx
)
789 /* Color buffer group */
790 ctx
->Color
.IndexMask
= ~0u;
791 memset(ctx
->Color
.ColorMask
, 0xff, sizeof(ctx
->Color
.ColorMask
));
792 ctx
->Color
.ClearIndex
= 0;
793 ASSIGN_4V( ctx
->Color
.ClearColor
.f
, 0, 0, 0, 0 );
794 ctx
->Color
.AlphaEnabled
= GL_FALSE
;
795 ctx
->Color
.AlphaFunc
= GL_ALWAYS
;
796 ctx
->Color
.AlphaRef
= 0;
797 ctx
->Color
.BlendEnabled
= 0x0;
798 for (i
= 0; i
< Elements(ctx
->Color
.Blend
); i
++) {
799 ctx
->Color
.Blend
[i
].SrcRGB
= GL_ONE
;
800 ctx
->Color
.Blend
[i
].DstRGB
= GL_ZERO
;
801 ctx
->Color
.Blend
[i
].SrcA
= GL_ONE
;
802 ctx
->Color
.Blend
[i
].DstA
= GL_ZERO
;
803 ctx
->Color
.Blend
[i
].EquationRGB
= GL_FUNC_ADD
;
804 ctx
->Color
.Blend
[i
].EquationA
= GL_FUNC_ADD
;
806 ASSIGN_4V( ctx
->Color
.BlendColor
, 0.0, 0.0, 0.0, 0.0 );
807 ASSIGN_4V( ctx
->Color
.BlendColorUnclamped
, 0.0, 0.0, 0.0, 0.0 );
808 ctx
->Color
.IndexLogicOpEnabled
= GL_FALSE
;
809 ctx
->Color
.ColorLogicOpEnabled
= GL_FALSE
;
810 ctx
->Color
.LogicOp
= GL_COPY
;
811 ctx
->Color
.DitherFlag
= GL_TRUE
;
813 if (ctx
->Visual
.doubleBufferMode
) {
814 ctx
->Color
.DrawBuffer
[0] = GL_BACK
;
817 ctx
->Color
.DrawBuffer
[0] = GL_FRONT
;
820 ctx
->Color
.ClampFragmentColor
= GL_FIXED_ONLY_ARB
;
821 ctx
->Color
._ClampFragmentColor
= GL_TRUE
;
822 ctx
->Color
.ClampReadColor
= GL_FIXED_ONLY_ARB
;
823 ctx
->Color
._ClampReadColor
= GL_TRUE
;