From 9034b299962ac71e809dc33f7bea83f587c0c269 Mon Sep 17 00:00:00 2001 From: iurii Date: Sun, 8 Sep 2024 03:07:12 +0300 Subject: wip mesh --- src/mesh.odin | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/mesh.odin (limited to 'src/mesh.odin') diff --git a/src/mesh.odin b/src/mesh.odin new file mode 100644 index 0000000..07643e6 --- /dev/null +++ b/src/mesh.odin @@ -0,0 +1,52 @@ +package funhalla + +import gl "vendor:OpenGL" + +Vertex :: struct { + position: Vec3, + normal: Vec3, + tex_coords: Vec2 +} + +Texture :: struct { + id: u32, + type: string +} + +Mesh :: struct { + vertices: [dynamic]Vertex, + indices: [dynamic]u32, + textures: [dynamic]Texture, + + vao, vbo, ebo: u32 +} + + +mesh_init :: proc(vertices: [dynamic]Vertex, indices: [dynamic]u32, textures: [dynamic]Texture) -> ^Mesh { + mesh := new(Mesh) + mesh.vertices = vertices + mesh.indices = indices + mesh.textures = textures + + _setup_mesh(mesh) + + return mesh +} + +mesh_draw :: proc() { + +} + +@(private) +_setup_mesh :: proc(using mesh: ^Mesh) { + using gl + + GenVertexArrays(1, &vao) + GenBuffers(1, &vbo) + GenBuffers(1, &ebo) + + BindVertexArray(vao) + BindBuffer(ARRAY_BUFFER, vbo) + + +} -- cgit 1.4.1-2-gfad0