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
)
292 case GL_FUNC_SUBTRACT
:
293 case GL_FUNC_REVERSE_SUBTRACT
:
297 return ctx
->Extensions
.EXT_blend_minmax
;
304 /* This is really an extension function! */
306 _mesa_BlendEquation( GLenum mode
)
308 GLuint buf
, numBuffers
;
310 GET_CURRENT_CONTEXT(ctx
);
311 ASSERT_OUTSIDE_BEGIN_END(ctx
);
313 if (MESA_VERBOSE
& VERBOSE_API
)
314 _mesa_debug(ctx
, "glBlendEquation(%s)\n",
315 _mesa_lookup_enum_by_nr(mode
));
317 if (!legal_blend_equation(ctx
, mode
)) {
318 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBlendEquation");
322 numBuffers
= ctx
->Extensions
.ARB_draw_buffers_blend
323 ? ctx
->Const
.MaxDrawBuffers
: 1;
326 for (buf
= 0; buf
< numBuffers
; buf
++) {
327 if (ctx
->Color
.Blend
[buf
].EquationRGB
!= mode
||
328 ctx
->Color
.Blend
[buf
].EquationA
!= mode
) {
336 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
337 for (buf
= 0; buf
< numBuffers
; buf
++) {
338 ctx
->Color
.Blend
[buf
].EquationRGB
= mode
;
339 ctx
->Color
.Blend
[buf
].EquationA
= mode
;
341 ctx
->Color
._BlendEquationPerBuffer
= GL_FALSE
;
343 if (ctx
->Driver
.BlendEquationSeparate
)
344 (*ctx
->Driver
.BlendEquationSeparate
)( ctx
, mode
, mode
);
349 * Set blend equation for one color buffer/target.
352 _mesa_BlendEquationi(GLuint buf
, GLenum mode
)
354 GET_CURRENT_CONTEXT(ctx
);
355 ASSERT_OUTSIDE_BEGIN_END(ctx
);
357 if (MESA_VERBOSE
& VERBOSE_API
)
358 _mesa_debug(ctx
, "glBlendEquationi(%u, %s)\n",
359 buf
, _mesa_lookup_enum_by_nr(mode
));
361 if (buf
>= ctx
->Const
.MaxDrawBuffers
) {
362 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBlendFuncSeparatei(buffer=%u)",
367 if (!legal_blend_equation(ctx
, mode
)) {
368 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBlendEquationi");
372 if (ctx
->Color
.Blend
[buf
].EquationRGB
== mode
&&
373 ctx
->Color
.Blend
[buf
].EquationA
== mode
)
374 return; /* no change */
376 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
377 ctx
->Color
.Blend
[buf
].EquationRGB
= mode
;
378 ctx
->Color
.Blend
[buf
].EquationA
= mode
;
379 ctx
->Color
._BlendEquationPerBuffer
= GL_TRUE
;
381 if (ctx
->Driver
.BlendEquationSeparatei
)
382 ctx
->Driver
.BlendEquationSeparatei(ctx
, buf
, mode
, mode
);
387 _mesa_BlendEquationSeparateEXT( GLenum modeRGB
, GLenum modeA
)
389 GLuint buf
, numBuffers
;
391 GET_CURRENT_CONTEXT(ctx
);
392 ASSERT_OUTSIDE_BEGIN_END(ctx
);
394 if (MESA_VERBOSE
& VERBOSE_API
)
395 _mesa_debug(ctx
, "glBlendEquationSeparateEXT(%s %s)\n",
396 _mesa_lookup_enum_by_nr(modeRGB
),
397 _mesa_lookup_enum_by_nr(modeA
));
399 if ( (modeRGB
!= modeA
) && !ctx
->Extensions
.EXT_blend_equation_separate
) {
400 _mesa_error(ctx
, GL_INVALID_OPERATION
,
401 "glBlendEquationSeparateEXT not supported by driver");
405 if (!legal_blend_equation(ctx
, modeRGB
)) {
406 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBlendEquationSeparateEXT(modeRGB)");
410 if (!legal_blend_equation(ctx
, modeA
)) {
411 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBlendEquationSeparateEXT(modeA)");
415 numBuffers
= ctx
->Extensions
.ARB_draw_buffers_blend
416 ? ctx
->Const
.MaxDrawBuffers
: 1;
419 for (buf
= 0; buf
< numBuffers
; buf
++) {
420 if (ctx
->Color
.Blend
[buf
].EquationRGB
!= modeRGB
||
421 ctx
->Color
.Blend
[buf
].EquationA
!= modeA
) {
429 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
430 for (buf
= 0; buf
< numBuffers
; buf
++) {
431 ctx
->Color
.Blend
[buf
].EquationRGB
= modeRGB
;
432 ctx
->Color
.Blend
[buf
].EquationA
= modeA
;
434 ctx
->Color
._BlendEquationPerBuffer
= GL_FALSE
;
436 if (ctx
->Driver
.BlendEquationSeparate
)
437 ctx
->Driver
.BlendEquationSeparate(ctx
, modeRGB
, modeA
);
442 * Set separate blend equations for one color buffer/target.
445 _mesa_BlendEquationSeparatei(GLuint buf
, GLenum modeRGB
, GLenum modeA
)
447 GET_CURRENT_CONTEXT(ctx
);
448 ASSERT_OUTSIDE_BEGIN_END(ctx
);
450 if (MESA_VERBOSE
& VERBOSE_API
)
451 _mesa_debug(ctx
, "glBlendEquationSeparatei(%u, %s %s)\n", buf
,
452 _mesa_lookup_enum_by_nr(modeRGB
),
453 _mesa_lookup_enum_by_nr(modeA
));
455 if (buf
>= ctx
->Const
.MaxDrawBuffers
) {
456 _mesa_error(ctx
, GL_INVALID_VALUE
, "glBlendEquationSeparatei(buffer=%u)",
461 if (!legal_blend_equation(ctx
, modeRGB
)) {
462 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBlendEquationSeparatei(modeRGB)");
466 if (!legal_blend_equation(ctx
, modeA
)) {
467 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBlendEquationSeparatei(modeA)");
471 if (ctx
->Color
.Blend
[buf
].EquationRGB
== modeRGB
&&
472 ctx
->Color
.Blend
[buf
].EquationA
== modeA
)
473 return; /* no change */
475 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
476 ctx
->Color
.Blend
[buf
].EquationRGB
= modeRGB
;
477 ctx
->Color
.Blend
[buf
].EquationA
= modeA
;
478 ctx
->Color
._BlendEquationPerBuffer
= GL_TRUE
;
480 if (ctx
->Driver
.BlendEquationSeparatei
)
481 ctx
->Driver
.BlendEquationSeparatei(ctx
, buf
, modeRGB
, modeA
);
486 #endif /* _HAVE_FULL_GL */
490 * Set the blending color.
492 * \param red red color component.
493 * \param green green color component.
494 * \param blue blue color component.
495 * \param alpha alpha color component.
497 * \sa glBlendColor().
499 * Clamps the parameters and updates gl_colorbuffer_attrib::BlendColor. On a
500 * change, flushes the vertices and notifies the driver via
501 * dd_function_table::BlendColor callback.
504 _mesa_BlendColor( GLclampf red
, GLclampf green
, GLclampf blue
, GLclampf alpha
)
507 GET_CURRENT_CONTEXT(ctx
);
508 ASSERT_OUTSIDE_BEGIN_END(ctx
);
515 if (TEST_EQ_4V(tmp
, ctx
->Color
.BlendColorUnclamped
))
518 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
519 COPY_4FV( ctx
->Color
.BlendColorUnclamped
, tmp
);
521 ctx
->Color
.BlendColor
[0] = CLAMP(tmp
[0], 0.0F
, 1.0F
);
522 ctx
->Color
.BlendColor
[1] = CLAMP(tmp
[1], 0.0F
, 1.0F
);
523 ctx
->Color
.BlendColor
[2] = CLAMP(tmp
[2], 0.0F
, 1.0F
);
524 ctx
->Color
.BlendColor
[3] = CLAMP(tmp
[3], 0.0F
, 1.0F
);
526 if (ctx
->Driver
.BlendColor
)
527 (*ctx
->Driver
.BlendColor
)(ctx
, ctx
->Color
.BlendColor
);
532 * Specify the alpha test function.
534 * \param func alpha comparison function.
535 * \param ref reference value.
537 * Verifies the parameters and updates gl_colorbuffer_attrib.
538 * On a change, flushes the vertices and notifies the driver via
539 * dd_function_table::AlphaFunc callback.
542 _mesa_AlphaFunc( GLenum func
, GLclampf ref
)
544 GET_CURRENT_CONTEXT(ctx
);
545 ASSERT_OUTSIDE_BEGIN_END(ctx
);
547 if (MESA_VERBOSE
& VERBOSE_API
)
548 _mesa_debug(ctx
, "glAlphaFunc(%s, %f)\n",
549 _mesa_lookup_enum_by_nr(func
), ref
);
560 if (ctx
->Color
.AlphaFunc
== func
&& ctx
->Color
.AlphaRefUnclamped
== ref
)
561 return; /* no change */
563 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
564 ctx
->Color
.AlphaFunc
= func
;
565 ctx
->Color
.AlphaRefUnclamped
= ref
;
566 ctx
->Color
.AlphaRef
= CLAMP(ref
, 0.0F
, 1.0F
);
568 if (ctx
->Driver
.AlphaFunc
)
569 ctx
->Driver
.AlphaFunc(ctx
, func
, ctx
->Color
.AlphaRef
);
573 _mesa_error( ctx
, GL_INVALID_ENUM
, "glAlphaFunc(func)" );
580 * Specify a logic pixel operation for color index rendering.
582 * \param opcode operation.
584 * Verifies that \p opcode is a valid enum and updates
585 gl_colorbuffer_attrib::LogicOp.
586 * On a change, flushes the vertices and notifies the driver via the
587 * dd_function_table::LogicOpcode callback.
590 _mesa_LogicOp( GLenum opcode
)
592 GET_CURRENT_CONTEXT(ctx
);
593 ASSERT_OUTSIDE_BEGIN_END(ctx
);
595 if (MESA_VERBOSE
& VERBOSE_API
)
596 _mesa_debug(ctx
, "glLogicOp(%s)\n", _mesa_lookup_enum_by_nr(opcode
));
602 case GL_COPY_INVERTED
:
612 case GL_AND_INVERTED
:
617 _mesa_error( ctx
, GL_INVALID_ENUM
, "glLogicOp" );
621 if (ctx
->Color
.LogicOp
== opcode
)
624 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
625 ctx
->Color
.LogicOp
= opcode
;
627 if (ctx
->Driver
.LogicOpcode
)
628 ctx
->Driver
.LogicOpcode( ctx
, opcode
);
633 _mesa_IndexMask( GLuint mask
)
635 GET_CURRENT_CONTEXT(ctx
);
636 ASSERT_OUTSIDE_BEGIN_END(ctx
);
638 if (ctx
->Color
.IndexMask
== mask
)
641 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
642 ctx
->Color
.IndexMask
= mask
;
648 * Enable or disable writing of frame buffer color components.
650 * \param red whether to mask writing of the red color component.
651 * \param green whether to mask writing of the green color component.
652 * \param blue whether to mask writing of the blue color component.
653 * \param alpha whether to mask writing of the alpha color component.
657 * Sets the appropriate value of gl_colorbuffer_attrib::ColorMask. On a
658 * change, flushes the vertices and notifies the driver via the
659 * dd_function_table::ColorMask callback.
662 _mesa_ColorMask( GLboolean red
, GLboolean green
,
663 GLboolean blue
, GLboolean alpha
)
665 GET_CURRENT_CONTEXT(ctx
);
669 ASSERT_OUTSIDE_BEGIN_END(ctx
);
671 if (MESA_VERBOSE
& VERBOSE_API
)
672 _mesa_debug(ctx
, "glColorMask(%d, %d, %d, %d)\n",
673 red
, green
, blue
, alpha
);
675 /* Shouldn't have any information about channel depth in core mesa
676 * -- should probably store these as the native booleans:
678 tmp
[RCOMP
] = red
? 0xff : 0x0;
679 tmp
[GCOMP
] = green
? 0xff : 0x0;
680 tmp
[BCOMP
] = blue
? 0xff : 0x0;
681 tmp
[ACOMP
] = alpha
? 0xff : 0x0;
684 for (i
= 0; i
< ctx
->Const
.MaxDrawBuffers
; i
++) {
685 if (!TEST_EQ_4V(tmp
, ctx
->Color
.ColorMask
[i
])) {
687 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
690 COPY_4UBV(ctx
->Color
.ColorMask
[i
], tmp
);
694 if (ctx
->Driver
.ColorMask
)
695 ctx
->Driver
.ColorMask( ctx
, red
, green
, blue
, alpha
);
700 * For GL_EXT_draw_buffers2 and GL3
703 _mesa_ColorMaskIndexed( GLuint buf
, GLboolean red
, GLboolean green
,
704 GLboolean blue
, GLboolean alpha
)
707 GET_CURRENT_CONTEXT(ctx
);
708 ASSERT_OUTSIDE_BEGIN_END(ctx
);
710 if (MESA_VERBOSE
& VERBOSE_API
)
711 _mesa_debug(ctx
, "glColorMaskIndexed %u %d %d %d %d\n",
712 buf
, red
, green
, blue
, alpha
);
714 if (buf
>= ctx
->Const
.MaxDrawBuffers
) {
715 _mesa_error(ctx
, GL_INVALID_VALUE
, "glColorMaskIndexed(buf=%u)", buf
);
719 /* Shouldn't have any information about channel depth in core mesa
720 * -- should probably store these as the native booleans:
722 tmp
[RCOMP
] = red
? 0xff : 0x0;
723 tmp
[GCOMP
] = green
? 0xff : 0x0;
724 tmp
[BCOMP
] = blue
? 0xff : 0x0;
725 tmp
[ACOMP
] = alpha
? 0xff : 0x0;
727 if (TEST_EQ_4V(tmp
, ctx
->Color
.ColorMask
[buf
]))
730 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
731 COPY_4UBV(ctx
->Color
.ColorMask
[buf
], tmp
);
733 if (ctx
->Driver
.ColorMaskIndexed
)
734 ctx
->Driver
.ColorMaskIndexed(ctx
, buf
, red
, green
, blue
, alpha
);
739 _mesa_ClampColorARB(GLenum target
, GLenum clamp
)
741 GET_CURRENT_CONTEXT(ctx
);
743 ASSERT_OUTSIDE_BEGIN_END(ctx
);
745 if (clamp
!= GL_TRUE
&& clamp
!= GL_FALSE
&& clamp
!= GL_FIXED_ONLY_ARB
) {
746 _mesa_error(ctx
, GL_INVALID_ENUM
, "glClampColorARB(clamp)");
751 case GL_CLAMP_VERTEX_COLOR_ARB
:
752 FLUSH_VERTICES(ctx
, _NEW_LIGHT
);
753 ctx
->Light
.ClampVertexColor
= clamp
;
755 case GL_CLAMP_FRAGMENT_COLOR_ARB
:
756 FLUSH_VERTICES(ctx
, _NEW_FRAG_CLAMP
);
757 ctx
->Color
.ClampFragmentColor
= clamp
;
759 case GL_CLAMP_READ_COLOR_ARB
:
760 FLUSH_VERTICES(ctx
, _NEW_COLOR
);
761 ctx
->Color
.ClampReadColor
= clamp
;
764 _mesa_error(ctx
, GL_INVALID_ENUM
, "glClampColorARB(target)");
772 /**********************************************************************/
773 /** \name Initialization */
777 * Initialization of the context's Color attribute group.
779 * \param ctx GL context.
781 * Initializes the related fields in the context color attribute group,
782 * __struct gl_contextRec::Color.
784 void _mesa_init_color( struct gl_context
* ctx
)
788 /* Color buffer group */
789 ctx
->Color
.IndexMask
= ~0u;
790 memset(ctx
->Color
.ColorMask
, 0xff, sizeof(ctx
->Color
.ColorMask
));
791 ctx
->Color
.ClearIndex
= 0;
792 ASSIGN_4V( ctx
->Color
.ClearColor
.f
, 0, 0, 0, 0 );
793 ctx
->Color
.AlphaEnabled
= GL_FALSE
;
794 ctx
->Color
.AlphaFunc
= GL_ALWAYS
;
795 ctx
->Color
.AlphaRef
= 0;
796 ctx
->Color
.BlendEnabled
= 0x0;
797 for (i
= 0; i
< Elements(ctx
->Color
.Blend
); i
++) {
798 ctx
->Color
.Blend
[i
].SrcRGB
= GL_ONE
;
799 ctx
->Color
.Blend
[i
].DstRGB
= GL_ZERO
;
800 ctx
->Color
.Blend
[i
].SrcA
= GL_ONE
;
801 ctx
->Color
.Blend
[i
].DstA
= GL_ZERO
;
802 ctx
->Color
.Blend
[i
].EquationRGB
= GL_FUNC_ADD
;
803 ctx
->Color
.Blend
[i
].EquationA
= GL_FUNC_ADD
;
805 ASSIGN_4V( ctx
->Color
.BlendColor
, 0.0, 0.0, 0.0, 0.0 );
806 ASSIGN_4V( ctx
->Color
.BlendColorUnclamped
, 0.0, 0.0, 0.0, 0.0 );
807 ctx
->Color
.IndexLogicOpEnabled
= GL_FALSE
;
808 ctx
->Color
.ColorLogicOpEnabled
= GL_FALSE
;
809 ctx
->Color
.LogicOp
= GL_COPY
;
810 ctx
->Color
.DitherFlag
= GL_TRUE
;
812 if (ctx
->Visual
.doubleBufferMode
) {
813 ctx
->Color
.DrawBuffer
[0] = GL_BACK
;
816 ctx
->Color
.DrawBuffer
[0] = GL_FRONT
;
819 ctx
->Color
.ClampFragmentColor
= GL_FIXED_ONLY_ARB
;
820 ctx
->Color
._ClampFragmentColor
= GL_TRUE
;
821 ctx
->Color
.ClampReadColor
= GL_FIXED_ONLY_ARB
;
822 ctx
->Color
._ClampReadColor
= GL_TRUE
;