Lines Matching refs:ctx
46 legal_src_factor(const struct gl_context *ctx, GLenum factor)
51 return ctx->Extensions.NV_blend_square;
66 return _mesa_is_desktop_gl(ctx) || ctx->API == API_OPENGLES2;
71 return _mesa_is_desktop_gl(ctx)
72 && ctx->Extensions.ARB_blend_func_extended;
84 legal_dst_factor(const struct gl_context *ctx, GLenum factor)
89 return ctx->Extensions.NV_blend_square;
103 return _mesa_is_desktop_gl(ctx) || ctx->API == API_OPENGLES2;
105 return (_mesa_is_desktop_gl(ctx)
106 && ctx->Extensions.ARB_blend_func_extended)
107 || _mesa_is_gles3(ctx);
112 return _mesa_is_desktop_gl(ctx)
113 && ctx->Extensions.ARB_blend_func_extended;
126 validate_blend_factors(struct gl_context *ctx, const char *func,
130 if (!legal_src_factor(ctx, sfactorRGB)) {
131 _mesa_error(ctx, GL_INVALID_ENUM,
137 if (!legal_dst_factor(ctx, dfactorRGB)) {
138 _mesa_error(ctx, GL_INVALID_ENUM,
144 if (sfactorA != sfactorRGB && !legal_src_factor(ctx, sfactorA)) {
145 _mesa_error(ctx, GL_INVALID_ENUM,
151 if (dfactorA != dfactorRGB && !legal_dst_factor(ctx, dfactorA)) {
152 _mesa_error(ctx, GL_INVALID_ENUM,
186 update_uses_dual_src(struct gl_context *ctx, int buf)
188 ctx->Color.Blend[buf]._UsesDualSrc =
189 (blend_factor_is_dual_src(ctx->Color.Blend[buf].SrcRGB) ||
190 blend_factor_is_dual_src(ctx->Color.Blend[buf].DstRGB) ||
191 blend_factor_is_dual_src(ctx->Color.Blend[buf].SrcA) ||
192 blend_factor_is_dual_src(ctx->Color.Blend[buf].DstA));
209 GET_CURRENT_CONTEXT(ctx);
210 ASSERT_OUTSIDE_BEGIN_END(ctx);
213 _mesa_debug(ctx, "glBlendFuncSeparate %s %s %s %s\n",
219 if (!validate_blend_factors(ctx, "glBlendFuncSeparate",
225 numBuffers = ctx->Extensions.ARB_draw_buffers_blend
226 ? ctx->Const.MaxDrawBuffers : 1;
230 if (ctx->Color.Blend[buf].SrcRGB != sfactorRGB ||
231 ctx->Color.Blend[buf].DstRGB != dfactorRGB ||
232 ctx->Color.Blend[buf].SrcA != sfactorA ||
233 ctx->Color.Blend[buf].DstA != dfactorA) {
241 FLUSH_VERTICES(ctx, _NEW_COLOR);
244 ctx->Color.Blend[buf].SrcRGB = sfactorRGB;
245 ctx->Color.Blend[buf].DstRGB = dfactorRGB;
246 ctx->Color.Blend[buf].SrcA = sfactorA;
247 ctx->Color.Blend[buf].DstA = dfactorA;
248 update_uses_dual_src(ctx, buf);
250 ctx->Color._BlendFuncPerBuffer = GL_FALSE;
252 if (ctx->Driver.BlendFuncSeparate) {
253 ctx->Driver.BlendFuncSeparate(ctx, sfactorRGB, dfactorRGB,
279 GET_CURRENT_CONTEXT(ctx);
280 ASSERT_OUTSIDE_BEGIN_END(ctx);
282 if (!ctx->Extensions.ARB_draw_buffers_blend) {
283 _mesa_error(ctx, GL_INVALID_OPERATION, "glBlendFunc[Separate]i()");
287 if (buf >= ctx->Const.MaxDrawBuffers) {
288 _mesa_error(ctx, GL_INVALID_VALUE, "glBlendFuncSeparatei(buffer=%u)",
293 if (!validate_blend_factors(ctx, "glBlendFuncSeparatei",
299 if (ctx->Color.Blend[buf].SrcRGB == sfactorRGB &&
300 ctx->Color.Blend[buf].DstRGB == dfactorRGB &&
301 ctx->Color.Blend[buf].SrcA == sfactorA &&
302 ctx->Color.Blend[buf].DstA == dfactorA)
305 FLUSH_VERTICES(ctx, _NEW_COLOR);
307 ctx->Color.Blend[buf].SrcRGB = sfactorRGB;
308 ctx->Color.Blend[buf].DstRGB = dfactorRGB;
309 ctx->Color.Blend[buf].SrcA = sfactorA;
310 ctx->Color.Blend[buf].DstA = dfactorA;
311 update_uses_dual_src(ctx, buf);
312 ctx->Color._BlendFuncPerBuffer = GL_TRUE;
314 if (ctx->Driver.BlendFuncSeparatei) {
315 ctx->Driver.BlendFuncSeparatei(ctx, buf, sfactorRGB, dfactorRGB,
326 legal_blend_equation(const struct gl_context *ctx, GLenum mode)
335 return ctx->Extensions.EXT_blend_minmax;
348 GET_CURRENT_CONTEXT(ctx);
349 ASSERT_OUTSIDE_BEGIN_END(ctx);
352 _mesa_debug(ctx, "glBlendEquation(%s)\n",
355 if (!legal_blend_equation(ctx, mode)) {
356 _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquation");
360 numBuffers = ctx->Extensions.ARB_draw_buffers_blend
361 ? ctx->Const.MaxDrawBuffers : 1;
365 if (ctx->Color.Blend[buf].EquationRGB != mode ||
366 ctx->Color.Blend[buf].EquationA != mode) {
374 FLUSH_VERTICES(ctx, _NEW_COLOR);
376 ctx->Color.Blend[buf].EquationRGB = mode;
377 ctx->Color.Blend[buf].EquationA = mode;
379 ctx->Color._BlendEquationPerBuffer = GL_FALSE;
381 if (ctx->Driver.BlendEquationSeparate)
382 (*ctx->Driver.BlendEquationSeparate)( ctx, mode, mode );
392 GET_CURRENT_CONTEXT(ctx);
393 ASSERT_OUTSIDE_BEGIN_END(ctx);
396 _mesa_debug(ctx, "glBlendEquationi(%u, %s)\n",
399 if (buf >= ctx->Const.MaxDrawBuffers) {
400 _mesa_error(ctx, GL_INVALID_VALUE, "glBlendFuncSeparatei(buffer=%u)",
405 if (!legal_blend_equation(ctx, mode)) {
406 _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquationi");
410 if (ctx->Color.Blend[buf].EquationRGB == mode &&
411 ctx->Color.Blend[buf].EquationA == mode)
414 FLUSH_VERTICES(ctx, _NEW_COLOR);
415 ctx->Color.Blend[buf].EquationRGB = mode;
416 ctx->Color.Blend[buf].EquationA = mode;
417 ctx->Color._BlendEquationPerBuffer = GL_TRUE;
419 if (ctx->Driver.BlendEquationSeparatei)
420 ctx->Driver.BlendEquationSeparatei(ctx, buf, mode, mode);
429 GET_CURRENT_CONTEXT(ctx);
430 ASSERT_OUTSIDE_BEGIN_END(ctx);
433 _mesa_debug(ctx, "glBlendEquationSeparateEXT(%s %s)\n",
437 if ( (modeRGB != modeA) && !ctx->Extensions.EXT_blend_equation_separate ) {
438 _mesa_error(ctx, GL_INVALID_OPERATION,
443 if (!legal_blend_equation(ctx, modeRGB)) {
444 _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquationSeparateEXT(modeRGB)");
448 if (!legal_blend_equation(ctx, modeA)) {
449 _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquationSeparateEXT(modeA)");
453 numBuffers = ctx->Extensions.ARB_draw_buffers_blend
454 ? ctx->Const.MaxDrawBuffers : 1;
458 if (ctx->Color.Blend[buf].EquationRGB != modeRGB ||
459 ctx->Color.Blend[buf].EquationA != modeA) {
467 FLUSH_VERTICES(ctx, _NEW_COLOR);
469 ctx->Color.Blend[buf].EquationRGB = modeRGB;
470 ctx->Color.Blend[buf].EquationA = modeA;
472 ctx->Color._BlendEquationPerBuffer = GL_FALSE;
474 if (ctx->Driver.BlendEquationSeparate)
475 ctx->Driver.BlendEquationSeparate(ctx, modeRGB, modeA);
485 GET_CURRENT_CONTEXT(ctx);
486 ASSERT_OUTSIDE_BEGIN_END(ctx);
489 _mesa_debug(ctx, "glBlendEquationSeparatei(%u, %s %s)\n", buf,
493 if (buf >= ctx->Const.MaxDrawBuffers) {
494 _mesa_error(ctx, GL_INVALID_VALUE, "glBlendEquationSeparatei(buffer=%u)",
499 if (!legal_blend_equation(ctx, modeRGB)) {
500 _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquationSeparatei(modeRGB)");
504 if (!legal_blend_equation(ctx, modeA)) {
505 _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquationSeparatei(modeA)");
509 if (ctx->Color.Blend[buf].EquationRGB == modeRGB &&
510 ctx->Color.Blend[buf].EquationA == modeA)
513 FLUSH_VERTICES(ctx, _NEW_COLOR);
514 ctx->Color.Blend[buf].EquationRGB = modeRGB;
515 ctx->Color.Blend[buf].EquationA = modeA;
516 ctx->Color._BlendEquationPerBuffer = GL_TRUE;
518 if (ctx->Driver.BlendEquationSeparatei)
519 ctx->Driver.BlendEquationSeparatei(ctx, buf, modeRGB, modeA);
545 GET_CURRENT_CONTEXT(ctx);
546 ASSERT_OUTSIDE_BEGIN_END(ctx);
553 if (TEST_EQ_4V(tmp, ctx->Color.BlendColorUnclamped))
556 FLUSH_VERTICES(ctx, _NEW_COLOR);
557 COPY_4FV( ctx->Color.BlendColorUnclamped, tmp );
559 ctx->Color.BlendColor[0] = CLAMP(tmp[0], 0.0F, 1.0F);
560 ctx->Color.BlendColor[1] = CLAMP(tmp[1], 0.0F, 1.0F);
561 ctx->Color.BlendColor[2] = CLAMP(tmp[2], 0.0F, 1.0F);
562 ctx->Color.BlendColor[3] = CLAMP(tmp[3], 0.0F, 1.0F);
564 if (ctx->Driver.BlendColor)
565 (*ctx->Driver.BlendColor)(ctx, ctx->Color.BlendColor);
582 GET_CURRENT_CONTEXT(ctx);
583 ASSERT_OUTSIDE_BEGIN_END(ctx);
586 _mesa_debug(ctx, "glAlphaFunc(%s, %f)\n",
598 if (ctx->Color.AlphaFunc == func && ctx->Color.AlphaRefUnclamped == ref)
601 FLUSH_VERTICES(ctx, _NEW_COLOR);
602 ctx->Color.AlphaFunc = func;
603 ctx->Color.AlphaRefUnclamped = ref;
604 ctx->Color.AlphaRef = CLAMP(ref, 0.0F, 1.0F);
606 if (ctx->Driver.AlphaFunc)
607 ctx->Driver.AlphaFunc(ctx, func, ctx->Color.AlphaRef);
611 _mesa_error( ctx, GL_INVALID_ENUM, "glAlphaFunc(func)" );
630 GET_CURRENT_CONTEXT(ctx);
631 ASSERT_OUTSIDE_BEGIN_END(ctx);
634 _mesa_debug(ctx, "glLogicOp(%s)\n", _mesa_lookup_enum_by_nr(opcode));
655 _mesa_error( ctx, GL_INVALID_ENUM, "glLogicOp" );
659 if (ctx->Color.LogicOp == opcode)
662 FLUSH_VERTICES(ctx, _NEW_COLOR);
663 ctx->Color.LogicOp = opcode;
665 if (ctx->Driver.LogicOpcode)
666 ctx->Driver.LogicOpcode( ctx, opcode );
673 GET_CURRENT_CONTEXT(ctx);
674 ASSERT_OUTSIDE_BEGIN_END(ctx);
676 if (ctx->Color.IndexMask == mask)
679 FLUSH_VERTICES(ctx, _NEW_COLOR);
680 ctx->Color.IndexMask = mask;
703 GET_CURRENT_CONTEXT(ctx);
707 ASSERT_OUTSIDE_BEGIN_END(ctx);
710 _mesa_debug(ctx, "glColorMask(%d, %d, %d, %d)\n",
722 for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
723 if (!TEST_EQ_4V(tmp, ctx->Color.ColorMask[i])) {
725 FLUSH_VERTICES(ctx, _NEW_COLOR);
728 COPY_4UBV(ctx->Color.ColorMask[i], tmp);
732 if (ctx->Driver.ColorMask)
733 ctx->Driver.ColorMask( ctx, red, green, blue, alpha );
745 GET_CURRENT_CONTEXT(ctx);
746 ASSERT_OUTSIDE_BEGIN_END(ctx);
749 _mesa_debug(ctx, "glColorMaskIndexed %u %d %d %d %d\n",
752 if (buf >= ctx->Const.MaxDrawBuffers) {
753 _mesa_error(ctx, GL_INVALID_VALUE, "glColorMaskIndexed(buf=%u)", buf);
765 if (TEST_EQ_4V(tmp, ctx->Color.ColorMask[buf]))
768 FLUSH_VERTICES(ctx, _NEW_COLOR);
769 COPY_4UBV(ctx->Color.ColorMask[buf], tmp);
771 if (ctx->Driver.ColorMaskIndexed)
772 ctx->Driver.ColorMaskIndexed(ctx, buf, red, green, blue, alpha);
779 GET_CURRENT_CONTEXT(ctx);
781 ASSERT_OUTSIDE_BEGIN_END(ctx);
784 _mesa_error(ctx, GL_INVALID_ENUM, "glClampColorARB(clamp)");
790 FLUSH_VERTICES(ctx, _NEW_LIGHT);
791 ctx->Light.ClampVertexColor = clamp;
794 FLUSH_VERTICES(ctx, _NEW_FRAG_CLAMP);
795 ctx->Color.ClampFragmentColor = clamp;
798 FLUSH_VERTICES(ctx, _NEW_COLOR);
799 ctx->Color.ClampReadColor = clamp;
802 _mesa_error(ctx, GL_INVALID_ENUM, "glClampColorARB(target)");
817 * \param ctx GL context.
822 void _mesa_init_color( struct gl_context * ctx )
827 ctx->Color.IndexMask = ~0u;
828 memset(ctx->Color.ColorMask, 0xff, sizeof(ctx->Color.ColorMask));
829 ctx->Color.ClearIndex = 0;
830 ASSIGN_4V( ctx->Color.ClearColor.f, 0, 0, 0, 0 );
831 ctx->Color.AlphaEnabled = GL_FALSE;
832 ctx->Color.AlphaFunc = GL_ALWAYS;
833 ctx->Color.AlphaRef = 0;
834 ctx->Color.BlendEnabled = 0x0;
835 for (i = 0; i < Elements(ctx->Color.Blend); i++) {
836 ctx->Color.Blend[i].SrcRGB = GL_ONE;
837 ctx->Color.Blend[i].DstRGB = GL_ZERO;
838 ctx->Color.Blend[i].SrcA = GL_ONE;
839 ctx->Color.Blend[i].DstA = GL_ZERO;
840 ctx->Color.Blend[i].EquationRGB = GL_FUNC_ADD;
841 ctx->Color.Blend[i].EquationA = GL_FUNC_ADD;
843 ASSIGN_4V( ctx->Color.BlendColor, 0.0, 0.0, 0.0, 0.0 );
844 ASSIGN_4V( ctx->Color.BlendColorUnclamped, 0.0, 0.0, 0.0, 0.0 );
845 ctx->Color.IndexLogicOpEnabled = GL_FALSE;
846 ctx->Color.ColorLogicOpEnabled = GL_FALSE;
847 ctx->Color.LogicOp = GL_COPY;
848 ctx->Color.DitherFlag = GL_TRUE;
850 if (ctx->Visual.doubleBufferMode) {
851 ctx->Color.DrawBuffer[0] = GL_BACK;
854 ctx->Color.DrawBuffer[0] = GL_FRONT;
857 ctx->Color.ClampFragmentColor = GL_FIXED_ONLY_ARB;
858 ctx->Color._ClampFragmentColor = GL_TRUE;
859 ctx->Color.ClampReadColor = GL_FIXED_ONLY_ARB;
860 ctx->Color._ClampReadColor = GL_TRUE;