diff options
Diffstat (limited to 'src')
-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) + + +} |