1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-11-23 21:02:03 +00:00
Ryujinx/Ryujinx.Graphics/Gal/OpenGL/OGLStreamBuffer.cs
ReinUsesLisp 25dd5f4238 Low level graphics API prerequisites (#319)
* Add GalPipelineState and IGalPipeline

* Separate UploadVertex call

* Add ConstBuffer cache

* Move Vertex Assembly into GalPipelineState

* Move Uniform binds to GalPipelineState

* Move framebuffer flip into a buffer

* Rebase

* Fix regression

* Move clear values from VertexEndGl to ClearBuffers

* Rename obscure names O->Old S->New
2018-08-10 01:09:40 -03:00

48 lines
1.1 KiB
C#

using OpenTK.Graphics.OpenGL;
using System;
namespace Ryujinx.Graphics.Gal.OpenGL
{
class OGLStreamBuffer : IDisposable
{
public int Handle { get; protected set; }
public long Size { get; protected set; }
protected BufferTarget Target { get; private set; }
public OGLStreamBuffer(BufferTarget Target, long Size)
{
this.Target = Target;
this.Size = Size;
Handle = GL.GenBuffer();
GL.BindBuffer(Target, Handle);
GL.BufferData(Target, (IntPtr)Size, IntPtr.Zero, BufferUsageHint.StreamDraw);
}
public void SetData(long Size, IntPtr HostAddress)
{
GL.BindBuffer(Target, Handle);
GL.BufferSubData(Target, IntPtr.Zero, (IntPtr)Size, HostAddress);
}
public void Dispose()
{
Dispose(true);
}
protected virtual void Dispose(bool Disposing)
{
if (Disposing && Handle != 0)
{
GL.DeleteBuffer(Handle);
Handle = 0;
}
}
}
}