Skip to content

Commit

Permalink
Add get_vertex_attrib_parameter_f32_slice
Browse files Browse the repository at this point in the history
Signed-off-by: sagudev <[email protected]>
  • Loading branch information
sagudev committed Oct 24, 2024
1 parent 585e426 commit b5f376c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1569,6 +1569,13 @@ pub trait HasContext: __private::Sealed {

unsafe fn vertex_attrib_divisor(&self, index: u32, divisor: u32);

unsafe fn get_vertex_attrib_parameter_f32_slice(
&self,
index: u32,
pname: u32,
result: &mut [f32],
);

unsafe fn vertex_attrib_pointer_f32(
&self,
index: u32,
Expand Down
10 changes: 10 additions & 0 deletions src/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3498,6 +3498,16 @@ impl HasContext for Context {
gl.VertexAttribDivisor(index, divisor);
}

unsafe fn get_vertex_attrib_parameter_f32_slice(
&self,
index: u32,
pname: u32,
result: &mut [f32],
) {
let gl = &self.raw;
gl.GetVertexAttribfv(index, pname, result.as_mut_ptr());
}

unsafe fn vertex_attrib_pointer_f32(
&self,
index: u32,
Expand Down
19 changes: 19 additions & 0 deletions src/web_sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5161,6 +5161,25 @@ impl HasContext for Context {
}
}

unsafe fn get_vertex_attrib_parameter_f32_slice(
&self,
index: u32,
pname: u32,
result: &mut [f32],
) {
let value = match self.raw {
RawRenderingContext::WebGl1(ref gl) => gl.get_vertex_attrib(index, pname),
RawRenderingContext::WebGl2(ref gl) => gl.get_vertex_attrib(index, pname),
}
.unwrap();
use wasm_bindgen::JsCast;
if let Some(value) = value.as_f64() {
result[0] = value as f32;
} else if let Some(values) = value.dyn_ref::<js_sys::Float32Array>() {
values.copy_to(result)
}
}

unsafe fn vertex_attrib_pointer_f32(
&self,
index: u32,
Expand Down

0 comments on commit b5f376c

Please sign in to comment.