summaryrefslogtreecommitdiff
path: root/engine/src/opengl/vertex_array.rs
diff options
context:
space:
mode:
Diffstat (limited to 'engine/src/opengl/vertex_array.rs')
-rw-r--r--engine/src/opengl/vertex_array.rs29
1 files changed, 24 insertions, 5 deletions
diff --git a/engine/src/opengl/vertex_array.rs b/engine/src/opengl/vertex_array.rs
index ba2ded2..6b6065c 100644
--- a/engine/src/opengl/vertex_array.rs
+++ b/engine/src/opengl/vertex_array.rs
@@ -1,6 +1,6 @@
use std::mem::size_of;
-use crate::opengl::buffer::Buffer;
+use crate::opengl::buffer::{ArrayKind as ArrayBufferKind, Buffer};
use crate::opengl::currently_bound::CurrentlyBound;
use crate::vertex::{Attribute, AttributeComponentType, Vertex};
@@ -26,11 +26,11 @@ impl VertexArray
}
/// Draws the currently bound vertex array.
- pub fn draw(
+ pub fn draw_arrays(
_currently_bound: &CurrentlyBound<Self>,
primitive_kind: PrimitiveKind,
start_index: u32,
- index_cnt: u32,
+ cnt: u32,
)
{
unsafe {
@@ -38,14 +38,33 @@ impl VertexArray
gl::DrawArrays(
primitive_kind.into_gl(),
start_index as gl::types::GLint,
- index_cnt as gl::types::GLsizei,
+ cnt as gl::types::GLsizei,
+ );
+ }
+ }
+
+ /// Draws the currently bound vertex array.
+ pub fn draw_elements(
+ _currently_bound: &CurrentlyBound<Self>,
+ primitive_kind: PrimitiveKind,
+ offset: u32,
+ cnt: u32,
+ )
+ {
+ unsafe {
+ #[allow(clippy::cast_possible_wrap)]
+ gl::DrawElements(
+ primitive_kind.into_gl(),
+ cnt as gl::types::GLsizei,
+ gl::UNSIGNED_INT,
+ (offset as gl::types::GLint) as *const _,
);
}
}
pub fn configure_attrs(
_currently_bound: &CurrentlyBound<Self>,
- _vert_buf_curr_bound: &CurrentlyBound<Buffer<Vertex>>,
+ _vert_buf_curr_bound: &CurrentlyBound<Buffer<Vertex, ArrayBufferKind>>,
)
{
let mut offset = 0;