ScreenEffectManager now passes off a "service-located" SpriteBatch object to it's effects
This commit is contained in:
parent
db4802beda
commit
2547677649
|
@ -16,7 +16,7 @@ namespace Blarg.GameFramework.Graphics.ScreenEffects
|
||||||
Alpha = DefaultDimAlpha;
|
Alpha = DefaultDimAlpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnRender(float delta)
|
public override void OnRender(float delta, SpriteBatch spriteBatch)
|
||||||
{
|
{
|
||||||
int width = Framework.GraphicsDevice.ViewContext.ViewportWidth;
|
int width = Framework.GraphicsDevice.ViewContext.ViewportWidth;
|
||||||
int height = Framework.GraphicsDevice.ViewContext.ViewportHeight;
|
int height = Framework.GraphicsDevice.ViewContext.ViewportHeight;
|
||||||
|
@ -25,7 +25,7 @@ namespace Blarg.GameFramework.Graphics.ScreenEffects
|
||||||
var color = Color;
|
var color = Color;
|
||||||
color.A = Alpha;
|
color.A = Alpha;
|
||||||
|
|
||||||
//Platform.SpriteBatch.Render(texture, 0, 0, width, height, ref color);
|
spriteBatch.Render(texture, 0, 0, width, height, ref color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace Blarg.GameFramework.Graphics.ScreenEffects
|
||||||
_fadeToAlpha = toAlpha;
|
_fadeToAlpha = toAlpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnRender(float delta)
|
public override void OnRender(float delta, SpriteBatch spriteBatch)
|
||||||
{
|
{
|
||||||
int width = Framework.GraphicsDevice.ViewContext.ViewportWidth;
|
int width = Framework.GraphicsDevice.ViewContext.ViewportWidth;
|
||||||
int height = Framework.GraphicsDevice.ViewContext.ViewportHeight;
|
int height = Framework.GraphicsDevice.ViewContext.ViewportHeight;
|
||||||
|
@ -50,7 +50,7 @@ namespace Blarg.GameFramework.Graphics.ScreenEffects
|
||||||
var texture = Framework.GraphicsDevice.GetSolidColorTexture(Color.White);
|
var texture = Framework.GraphicsDevice.GetSolidColorTexture(Color.White);
|
||||||
_color.A = _alpha;
|
_color.A = _alpha;
|
||||||
|
|
||||||
//Platform.SpriteBatch.Render(texture, 0, 0, width, height, ref _color);
|
spriteBatch.Render(texture, 0, 0, width, height, ref _color);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnUpdate(float delta)
|
public override void OnUpdate(float delta)
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace Blarg.GameFramework.Graphics.ScreenEffects
|
||||||
Color = Color.White;
|
Color = Color.White;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnRender(float delta)
|
public override void OnRender(float delta, SpriteBatch spriteBatch)
|
||||||
{
|
{
|
||||||
int width = Framework.GraphicsDevice.ViewContext.ViewportWidth;
|
int width = Framework.GraphicsDevice.ViewContext.ViewportWidth;
|
||||||
int height = Framework.GraphicsDevice.ViewContext.ViewportHeight;
|
int height = Framework.GraphicsDevice.ViewContext.ViewportHeight;
|
||||||
|
@ -33,7 +33,7 @@ namespace Blarg.GameFramework.Graphics.ScreenEffects
|
||||||
var color = Color;
|
var color = Color;
|
||||||
color.A = _alpha;
|
color.A = _alpha;
|
||||||
|
|
||||||
//Platform.SpriteBatch.Render(texture, 0, 0, width, height, ref color);
|
spriteBatch.Render(texture, 0, 0, width, height, ref color);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnUpdate(float delta)
|
public override void OnUpdate(float delta)
|
||||||
|
|
|
@ -44,7 +44,7 @@ namespace Blarg.GameFramework.Graphics.ScreenEffects
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void OnRender(float delta)
|
public virtual void OnRender(float delta, SpriteBatch spriteBatch)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,17 @@ namespace Blarg.GameFramework.Graphics.ScreenEffects
|
||||||
LinkedList<EffectInfo> _effects;
|
LinkedList<EffectInfo> _effects;
|
||||||
int _numLocalEffects;
|
int _numLocalEffects;
|
||||||
int _numGlobalEffects;
|
int _numGlobalEffects;
|
||||||
|
SpriteBatch _spriteBatch;
|
||||||
|
|
||||||
public ScreenEffectManager()
|
public ScreenEffectManager()
|
||||||
{
|
{
|
||||||
_effects = new LinkedList<EffectInfo>();
|
_effects = new LinkedList<EffectInfo>();
|
||||||
_numLocalEffects = 0;
|
_numLocalEffects = 0;
|
||||||
_numGlobalEffects = 0;
|
_numGlobalEffects = 0;
|
||||||
|
|
||||||
|
_spriteBatch = Framework.Services.Get<SpriteBatch>();
|
||||||
|
if (_spriteBatch == null)
|
||||||
|
throw new InvalidOperationException("No SpriteBatch object registered with the service locator.");
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Get / Add / Remove
|
#region Get / Add / Remove
|
||||||
|
@ -133,7 +138,7 @@ namespace Blarg.GameFramework.Graphics.ScreenEffects
|
||||||
for (var node = _effects.First; node != null; node = node.Next)
|
for (var node = _effects.First; node != null; node = node.Next)
|
||||||
{
|
{
|
||||||
if (node.Value.IsLocal)
|
if (node.Value.IsLocal)
|
||||||
node.Value.Effect.OnRender(delta);
|
node.Value.Effect.OnRender(delta, _spriteBatch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +150,7 @@ namespace Blarg.GameFramework.Graphics.ScreenEffects
|
||||||
for (var node = _effects.First; node != null; node = node.Next)
|
for (var node = _effects.First; node != null; node = node.Next)
|
||||||
{
|
{
|
||||||
if (!node.Value.IsLocal)
|
if (!node.Value.IsLocal)
|
||||||
node.Value.Effect.OnRender(delta);
|
node.Value.Effect.OnRender(delta, _spriteBatch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue