mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
RefCounted GraphicsContext
This commit is contained in:
@@ -31,7 +31,7 @@ namespace GlitchyEngine
|
||||
|
||||
private bool _isVSync = true;
|
||||
|
||||
private GraphicsContext _graphicsContext ~ delete _;
|
||||
private GraphicsContext _graphicsContext ~ _?.ReleaseRef();
|
||||
|
||||
public override GraphicsContext Context => _graphicsContext;
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace GlitchyEngine.Renderer
|
||||
/// Represents a buffer containing binary data on the GPU.
|
||||
public class Buffer : RefCounted
|
||||
{
|
||||
internal GraphicsContext _context;
|
||||
internal GraphicsContext _context ~ _?.ReleaseRef();
|
||||
|
||||
protected BufferDescription _description;
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
protected this(GraphicsContext context)
|
||||
{
|
||||
_context = context;
|
||||
_context = context..AddRef();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace GlitchyEngine.Renderer
|
||||
{
|
||||
public class Effect : RefCounted
|
||||
{
|
||||
protected GraphicsContext _context;
|
||||
protected GraphicsContext _context; // Todo:???
|
||||
internal VertexShader _vs ~ _?.ReleaseRef();
|
||||
internal PixelShader _ps ~ _?.ReleaseRef();
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace GlitchyEngine.Renderer
|
||||
{
|
||||
public class GeometryBinding
|
||||
{
|
||||
internal GraphicsContext _context;
|
||||
internal GraphicsContext _context ~ _?.ReleaseRef();
|
||||
|
||||
internal List<VertexBufferBinding> _vertexBuffers = new .() ~ delete _;
|
||||
internal IndexBuffer _indexBuffer;
|
||||
@@ -16,7 +16,7 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
public this(GraphicsContext context)
|
||||
{
|
||||
_context = context;
|
||||
_context = context..AddRef();
|
||||
}
|
||||
|
||||
public VertexBufferBinding GetVertexBuffer(uint32 slot)
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace GlitchyEngine.Renderer
|
||||
{
|
||||
public class RenderTarget;
|
||||
|
||||
public class GraphicsContext
|
||||
public class GraphicsContext : RefCounted
|
||||
{
|
||||
private RasterizerState _currentRasterizerState;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
public this(Effect effect)
|
||||
{
|
||||
_effect = effect;
|
||||
_effect = effect..AddRef();
|
||||
}
|
||||
|
||||
// public void Set(String name, VALUE)...
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
public class RasterizerState
|
||||
{
|
||||
internal GraphicsContext _context;
|
||||
internal GraphicsContext _context ~ _?.ReleaseRef();
|
||||
private RasterizerStateDescription _description;
|
||||
|
||||
public GraphicsContext Context => _context;
|
||||
@@ -59,7 +59,7 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
protected this(GraphicsContext context)
|
||||
{
|
||||
_context = context;
|
||||
_context = context..AddRef();
|
||||
}
|
||||
|
||||
public extern this(GraphicsContext context, RasterizerStateDescription description);
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace GlitchyEngine.Renderer
|
||||
public Matrix Transform;
|
||||
}
|
||||
|
||||
static GraphicsContext _context;
|
||||
static GraphicsContext _context ~ _?.ReleaseRef();
|
||||
|
||||
static Buffer<SceneConstants> _sceneConstants ~ _?.ReleaseRef();
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
public static void Init(GraphicsContext context)
|
||||
{
|
||||
_context = context;
|
||||
_context = context..AddRef();
|
||||
_sceneConstants = new Buffer<SceneConstants>(_context, .(0, .Constant, .Dynamic, .Write));
|
||||
_sceneConstants.Update();
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
public abstract class Shader : RefCounted
|
||||
{
|
||||
protected GraphicsContext _context;
|
||||
protected GraphicsContext _context ~ _?.ReleaseRef();
|
||||
|
||||
protected BufferCollection _buffers ~ delete _;//:append _;
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace GlitchyEngine.Renderer
|
||||
//let buffers = new BufferCollection();
|
||||
_buffers = new BufferCollection();
|
||||
|
||||
_context = context;
|
||||
_context = context..AddRef();
|
||||
CompileFromSource(source, entryPoint);
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
public class VertexLayout
|
||||
{
|
||||
private GraphicsContext _context;
|
||||
private GraphicsContext _context ~ _?.ReleaseRef();
|
||||
|
||||
private VertexElement[] _elements ~ delete _;
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace GlitchyEngine.Renderer
|
||||
/// Takes ownership of ownElements!
|
||||
public this(GraphicsContext context, VertexElement[] ownElements, VertexShader vertexShader)
|
||||
{
|
||||
_context = context;
|
||||
_context = context..AddRef();
|
||||
_elements = ownElements;
|
||||
|
||||
CreateNativeLayout();
|
||||
|
||||
Reference in New Issue
Block a user