diff --git a/example/chair.odin b/example/chair.odin index fafc8a9..a94fc8a 100644 --- a/example/chair.odin +++ b/example/chair.odin @@ -24,6 +24,9 @@ chair_obj_bytes := #load("./public/chair.obj", string) @private setup_chair :: proc(s: ^State_Chair, program: gl.Program) { + + gl.Enable(gl.CULL_FACE) // don't draw back faces + gl.Enable(gl.DEPTH_TEST) // draw only closest faces data := obj.data_make(context.temp_allocator) it := chair_obj_bytes @@ -39,25 +42,23 @@ setup_chair :: proc(s: ^State_Chair, program: gl.Program) { o.vao = gl.CreateVertexArray() - lines := obj.object_to_lines(data, object, context.allocator) + lines := obj.object_to_triangles(data, object, context.allocator) o.positions = lines.pos[:len(lines)] o.colors = lines.col[:len(lines)] for &pos in o.positions { pos *= 100 + pos.y -= 300 } - slice.fill(o.colors, GREEN) + slice.fill(o.colors, rand_color()) gl.BindVertexArray(o.vao) input_locations_boxes(&o.locations, program) - // gl.Enable(gl.CULL_FACE) // don't draw back faces - // gl.Enable(gl.DEPTH_TEST) // draw only closest faces - attribute(o.a_position, gl.CreateBuffer(), o.positions) attribute(o.a_color , gl.CreateBuffer(), o.colors) } @@ -98,7 +99,7 @@ frame_chair :: proc(s: ^State_Chair, delta: f32) { uniform(o.u_matrix, mat) - gl.DrawArrays(gl.LINES, 0, len(o.positions)) + gl.DrawArrays(gl.TRIANGLES, 0, len(o.positions)) } } diff --git a/example/suzanne.odin b/example/suzanne.odin index f240d90..a7395f8 100644 --- a/example/suzanne.odin +++ b/example/suzanne.odin @@ -36,7 +36,6 @@ setup_suzanne :: proc(s: ^State_Suzanne, program: gl.Program) { pos *= 100 } - // rand_colors(s.colors) slice.fill(s.colors, GREEN) /* Init rotation */ @@ -48,9 +47,6 @@ setup_suzanne :: proc(s: ^State_Suzanne, program: gl.Program) { input_locations_boxes(s, program) - // gl.Enable(gl.CULL_FACE) // don't draw back faces - // gl.Enable(gl.DEPTH_TEST) // draw only closest faces - attribute(s.a_position, gl.CreateBuffer(), s.positions) attribute(s.a_color , gl.CreateBuffer(), s.colors) }