2018-06-26 05:10:54 +00:00
|
|
|
using OpenTK.Graphics.OpenGL;
|
2018-07-19 19:02:51 +00:00
|
|
|
using System;
|
2018-06-26 05:10:54 +00:00
|
|
|
|
|
|
|
namespace Ryujinx.Graphics.Gal.OpenGL
|
|
|
|
{
|
2018-07-19 19:02:51 +00:00
|
|
|
class OGLStreamBuffer : IDisposable
|
2018-06-26 05:10:54 +00:00
|
|
|
{
|
|
|
|
public int Handle { get; protected set; }
|
|
|
|
|
|
|
|
public int Size { get; protected set; }
|
|
|
|
|
|
|
|
protected BufferTarget Target { get; private set; }
|
|
|
|
|
2018-07-19 19:02:51 +00:00
|
|
|
public OGLStreamBuffer(BufferTarget Target, int Size)
|
2018-06-26 05:10:54 +00:00
|
|
|
{
|
|
|
|
this.Target = Target;
|
2018-07-19 19:02:51 +00:00
|
|
|
this.Size = Size;
|
2018-06-26 05:10:54 +00:00
|
|
|
|
2018-07-19 19:02:51 +00:00
|
|
|
Handle = GL.GenBuffer();
|
2018-06-26 05:10:54 +00:00
|
|
|
|
2018-07-19 19:02:51 +00:00
|
|
|
GL.BindBuffer(Target, Handle);
|
2018-06-26 05:10:54 +00:00
|
|
|
|
2018-07-19 19:02:51 +00:00
|
|
|
GL.BufferData(Target, Size, IntPtr.Zero, BufferUsageHint.StreamDraw);
|
2018-06-26 05:10:54 +00:00
|
|
|
}
|
|
|
|
|
2018-07-19 19:02:51 +00:00
|
|
|
public void SetData(int Size, IntPtr HostAddress)
|
2018-06-26 05:10:54 +00:00
|
|
|
{
|
2018-07-19 19:02:51 +00:00
|
|
|
GL.BindBuffer(Target, Handle);
|
2018-06-26 05:10:54 +00:00
|
|
|
|
2018-07-19 19:02:51 +00:00
|
|
|
GL.BufferSubData(Target, IntPtr.Zero, Size, HostAddress);
|
2018-06-26 05:10:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
{
|
|
|
|
Dispose(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected virtual void Dispose(bool Disposing)
|
|
|
|
{
|
|
|
|
if (Disposing && Handle != 0)
|
|
|
|
{
|
|
|
|
GL.DeleteBuffer(Handle);
|
|
|
|
|
|
|
|
Handle = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-06-26 05:30:46 +00:00
|
|
|
}
|