From 7e7c6586948e4ce1eacce20f70b73fcd31d50e32 Mon Sep 17 00:00:00 2001 From: Jose Antonio Leal de Farias Date: Thu, 24 Jan 2013 23:17:05 -0300 Subject: [PATCH] Fix bug using several blend modes at same time on PSVITA. --- MonoGame.Framework/Graphics/GraphicsDevice.cs | 1 - MonoGame.Framework/Graphics/SpriteBatch.cs | 6 +++++- MonoGame.Framework/Graphics/States/BlendState.cs | 7 +++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/MonoGame.Framework/Graphics/GraphicsDevice.cs b/MonoGame.Framework/Graphics/GraphicsDevice.cs index 2854da809c7..5945eba97e9 100644 --- a/MonoGame.Framework/Graphics/GraphicsDevice.cs +++ b/MonoGame.Framework/Graphics/GraphicsDevice.cs @@ -1094,7 +1094,6 @@ public void Clear(ClearOptions options, Vector4 color, float depth, int stencil) _graphics.SetClearColor(color.ToPssVector4()); _graphics.Clear(); - ApplyState(false); #elif OPENGL // Unlike with XNA and DirectX... GL.Clear() obeys several diff --git a/MonoGame.Framework/Graphics/SpriteBatch.cs b/MonoGame.Framework/Graphics/SpriteBatch.cs index a83aca839e1..e7ba85e48cd 100644 --- a/MonoGame.Framework/Graphics/SpriteBatch.cs +++ b/MonoGame.Framework/Graphics/SpriteBatch.cs @@ -87,7 +87,11 @@ public void End () if (_sortMode != SpriteSortMode.Immediate) Setup(); - +#if PSM + GraphicsDevice.BlendState = _blendState; + _blendState.ApplyState(GraphicsDevice); +#endif + _batcher.DrawBatch(_sortMode); } diff --git a/MonoGame.Framework/Graphics/States/BlendState.cs b/MonoGame.Framework/Graphics/States/BlendState.cs index e0e3b490b8d..f14c26160c9 100644 --- a/MonoGame.Framework/Graphics/States/BlendState.cs +++ b/MonoGame.Framework/Graphics/States/BlendState.cs @@ -323,24 +323,27 @@ static private SharpDX.Direct3D11.ColorWriteMaskFlags GetColorWriteMask(ColorWri #if PSM internal void ApplyState(GraphicsDevice device) { -#warning its a simplistic implementation..i am not sure about this equivalence - device._graphics.Enable(EnableMode.Blend); if (device.BlendState == BlendState.Additive) { + device._graphics.Enable(EnableMode.Blend); device._graphics.SetBlendFunc(BlendFuncMode.Add, BlendFuncFactor.One, BlendFuncFactor.One); } else if (device.BlendState == BlendState.AlphaBlend) { + device._graphics.Enable(EnableMode.Blend); device._graphics.SetBlendFunc(BlendFuncMode.Add, BlendFuncFactor.SrcAlpha, BlendFuncFactor.OneMinusSrcAlpha); } else if (device.BlendState == BlendState.NonPremultiplied) { + device._graphics.Enable(EnableMode.Blend); device._graphics.SetBlendFunc(BlendFuncMode.Add, BlendFuncFactor.SrcColor, BlendFuncFactor.OneMinusSrcColor); } else if (device.BlendState == BlendState.Opaque) { + device._graphics.Enable(EnableMode.Blend); device._graphics.SetBlendFunc(BlendFuncMode.Add, BlendFuncFactor.One, BlendFuncFactor.Zero); } + else device._graphics.Disable(EnableMode.Blend); } #endif }