Add blend modes to renderer.

This commit is contained in:
2024-10-15 17:10:48 +02:00
parent 851abd7c90
commit ecd752e961
5 changed files with 62 additions and 1 deletions

View File

@@ -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);

View File

@@ -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();

View File

@@ -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;