Skip to content

Commit

Permalink
Merge pull request #1230 from jalf/develop3d
Browse files Browse the repository at this point in the history
FIX: Using several BlendModes in PSVita
  • Loading branch information
tomspilman committed Jan 25, 2013
2 parents 56a442f + 4dcea6e commit 2fe2dbc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 0 additions & 1 deletion MonoGame.Framework/Graphics/GraphicsDevice.cs
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion MonoGame.Framework/Graphics/SpriteBatch.cs
Expand Up @@ -87,7 +87,11 @@ public void End ()

if (_sortMode != SpriteSortMode.Immediate)
Setup();

#if PSM
GraphicsDevice.BlendState = _blendState;
_blendState.ApplyState(GraphicsDevice);
#endif

_batcher.DrawBatch(_sortMode);
}

Expand Down
7 changes: 5 additions & 2 deletions MonoGame.Framework/Graphics/States/BlendState.cs
Expand Up @@ -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
}
Expand Down

0 comments on commit 2fe2dbc

Please sign in to comment.