classicube_sys\graphics/
mod.rs1mod owned_gfx_texture;
2mod owned_vertex_buffer;
3
4pub use self::{owned_gfx_texture::*, owned_vertex_buffer::*};
5use crate::{
6 bindings::{
7 Gfx_DrawVb_IndexedTris, Gfx_SetDynamicVbData, GfxResourceID, PackedCol, Texture,
8 VertexTextured,
9 },
10 std_types::{c_int, c_void},
11};
12
13#[allow(clippy::missing_safety_doc)]
14pub unsafe fn Gfx_UpdateDynamicVb_IndexedTris(
15 vb: GfxResourceID,
16 vertices: *mut c_void,
17 vCount: c_int,
18) {
19 unsafe {
20 Gfx_SetDynamicVbData(vb, vertices, vCount);
21 Gfx_DrawVb_IndexedTris(vCount);
22 }
23}
24
25pub fn Gfx_Make2DQuad(tex: &mut Texture, col: PackedCol) -> [VertexTextured; 4] {
26 let x1: f32 = f32::from(tex.x);
27 let x2: f32 = f32::from(tex.x) + f32::from(tex.width);
28 let y1: f32 = f32::from(tex.y);
29 let y2: f32 = f32::from(tex.y) + f32::from(tex.height);
30
31 [
32 VertexTextured {
33 x: x1,
34 y: y1,
35 z: 0.0,
36 Col: col,
37 U: tex.uv.u1,
38 V: tex.uv.v1,
39 },
40 VertexTextured {
41 x: x2,
42 y: y1,
43 z: 0.0,
44 Col: col,
45 U: tex.uv.u2,
46 V: tex.uv.v1,
47 },
48 VertexTextured {
49 x: x2,
50 y: y2,
51 z: 0.0,
52 Col: col,
53 U: tex.uv.u2,
54 V: tex.uv.v2,
55 },
56 VertexTextured {
57 x: x1,
58 y: y2,
59 z: 0.0,
60 Col: col,
61 U: tex.uv.u1,
62 V: tex.uv.v2,
63 },
64 ]
65}