Removed unneeded usings
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
|
||||
namespace Diamond.Buffers
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using OpenTK.Graphics.ES20;
|
||||
|
||||
namespace Diamond.Buffers
|
||||
{
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Diamond.Buffers
|
||||
{
|
||||
|
||||
@@ -30,6 +30,9 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="OpenTK, Version=2.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\OpenTK.2.0.0\lib\net20\OpenTK.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -48,6 +51,7 @@
|
||||
<Compile Include="Buffers\SubArray.cs" />
|
||||
<Compile Include="Buffers\VertexDataAttribute.cs" />
|
||||
<Compile Include="GLObject.cs" />
|
||||
<Compile Include="Mesh.cs" />
|
||||
<Compile Include="Shaders\Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Shaders\Shader.cs" />
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
namespace Diamond
|
||||
{
|
||||
|
||||
74
Diamond/Mesh.cs
Normal file
74
Diamond/Mesh.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Diamond.Buffers;
|
||||
using Newtonsoft.Json;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
|
||||
namespace Diamond
|
||||
{
|
||||
public class Mesh<T> where T : struct
|
||||
{
|
||||
public SubArray<T> Vertices;
|
||||
public PrimitiveType Primitive;
|
||||
|
||||
private static VertexDataInfo tVdi;
|
||||
private static List<VertexPointerAttribute> attribs;
|
||||
|
||||
static Mesh()
|
||||
{
|
||||
tVdi = VertexDataInfo.GetInfo<T>();
|
||||
}
|
||||
|
||||
public Mesh(T[] vertices, PrimitiveType primitive = PrimitiveType.Triangles)
|
||||
: this(new SubArray<T>(vertices), primitive)
|
||||
{
|
||||
}
|
||||
|
||||
public Mesh(SubArray<T> vertices, PrimitiveType primitive = PrimitiveType.Triangles)
|
||||
{
|
||||
Vertices = vertices;
|
||||
Primitive = primitive;
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
tVdi.EnableVertexPointers();
|
||||
|
||||
GL.DrawArrays(Primitive, Vertices.Offset, Vertices.Length);
|
||||
|
||||
tVdi.DisableVertexPointers();
|
||||
}
|
||||
|
||||
public void DrawInstanced<TI>(SubArray<TI> instanceArray) where TI : struct
|
||||
{
|
||||
var tiVdi = VertexDataInfo.GetInfo<TI>();
|
||||
|
||||
tVdi.EnableVertexPointers();
|
||||
tiVdi.EnableVertexPointers();
|
||||
|
||||
GL.DrawArraysInstancedBaseInstance(Primitive, Vertices.Offset, Vertices.Length, instanceArray.Length,
|
||||
instanceArray.Offset);
|
||||
|
||||
tVdi.DisableVertexPointers();
|
||||
tiVdi.DisableVertexPointers();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Mesh
|
||||
{
|
||||
public static Mesh<T> FromJson<T>(string json) where T : struct
|
||||
{
|
||||
var vertices = JsonConvert.DeserializeObject<T[]>(json);
|
||||
return new Mesh<T>(vertices);
|
||||
}
|
||||
|
||||
//todo add fromObj
|
||||
|
||||
public static T[] Join<T>(params Mesh<T>[] meshes) where T : struct => Join((IEnumerable<Mesh<T>>) meshes);
|
||||
|
||||
public static T[] Join<T>(IEnumerable<Mesh<T>> meshes) where T : struct
|
||||
{
|
||||
return SubArray.Join(meshes.Select(x => x.Vertices));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Diamond.Buffers;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
|
||||
<package id="OpenTK" version="2.0.0" targetFramework="net452" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user