mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-06-04 13:45:47 +00:00
GenericMesh - Remove dependency of IVertexLayout
This commit is contained in:
@@ -158,7 +158,6 @@
|
||||
<Compile Include="Rendering\CubeGroupMesh.cs" />
|
||||
<Compile Include="Rendering\FrameBuffer.cs" />
|
||||
<Compile Include="Rendering\IndexBuffer.cs" />
|
||||
<Compile Include="Rendering\IVertexLayout.cs" />
|
||||
<Compile Include="Rendering\DrawContext.cs" />
|
||||
<Compile Include="Rendering\ColorVertex.cs" />
|
||||
<Compile Include="Rendering\OutlineDefinition.cs" />
|
||||
|
||||
@@ -52,6 +52,14 @@ namespace PckStudio.Rendering
|
||||
Inflate = inflate;
|
||||
}
|
||||
|
||||
public static VertexBufferLayout GetLayout()
|
||||
{
|
||||
var layout = new VertexBufferLayout();
|
||||
layout.Add(ShaderDataType.Float3);
|
||||
layout.Add(ShaderDataType.Float2);
|
||||
return layout;
|
||||
}
|
||||
|
||||
internal void AddSkinBox(SkinBOX skinBox)
|
||||
{
|
||||
var cube = CubeMesh.Create(skinBox);
|
||||
|
||||
@@ -24,7 +24,7 @@ using PckStudio.Rendering.Shader;
|
||||
|
||||
namespace PckStudio.Rendering
|
||||
{
|
||||
internal class GenericMesh<T> where T : struct, IVertexLayout
|
||||
internal class GenericMesh<T> where T : struct
|
||||
{
|
||||
internal string Name { get; }
|
||||
|
||||
@@ -37,7 +37,6 @@ namespace PckStudio.Rendering
|
||||
private VertexArray vertexArray;
|
||||
private VertexBuffer vertexBuffer;
|
||||
private IndexBuffer indexBuffer;
|
||||
private readonly VertexBufferLayout _layout;
|
||||
private readonly PrimitiveType drawType;
|
||||
private DrawContext drawContext;
|
||||
|
||||
@@ -48,15 +47,14 @@ namespace PckStudio.Rendering
|
||||
indicesOffset = 0;
|
||||
vertices = new List<T>(10);
|
||||
indices = new List<int>(10);
|
||||
_layout = new T().GetLayout();
|
||||
}
|
||||
|
||||
internal void Initialize()
|
||||
internal void Initialize(VertexBufferLayout layout)
|
||||
{
|
||||
vertexArray = new VertexArray();
|
||||
vertexBuffer = new VertexBuffer();
|
||||
indexBuffer = new IndexBuffer();
|
||||
vertexArray.AddBuffer(vertexBuffer, _layout);
|
||||
vertexArray.AddBuffer(vertexBuffer, layout);
|
||||
drawContext = new DrawContext(vertexArray, indexBuffer, drawType);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PckStudio.Rendering
|
||||
{
|
||||
internal interface IVertexLayout
|
||||
{
|
||||
public VertexBufferLayout GetLayout();
|
||||
}
|
||||
}
|
||||
@@ -265,14 +265,15 @@ namespace PckStudio.Rendering
|
||||
InitializeShaders();
|
||||
InitializeFramebuffer();
|
||||
Renderer.SetClearColor(BackColor);
|
||||
var layout = CubeGroupMesh.GetLayout();
|
||||
foreach (var item in meshStorage)
|
||||
{
|
||||
item.Value.Initialize();
|
||||
item.Value.Initialize(layout);
|
||||
}
|
||||
UploadMeshData();
|
||||
foreach (var cubeMesh in offsetSpecificMeshStorage?.Values)
|
||||
{
|
||||
cubeMesh.Initialize();
|
||||
cubeMesh.Initialize(layout);
|
||||
cubeMesh.UploadData();
|
||||
}
|
||||
GLErrorCheck();
|
||||
@@ -656,7 +657,7 @@ namespace PckStudio.Rendering
|
||||
VertexBuffer vertexBuffer = new VertexBuffer();
|
||||
vertexBuffer.SetData(rectVertices);
|
||||
VertexBufferLayout layout = new VertexBufferLayout();
|
||||
layout.Add<float>(4);
|
||||
layout.Add(ShaderDataType.Float4);
|
||||
framebufferVAO.AddBuffer(vertexBuffer, layout);
|
||||
framebuffer.CheckStatus();
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ using OpenTK;
|
||||
namespace PckStudio.Rendering
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4, Size = 20)]
|
||||
internal struct TextureVertex : IVertexLayout
|
||||
internal struct TextureVertex
|
||||
{
|
||||
internal Vector3 Position { get; set; }
|
||||
internal Vector2 TexPosition { get; set; }
|
||||
@@ -18,13 +18,5 @@ namespace PckStudio.Rendering
|
||||
Position = position;
|
||||
TexPosition = texPosition;
|
||||
}
|
||||
|
||||
public VertexBufferLayout GetLayout()
|
||||
{
|
||||
var layout = new VertexBufferLayout();
|
||||
layout.Add(ShaderDataType.Float3);
|
||||
layout.Add(ShaderDataType.Float2);
|
||||
return layout;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user