15.09.2020
Everything currently don't work / can't be tested. + Generic Shader-Implermentation + Mesh-System + Plate-Mesh
This commit is contained in:
parent
551d393ac2
commit
421d03f91d
24 changed files with 726 additions and 4 deletions
34
SM.Core/Mesh/VBO.cs
Normal file
34
SM.Core/Mesh/VBO.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
|
||||
namespace SM.OGL.Mesh
|
||||
{
|
||||
public class VBO : List<float>
|
||||
{
|
||||
public BufferUsageHint BufferUsageHint = BufferUsageHint.StaticDraw;
|
||||
public VertexAttribPointerType PointerType = VertexAttribPointerType.Float;
|
||||
public int PointerSize = 3;
|
||||
public bool Normalised = false;
|
||||
public int PointerStride = 0;
|
||||
public int PointerOffset = 0;
|
||||
|
||||
public void Add(float x, float y) => AddRange(new[] {x,y});
|
||||
public void Add(float x, float y, float z) => AddRange(new[] {x,y,z});
|
||||
public void Add(float x, float y, float z, float w) => AddRange(new[] {x,y,z,w});
|
||||
|
||||
public void BindBuffer(int attribID)
|
||||
{
|
||||
float[] data = ToArray();
|
||||
|
||||
int buffer = GL.GenBuffer();
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, buffer);
|
||||
GL.BufferData(BufferTarget.ArrayBuffer, data.Length * Mesh.BufferSizeMultiplier, data, BufferUsageHint);
|
||||
|
||||
GL.VertexAttribPointer(attribID, PointerSize, PointerType, Normalised, PointerStride, PointerOffset);
|
||||
GL.EnableVertexAttribArray(attribID);
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue