Skip to content

Commit

Permalink
Fix render mode in SpriteBatch. 2D render is now working.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose Antonio Leal de Farias committed Jan 24, 2013
1 parent f2d37fa commit 266937f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion MonoGame.Framework/Graphics/GraphicsDevice.cs
Expand Up @@ -1094,7 +1094,7 @@ 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
19 changes: 18 additions & 1 deletion MonoGame.Framework/Graphics/States/BlendState.cs
Expand Up @@ -323,7 +323,24 @@ static private SharpDX.Direct3D11.ColorWriteMaskFlags GetColorWriteMask(ColorWri
#if PSM
internal void ApplyState(GraphicsDevice device)
{
#warning Unimplemented
#warning its a simplistic implementation..i am not sure about this equivalence
device._graphics.Enable(EnableMode.Blend);
if (device.BlendState == BlendState.Additive)
{
device._graphics.SetBlendFunc(BlendFuncMode.Add, BlendFuncFactor.One, BlendFuncFactor.One);
}
else if (device.BlendState == BlendState.AlphaBlend)
{
device._graphics.SetBlendFunc(BlendFuncMode.Add, BlendFuncFactor.SrcAlpha, BlendFuncFactor.OneMinusSrcAlpha);
}
else if (device.BlendState == BlendState.NonPremultiplied)
{
device._graphics.SetBlendFunc(BlendFuncMode.Add, BlendFuncFactor.SrcColor, BlendFuncFactor.OneMinusSrcColor);
}
else if (device.BlendState == BlendState.Opaque)
{
device._graphics.SetBlendFunc(BlendFuncMode.Add, BlendFuncFactor.One, BlendFuncFactor.Zero);
}
}
#endif
}
Expand Down
4 changes: 0 additions & 4 deletions MonoGame.Framework/PSSuite/Graphics/SpriteBatcher.cs
Expand Up @@ -223,10 +223,6 @@ void DrawVertexArray ( int start, int end )
return;

var vertexCount = end - start;

#warning this should be applied somewhere else
_device._graphics.Enable(EnableMode.Blend);
_device._graphics.SetBlendFunc(BlendFuncMode.Add, BlendFuncFactor.One, BlendFuncFactor.OneMinusSrcAlpha);
_device._graphics.DrawArrays(DrawMode.Triangles, start / 2 * 3, vertexCount / 2 * 3);
}
}
Expand Down

0 comments on commit 266937f

Please sign in to comment.