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 | |
parent | 54c16a561d077d09b56c57ddf728b364fc255991 (diff) | |
download | funhalla-9034b299962ac71e809dc33f7bea83f587c0c269.tar.gz |
wip mesh main
-rw-r--r-- | src/main.odin | 1 | ||||
-rw-r--r-- | src/mesh.odin | 52 |
2 files changed, 53 insertions, 0 deletions
diff --git a/src/main.odin b/src/main.odin index d518e93..9f900bc 100644 --- a/src/main.odin +++ b/src/main.odin @@ -10,6 +10,7 @@ import "core:math" import "core:math/linalg" import "core:os" +Vec2 :: linalg.Vector2f32 Vec3 :: linalg.Vector3f32 Mat4 :: linalg.Matrix4x4f32 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) + + +} |