From c0448fce3e1f183145a5967b56105052821febbc Mon Sep 17 00:00:00 2001 From: reaperrr Date: Tue, 31 Mar 2015 20:44:31 +0200 Subject: [PATCH] Adds two new BlendModes. --- OpenRA.Game/Graphics/IGraphicsDevice.cs | 13 ++++++++++- OpenRA.Renderer.Sdl2/Sdl2GraphicsDevice.cs | 26 ++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/OpenRA.Game/Graphics/IGraphicsDevice.cs b/OpenRA.Game/Graphics/IGraphicsDevice.cs index 3dde38bad4..fcb356aad0 100755 --- a/OpenRA.Game/Graphics/IGraphicsDevice.cs +++ b/OpenRA.Game/Graphics/IGraphicsDevice.cs @@ -34,7 +34,18 @@ namespace OpenRA public interface IHardwareCursor : IDisposable { } - public enum BlendMode : byte { None, Alpha, Additive, Subtractive, Multiply } + public enum BlendMode : byte + { + None, + Alpha, + Additive, + Subtractive, + Multiply, + SoftAdditive, + Translucency25, + Translucency50, + Translucency75 + } public interface IGraphicsDevice : IDisposable { diff --git a/OpenRA.Renderer.Sdl2/Sdl2GraphicsDevice.cs b/OpenRA.Renderer.Sdl2/Sdl2GraphicsDevice.cs index 736270c017..2c866d194f 100755 --- a/OpenRA.Renderer.Sdl2/Sdl2GraphicsDevice.cs +++ b/OpenRA.Renderer.Sdl2/Sdl2GraphicsDevice.cs @@ -241,6 +241,32 @@ namespace OpenRA.Renderer.Sdl2 GL.BlendFuncSeparate(BlendingFactorSrc.DstColor, BlendingFactorDest.Zero, BlendingFactorSrc.One, BlendingFactorDest.OneMinusSrcAlpha); ErrorHandler.CheckGlError(); break; + case BlendMode.SoftAdditive: + GL.Enable(EnableCap.Blend); + ErrorHandler.CheckGlError(); + GL.BlendFunc(BlendingFactorSrc.OneMinusDstColor, BlendingFactorDest.One); + break; + case BlendMode.Translucency25: + GL.Enable(EnableCap.Blend); + ErrorHandler.CheckGlError(); + GL.BlendFunc(BlendingFactorSrc.OneMinusConstantAlpha, BlendingFactorDest.One); + ErrorHandler.CheckGlError(); + GL.BlendColor(1f, 1f, 1f, 0.25f); + break; + case BlendMode.Translucency50: + GL.Enable(EnableCap.Blend); + ErrorHandler.CheckGlError(); + GL.BlendFunc(BlendingFactorSrc.OneMinusConstantAlpha, BlendingFactorDest.One); + ErrorHandler.CheckGlError(); + GL.BlendColor(1f, 1f, 1f, 0.5f); + break; + case BlendMode.Translucency75: + GL.Enable(EnableCap.Blend); + ErrorHandler.CheckGlError(); + GL.BlendFunc(BlendingFactorSrc.OneMinusConstantAlpha, BlendingFactorDest.One); + ErrorHandler.CheckGlError(); + GL.BlendColor(1f, 1f, 1f, 0.75f); + break; } ErrorHandler.CheckGlError();