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