Skip to main content

mireforge_render_wgpu/
gfx.rs

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