mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
sokol: type alias all sapp
structs (#12962)
This commit is contained in:
@@ -102,7 +102,7 @@ pub fn userdata() voidptr {
|
||||
|
||||
// return a copy of the sapp_desc structure
|
||||
[inline]
|
||||
pub fn query_desc() C.sapp_desc {
|
||||
pub fn query_desc() Desc {
|
||||
return C.sapp_query_desc()
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ pub fn get_clipboard_string() &char {
|
||||
|
||||
// special run-function for SOKOL_NO_ENTRY (in standard mode this is an empty stub)
|
||||
[inline]
|
||||
pub fn run(desc &C.sapp_desc) {
|
||||
pub fn run(desc &Desc) {
|
||||
g_desc = *desc
|
||||
C.sapp_run(desc)
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@ fn C.sapp_mouse_locked() bool
|
||||
fn C.sapp_userdata() voidptr
|
||||
|
||||
// return a copy of the sapp_desc structure
|
||||
fn C.sapp_query_desc() C.sapp_desc
|
||||
fn C.sapp_query_desc() Desc
|
||||
|
||||
// initiate a "soft quit" (sends SAPP_EVENTTYPE_QUIT_REQUESTED)
|
||||
fn C.sapp_request_quit()
|
||||
@@ -63,7 +63,7 @@ fn C.sapp_set_clipboard_string(str &byte)
|
||||
fn C.sapp_get_clipboard_string() &byte
|
||||
|
||||
// special run-function for SOKOL_NO_ENTRY (in standard mode this is an empty stub)
|
||||
fn C.sapp_run(desc &C.sapp_desc) int
|
||||
fn C.sapp_run(desc &Desc) int
|
||||
|
||||
// GL: return true when GLES2 fallback is active (to detect fallback from GLES3)
|
||||
fn C.sapp_gles2() bool
|
||||
|
@@ -13,31 +13,37 @@ pub:
|
||||
size usize
|
||||
}
|
||||
|
||||
pub type Range = C.sapp_range
|
||||
|
||||
pub struct C.sapp_image_desc {
|
||||
pub:
|
||||
width int
|
||||
height int
|
||||
pixels C.spp_range
|
||||
pixels Range
|
||||
}
|
||||
|
||||
pub type ImageDesc = C.sapp_image_desc
|
||||
|
||||
pub struct C.sapp_icon_desc {
|
||||
sokol_default bool
|
||||
images [sapp_max_iconimages]C.sapp_image_desc
|
||||
images [sapp_max_iconimages]ImageDesc
|
||||
}
|
||||
|
||||
pub type IconDesc = C.sapp_icon_desc
|
||||
|
||||
pub struct C.sapp_desc {
|
||||
pub:
|
||||
init_cb fn () // these are the user-provided callbacks without user data
|
||||
frame_cb fn ()
|
||||
cleanup_cb fn ()
|
||||
event_cb fn (&C.sapp_event) //&sapp_event)
|
||||
event_cb fn (&Event) //&sapp_event)
|
||||
fail_cb fn (&byte)
|
||||
|
||||
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)
|
||||
event_userdata_cb fn (&C.sapp_event, voidptr)
|
||||
event_userdata_cb fn (&Event, voidptr)
|
||||
fail_userdata_cb fn (&char, voidptr)
|
||||
|
||||
width int // the preferred width of the window / canvas
|
||||
@@ -54,7 +60,7 @@ pub:
|
||||
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 C.sapp_icon_desc
|
||||
icon IconDesc
|
||||
// backend-specific options
|
||||
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
|
||||
@@ -70,28 +76,7 @@ pub:
|
||||
__v_native_render bool // V patch to allow for native rendering
|
||||
}
|
||||
|
||||
pub struct Event {
|
||||
pub:
|
||||
frame_count u64
|
||||
typ EventType
|
||||
key_code KeyCode
|
||||
char_code u32
|
||||
key_repeat bool
|
||||
modifiers u32
|
||||
mouse_button MouseButton
|
||||
mouse_x f32
|
||||
mouse_y f32
|
||||
mouse_dx f32
|
||||
mouse_dy f32
|
||||
scroll_x f32
|
||||
scroll_y f32
|
||||
num_touches int
|
||||
touches [sapp_max_touchpoints]C.sapp_touchpoint
|
||||
window_width int
|
||||
window_height int
|
||||
framebuffer_width int
|
||||
framebuffer_height int
|
||||
}
|
||||
pub type Desc = C.sapp_desc
|
||||
|
||||
pub struct C.sapp_event {
|
||||
pub:
|
||||
@@ -109,13 +94,15 @@ pub:
|
||||
scroll_x f32
|
||||
scroll_y f32
|
||||
num_touches int
|
||||
touches [sapp_max_touchpoints]C.sapp_touchpoint
|
||||
touches [sapp_max_touchpoints]TouchPoint
|
||||
window_width int
|
||||
window_height int
|
||||
framebuffer_width int
|
||||
framebuffer_height int
|
||||
}
|
||||
|
||||
pub type Event = C.sapp_event
|
||||
|
||||
pub fn (e &C.sapp_event) str() string {
|
||||
t := e.@type
|
||||
return 'evt: frame_count=$e.frame_count, type=$t'
|
||||
@@ -128,3 +115,5 @@ pub:
|
||||
pos_y f32
|
||||
changed bool
|
||||
}
|
||||
|
||||
pub type TouchPoint = C.sapp_touchpoint
|
||||
|
Reference in New Issue
Block a user