29 lines
930 B
C++
29 lines
930 B
C++
//
|
|
// Created by slinky on 4/26/26.
|
|
//
|
|
#include "Mesh.h"
|
|
|
|
Mesh::Mesh(const std::vector<float> &positions, const std::vector<float> &uvs, const std::vector<float> &normals, const std::vector<int> &indices) {
|
|
vao = 0;
|
|
glGenVertexArrays(1, &vao);
|
|
glBindVertexArray(vao);
|
|
|
|
// positions
|
|
GLuint positionVbo = 0;
|
|
glGenBuffers(1, &positionVbo);
|
|
glBindBuffer(GL_ARRAY_BUFFER, positionVbo);
|
|
glBufferData(GL_ARRAY_BUFFER, positions.size() * sizeof(float), positions.data(), GL_STATIC_DRAW);
|
|
|
|
// uvs
|
|
GLuint uvVbo = 0;
|
|
glGenBuffers(1, &uvVbo);
|
|
glBindBuffer(GL_ARRAY_BUFFER, uvVbo);
|
|
glBufferData(GL_ARRAY_BUFFER, uvs.size() * sizeof(float), uvs.data(), GL_STATIC_DRAW);
|
|
|
|
// normals
|
|
GLuint normalVbo = 0;
|
|
glGenBuffers(1, &normalVbo);
|
|
glBindBuffer(GL_ARRAY_BUFFER, normalVbo);
|
|
glBufferData(GL_ARRAY_BUFFER, normals.size() * sizeof(float), normals.data(), GL_STATIC_DRAW);
|
|
}
|