2020-01-16 22:45:47 +03:00
|
|
|
module sapp
|
|
|
|
|
2021-09-21 09:55:06 +03:00
|
|
|
const (
|
2022-01-07 19:01:07 +03:00
|
|
|
max_touchpoints = 8
|
|
|
|
max_mousebuttons = 3
|
|
|
|
max_keycodes = 512
|
|
|
|
max_iconimages = 8
|
2021-09-21 09:55:06 +03:00
|
|
|
)
|
|
|
|
|
2022-10-02 12:10:03 +03:00
|
|
|
[typedef]
|
2021-09-21 09:55:06 +03:00
|
|
|
pub struct C.sapp_range {
|
|
|
|
pub:
|
|
|
|
ptr voidptr
|
|
|
|
size usize
|
|
|
|
}
|
|
|
|
|
2021-12-26 14:02:51 +03:00
|
|
|
pub type Range = C.sapp_range
|
|
|
|
|
2022-10-02 12:10:03 +03:00
|
|
|
[typedef]
|
2021-09-21 09:55:06 +03:00
|
|
|
pub struct C.sapp_image_desc {
|
|
|
|
pub:
|
|
|
|
width int
|
|
|
|
height int
|
2021-12-26 14:02:51 +03:00
|
|
|
pixels Range
|
2021-09-21 09:55:06 +03:00
|
|
|
}
|
|
|
|
|
2021-12-26 14:02:51 +03:00
|
|
|
pub type ImageDesc = C.sapp_image_desc
|
|
|
|
|
2022-10-02 12:10:03 +03:00
|
|
|
[typedef]
|
2021-09-21 09:55:06 +03:00
|
|
|
pub struct C.sapp_icon_desc {
|
|
|
|
sokol_default bool
|
2022-01-07 19:01:07 +03:00
|
|
|
images [max_iconimages]ImageDesc
|
2021-09-21 09:55:06 +03:00
|
|
|
}
|
|
|
|
|
2021-12-26 14:02:51 +03:00
|
|
|
pub type IconDesc = C.sapp_icon_desc
|
|
|
|
|
2022-10-02 12:10:03 +03:00
|
|
|
[typedef]
|
2020-01-16 22:45:47 +03:00
|
|
|
pub struct C.sapp_desc {
|
|
|
|
pub:
|
2021-05-08 13:32:29 +03:00
|
|
|
init_cb fn () // these are the user-provided callbacks without user data
|
|
|
|
frame_cb fn ()
|
|
|
|
cleanup_cb fn ()
|
2021-12-26 14:02:51 +03:00
|
|
|
event_cb fn (&Event) //&sapp_event)
|
2022-04-15 18:25:45 +03:00
|
|
|
fail_cb fn (&u8)
|
2021-04-07 21:39:23 +03:00
|
|
|
|
2021-05-08 13:32:29 +03:00
|
|
|
user_data voidptr // these are the user-provided callbacks with user data
|
|
|
|
init_userdata_cb fn (voidptr)
|
|
|
|
frame_userdata_cb fn (voidptr)
|
|
|
|
cleanup_userdata_cb fn (voidptr)
|
2021-12-26 14:02:51 +03:00
|
|
|
event_userdata_cb fn (&Event, voidptr)
|
2021-05-08 13:32:29 +03:00
|
|
|
fail_userdata_cb fn (&char, voidptr)
|
2021-04-07 21:39:23 +03:00
|
|
|
|
2023-01-11 12:29:38 +03:00
|
|
|
width int // the preferred width of the window / canvas
|
|
|
|
height int // the preferred height of the window / canvas
|
|
|
|
sample_count int // MSAA sample count
|
|
|
|
swap_interval int // the preferred swap interval (ignored on some platforms)
|
|
|
|
high_dpi bool // whether the rendering canvas is full-resolution on HighDPI displays
|
|
|
|
fullscreen bool // whether the window should be created in fullscreen mode
|
|
|
|
alpha bool // whether the framebuffer should have an alpha channel (ignored on some platforms)
|
|
|
|
window_title &char // the window title as UTF-8 encoded string
|
|
|
|
enable_clipboard bool // enable clipboard access, default is false
|
|
|
|
clipboard_size int // max size of clipboard content in bytes
|
|
|
|
enable_dragndrop bool // enable file dropping (drag'n'drop), default is false
|
|
|
|
max_dropped_files int // max number of dropped files to process (default: 1)
|
|
|
|
max_dropped_file_path_length int // max length in bytes of a dropped UTF-8 file path (default: 2048)
|
|
|
|
icon IconDesc // the initial window icon to set
|
2021-05-08 13:32:29 +03:00
|
|
|
// backend-specific options
|
2021-04-07 21:39:23 +03:00
|
|
|
gl_force_gles2 bool // if true, setup GLES2/WebGL even if GLES3/WebGL2 is available
|
|
|
|
win32_console_utf8 bool // if true, set the output console codepage to UTF-8
|
2021-05-08 13:32:29 +03:00
|
|
|
win32_console_create bool // if true, attach stdout/stderr to a new console window
|
|
|
|
win32_console_attach bool // if true, attach stdout/stderr to parent process
|
2021-04-07 21:39:23 +03:00
|
|
|
html5_canvas_name &char // the name (id) of the HTML5 canvas element, default is "canvas"
|
2021-04-04 18:05:01 +03:00
|
|
|
html5_canvas_resize bool // if true, the HTML5 canvas size is set to sapp_desc.width/height, otherwise canvas size is tracked
|
|
|
|
html5_preserve_drawing_buffer bool // HTML5 only: whether to preserve default framebuffer content between frames
|
|
|
|
html5_premultiplied_alpha bool // HTML5 only: whether the rendered pixels use premultiplied alpha convention
|
|
|
|
html5_ask_leave_site bool // initial state of the internal html5_ask_leave_site flag (see sapp_html5_ask_leave_site())
|
|
|
|
ios_keyboard_resizes_canvas bool // if true, showing the iOS keyboard shrinks the canvas
|
2021-05-08 13:32:29 +03:00
|
|
|
// V patches
|
|
|
|
__v_native_render bool // V patch to allow for native rendering
|
2023-01-11 12:29:38 +03:00
|
|
|
pub mut:
|
|
|
|
allocator C.sapp_allocator // optional memory allocation overrides (default: malloc/free)
|
|
|
|
logger C.sapp_logger // optional log callback overrides (default: SAPP_LOG(message))
|
2020-01-16 22:45:47 +03:00
|
|
|
}
|
|
|
|
|
2021-12-26 14:02:51 +03:00
|
|
|
pub type Desc = C.sapp_desc
|
2020-06-01 13:57:04 +03:00
|
|
|
|
2022-10-02 12:10:03 +03:00
|
|
|
[typedef]
|
2020-01-16 22:45:47 +03:00
|
|
|
pub struct C.sapp_event {
|
|
|
|
pub:
|
2023-01-11 12:29:38 +03:00
|
|
|
frame_count u64 // current frame counter, always valid, useful for checking if two events were issued in the same frame
|
|
|
|
@type EventType // the event type, always valid
|
|
|
|
key_code KeyCode // the virtual key code, only valid in KEY_UP, KEY_DOWN
|
|
|
|
char_code u32 // the UTF-32 character code, only valid in CHAR events
|
|
|
|
key_repeat bool // true if this is a key-repeat event, valid in KEY_UP, KEY_DOWN and CHAR
|
|
|
|
modifiers u32 // current modifier keys, valid in all key-, char- and mouse-events
|
|
|
|
mouse_button MouseButton // mouse button that was pressed or released, valid in MOUSE_DOWN, MOUSE_UP
|
|
|
|
mouse_x f32 // current horizontal mouse position in pixels, always valid except during mouse lock
|
|
|
|
mouse_y f32 // current vertical mouse position in pixels, always valid except during mouse lock
|
|
|
|
mouse_dx f32 // relative horizontal mouse movement since last frame, always valid
|
|
|
|
mouse_dy f32 // relative vertical mouse movement since last frame, always valid
|
|
|
|
scroll_x f32 // horizontal mouse wheel scroll distance, valid in MOUSE_SCROLL events
|
|
|
|
scroll_y f32 // vertical mouse wheel scroll distance, valid in MOUSE_SCROLL events
|
|
|
|
num_touches int // number of valid items in the touches[] array
|
|
|
|
touches [max_touchpoints]TouchPoint // current touch points, valid in TOUCHES_BEGIN, TOUCHES_MOVED, TOUCHES_ENDED
|
|
|
|
window_width int // current window- and framebuffer width in pixels, always valid
|
|
|
|
window_height int // current window- and framebuffer height in pixels, always valid
|
|
|
|
framebuffer_width int // = window_width * dpi_scale
|
|
|
|
framebuffer_height int // = window_height * dpi_scale
|
2020-01-16 22:45:47 +03:00
|
|
|
}
|
2021-01-23 12:25:40 +03:00
|
|
|
|
2021-12-26 14:02:51 +03:00
|
|
|
pub type Event = C.sapp_event
|
|
|
|
|
2020-01-16 22:45:47 +03:00
|
|
|
pub fn (e &C.sapp_event) str() string {
|
2022-11-15 16:53:13 +03:00
|
|
|
return 'evt: frame_count=${e.frame_count}, type=${e.@type}'
|
2020-01-16 22:45:47 +03:00
|
|
|
}
|
|
|
|
|
2022-10-02 12:10:03 +03:00
|
|
|
[typedef]
|
2020-01-16 22:45:47 +03:00
|
|
|
pub struct C.sapp_touchpoint {
|
|
|
|
pub:
|
2023-01-11 12:29:38 +03:00
|
|
|
identifier u64
|
|
|
|
pos_x f32
|
|
|
|
pos_y f32
|
|
|
|
android_tooltype TouchToolType
|
|
|
|
changed bool
|
2020-01-16 22:45:47 +03:00
|
|
|
}
|
2021-12-26 14:02:51 +03:00
|
|
|
|
|
|
|
pub type TouchPoint = C.sapp_touchpoint
|