Skip to main content

repame_view2d/
lib.rs

1//! 2D viewport: snapshot in, pixels out.
2//!
3//! The whole 2D screen path of a game lives here, plain sprites included: a
4//! game that draws sprite quads over an atlas needs nothing else, and uses
5//! [`SpriteInstance`] rows through the instanced [`SpriteBatch`], framed by a
6//! dp-space [`Camera2d`] ([`FitMode`]) whose fit law the canvas, the GPU batch
7//! and the CPU picks all read from the same functions ([`effective_fit`],
8//! [`fit_view_proj`], [`world_to_dp`], [`dp_to_world`]).
9//!
10//! Around that core:
11//!
12//! * [`RasterAtlas`] - raster sheets drawn through the same batch, and the
13//!   world-anchored [`ActorDrawList`] that puts them, `.ren` vector rigs and
14//!   solid rects in one z order.
15//! * [`light`] / [`lightpass`] - 2D lighting: point lights with ramped or
16//!   textured falloff, Godot's add/sub/mix blend modes, `light_mask` layers,
17//!   and polygon occluders casting filtered shadows into a light map that
18//!   [`SpriteBatch::set_light_source`] consumes.
19//! * [`WorldText`] - world-anchored text floaters, and [`design`] - the design
20//!   box onto dp canvas mapping games would otherwise hand-roll.
21//! * [`PickEvent`] - presses, hovers and the slop rule behind a click, plus
22//!   [`CursorFrame`]s for a hardware cursor.
23//! * [`fullscreen`] - the fullscreen post pass hook, driven by a WGSL shader
24//!   and per-pass uniforms/textures.
25//! * [`actors_view`] - `.ren` rigs played through `renamite-player`, one rig
26//!   filling one presented surface.
27//!
28//! Unit discipline lives here, once: games work in world/dp units and do not
29//! touch physical px.
30
31pub mod actors;
32pub use actors::{
33    ActorFit, ActorViewOpts, MINIMAL_REN, actors_view, actors_view_with, host_from_bytes,
34    host_from_str,
35};
36pub use renamite_player::{Player, PlayerError};
37pub use renamite_player_ui::{PlayerHost, PlayerHostRef, ViewTransform};
38
39pub mod batch;
40pub use batch::{
41    AtlasUpload, BatchDesc, BatchFrame, SpriteBatch, TextureFilter, draw_batch, draw_batch_with_id,
42    frame_uv, instance_rows, screen_camera, sprite_aabb,
43};
44
45pub mod camera;
46pub use camera::{
47    Camera2d, FitMode, contain_fit, dp_to_world, dp_to_world_with_roll, effective_fit,
48    fit_view_proj, fit_view_proj_with_roll, unproject_px, world_to_dp, world_to_dp_with_roll,
49};
50
51pub mod cursor;
52pub use cursor::{CursorFrame, cursor_frame};
53
54pub mod design;
55pub use design::{DesignFit, DesignMapping, cover_fit};
56
57pub mod draw;
58pub use draw::{
59    ActorDraw, ActorDrawList, ActorId, ActorItem, ActorLibrary, RasterAtlas, actors_view_mixed,
60    actors_view_mixed_with_events, actors_view_world, actors_view_world_with_events,
61};
62
63pub mod fullscreen;
64pub use fullscreen::{
65    FullscreenDesc, FullscreenPass, FullscreenTexture, FullscreenTextureRef,
66    FullscreenTextureUpload,
67};
68
69pub mod light;
70pub use light::{
71    AMBIENT_SOURCE, AmbientLight, Light2d, LightBlend, LightBudget, LightFalloff, LightIssue,
72    LightIssueKind, LightStop, LightingPlan, MAX_FALLOFF_STOPS, MAX_LIGHT_LAYERS, MAX_MASK_TAPS,
73    MAX_OCCLUDER_POINTS, Occluder2d, OccluderReject, OccluderRejectReason, PlannedLight,
74    ShadowCasters, ShadowFilter, ShadowWedge, ValidatedOccluder, item_layer, plan_lighting,
75    shadow_wedges, stops_at, texture_uv, visible_world_rect,
76};
77
78pub mod lightpass;
79pub use lightpass::{
80    Light2dDesc, Light2dPass, LightTextureUpload, LightmapInfo, lookup_lightmap,
81};
82
83pub mod pick;
84pub use pick::{CLICK_SLOP_DP, PickEvent, click_within_slop_dp};
85
86pub mod sprite;
87pub use sprite::{SpriteBlend, SpriteInstance, WorldText, rgba8};