remove unused support for index buffers in Renderer

This commit is contained in:
tali 2024-01-20 12:21:29 -05:00
parent a898d1c38a
commit 93ed4c82fa
1 changed files with 13 additions and 18 deletions

View File

@ -155,24 +155,20 @@ let set_mat2a : mat2a set_fn =
type geometry = { type geometry = {
vao : int; vao : int;
draw_mode : Gl.enum; draw_mode : Gl.enum;
indices : [`count of int | `elems of int]; indices : [`range of int * int (* | `elems of int*)];
} }
let make_geometry let make_geometry
~draw_mode ~draw_mode
~index ~count
vertex_buffers vertex_buffers
= =
let vao = Gl.gen_vertex_arrays 1 Gl._i32; Int32.to_int Gl._i32.{0} in let vao = Gl.gen_vertex_arrays 1 Gl._i32; Int32.to_int Gl._i32.{0} in
Gl.bind_vertex_array vao; Gl.bind_vertex_array vao;
let indices = match index with let indices =
| `count n ->
Gl.bind_buffer Gl.element_array_buffer 0; Gl.bind_buffer Gl.element_array_buffer 0;
`count n `range (0, count)
| `elems ibuf -> (* TODO: index buffer (useful for drawing rect borders) *)
Gl.bind_buffer Gl.element_array_buffer ibuf.bo;
(* divide by 2 since the buffer should contain int16_unsigned *)
`elems (buffer_size_in_bytes ibuf / 2)
in in
List.iter bind_vertex_buffer vertex_buffers; List.iter bind_vertex_buffer vertex_buffers;
{ {
@ -184,12 +180,11 @@ let make_geometry
let draw_geometry ?(instances = 1) { vao; draw_mode; indices } = let draw_geometry ?(instances = 1) { vao; draw_mode; indices } =
Gl.bind_vertex_array vao; Gl.bind_vertex_array vao;
match indices with match indices with
| `count n -> | `range (ofs, len) ->
Gl.draw_arrays_instanced draw_mode 0 n instances Gl.draw_arrays_instanced draw_mode ofs len instances
| `elems n ->
let offset = `Offset 0 in (* | `elems n -> *)
let type_ = Gl.unsigned_short in (* Gl.draw_elements_instanced draw_mode count type_ offset instances *)
Gl.draw_elements_instanced draw_mode n type_ offset instances
(* Texture *) (* Texture *)
@ -286,7 +281,7 @@ let make ~(wnd : Sdl.window) : t =
] ]
] ]
~draw_mode:Gl.triangle_strip ~draw_mode:Gl.triangle_strip
~index:(`count 4) ~count:4
in in
let sprite = load_shader ~name:"sprite" in let sprite = load_shader ~name:"sprite" in
@ -298,7 +293,7 @@ let make ~(wnd : Sdl.window) : t =
(* sprite_instances *) (* sprite_instances *)
] ]
~draw_mode:Gl.triangle_strip ~draw_mode:Gl.triangle_strip
~index:(`count 4) ~count:4
in in
{ {