remove unused support for index buffers in Renderer
This commit is contained in:
parent
a898d1c38a
commit
93ed4c82fa
|
@ -155,24 +155,20 @@ let set_mat2a : mat2a set_fn =
|
|||
type geometry = {
|
||||
vao : int;
|
||||
draw_mode : Gl.enum;
|
||||
indices : [`count of int | `elems of int];
|
||||
indices : [`range of int * int (* | `elems of int*)];
|
||||
}
|
||||
|
||||
let make_geometry
|
||||
~draw_mode
|
||||
~index
|
||||
~count
|
||||
vertex_buffers
|
||||
=
|
||||
let vao = Gl.gen_vertex_arrays 1 Gl._i32; Int32.to_int Gl._i32.{0} in
|
||||
Gl.bind_vertex_array vao;
|
||||
let indices = match index with
|
||||
| `count n ->
|
||||
let indices =
|
||||
Gl.bind_buffer Gl.element_array_buffer 0;
|
||||
`count n
|
||||
| `elems ibuf ->
|
||||
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)
|
||||
`range (0, count)
|
||||
(* TODO: index buffer (useful for drawing rect borders) *)
|
||||
in
|
||||
List.iter bind_vertex_buffer vertex_buffers;
|
||||
{
|
||||
|
@ -184,12 +180,11 @@ let make_geometry
|
|||
let draw_geometry ?(instances = 1) { vao; draw_mode; indices } =
|
||||
Gl.bind_vertex_array vao;
|
||||
match indices with
|
||||
| `count n ->
|
||||
Gl.draw_arrays_instanced draw_mode 0 n instances
|
||||
| `elems n ->
|
||||
let offset = `Offset 0 in
|
||||
let type_ = Gl.unsigned_short in
|
||||
Gl.draw_elements_instanced draw_mode n type_ offset instances
|
||||
| `range (ofs, len) ->
|
||||
Gl.draw_arrays_instanced draw_mode ofs len instances
|
||||
|
||||
(* | `elems n -> *)
|
||||
(* Gl.draw_elements_instanced draw_mode count type_ offset instances *)
|
||||
|
||||
|
||||
(* Texture *)
|
||||
|
@ -286,7 +281,7 @@ let make ~(wnd : Sdl.window) : t =
|
|||
]
|
||||
]
|
||||
~draw_mode:Gl.triangle_strip
|
||||
~index:(`count 4)
|
||||
~count:4
|
||||
in
|
||||
|
||||
let sprite = load_shader ~name:"sprite" in
|
||||
|
@ -298,7 +293,7 @@ let make ~(wnd : Sdl.window) : t =
|
|||
(* sprite_instances *)
|
||||
]
|
||||
~draw_mode:Gl.triangle_strip
|
||||
~index:(`count 4)
|
||||
~count:4
|
||||
in
|
||||
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue