updated mesh to also pass normals to shader
Some checks failed
Gitea Actions Demo / Scan the project (push) Failing after 6s

This commit is contained in:
Daniel 2023-12-23 11:26:59 +01:00
parent 3c598d57f3
commit cf6fb35eb2

View File

@ -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<float> verticesData = new(vertices);
// TODO: meshData needs to also contain uv coords if I decide to add some
List<float> meshData = new(vertices.Length + normals.Length);
meshData.AddRange(vertices);
meshData.AddRange(normals);
ReadOnlySpan<float> 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<float> indicesData = new(indices);
gl.BindBuffer(BufferTargetARB.ElementArrayBuffer, ebo);