API / platform
platform
플랫폼 층.
- 창(또는 캔버스), GL 컨텍스트, 입력 이벤트, 프레임 루프, 화면 넘기기를 맡는다.
- 엔진 본체(core::engine::EngineRunner)는 플랫폼을 모른다. 플랫폼마다 아래 것들을 같은 이름으로 낸다. run(엔진 실행자), set_cursor_visible, set_cursor(커서 모양), is_coarse_pointer(주된 손이 손가락인지), set_title, request_asset_bytes(애셋 바이트 읽기), PlatformWindow(엔진이 들고 있는 창 손잡이), write_clipboard_text / read_clipboard_text(시스템 클립보드) read_page_query_value(페이지 주소의 쿼리 값), read_safe_area_insets(CSS env 세이프 에어리어 인셋) read_canvas_client_position(화면 좌표에서 캔버스의 왼쪽 위), read_client_native_size(페이지 전체 크기, 데스크탑은 None) save_capture_file(검증용 화면 저장, 데스크탑은 파일, 웹은 내려받기)
- 웹만 is_gl_binding_present(GL 의 묶인 것이 있는지, glow 웹이 null 을 읽으면 패닉해서)를 낸다. (core::graphic 의 read_*_binding 이 쓴다)
- 맥만 vibrate_gamepads / release_disconnected_gamepad_haptics(게임패드 진동, desktop/gamepadhaptics.rs)를 낸다.
- 데스크탑만 desktop::read_heap_usage(시스템 할당자의 힙 사용량, 개발자 도구의 메모리 칸)를 낸다. (웹은 원본처럼 performance.memory 를 읽는다)
- 안드로이드, iOS 는 여기에 모듈을 더한다. (아직 없음)
Platform layer.
- Handles the window (or canvas), GL context, input events, frame loop and buffer swapping.
- The engine core (core::engine::EngineRunner) does not know the platform. Each platform exposes the following under the same names. run (engine runner), set_cursor_visible, set_cursor (cursor shape), is_coarse_pointer (whether the primary pointer is a finger), set_title, request_asset_bytes (reading asset bytes), PlatformWindow (the window handle the engine holds), write_clipboard_text / read_clipboard_text (system clipboard) read_page_query_value (a query value of the page URL), read_safe_area_insets (CSS env safe area insets) read_canvas_client_position (the top-left of the canvas in screen coordinates), read_client_native_size (the whole page size, None on desktop) save_capture_file (saving a screenshot for verification, a file on desktop, a download on the web)
- Only the web exposes is_gl_binding_present (whether something is bound in GL, because glow on the web panics when it reads null). (used by read_*_binding in core::graphic)
- Only macOS exposes vibrate_gamepads / release_disconnected_gamepad_haptics (gamepad vibration, desktop/gamepadhaptics.rs).
- Only desktop exposes desktop::read_heap_usage (heap usage of the system allocator, the memory field of the developer tools). (the web reads performance.memory as in the original)
- Android and iOS add modules here. (not yet)
LocalTimestruct traits Clone, Copy, Debug, PartialEq, Eq
현지 시각. (이 기계의 시간대로 본 달력 시각, 원본 Engine.readLocalTime 이 돌려주는 {year, month, day, hour, minute, second, weekday} 와 같다)
Local time. (the calendar time in this machine's time zone, same as the {year, month, day, hour, minute, second, weekday} that the original Engine.readLocalTime returns)
예제Example지금의 현지 시각 읽기Read the current local time
use vanilla::platform::read_local_time;
let local_time = read_local_time(0.0);
assert!(local_time.year >= 2026);
assert!((1..=12).contains(&local_time.month));
assert!((1..=31).contains(&local_time.day));
assert!(local_time.hour < 24);