private void SetAllBlendState(BlendState New) { Enable(EnableCap.Blend, New.Enabled); if (New.Enabled) { if (New.SeparateAlpha) { GL.BlendEquationSeparate( OGLEnumConverter.GetBlendEquation(New.EquationRgb), OGLEnumConverter.GetBlendEquation(New.EquationAlpha)); GL.BlendFuncSeparate( (BlendingFactorSrc)OGLEnumConverter.GetBlendFactor(New.FuncSrcRgb), (BlendingFactorDest)OGLEnumConverter.GetBlendFactor(New.FuncDstRgb), (BlendingFactorSrc)OGLEnumConverter.GetBlendFactor(New.FuncSrcAlpha), (BlendingFactorDest)OGLEnumConverter.GetBlendFactor(New.FuncDstAlpha)); } else { GL.BlendEquation(OGLEnumConverter.GetBlendEquation(New.EquationRgb)); GL.BlendFunc( OGLEnumConverter.GetBlendFactor(New.FuncSrcRgb), OGLEnumConverter.GetBlendFactor(New.FuncDstRgb)); } } }
public void Set( GalBlendEquation Equation, GalBlendFactor FuncSrc, GalBlendFactor FuncDst) { GL.BlendEquation( OGLEnumConverter.GetBlendEquation(Equation)); GL.BlendFunc( OGLEnumConverter.GetBlendFactorSrc(FuncSrc), OGLEnumConverter.GetBlendFactorDst(FuncDst)); }
private void SetBlendState(int Index, BlendState New, BlendState Old) { if (New.Enabled != Old.Enabled) { Enable(IndexedEnableCap.Blend, Index, New.Enabled); } if (New.Enabled) { if (New.SeparateAlpha) { if (New.EquationRgb != Old.EquationRgb || New.EquationAlpha != Old.EquationAlpha) { GL.BlendEquationSeparate( Index, OGLEnumConverter.GetBlendEquation(New.EquationRgb), OGLEnumConverter.GetBlendEquation(New.EquationAlpha)); } if (New.FuncSrcRgb != Old.FuncSrcRgb || New.FuncDstRgb != Old.FuncDstRgb || New.FuncSrcAlpha != Old.FuncSrcAlpha || New.FuncDstAlpha != Old.FuncDstAlpha) { GL.BlendFuncSeparate( Index, (BlendingFactorSrc)OGLEnumConverter.GetBlendFactor(New.FuncSrcRgb), (BlendingFactorDest)OGLEnumConverter.GetBlendFactor(New.FuncDstRgb), (BlendingFactorSrc)OGLEnumConverter.GetBlendFactor(New.FuncSrcAlpha), (BlendingFactorDest)OGLEnumConverter.GetBlendFactor(New.FuncDstAlpha)); } } else { if (New.EquationRgb != Old.EquationRgb) { GL.BlendEquation(Index, OGLEnumConverter.GetBlendEquation(New.EquationRgb)); } if (New.FuncSrcRgb != Old.FuncSrcRgb || New.FuncDstRgb != Old.FuncDstRgb) { GL.BlendFunc( Index, (BlendingFactorSrc)OGLEnumConverter.GetBlendFactor(New.FuncSrcRgb), (BlendingFactorDest)OGLEnumConverter.GetBlendFactor(New.FuncDstRgb)); } } } }
public void SetSeparate( GalBlendEquation EquationRgb, GalBlendEquation EquationAlpha, GalBlendFactor FuncSrcRgb, GalBlendFactor FuncDstRgb, GalBlendFactor FuncSrcAlpha, GalBlendFactor FuncDstAlpha) { GL.BlendEquationSeparate( OGLEnumConverter.GetBlendEquation(EquationRgb), OGLEnumConverter.GetBlendEquation(EquationAlpha)); GL.BlendFuncSeparate( OGLEnumConverter.GetBlendFactorSrc(FuncSrcRgb), OGLEnumConverter.GetBlendFactorDst(FuncDstRgb), OGLEnumConverter.GetBlendFactorSrc(FuncSrcAlpha), OGLEnumConverter.GetBlendFactorDst(FuncDstAlpha)); }
public void Bind(GalPipelineState New) { BindConstBuffers(New); BindVertexLayout(New); if (New.FlipX != Old.FlipX || New.FlipY != Old.FlipY) { Shader.SetFlip(New.FlipX, New.FlipY); } //Note: Uncomment SetFrontFace and SetCullFace when flipping issues are solved //if (New.FrontFace != O.FrontFace) //{ // GL.FrontFace(OGLEnumConverter.GetFrontFace(New.FrontFace)); //} //if (New.CullFaceEnabled != O.CullFaceEnabled) //{ // Enable(EnableCap.CullFace, New.CullFaceEnabled); //} //if (New.CullFaceEnabled) //{ // if (New.CullFace != O.CullFace) // { // GL.CullFace(OGLEnumConverter.GetCullFace(New.CullFace)); // } //} if (New.DepthTestEnabled != Old.DepthTestEnabled) { Enable(EnableCap.DepthTest, New.DepthTestEnabled); } if (New.DepthTestEnabled) { if (New.DepthFunc != Old.DepthFunc) { GL.DepthFunc(OGLEnumConverter.GetDepthFunc(New.DepthFunc)); } } if (New.StencilTestEnabled != Old.StencilTestEnabled) { Enable(EnableCap.StencilTest, New.StencilTestEnabled); } if (New.StencilTestEnabled) { if (New.StencilBackFuncFunc != Old.StencilBackFuncFunc || New.StencilBackFuncRef != Old.StencilBackFuncRef || New.StencilBackFuncMask != Old.StencilBackFuncMask) { GL.StencilFuncSeparate( StencilFace.Back, OGLEnumConverter.GetStencilFunc(New.StencilBackFuncFunc), New.StencilBackFuncRef, New.StencilBackFuncMask); } if (New.StencilBackOpFail != Old.StencilBackOpFail || New.StencilBackOpZFail != Old.StencilBackOpZFail || New.StencilBackOpZPass != Old.StencilBackOpZPass) { GL.StencilOpSeparate( StencilFace.Back, OGLEnumConverter.GetStencilOp(New.StencilBackOpFail), OGLEnumConverter.GetStencilOp(New.StencilBackOpZFail), OGLEnumConverter.GetStencilOp(New.StencilBackOpZPass)); } if (New.StencilBackMask != Old.StencilBackMask) { GL.StencilMaskSeparate(StencilFace.Back, New.StencilBackMask); } if (New.StencilFrontFuncFunc != Old.StencilFrontFuncFunc || New.StencilFrontFuncRef != Old.StencilFrontFuncRef || New.StencilFrontFuncMask != Old.StencilFrontFuncMask) { GL.StencilFuncSeparate( StencilFace.Front, OGLEnumConverter.GetStencilFunc(New.StencilFrontFuncFunc), New.StencilFrontFuncRef, New.StencilFrontFuncMask); } if (New.StencilFrontOpFail != Old.StencilFrontOpFail || New.StencilFrontOpZFail != Old.StencilFrontOpZFail || New.StencilFrontOpZPass != Old.StencilFrontOpZPass) { GL.StencilOpSeparate( StencilFace.Front, OGLEnumConverter.GetStencilOp(New.StencilFrontOpFail), OGLEnumConverter.GetStencilOp(New.StencilFrontOpZFail), OGLEnumConverter.GetStencilOp(New.StencilFrontOpZPass)); } if (New.StencilFrontMask != Old.StencilFrontMask) { GL.StencilMaskSeparate(StencilFace.Front, New.StencilFrontMask); } } if (New.BlendEnabled != Old.BlendEnabled) { Enable(EnableCap.Blend, New.BlendEnabled); } if (New.BlendEnabled) { if (New.BlendSeparateAlpha) { if (New.BlendEquationRgb != Old.BlendEquationRgb || New.BlendEquationAlpha != Old.BlendEquationAlpha) { GL.BlendEquationSeparate( OGLEnumConverter.GetBlendEquation(New.BlendEquationRgb), OGLEnumConverter.GetBlendEquation(New.BlendEquationAlpha)); } if (New.BlendFuncSrcRgb != Old.BlendFuncSrcRgb || New.BlendFuncDstRgb != Old.BlendFuncDstRgb || New.BlendFuncSrcAlpha != Old.BlendFuncSrcAlpha || New.BlendFuncDstAlpha != Old.BlendFuncDstAlpha) { GL.BlendFuncSeparate( (BlendingFactorSrc)OGLEnumConverter.GetBlendFactor(New.BlendFuncSrcRgb), (BlendingFactorDest)OGLEnumConverter.GetBlendFactor(New.BlendFuncDstRgb), (BlendingFactorSrc)OGLEnumConverter.GetBlendFactor(New.BlendFuncSrcAlpha), (BlendingFactorDest)OGLEnumConverter.GetBlendFactor(New.BlendFuncDstAlpha)); } } else { if (New.BlendEquationRgb != Old.BlendEquationRgb) { GL.BlendEquation(OGLEnumConverter.GetBlendEquation(New.BlendEquationRgb)); } if (New.BlendFuncSrcRgb != Old.BlendFuncSrcRgb || New.BlendFuncDstRgb != Old.BlendFuncDstRgb) { GL.BlendFunc( OGLEnumConverter.GetBlendFactor(New.BlendFuncSrcRgb), OGLEnumConverter.GetBlendFactor(New.BlendFuncDstRgb)); } } } if (New.PrimitiveRestartEnabled != Old.PrimitiveRestartEnabled) { Enable(EnableCap.PrimitiveRestart, New.PrimitiveRestartEnabled); } if (New.PrimitiveRestartEnabled) { if (New.PrimitiveRestartIndex != Old.PrimitiveRestartIndex) { GL.PrimitiveRestartIndex(New.PrimitiveRestartIndex); } } Old = New; }
public void Bind(GalPipelineState New) { BindConstBuffers(New); BindVertexLayout(New); if (New.FramebufferSrgb != Old.FramebufferSrgb) { Enable(EnableCap.FramebufferSrgb, New.FramebufferSrgb); } if (New.FlipX != Old.FlipX || New.FlipY != Old.FlipY || New.Instance != Old.Instance) { Shader.SetExtraData(New.FlipX, New.FlipY, New.Instance); } //Note: Uncomment SetFrontFace and SetCullFace when flipping issues are solved //if (New.FrontFace != Old.FrontFace) //{ // GL.FrontFace(OGLEnumConverter.GetFrontFace(New.FrontFace)); //} //if (New.CullFaceEnabled != Old.CullFaceEnabled) //{ // Enable(EnableCap.CullFace, New.CullFaceEnabled); //} //if (New.CullFaceEnabled) //{ // if (New.CullFace != Old.CullFace) // { // GL.CullFace(OGLEnumConverter.GetCullFace(New.CullFace)); // } //} if (New.DepthTestEnabled != Old.DepthTestEnabled) { Enable(EnableCap.DepthTest, New.DepthTestEnabled); } if (New.DepthWriteEnabled != Old.DepthWriteEnabled) { GL.DepthMask(New.DepthWriteEnabled); } if (New.DepthTestEnabled) { if (New.DepthFunc != Old.DepthFunc) { GL.DepthFunc(OGLEnumConverter.GetDepthFunc(New.DepthFunc)); } } if (New.DepthRangeNear != Old.DepthRangeNear || New.DepthRangeFar != Old.DepthRangeFar) { GL.DepthRange(New.DepthRangeNear, New.DepthRangeFar); } if (New.StencilTestEnabled != Old.StencilTestEnabled) { Enable(EnableCap.StencilTest, New.StencilTestEnabled); } if (New.StencilTwoSideEnabled != Old.StencilTwoSideEnabled) { Enable((EnableCap)All.StencilTestTwoSideExt, New.StencilTwoSideEnabled); } if (New.StencilTestEnabled) { if (New.StencilBackFuncFunc != Old.StencilBackFuncFunc || New.StencilBackFuncRef != Old.StencilBackFuncRef || New.StencilBackFuncMask != Old.StencilBackFuncMask) { GL.StencilFuncSeparate( StencilFace.Back, OGLEnumConverter.GetStencilFunc(New.StencilBackFuncFunc), New.StencilBackFuncRef, New.StencilBackFuncMask); } if (New.StencilBackOpFail != Old.StencilBackOpFail || New.StencilBackOpZFail != Old.StencilBackOpZFail || New.StencilBackOpZPass != Old.StencilBackOpZPass) { GL.StencilOpSeparate( StencilFace.Back, OGLEnumConverter.GetStencilOp(New.StencilBackOpFail), OGLEnumConverter.GetStencilOp(New.StencilBackOpZFail), OGLEnumConverter.GetStencilOp(New.StencilBackOpZPass)); } if (New.StencilBackMask != Old.StencilBackMask) { GL.StencilMaskSeparate(StencilFace.Back, New.StencilBackMask); } if (New.StencilFrontFuncFunc != Old.StencilFrontFuncFunc || New.StencilFrontFuncRef != Old.StencilFrontFuncRef || New.StencilFrontFuncMask != Old.StencilFrontFuncMask) { GL.StencilFuncSeparate( StencilFace.Front, OGLEnumConverter.GetStencilFunc(New.StencilFrontFuncFunc), New.StencilFrontFuncRef, New.StencilFrontFuncMask); } if (New.StencilFrontOpFail != Old.StencilFrontOpFail || New.StencilFrontOpZFail != Old.StencilFrontOpZFail || New.StencilFrontOpZPass != Old.StencilFrontOpZPass) { GL.StencilOpSeparate( StencilFace.Front, OGLEnumConverter.GetStencilOp(New.StencilFrontOpFail), OGLEnumConverter.GetStencilOp(New.StencilFrontOpZFail), OGLEnumConverter.GetStencilOp(New.StencilFrontOpZPass)); } if (New.StencilFrontMask != Old.StencilFrontMask) { GL.StencilMaskSeparate(StencilFace.Front, New.StencilFrontMask); } } if (New.BlendEnabled != Old.BlendEnabled) { Enable(EnableCap.Blend, New.BlendEnabled); } if (New.BlendEnabled) { if (New.BlendSeparateAlpha) { if (New.BlendEquationRgb != Old.BlendEquationRgb || New.BlendEquationAlpha != Old.BlendEquationAlpha) { GL.BlendEquationSeparate( OGLEnumConverter.GetBlendEquation(New.BlendEquationRgb), OGLEnumConverter.GetBlendEquation(New.BlendEquationAlpha)); } if (New.BlendFuncSrcRgb != Old.BlendFuncSrcRgb || New.BlendFuncDstRgb != Old.BlendFuncDstRgb || New.BlendFuncSrcAlpha != Old.BlendFuncSrcAlpha || New.BlendFuncDstAlpha != Old.BlendFuncDstAlpha) { GL.BlendFuncSeparate( (BlendingFactorSrc)OGLEnumConverter.GetBlendFactor(New.BlendFuncSrcRgb), (BlendingFactorDest)OGLEnumConverter.GetBlendFactor(New.BlendFuncDstRgb), (BlendingFactorSrc)OGLEnumConverter.GetBlendFactor(New.BlendFuncSrcAlpha), (BlendingFactorDest)OGLEnumConverter.GetBlendFactor(New.BlendFuncDstAlpha)); } } else { if (New.BlendEquationRgb != Old.BlendEquationRgb) { GL.BlendEquation(OGLEnumConverter.GetBlendEquation(New.BlendEquationRgb)); } if (New.BlendFuncSrcRgb != Old.BlendFuncSrcRgb || New.BlendFuncDstRgb != Old.BlendFuncDstRgb) { GL.BlendFunc( OGLEnumConverter.GetBlendFactor(New.BlendFuncSrcRgb), OGLEnumConverter.GetBlendFactor(New.BlendFuncDstRgb)); } } } if (New.ColorMaskCommon) { if (New.ColorMaskCommon != Old.ColorMaskCommon || !New.ColorMasks[0].Equals(Old.ColorMasks[0])) { GL.ColorMask( New.ColorMasks[0].Red, New.ColorMasks[0].Green, New.ColorMasks[0].Blue, New.ColorMasks[0].Alpha); } } else { for (int Index = 0; Index < GalPipelineState.RenderTargetsCount; Index++) { if (!New.ColorMasks[Index].Equals(Old.ColorMasks[Index])) { GL.ColorMask( Index, New.ColorMasks[Index].Red, New.ColorMasks[Index].Green, New.ColorMasks[Index].Blue, New.ColorMasks[Index].Alpha); } } } if (New.PrimitiveRestartEnabled != Old.PrimitiveRestartEnabled) { Enable(EnableCap.PrimitiveRestart, New.PrimitiveRestartEnabled); } if (New.PrimitiveRestartEnabled) { if (New.PrimitiveRestartIndex != Old.PrimitiveRestartIndex) { GL.PrimitiveRestartIndex(New.PrimitiveRestartIndex); } } Old = New; }