mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-11-27 19:28:56 +03:00
Switched from raw pointer casts to using as_ptr()
This commit is contained in:
parent
52128e9baa
commit
30bb9b09d3
@ -47,9 +47,10 @@ pub fn draw() {
|
||||
|
||||
let vertices: [f32; 9] = [-0.7, -0.7, 0.0, 0.7, -0.7, 0.0, 0.0, 0.7, 0.0];
|
||||
let memory_buffer = wasm_bindgen::memory().dyn_into::<WebAssembly::Memory>().unwrap().buffer();
|
||||
let verticles_location = vertices.as_ptr() as u32 / 4;
|
||||
let vert_array = js_sys::Float32Array::new(&memory_buffer).subarray(
|
||||
&vertices as *const f32 as u32 / 4,
|
||||
&vertices as *const f32 as u32 / 4 + vertices.len() as u32,
|
||||
verticles_location,
|
||||
verticles_location + vertices.len() as u32,
|
||||
);
|
||||
|
||||
let buffer = context.create_buffer().unwrap();
|
||||
|
Loading…
Reference in New Issue
Block a user