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-16 09:24:22 +00:00
|
|
|
|
unsafe 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-13 02:12:04 +00:00
|
|
|
|
Count = indexData.Length;
|
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-15 12:49:49 +00:00
|
|
|
|
device.DrawIndexed(PrimitiveType.TriangleList, 0, Count / 3);
|
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-13 02:12:04 +00:00
|
|
|
|
int Count;
|
2019-08-09 04:18:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|