Add blend modes to renderer.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
[ParticleEmitterSettings]
|
||||
|
||||
MaxParticles = 1024
|
||||
EmitRadius = 128
|
||||
EmitRadius = 3
|
||||
LifeTime = 0.5
|
||||
Direction = { x = 0.0, y = 1.0 }
|
||||
LinearVelocity = 980.0
|
||||
|
||||
@@ -74,6 +74,8 @@ public class TestGame : Game
|
||||
|
||||
private void DrawEmitter(ParticleEmitter emitter)
|
||||
{
|
||||
Renderer.BeginBlended(Voile.Rendering.BlendMode.BlendAdd);
|
||||
|
||||
for (int i = 0; i < emitter.Particles.Length; i++)
|
||||
{
|
||||
var particle = emitter.Particles[i];
|
||||
@@ -83,6 +85,8 @@ public class TestGame : Game
|
||||
Renderer.SetTransform(emitter.OriginPosition + particle.Position, Vector2.Zero);
|
||||
Renderer.DrawCircle(16f * particle.Scale, color);
|
||||
}
|
||||
|
||||
Renderer.EndBlended();
|
||||
}
|
||||
|
||||
private ParticleSystem? _particleSystem;
|
||||
|
||||
@@ -121,6 +121,16 @@ namespace Voile.Rendering
|
||||
Raylib.EndDrawing();
|
||||
}
|
||||
|
||||
public override void BeginBlended(BlendMode blendMode)
|
||||
{
|
||||
Raylib.BeginBlendMode((Raylib_cs.BlendMode)blendMode);
|
||||
}
|
||||
|
||||
public override void EndBlended()
|
||||
{
|
||||
Raylib.EndBlendMode();
|
||||
}
|
||||
|
||||
public override void BeginCamera2d(Vector2 offset, Vector2 target, float rotation, float zoom)
|
||||
{
|
||||
var camera = new Camera2D(offset, target, rotation, zoom);
|
||||
|
||||
@@ -2,6 +2,38 @@ using System.Numerics;
|
||||
|
||||
namespace Voile.Rendering
|
||||
{
|
||||
public enum BlendMode
|
||||
{
|
||||
//
|
||||
// Summary:
|
||||
// Blend textures considering alpha (default)
|
||||
BlendAlpha,
|
||||
//
|
||||
// Summary:
|
||||
// Blend textures adding colors
|
||||
BlendAdditive,
|
||||
//
|
||||
// Summary:
|
||||
// Blend textures multiplying colors
|
||||
BlendMultiplied,
|
||||
//
|
||||
// Summary:
|
||||
// Blend textures adding colors (alternative)
|
||||
BlendAdd,
|
||||
//
|
||||
// Summary:
|
||||
// Blend textures subtracting colors (alternative)
|
||||
BlendSubtract,
|
||||
//
|
||||
// Summary:
|
||||
// Blend premultiplied textures considering alpha
|
||||
BlendAlphaPremul,
|
||||
//
|
||||
// Summary:
|
||||
// Blend textures using custom src/dst factors (use rlSetBlendMode())
|
||||
BlendCustom
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An abstract class representing the graphics renderer.
|
||||
/// </summary>
|
||||
@@ -82,6 +114,9 @@ namespace Voile.Rendering
|
||||
/// </summary>
|
||||
public abstract void EndFrame();
|
||||
|
||||
public abstract void BeginBlended(BlendMode blendMode);
|
||||
public abstract void EndBlended();
|
||||
|
||||
public abstract void BeginCamera2d(Vector2 offset, Vector2 target, float rotation, float zoom);
|
||||
public abstract void EndCamera2d();
|
||||
|
||||
|
||||
@@ -353,6 +353,18 @@ namespace Voile.Rendering
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public override void BeginBlended(BlendMode blendMode)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void EndBlended()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
private Vector2 _windowSize;
|
||||
private IWindow? _window;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user