Remove compatibility fn UiPanel_drawTriangle()
This commit is contained in:
parent
0ead815fa1
commit
f53c7ac4cb
|
@ -84,33 +84,44 @@ impl Panel {
|
|||
Self(id)
|
||||
}
|
||||
|
||||
pub fn draw_indexed(&self, vertices: &[MeshVertex], indices: &[MeshIndex]) {
|
||||
unsafe {
|
||||
draw_indexed(
|
||||
vertices.as_ptr() as u32,
|
||||
vertices.len() as u32,
|
||||
indices.as_ptr() as u32,
|
||||
indices.len() as u32,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn draw_text(&self, text: &str) {
|
||||
unsafe { draw_text(text.as_ptr() as u32, text.len() as u32) }
|
||||
}
|
||||
|
||||
pub fn draw_triangle(&self, v1: Vec2, v2: Vec2, v3: Vec2, color: Color) {
|
||||
unsafe {
|
||||
UiPanel_drawTriangle(
|
||||
self.0, v1.x, v1.y, v2.x, v2.y, v3.x, v3.y, color.r, color.g, color.b, color.a,
|
||||
)
|
||||
}
|
||||
let vertices = [
|
||||
MeshVertex {
|
||||
position: v1,
|
||||
color,
|
||||
},
|
||||
MeshVertex {
|
||||
position: v2,
|
||||
color,
|
||||
},
|
||||
MeshVertex {
|
||||
position: v3,
|
||||
color,
|
||||
},
|
||||
];
|
||||
|
||||
let indices = [0, 1, 2];
|
||||
|
||||
self.draw_indexed(&vertices, &indices);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
fn UiPanel_drawTriangle(
|
||||
panel: u32,
|
||||
x1: f32,
|
||||
y1: f32,
|
||||
x2: f32,
|
||||
y2: f32,
|
||||
x3: f32,
|
||||
y3: f32,
|
||||
r: f32,
|
||||
g: f32,
|
||||
b: f32,
|
||||
a: f32,
|
||||
);
|
||||
|
||||
fn draw_indexed(vertices_ptr: u32, vertices_num: u32, indices_ptr: u32, indices_num: u32);
|
||||
fn draw_text(text_ptr: u32, text_len: u32);
|
||||
}
|
||||
|
|
41
src/lib.rs
41
src/lib.rs
|
@ -104,47 +104,6 @@ impl<T: ScriptAbi> WasmtimeScript<T> {
|
|||
},
|
||||
)?;
|
||||
|
||||
linker.func_wrap(
|
||||
module,
|
||||
"UiPanel_drawTriangle",
|
||||
|caller: wasmtime::Caller<'_, T>,
|
||||
_panel: u32,
|
||||
x1: f32,
|
||||
y1: f32,
|
||||
x2: f32,
|
||||
y2: f32,
|
||||
x3: f32,
|
||||
y3: f32,
|
||||
r: f32,
|
||||
g: f32,
|
||||
b: f32,
|
||||
a: f32| {
|
||||
let v1 = Vec2 { x: x1, y: y1 };
|
||||
let v2 = Vec2 { x: x2, y: y2 };
|
||||
let v3 = Vec2 { x: x3, y: y3 };
|
||||
let color = Color { r, g, b, a };
|
||||
|
||||
let vertices = [
|
||||
MeshVertex {
|
||||
position: v1,
|
||||
color,
|
||||
},
|
||||
MeshVertex {
|
||||
position: v2,
|
||||
color,
|
||||
},
|
||||
MeshVertex {
|
||||
position: v3,
|
||||
color,
|
||||
},
|
||||
];
|
||||
|
||||
let indices = [0, 1, 2];
|
||||
|
||||
caller.data().draw_indexed(&vertices, &indices);
|
||||
},
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue