diff options
author | iurii <[email protected]> | 2024-09-08 02:07:12 +0200 |
---|---|---|
committer | iurii <[email protected]> | 2024-09-08 02:07:12 +0200 |
commit | 9034b299962ac71e809dc33f7bea83f587c0c269 (patch) | |
tree | 312cb012756418ff933b91f76cee383ecd9b30df /src/mesh.odin | |
parent | 54c16a561d077d09b56c57ddf728b364fc255991 (diff) | |
download | funhalla-main.tar.gz |
wip mesh main
Diffstat (limited to '')
-rw-r--r-- | src/mesh.odin | 52 |
1 files changed, 52 insertions, 0 deletions
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) + + +} |