From cf6fb35eb23befb8606b5b72b36c7be52d9fab50 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 23 Dec 2023 11:26:59 +0100 Subject: [PATCH] updated mesh to also pass normals to shader --- Nebulix/Rendering/Mesh.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Nebulix/Rendering/Mesh.cs b/Nebulix/Rendering/Mesh.cs index d6f5d9b..25340e1 100644 --- a/Nebulix/Rendering/Mesh.cs +++ b/Nebulix/Rendering/Mesh.cs @@ -1,9 +1,4 @@ using Silk.NET.OpenGL; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Nebulix.Rendering { @@ -41,10 +36,13 @@ namespace Nebulix.Rendering gl.BindVertexArray(vao); - // TODO: verticesData needs to also contain "normals" not just vertices (and uv coords if I decide to add some) - ReadOnlySpan verticesData = new(vertices); + // TODO: meshData needs to also contain uv coords if I decide to add some + List meshData = new(vertices.Length + normals.Length); + meshData.AddRange(vertices); + meshData.AddRange(normals); + ReadOnlySpan data = new(meshData.ToArray()); gl.BindBuffer(BufferTargetARB.ArrayBuffer, vbo); - gl.BufferData(BufferTargetARB.ArrayBuffer, (nuint)(verticesData.Length * sizeof(float)), verticesData, BufferUsageARB.StaticDraw); + gl.BufferData(BufferTargetARB.ArrayBuffer, (nuint)(data.Length * sizeof(float)), data, BufferUsageARB.StaticDraw); ReadOnlySpan indicesData = new(indices); gl.BindBuffer(BufferTargetARB.ElementArrayBuffer, ebo);