mireforge_render_wgpu/
gfx.rs

1use crate::{
2    FixedAtlas, FontAndMaterial, FrameLookup, MaterialRef, NineSliceAndMaterial, SpriteParams,
3};
4use int_math::{URect, UVec2, Vec2, Vec3};
5use mireforge_render::{AspectRatio, Color, ViewportStrategy, VirtualScale};
6use monotonic_time_rs::Millis;
7
8pub trait Gfx {
9    fn sprite_atlas_frame(&mut self, position: Vec3, frame: u16, atlas: &impl FrameLookup);
10    fn sprite_atlas(&mut self, position: Vec3, atlas_rect: URect, material_ref: &MaterialRef);
11    fn draw_sprite(&mut self, position: Vec3, material_ref: &MaterialRef);
12    fn draw_sprite_ex(&mut self, position: Vec3, material_ref: &MaterialRef, params: &SpriteParams);
13    fn quad(&mut self, position: Vec3, size: UVec2, color: Color);
14    fn draw_with_mask(
15        &mut self,
16        position: Vec3,
17        size: UVec2,
18        color: Color,
19        alpha_masked: &MaterialRef,
20    );
21
22    fn nine_slice(
23        &mut self,
24        position: Vec3,
25        size: UVec2,
26        color: Color,
27        nine_slice: &NineSliceAndMaterial,
28    );
29    fn set_origin(&mut self, position: Vec2);
30    fn set_clear_color(&mut self, color: Color);
31
32    fn tilemap_params(
33        &mut self,
34        position: Vec3,
35        tiles: &[u16],
36        width: u16,
37        atlas_ref: &FixedAtlas,
38        scale: u8,
39    );
40
41    fn text_draw(&mut self, position: Vec3, text: &str, font_ref: &FontAndMaterial, color: &Color);
42
43    #[must_use]
44    fn now(&self) -> Millis;
45
46    #[must_use]
47    fn physical_aspect_ratio(&self) -> AspectRatio;
48
49    #[must_use]
50    fn physical_size(&self) -> UVec2;
51
52    fn set_viewport(&mut self, viewport_strategy: ViewportStrategy);
53
54    #[must_use]
55    fn viewport(&self) -> &ViewportStrategy;
56
57    fn set_scale(&mut self, scale_factor: VirtualScale);
58
59    fn set_virtual_size(&mut self, virtual_size: UVec2);
60}