private void BindBlendState(bool force) { blendStateDirty |= force; if (!blendStateDirty) { return; } if (force || blendState.Enable != boundBlendState.Enable) { if (blendState.Enable) { GL.Enable(EnableCap.Blend); GLHelper.CheckGLErrors(); } else { GL.Disable(EnableCap.Blend); GLHelper.CheckGLErrors(); } boundBlendState.Enable = blendState.Enable; } if (force || blendState.Enable) { if (force || blendState.ColorBlendFunc != boundBlendState.ColorBlendFunc || blendState.AlphaBlendFunc != boundBlendState.AlphaBlendFunc ) { GL.BlendEquationSeparate( (BlendEquationMode)GLHelper.GetGLBlendEquationMode(blendState.ColorBlendFunc), (BlendEquationMode)GLHelper.GetGLBlendEquationMode(blendState.AlphaBlendFunc)); GLHelper.CheckGLErrors(); boundBlendState.ColorBlendFunc = blendState.ColorBlendFunc; boundBlendState.AlphaBlendFunc = blendState.AlphaBlendFunc; } if (force || blendState.ColorSrcBlend != boundBlendState.ColorSrcBlend || blendState.ColorDstBlend != boundBlendState.ColorDstBlend || blendState.AlphaSrcBlend != boundBlendState.AlphaSrcBlend || blendState.AlphaDstBlend != boundBlendState.AlphaDstBlend ) { GL.BlendFuncSeparate( (BlendingFactorSrc)GLHelper.GetGLBlendFactor(blendState.ColorSrcBlend), (BlendingFactorDest)GLHelper.GetGLBlendFactor(blendState.ColorDstBlend), (BlendingFactorSrc)GLHelper.GetGLBlendFactor(blendState.AlphaSrcBlend), (BlendingFactorDest)GLHelper.GetGLBlendFactor(blendState.AlphaDstBlend)); GLHelper.CheckGLErrors(); boundBlendState.ColorSrcBlend = blendState.ColorSrcBlend; boundBlendState.ColorDstBlend = blendState.ColorDstBlend; boundBlendState.AlphaSrcBlend = blendState.AlphaSrcBlend; boundBlendState.AlphaDstBlend = blendState.AlphaDstBlend; } if (force || blendState.BlendFactor != boundBlendState.BlendFactor) { GL.BlendColor( blendState.BlendFactor.R / 255f, blendState.BlendFactor.G / 255f, blendState.BlendFactor.B / 255f, blendState.BlendFactor.A / 255f); GLHelper.CheckGLErrors(); boundBlendState.BlendFactor = blendState.BlendFactor; } } blendStateDirty = false; }