summary refs log tree commit diff
path: root/src/mesh.odin
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesh.odin')
-rw-r--r--src/mesh.odin52
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)
+
+
+}