40 lines
855 B
Odin
40 lines
855 B
Odin
package renderer
|
|
|
|
Mesh :: struct {
|
|
amount_of_indices: u32,
|
|
backend: Mesh_Backend,
|
|
}
|
|
|
|
Mesh_Handle :: distinct u32
|
|
Buffer_Handle :: distinct u32
|
|
|
|
Vertex :: distinct [3]f32
|
|
Index :: distinct u32
|
|
|
|
|
|
create_mesh :: proc(renderer: ^Renderer, vertices: []Vertex, indices: []Index) -> (Mesh, bool) { // TODO: SS - Should probably return a Mesh_Handle.
|
|
mesh: Mesh
|
|
|
|
if len(vertices) == 0 {
|
|
return {}, false
|
|
}
|
|
if len(indices) == 0 {
|
|
return {}, false
|
|
}
|
|
|
|
m: Mesh
|
|
m.amount_of_indices = u32(len(indices))
|
|
|
|
when RENDER_BACKEND_OPENGL {
|
|
opengl_mesh, ok := opengl_create_mesh(renderer, vertices, indices)
|
|
if !ok {
|
|
return {}, false
|
|
}
|
|
m.backend = opengl_mesh
|
|
}
|
|
else {
|
|
#assert(false)
|
|
}
|
|
|
|
return m, true
|
|
} |