2019-08-09 04:18:08 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.Rendering
|
|
|
|
|
{
|
2019-08-13 02:12:04 +00:00
|
|
|
|
internal class Mesh : IDisposable
|
2019-08-09 04:18:08 +00:00
|
|
|
|
{
|
2019-08-22 13:52:17 +00:00
|
|
|
|
public Mesh(RenderDevice graphics, WorldVertex[] vertexData, int[] indexData)
|
2019-08-09 04:18:08 +00:00
|
|
|
|
{
|
2019-08-15 00:52:21 +00:00
|
|
|
|
graphics.SetBufferData(Vertices, vertexData);
|
|
|
|
|
graphics.SetBufferData(Indices, indexData);
|
2019-08-22 13:52:17 +00:00
|
|
|
|
PrimitivesCount = indexData.Length / 3;
|
2019-08-09 04:18:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~Mesh()
|
|
|
|
|
{
|
|
|
|
|
Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-13 02:12:04 +00:00
|
|
|
|
internal void Draw(RenderDevice device)
|
2019-08-09 04:18:08 +00:00
|
|
|
|
{
|
2019-08-16 11:07:57 +00:00
|
|
|
|
device.SetVertexBuffer(Vertices);
|
2019-08-13 02:12:04 +00:00
|
|
|
|
device.SetIndexBuffer(Indices);
|
2019-08-22 13:52:17 +00:00
|
|
|
|
device.DrawIndexed(PrimitiveType.TriangleList, 0, PrimitivesCount);
|
2019-08-17 01:08:34 +00:00
|
|
|
|
device.SetIndexBuffer(null);
|
|
|
|
|
device.SetVertexBuffer(null);
|
2019-08-09 04:18:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
2019-08-16 09:24:22 +00:00
|
|
|
|
Vertices.Dispose();
|
|
|
|
|
Indices.Dispose();
|
2019-08-09 04:18:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-16 09:24:22 +00:00
|
|
|
|
VertexBuffer Vertices = new VertexBuffer();
|
|
|
|
|
IndexBuffer Indices = new IndexBuffer();
|
2019-08-22 13:52:17 +00:00
|
|
|
|
int PrimitivesCount;
|
2019-08-09 04:18:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|