sokol.sapp #
fn android_get_native_activity #
fn android_get_native_activity() voidptr
Android: get native activity handle
fn cancel_quit #
fn cancel_quit()
cancel a pending quit (when SAPP_EVENTTYPE_QUIT_REQUESTED has been received)
fn color_format #
fn color_format() int
color_format gets default framebuffer color pixel format
fn consume_event #
fn consume_event()
call from inside event callback to consume the current event (don't forward to platform)
fn create_default_pass #
fn create_default_pass(action gfx.PassAction) gfx.Pass
create_default_pass creates a default gfx.Pass
compatible with sapp
and sokol.gfx.begin_pass/1
.
fn create_desc #
fn create_desc() gfx.Desc
fn d3d11_get_depth_stencil_view #
fn d3d11_get_depth_stencil_view() voidptr
D3D11: get pointer to ID3D11DepthStencilView
fn d3d11_get_device #
fn d3d11_get_device() voidptr
D3D11: get pointer to ID3D11Device object
fn d3d11_get_device_context #
fn d3d11_get_device_context() voidptr
D3D11: get pointer to ID3D11DeviceContext object
fn d3d11_get_render_view #
fn d3d11_get_render_view() voidptr
D3D11: get pointer to ID3D11RenderView object
fn d3d11_get_resolve_view #
fn d3d11_get_resolve_view() voidptr
D3D11: get pointer ID3D11RenderTargetView object for msaa-resolve (may return null)
fn depth_format #
fn depth_format() int
depth_format gets default framebuffer depth pixel format
fn dpi_scale #
fn dpi_scale() f32
returns the dpi scaling factor (window pixels to framebuffer pixels)
fn frame_count #
fn frame_count() u64
get the current frame counter (for comparison with sapp_event.frame_count)
fn frame_duration #
fn frame_duration() f64
get an averaged/smoothed frame duration in seconds
fn get_clipboard_string #
fn get_clipboard_string() &char
read string from clipboard (usually during SAPP_EVENTTYPE_CLIPBOARD_PASTED)
fn get_dropped_file_path #
fn get_dropped_file_path(index int) string
fn get_num_dropped_files #
fn get_num_dropped_files() int
fn gl_get_framebuffer #
fn gl_get_framebuffer() u32
GL: get framebuffer object
fn glue_environment #
fn glue_environment() gfx.Environment
glue_environment returns a gfx.Environment
compatible for use with sapp
specific gfx.Pass
es. The retuned gfx.Environment
can be used when rendering via sapp
. See also: documentation at the top of thirdparty/sokol/sokol_gfx.h
fn glue_swapchain #
fn glue_swapchain() gfx.Swapchain
glue_swapchain returns a gfx.Swapchain
compatible for use with sapp
specific display/rendering gfx.Pass
es. The retuned gfx.Swapchain
can be used when rendering via sapp
. See also: documentation at the top of thirdparty/sokol/sokol_gfx.h
fn height #
fn height() int
returns the current framebuffer height in pixels
fn high_dpi #
fn high_dpi() bool
returns true when high_dpi was requested and actually running in a high-dpi scenario
fn html5_ask_leave_site #
fn html5_ask_leave_site(ask bool)
HTML5: enable or disable the hardwired "Leave Site?" dialog box
fn ios_get_window #
fn ios_get_window() voidptr
iOS: get ARC-bridged pointer to iOS UIWindow
fn is_fullscreen #
fn is_fullscreen() bool
Check if full screen rendering
fn isvalid #
fn isvalid() bool
returns true after sokol-app has been initialized
fn keyboard_shown #
fn keyboard_shown() bool
return true if the mobile device onscreen keyboard is currently shown
fn lock_mouse #
fn lock_mouse(locked bool)
fn macos_get_window #
fn macos_get_window() voidptr
macOS: get ARC-bridged pointer to macOS NSWindow
fn metal_get_current_drawable #
fn metal_get_current_drawable() voidptr
Metal: get ARC-bridged pointer to current drawable
fn metal_get_depth_stencil_texture #
fn metal_get_depth_stencil_texture() voidptr
Metal: get bridged pointer to MTKView's depth-stencil texture of type MTLTexture
fn metal_get_device #
fn metal_get_device() voidptr
Metal: get ARC-bridged pointer to Metal device object
fn metal_get_msaa_color_texture #
fn metal_get_msaa_color_texture() voidptr
Metal: get bridged pointer to MTKView's msaa-color-texture of type MTLTexture (may be null)
fn mouse_locked #
fn mouse_locked() bool
fn mouse_shown #
fn mouse_shown() bool
show or hide the mouse cursor
fn query_desc #
fn query_desc() Desc
return a copy of the sapp_desc structure
fn quit #
fn quit()
initiate a "hard quit" (quit application without sending SAPP_EVENTTYPE_QUIT_REQUESTED)
fn request_quit #
fn request_quit()
initiate a "soft quit" (sends SAPP_EVENTTYPE_QUIT_REQUESTED)
fn run #
fn run(desc &Desc)
special run-function for SOKOL_NO_ENTRY (in standard mode this is an empty stub)
fn sample_count #
fn sample_count() int
sample_count gets default framebuffer sample count
fn screenshot #
fn screenshot(path string) !
screenshot takes a screenshot of the current window and saves it to path
. The format is inferred from the extension of the file name in path
.
Supported formats are: .png
, .ppm
.
fn screenshot_png #
fn screenshot_png(path string) !
screenshot_png takes a screenshot of the current window and saves it to path
as a .png file.
fn screenshot_ppm #
fn screenshot_ppm(path string) !
screenshot_ppm takes a screenshot of the current window and saves it to path
as a .ppm file.
fn screenshot_window #
fn screenshot_window() &Screenshot
fn set_clipboard_string #
fn set_clipboard_string(str &u8)
write string into clipboard
fn set_mouse_cursor #
fn set_mouse_cursor(cursor MouseCursor)
set mouse cursor
fn show_keyboard #
fn show_keyboard(visible bool)
show or hide the mobile device onscreen keyboard
fn show_mouse #
fn show_mouse(visible bool)
show or hide the mouse cursor
fn toggle_fullscreen #
fn toggle_fullscreen()
Toggle full screen
fn userdata #
fn userdata() voidptr
return the userdata pointer optionally provided in sapp_desc
fn wgpu_get_depth_stencil_view #
fn wgpu_get_depth_stencil_view() voidptr
WebGPU: get swapchain's WGPUTextureView for the depth-stencil surface
fn wgpu_get_device #
fn wgpu_get_device() voidptr
WebGPU: get WGPUDevice handle
fn wgpu_get_render_view #
fn wgpu_get_render_view() voidptr
WebGPU: get swapchain's WGPUTextureView handle for rendering
fn wgpu_get_resolve_view #
fn wgpu_get_resolve_view() voidptr
WebGPU: get swapchain's MSAA-resolve WGPUTextureView (may return null)
fn width #
fn width() int
returns the current framebuffer width in pixels
fn win32_get_hwnd #
fn win32_get_hwnd() voidptr
Win32: get the HWND window handle
type Desc #
type Desc = C.sapp_desc
type Event #
type Event = C.sapp_event
type IconDesc #
type IconDesc = C.sapp_icon_desc
type ImageDesc #
type ImageDesc = C.sapp_image_desc
type Range #
type Range = C.sapp_range
type TouchPoint #
type TouchPoint = C.sapp_touchpoint
enum EventType #
enum EventType {
invalid
key_down
key_up
char
mouse_down
mouse_up
mouse_scroll
mouse_move
mouse_enter
mouse_leave
touches_began
touches_moved
touches_ended
touches_cancelled
resized
iconified
restored
focused
unfocused
suspended
resumed
quit_requested
clipboard_pasted
files_dropped
num
}
enum KeyCode #
enum KeyCode {
invalid = 0
space = 32
apostrophe = 39 //'
comma = 44 //,
minus = 45 //-
period = 46 //.
slash = 47 ///
_0 = 48
_1 = 49
_2 = 50
_3 = 51
_4 = 52
_5 = 53
_6 = 54
_7 = 55
_8 = 56
_9 = 57
semicolon = 59 //;
equal = 61 //=
a = 65
b = 66
c = 67
d = 68
e = 69
f = 70
g = 71
h = 72
i = 73
j = 74
k = 75
l = 76
m = 77
n = 78
o = 79
p = 80
q = 81
r = 82
s = 83
t = 84
u = 85
v = 86
w = 87
x = 88
y = 89
z = 90
left_bracket = 91 //[
backslash = 92 //\
right_bracket = 93 //]
grave_accent = 96 //`
world_1 = 161 // non-us #1
world_2 = 162 // non-us #2
escape = 256
enter = 257
tab = 258
backspace = 259
insert = 260
delete = 261
right = 262
left = 263
down = 264
up = 265
page_up = 266
page_down = 267
home = 268
end = 269
caps_lock = 280
scroll_lock = 281
num_lock = 282
print_screen = 283
pause = 284
f1 = 290
f2 = 291
f3 = 292
f4 = 293
f5 = 294
f6 = 295
f7 = 296
f8 = 297
f9 = 298
f10 = 299
f11 = 300
f12 = 301
f13 = 302
f14 = 303
f15 = 304
f16 = 305
f17 = 306
f18 = 307
f19 = 308
f20 = 309
f21 = 310
f22 = 311
f23 = 312
f24 = 313
f25 = 314
kp_0 = 320
kp_1 = 321
kp_2 = 322
kp_3 = 323
kp_4 = 324
kp_5 = 325
kp_6 = 326
kp_7 = 327
kp_8 = 328
kp_9 = 329
kp_decimal = 330
kp_divide = 331
kp_multiply = 332
kp_subtract = 333
kp_add = 334
kp_enter = 335
kp_equal = 336
left_shift = 340
left_control = 341
left_alt = 342
left_super = 343
right_shift = 344
right_control = 345
right_alt = 346
right_super = 347
menu = 348
}
enum Modifier #
enum Modifier {
shift = 1 //(1<<0)
ctrl = 2 //(1<<1)
alt = 4 //(1<<2)
super = 8 //(1<<3)
lmb = 0x100
rmb = 0x200
mmb = 0x400
}
enum MouseButton #
enum MouseButton {
invalid = -1
left = 0
right = 1
middle = 2
}
enum MouseCursor #
enum MouseCursor {
default = C.SAPP_MOUSECURSOR_DEFAULT
arrow = C.SAPP_MOUSECURSOR_ARROW
ibeam = C.SAPP_MOUSECURSOR_IBEAM
crosshair = C.SAPP_MOUSECURSOR_CROSSHAIR
pointing_hand = C.SAPP_MOUSECURSOR_POINTING_HAND
resize_ew = C.SAPP_MOUSECURSOR_RESIZE_EW
resize_ns = C.SAPP_MOUSECURSOR_RESIZE_NS
resize_nwse = C.SAPP_MOUSECURSOR_RESIZE_NWSE
resize_nesw = C.SAPP_MOUSECURSOR_RESIZE_NESW
resize_all = C.SAPP_MOUSECURSOR_RESIZE_ALL
not_allowed = C.SAPP_MOUSECURSOR_NOT_ALLOWED
}
enum TouchToolType #
enum TouchToolType {
unknown
finger
stylus
mouse
eraser
palm
}
TouchToolType is an Android specific 'tool type' enum for touch events. This lets the application check what type of input device was used for touch events.
Note: the values must remain in sync with the corresponding Android SDK type, so don't change those. See https://developer.android.com/reference/android/view/MotionEvent#TOOL_TYPE_UNKNOWN
struct C.sapp_allocator #
struct C.sapp_allocator {
pub mut:
alloc_fn memory.FnAllocatorAlloc = unsafe { nil }
free_fn memory.FnAllocatorFree = unsafe { nil }
user_data voidptr
}
struct C.sapp_desc #
struct C.sapp_desc {
pub:
// these are the user-provided callbacks without user data
init_cb fn () = unsafe { nil }
frame_cb fn () = unsafe { nil }
cleanup_cb fn () = unsafe { nil }
event_cb fn (&Event) = unsafe { nil } // &sapp_event
// fail_cb fn (&u8) = unsafe { nil }
user_data voidptr // these are the user-provided callbacks with user data
init_userdata_cb fn (voidptr) = unsafe { nil }
frame_userdata_cb fn (voidptr) = unsafe { nil }
cleanup_userdata_cb fn (voidptr) = unsafe { nil }
event_userdata_cb fn (&Event, voidptr) = unsafe { nil }
// fail_userdata_cb fn (&char, voidptr) = unsafe { nil }
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
// backend-specific options
win32_console_utf8 bool // if true, set the output console codepage to UTF-8
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
html5_canvas_name &char // the name (id) of the HTML5 canvas element, default is "canvas"
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
// V patches
__v_native_render bool // V patch to allow for native rendering
min_width int // V patch to allow for min window width
min_height int // V patch to allow for min window height
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))
}
struct C.sapp_event #
struct C.sapp_event {
pub:
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
}
fn (C.sapp_event) str #
fn (e &C.sapp_event) str() string
struct C.sapp_icon_desc #
struct C.sapp_icon_desc {
pub:
sokol_default bool
images [max_iconimages]ImageDesc
}
struct C.sapp_image_desc #
struct C.sapp_image_desc {
pub:
width int
height int
pixels Range
}
struct C.sapp_logger #
struct C.sapp_logger {
pub mut:
func memory.FnLogCb = unsafe { nil }
user_data voidptr
}
struct C.sapp_range #
struct C.sapp_range {
pub:
ptr voidptr
size usize
}
sapp_range is a general pointer/size-pair struct for passing binary blobs into sokol_app.h
struct C.sapp_touchpoint #
struct C.sapp_touchpoint {
pub:
identifier u64
pos_x f32
pos_y f32
android_tooltype TouchToolType
changed bool
}
struct Screenshot #
struct Screenshot {
width int
height int
size int
mut:
pixels &u8 = unsafe { nil }
}
fn (Screenshot) free #
fn (mut ss Screenshot) free()
free - free only the Screenshot pixels.
fn (Screenshot) destroy #
fn (mut ss Screenshot) destroy()
destroy - free the Screenshot pixels, then free the screenshot data structure itself.
- fn android_get_native_activity
- fn cancel_quit
- fn color_format
- fn consume_event
- fn create_default_pass
- fn create_desc
- fn d3d11_get_depth_stencil_view
- fn d3d11_get_device
- fn d3d11_get_device_context
- fn d3d11_get_render_view
- fn d3d11_get_resolve_view
- fn depth_format
- fn dpi_scale
- fn frame_count
- fn frame_duration
- fn get_clipboard_string
- fn get_dropped_file_path
- fn get_num_dropped_files
- fn gl_get_framebuffer
- fn glue_environment
- fn glue_swapchain
- fn height
- fn high_dpi
- fn html5_ask_leave_site
- fn ios_get_window
- fn is_fullscreen
- fn isvalid
- fn keyboard_shown
- fn lock_mouse
- fn macos_get_window
- fn metal_get_current_drawable
- fn metal_get_depth_stencil_texture
- fn metal_get_device
- fn metal_get_msaa_color_texture
- fn mouse_locked
- fn mouse_shown
- fn query_desc
- fn quit
- fn request_quit
- fn run
- fn sample_count
- fn screenshot
- fn screenshot_png
- fn screenshot_ppm
- fn screenshot_window
- fn set_clipboard_string
- fn set_mouse_cursor
- fn show_keyboard
- fn show_mouse
- fn toggle_fullscreen
- fn userdata
- fn wgpu_get_depth_stencil_view
- fn wgpu_get_device
- fn wgpu_get_render_view
- fn wgpu_get_resolve_view
- fn width
- fn win32_get_hwnd
- type Desc
- type Event
- type IconDesc
- type ImageDesc
- type Range
- type TouchPoint
- enum EventType
- enum KeyCode
- enum Modifier
- enum MouseButton
- enum MouseCursor
- enum TouchToolType
- struct C.sapp_allocator
- struct C.sapp_desc
- struct C.sapp_event
- struct C.sapp_icon_desc
- struct C.sapp_image_desc
- struct C.sapp_logger
- struct C.sapp_range
- struct C.sapp_touchpoint
- struct Screenshot