Files
egutierrez c5dc63699a feat(gfx): mesh_gpu — VAO/VBO/EBO upload para Mesh
mesh_gpu_upload sube positions+normals interleaved (stride 6 floats,
location 0=a_pos, location 1=a_normal) + EBO uint32. mesh_gpu_destroy
libera todo. GL_STATIC_DRAW (mesh inmutable post-upload).

issue 0029
2026-04-25 21:51:10 +02:00

26 lines
721 B
C++

#pragma once
#include "gfx/gl_loader.h"
#include "gfx/mesh_obj_load.h"
namespace fn::gfx {
// VAO + VBO interleaved (pos.xyz, nrm.xyz) + EBO. ok() despues de upload.
struct MeshGpu {
GLuint vao = 0;
GLuint vbo = 0;
GLuint ebo = 0;
int index_count = 0;
bool ok() const { return vao != 0 && index_count > 0; }
};
// Sube un Mesh CPU al GPU. Requiere contexto GL activo.
// Si Mesh esta vacio o no es valido, devuelve MeshGpu{} (ok() == false).
// Layout: location 0 = vec3 a_pos, location 1 = vec3 a_normal.
MeshGpu mesh_gpu_upload(const Mesh& mesh);
// Libera los recursos GL. Seguro con mesh_gpu vacio.
void mesh_gpu_destroy(MeshGpu& mesh_gpu);
} // namespace fn::gfx