1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
mod owned_gfx_texture;
mod owned_vertex_buffer;

pub use self::{owned_gfx_texture::*, owned_vertex_buffer::*};
use crate::{
    bindings::*,
    std_types::{c_int, c_void},
};

#[allow(clippy::missing_safety_doc)]
pub unsafe fn Gfx_UpdateDynamicVb_IndexedTris(
    vb: GfxResourceID,
    vertices: *mut c_void,
    vCount: c_int,
) {
    Gfx_SetDynamicVbData(vb, vertices, vCount);
    Gfx_DrawVb_IndexedTris(vCount);
}

pub fn Gfx_Make2DQuad(tex: &mut Texture, col: PackedCol) -> [VertexTextured; 4] {
    let x1: f32 = tex.x as _;
    let x2: f32 = (tex.x as f32 + tex.width as f32) as _;
    let y1: f32 = tex.y as _;
    let y2: f32 = (tex.y as f32 + tex.height as f32) as _;

    [
        VertexTextured {
            x: x1,
            y: y1,
            z: 0 as _,
            Col: col,
            U: tex.uv.u1,
            V: tex.uv.v1,
        },
        VertexTextured {
            x: x2,
            y: y1,
            z: 0 as _,
            Col: col,
            U: tex.uv.u2,
            V: tex.uv.v1,
        },
        VertexTextured {
            x: x2,
            y: y2,
            z: 0 as _,
            Col: col,
            U: tex.uv.u2,
            V: tex.uv.v2,
        },
        VertexTextured {
            x: x1,
            y: y2,
            z: 0 as _,
            Col: col,
            U: tex.uv.u1,
            V: tex.uv.v2,
        },
    ]
}