mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Replaced RefCounted with RefCounter
This commit is contained in:
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace GlitchyEngine.Core
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Provides a reference counter that, when reaching 0, automatically deletes itself.
|
||||||
|
* Implements the IDisposable interface so that it can be used with a using-Block so that the counter
|
||||||
|
* will be decremented automatically after leaving the block.
|
||||||
|
*/
|
||||||
|
public class RefCounter : System.RefCounted, IDisposable
|
||||||
|
{
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
ReleaseRef();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,20 +1,21 @@
|
|||||||
using System;
|
|
||||||
using DirectX.Common;
|
using DirectX.Common;
|
||||||
|
using GlitchyEngine.Core;
|
||||||
|
|
||||||
namespace GlitchyEngine
|
namespace GlitchyEngine
|
||||||
{
|
{
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
/// Releases the reference to destination, writes newValue into it and adds a reference to newValue.
|
/// Releases the reference to destination, writes newValue into it and adds a reference to newValue.
|
||||||
public static mixin SetReference<T>(T destination, T newValue) where T: RefCounted
|
public static mixin SetReference<T>(T destination, T newValue) where T: RefCounter
|
||||||
{
|
{
|
||||||
destination?.ReleaseRef();
|
var oldDest = destination;
|
||||||
destination = newValue;
|
destination = newValue;
|
||||||
destination?.AddRef();
|
destination?.AddRef();
|
||||||
|
oldDest?.ReleaseRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Releases the reference to value and nullifies it.
|
/// Releases the reference to value and nullifies it.
|
||||||
public static mixin ReleaseRefAndNullify<T>(T value) where T: RefCounted
|
public static mixin ReleaseRefAndNullify<T>(T value) where T: RefCounter
|
||||||
{
|
{
|
||||||
value?.ReleaseRef();
|
value?.ReleaseRef();
|
||||||
value = null;
|
value = null;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using GlitchyEngine.Math;
|
|
||||||
using System;
|
using System;
|
||||||
|
using GlitchyEngine.Core;
|
||||||
|
using GlitchyEngine.Math;
|
||||||
|
|
||||||
namespace GlitchyEngine.Renderer.Animation
|
namespace GlitchyEngine.Renderer.Animation
|
||||||
{
|
{
|
||||||
@@ -64,7 +65,7 @@ namespace GlitchyEngine.Renderer.Animation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AnimationClip : RefCounted
|
class AnimationClip : RefCounter
|
||||||
{
|
{
|
||||||
private Skeleton _skeleton ~ _.ReleaseRef();
|
private Skeleton _skeleton ~ _.ReleaseRef();
|
||||||
//public float FramesPerSecond;
|
//public float FramesPerSecond;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
using System;
|
using GlitchyEngine.Core;
|
||||||
using GlitchyEngine.Math;
|
using GlitchyEngine.Math;
|
||||||
|
|
||||||
namespace GlitchyEngine.Renderer.Animation
|
namespace GlitchyEngine.Renderer.Animation
|
||||||
{
|
{
|
||||||
public class Skeleton : RefCounted
|
public class Skeleton : RefCounter
|
||||||
{
|
{
|
||||||
public Joint[] Joints ~ delete _;
|
public Joint[] Joints ~ delete _;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using GlitchyEngine.Core;
|
||||||
using GlitchyEngine.Math;
|
using GlitchyEngine.Math;
|
||||||
|
|
||||||
namespace GlitchyEngine.Renderer
|
namespace GlitchyEngine.Renderer
|
||||||
{
|
{
|
||||||
public struct BlendStateDescription
|
public struct BlendStateDescription
|
||||||
@@ -70,7 +72,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
public static readonly Self Default = .(false, false, .(.Default, .Default, .Default, .Default, .Default, .Default, .Default, .Default));
|
public static readonly Self Default = .(false, false, .(.Default, .Default, .Default, .Default, .Default, .Default, .Default, .Default));
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BlendState : RefCounted
|
public class BlendState : RefCounter
|
||||||
{
|
{
|
||||||
protected GraphicsContext _context ~ _?.ReleaseRef();
|
protected GraphicsContext _context ~ _?.ReleaseRef();
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using GlitchyEngine.Core;
|
||||||
|
|
||||||
namespace GlitchyEngine.Renderer
|
namespace GlitchyEngine.Renderer
|
||||||
{
|
{
|
||||||
@@ -80,7 +81,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Represents a buffer containing binary data on the GPU.
|
/// Represents a buffer containing binary data on the GPU.
|
||||||
public class Buffer : RefCounted
|
public class Buffer : RefCounter
|
||||||
{
|
{
|
||||||
internal GraphicsContext _context ~ _?.ReleaseRef();
|
internal GraphicsContext _context ~ _?.ReleaseRef();
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using GlitchyEngine.Core;
|
||||||
|
|
||||||
namespace GlitchyEngine.Renderer
|
namespace GlitchyEngine.Renderer
|
||||||
{
|
{
|
||||||
public enum DepthStencilFormat
|
public enum DepthStencilFormat
|
||||||
@@ -11,7 +12,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: add all features.
|
// TODO: add all features.
|
||||||
public class DepthStencilTarget : RefCounted
|
public class DepthStencilTarget : RefCounter
|
||||||
{
|
{
|
||||||
protected internal GraphicsContext _context ~ _?.ReleaseRef();
|
protected internal GraphicsContext _context ~ _?.ReleaseRef();
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
using GlitchyEngine.Core;
|
||||||
|
|
||||||
namespace GlitchyEngine.Renderer
|
namespace GlitchyEngine.Renderer
|
||||||
{
|
{
|
||||||
@@ -89,7 +90,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
public bool Exists(String effectName) => _effects.ContainsKey(effectName);
|
public bool Exists(String effectName) => _effects.ContainsKey(effectName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Effect : RefCounted
|
public class Effect : RefCounter
|
||||||
{
|
{
|
||||||
protected GraphicsContext _context ~ _?.ReleaseRef();
|
protected GraphicsContext _context ~ _?.ReleaseRef();
|
||||||
internal VertexShader _vs ~ _?.ReleaseRef();
|
internal VertexShader _vs ~ _?.ReleaseRef();
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
using GlitchyEngine.Core;
|
||||||
|
|
||||||
namespace GlitchyEngine.Renderer
|
namespace GlitchyEngine.Renderer
|
||||||
{
|
{
|
||||||
public class GeometryBinding : RefCounted
|
public class GeometryBinding : RefCounter
|
||||||
{
|
{
|
||||||
internal GraphicsContext _context ~ _?.ReleaseRef();
|
internal GraphicsContext _context ~ _?.ReleaseRef();
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
using GlitchyEngine.Math;
|
|
||||||
using System;
|
using System;
|
||||||
|
using GlitchyEngine.Core;
|
||||||
|
using GlitchyEngine.Math;
|
||||||
|
|
||||||
namespace GlitchyEngine.Renderer
|
namespace GlitchyEngine.Renderer
|
||||||
{
|
{
|
||||||
public class GraphicsContext : RefCounted
|
public class GraphicsContext : RefCounter
|
||||||
{
|
{
|
||||||
private RasterizerState _currentRasterizerState;
|
private RasterizerState _currentRasterizerState;
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
using GlitchyEngine.Core;
|
||||||
using GlitchyEngine.Math;
|
using GlitchyEngine.Math;
|
||||||
|
|
||||||
using internal GlitchyEngine.Renderer;
|
using internal GlitchyEngine.Renderer;
|
||||||
|
|
||||||
namespace GlitchyEngine.Renderer
|
namespace GlitchyEngine.Renderer
|
||||||
{
|
{
|
||||||
public class Material : RefCounted
|
public class Material : RefCounter
|
||||||
{
|
{
|
||||||
private Effect _effect ~ _?.ReleaseRef();
|
private Effect _effect ~ _?.ReleaseRef();
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using GlitchyEngine.Core;
|
||||||
|
|
||||||
namespace GlitchyEngine.Renderer
|
namespace GlitchyEngine.Renderer
|
||||||
{
|
{
|
||||||
public enum FillMode
|
public enum FillMode
|
||||||
@@ -50,7 +52,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
public static readonly RasterizerStateDescription Default = .(.Solid, .Back, false, 0, 0f, 0f, true, false, false, false);
|
public static readonly RasterizerStateDescription Default = .(.Solid, .Back, false, 0, 0f, 0f, true, false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RasterizerState : RefCounted
|
public class RasterizerState : RefCounter
|
||||||
{
|
{
|
||||||
internal GraphicsContext _context ~ _?.ReleaseRef();
|
internal GraphicsContext _context ~ _?.ReleaseRef();
|
||||||
private RasterizerStateDescription _description;
|
private RasterizerStateDescription _description;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using GlitchyEngine.Core;
|
||||||
|
|
||||||
namespace GlitchyEngine.Renderer
|
namespace GlitchyEngine.Renderer
|
||||||
{
|
{
|
||||||
public struct RenderTarget2DDescription
|
public struct RenderTarget2DDescription
|
||||||
@@ -32,7 +33,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RenderTarget2D : RefCounted
|
public class RenderTarget2D : RefCounter
|
||||||
{
|
{
|
||||||
internal GraphicsContext _context;
|
internal GraphicsContext _context;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using GlitchyEngine.Core;
|
||||||
using GlitchyEngine.Math;
|
using GlitchyEngine.Math;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
|
||||||
@@ -285,7 +286,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SamplerState : RefCounted
|
public class SamplerState : RefCounter
|
||||||
{
|
{
|
||||||
protected GraphicsContext _context ~ _?.ReleaseRef();
|
protected GraphicsContext _context ~ _?.ReleaseRef();
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
using GlitchyEngine.Core;
|
||||||
|
|
||||||
namespace GlitchyEngine.Renderer
|
namespace GlitchyEngine.Renderer
|
||||||
{
|
{
|
||||||
@@ -18,7 +19,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class Shader : RefCounted
|
public abstract class Shader : RefCounter
|
||||||
{
|
{
|
||||||
protected GraphicsContext _context ~ _?.ReleaseRef();
|
protected GraphicsContext _context ~ _?.ReleaseRef();
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using FreeType;
|
using FreeType;
|
||||||
using GlitchyEngine.Math;
|
using GlitchyEngine.Math;
|
||||||
|
using GlitchyEngine.Core;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using msdfgen;
|
using msdfgen;
|
||||||
|
|
||||||
@@ -8,7 +9,7 @@ using internal GlitchyEngine.Renderer.Text;
|
|||||||
|
|
||||||
namespace GlitchyEngine.Renderer.Text
|
namespace GlitchyEngine.Renderer.Text
|
||||||
{
|
{
|
||||||
public class Font : RefCounted
|
public class Font : RefCounter
|
||||||
{
|
{
|
||||||
internal class GlyphDescriptor
|
internal class GlyphDescriptor
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using GlitchyEngine.Core;
|
||||||
using GlitchyEngine.Math;
|
using GlitchyEngine.Math;
|
||||||
|
|
||||||
namespace GlitchyEngine.Renderer
|
namespace GlitchyEngine.Renderer
|
||||||
{
|
{
|
||||||
public abstract class Texture : RefCounted
|
public abstract class Texture : RefCounter
|
||||||
{
|
{
|
||||||
protected GraphicsContext _context ~ _?.ReleaseRef();
|
protected GraphicsContext _context ~ _?.ReleaseRef();
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using GlitchyEngine.Core;
|
||||||
|
|
||||||
namespace GlitchyEngine.Renderer
|
namespace GlitchyEngine.Renderer
|
||||||
{
|
{
|
||||||
@@ -78,7 +79,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
public static readonly uint32 AppendAligned = 0xffffffff;
|
public static readonly uint32 AppendAligned = 0xffffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class VertexLayout : RefCounted
|
public class VertexLayout : RefCounter
|
||||||
{
|
{
|
||||||
private GraphicsContext _context ~ _?.ReleaseRef();
|
private GraphicsContext _context ~ _?.ReleaseRef();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user