16.09.2020
~ Fixed shading import ~ Fixed "Plate" mesh ~ Move the dll files into "SMCode"
This commit is contained in:
parent
421d03f91d
commit
9889366317
27 changed files with 30 additions and 17 deletions
34
SMCode/SM.OGL/Mesh/VBO.cs
Normal file
34
SMCode/SM.OGL/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