sokol/app

sokol_app

Types

37

Allocator

Allocator :: struct { alloc_fn: proc(a0: c.size_t, a1: rawptr) -> (rawptr), a0: c.size_t, size_t: rawptr, a1: rawptr, free_fn: proc(a0: rawptr, a1: rawptr), a0: rawptr, a1: rawptr, user_data: rawptr, }Source

sapp_allocator

Used in sapp_desc to provide custom memory-alloc and -free functions to sokol_app.h. If memory management should be overridden, both the alloc_fn and free_fn function must be provided (e.g. it's not valid to override one function but not the other).

Android_Tooltype

Android_Tooltype :: enum i32 { UNKNOWN = 0, FINGER = 1, STYLUS = 2, MOUSE = 3, }Source

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

Composite_Mode

Composite_Mode :: enum i32 { DEFAULT = 0, OPAQUE = 1, PREMULTIPLIED = 2, }Source

sapp_composite_mode

Preferred composition mode for the framebuffer surface with background. This is a highly optional feature and may only be fully implemented on the web APIs (WebGL2 and WebGPU)

Desc

Desc :: struct { init_cb: proc(), frame_cb: proc(), cleanup_cb: proc(), event_cb: proc(a0: ^Event), a0: ^Event, user_data: rawptr, init_userdata_cb: proc(a0: rawptr), a0: rawptr, frame_userdata_cb: proc(a0: rawptr), a0: rawptr, cleanup_userdata_cb: proc(a0: rawptr), a0: rawptr, event_userdata_cb: proc(a0: ^Event, a1: rawptr), a0: ^Event, Event: rawptr, a1: rawptr, width: c.int, height: c.int, depth_format: Pixel_Format, composite_mode: Composite_Mode, sample_count: c.int, swap_interval: c.int, srgb: bool, hdr: bool, disable_vsync: bool, high_dpi: bool, fullscreen: bool, window_title: cstring, enable_clipboard: bool, clipboard_size: c.int, enable_dragndrop: bool, max_dropped_files: c.int, max_dropped_file_path_length: c.int, icon: Icon_Desc, allocator: Allocator, logger: Logger, gl: Gl_Desc, metal: Metal_Desc, win32: Win32_Desc, html5: Html5_Desc, ios: Ios_Desc, android: Android_Desc, }Source

Environment_Defaults

Environment_Defaults :: struct { color_format: Pixel_Format, depth_format: Pixel_Format, sample_count: c.int, }Source

sapp_environment

Used to provide runtime environment information to the outside world (like default pixel formats and the backend 3D API device pointer) via a call to sapp_get_environment().

NOTE: when using sokol_gfx.h, don't assume that sapp_environment is binary compatible with sg_environment! Always use a translation function like sglue_environment() to populate sg_environment from sapp_environment!

Event

Event :: struct { frame_count: u64, type: Event_Type, 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: c.int, touches: [8]Touchpoint, window_width: c.int, window_height: c.int, framebuffer_width: c.int, framebuffer_height: c.int, }Source

sapp_event

This is an all-in-one event struct passed to the event handler user callback function. Note that it depends on the event type what struct fields actually contain useful values, so you should first check the event type before reading other struct fields.

Event_Type

Event_Type :: enum i32 { INVALID = 0, KEY_DOWN = 1, KEY_UP = 2, CHAR = 3, MOUSE_DOWN = 4, MOUSE_UP = 5, MOUSE_SCROLL = 6, MOUSE_MOVE = 7, MOUSE_ENTER = 8, MOUSE_LEAVE = 9, TOUCHES_BEGAN = 10, TOUCHES_MOVED = 11, TOUCHES_ENDED = 12, TOUCHES_CANCELLED = 13, RESIZED = 14, ICONIFIED = 15, RESTORED = 16, FOCUSED = 17, UNFOCUSED = 18, SUSPENDED = 19, RESUMED = 20, QUIT_REQUESTED = 21, CLIPBOARD_PASTED = 22, FILES_DROPPED = 23, }Source

sapp_event_type

The type of event that's passed to the event handler callback in the sapp_event.type field. These are not just "traditional" input events, but also notify the application about state changes or other user-invoked actions.

Gl_Desc

Gl_Desc :: struct { major_version: c.int, minor_version: c.int, }Source

sokol-app initialization options, used as return value of sokol_main() or sapp_run() argument.

Html5_Fetch_Error

Html5_Fetch_Error :: enum i32 { FETCH_ERROR_NO_ERROR = 0, FETCH_ERROR_BUFFER_TOO_SMALL = 1, FETCH_ERROR_OTHER = 2, }Source

HTML5 specific: request and response structs for asynchronously loading dropped-file content.

Icon_Desc

Icon_Desc :: struct { sokol_default: bool, images: [8]Image_Desc, }Source

sapp_icon_desc

An icon description structure for use in sapp_desc.icon and sapp_set_icon().

When setting a custom image, the application can provide a number of candidates differing in size, and sokol_app.h will pick the image(s) closest to the size expected by the platform's window system.

To set sokol-app's default icon, set .sokol_default to true.

Otherwise provide candidate images of different sizes in the images[] array.

If both the sokol_default flag is set to true, any image candidates will be ignored and the sokol_app.h default icon will be set.

Image_Desc

Image_Desc :: struct { width: c.int, height: c.int, cursor_hotspot_x: c.int, cursor_hotspot_y: c.int, pixels: Range, }Source

sapp_image_desc

This is used to describe image data to sokol_app.h (window icons and cursor images).

The pixel format is RGBA8.

cursor_hotspot_x and _y are used only for cursors, to define which pixel of the image should be aligned with the mouse position.

Keycode

Keycode :: enum i32 { 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, WORLD_2 = 162, 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, }Source

sapp_keycode

The 'virtual keycode' of a KEY_DOWN or KEY_UP event in the struct field sapp_event.key_code.

Note that the keycode values are identical with GLFW.

Log_Item

Log_Item :: enum i32 { OK = 0, MALLOC_FAILED = 1, SWAPCHAIN_DEPTHFORMAT_INVALID = 2, MACOS_INVALID_NSOPENGL_PROFILE = 3, METAL_CREATE_SWAPCHAIN_DEPTH_TEXTURE_FAILED = 4, METAL_CREATE_SWAPCHAIN_MSAA_TEXTURE_FAILED = 5, WIN32_LOAD_OPENGL32_DLL_FAILED = 6, WIN32_CREATE_HELPER_WINDOW_FAILED = 7, WIN32_HELPER_WINDOW_GETDC_FAILED = 8, WIN32_DUMMY_CONTEXT_SET_PIXELFORMAT_FAILED = 9, WIN32_CREATE_DUMMY_CONTEXT_FAILED = 10, WIN32_DUMMY_CONTEXT_MAKE_CURRENT_FAILED = 11, WIN32_GET_PIXELFORMAT_ATTRIB_FAILED = 12, WIN32_WGL_FIND_PIXELFORMAT_FAILED = 13, WIN32_WGL_DESCRIBE_PIXELFORMAT_FAILED = 14, WIN32_WGL_SET_PIXELFORMAT_FAILED = 15, WIN32_WGL_ARB_CREATE_CONTEXT_REQUIRED = 16, WIN32_WGL_ARB_CREATE_CONTEXT_PROFILE_REQUIRED = 17, WIN32_WGL_OPENGL_VERSION_NOT_SUPPORTED = 18, WIN32_WGL_OPENGL_PROFILE_NOT_SUPPORTED = 19, WIN32_WGL_INCOMPATIBLE_DEVICE_CONTEXT = 20, WIN32_WGL_CREATE_CONTEXT_ATTRIBS_FAILED_OTHER = 21, WIN32_D3D11_CREATE_DEVICE_AND_SWAPCHAIN_WITH_DEBUG_FAILED = 22, WIN32_D3D11_GET_IDXGIFACTORY_FAILED = 23, WIN32_D3D11_GET_IDXGIADAPTER_FAILED = 24, WIN32_D3D11_QUERY_INTERFACE_IDXGIDEVICE1_FAILED = 25, WIN32_REGISTER_RAW_INPUT_DEVICES_FAILED_MOUSE_LOCK = 26, WIN32_REGISTER_RAW_INPUT_DEVICES_FAILED_MOUSE_UNLOCK = 27, WIN32_GET_RAW_INPUT_DATA_FAILED = 28, WIN32_DESTROYICON_FOR_CURSOR_FAILED = 29, LINUX_GLX_LOAD_LIBGL_FAILED = 30, LINUX_GLX_LOAD_ENTRY_POINTS_FAILED = 31, LINUX_GLX_EXTENSION_NOT_FOUND = 32, LINUX_GLX_QUERY_VERSION_FAILED = 33, LINUX_GLX_VERSION_TOO_LOW = 34, LINUX_GLX_NO_GLXFBCONFIGS = 35, LINUX_GLX_NO_SUITABLE_GLXFBCONFIG = 36, LINUX_GLX_GET_VISUAL_FROM_FBCONFIG_FAILED = 37, LINUX_GLX_REQUIRED_EXTENSIONS_MISSING = 38, LINUX_GLX_CREATE_CONTEXT_FAILED = 39, LINUX_GLX_CREATE_WINDOW_FAILED = 40, LINUX_X11_CREATE_WINDOW_FAILED = 41, LINUX_EGL_BIND_OPENGL_API_FAILED = 42, LINUX_EGL_BIND_OPENGL_ES_API_FAILED = 43, LINUX_EGL_GET_DISPLAY_FAILED = 44, LINUX_EGL_INITIALIZE_FAILED = 45, LINUX_EGL_NO_CONFIGS = 46, LINUX_EGL_NO_NATIVE_VISUAL = 47, LINUX_EGL_GET_VISUAL_INFO_FAILED = 48, LINUX_EGL_CREATE_WINDOW_SURFACE_FAILED = 49, LINUX_EGL_CREATE_CONTEXT_FAILED = 50, LINUX_EGL_MAKE_CURRENT_FAILED = 51, LINUX_X11_OPEN_DISPLAY_FAILED = 52, LINUX_X11_QUERY_SYSTEM_DPI_FAILED = 53, LINUX_X11_DROPPED_FILE_URI_WRONG_SCHEME = 54, LINUX_X11_FAILED_TO_BECOME_OWNER_OF_CLIPBOARD = 55, ANDROID_UNSUPPORTED_INPUT_EVENT_INPUT_CB = 56, ANDROID_UNSUPPORTED_INPUT_EVENT_MAIN_CB = 57, ANDROID_READ_MSG_FAILED = 58, ANDROID_WRITE_MSG_FAILED = 59, ANDROID_MSG_CREATE = 60, ANDROID_MSG_RESUME = 61, ANDROID_MSG_PAUSE = 62, ANDROID_MSG_FOCUS = 63, ANDROID_MSG_NO_FOCUS = 64, ANDROID_MSG_SET_NATIVE_WINDOW = 65, ANDROID_MSG_SET_INPUT_QUEUE = 66, ANDROID_MSG_DESTROY = 67, ANDROID_UNKNOWN_MSG = 68, ANDROID_LOOP_THREAD_STARTED = 69, ANDROID_LOOP_THREAD_DONE = 70, ANDROID_NATIVE_ACTIVITY_ONSTART = 71, ANDROID_NATIVE_ACTIVITY_ONRESUME = 72, ANDROID_NATIVE_ACTIVITY_ONSAVEINSTANCESTATE = 73, ANDROID_NATIVE_ACTIVITY_ONWINDOWFOCUSCHANGED = 74, ANDROID_NATIVE_ACTIVITY_ONPAUSE = 75, ANDROID_NATIVE_ACTIVITY_ONSTOP = 76, ANDROID_NATIVE_ACTIVITY_ONNATIVEWINDOWCREATED = 77, ANDROID_NATIVE_ACTIVITY_ONNATIVEWINDOWDESTROYED = 78, ANDROID_NATIVE_ACTIVITY_ONINPUTQUEUECREATED = 79, ANDROID_NATIVE_ACTIVITY_ONINPUTQUEUEDESTROYED = 80, ANDROID_NATIVE_ACTIVITY_ONCONFIGURATIONCHANGED = 81, ANDROID_NATIVE_ACTIVITY_ONLOWMEMORY = 82, ANDROID_NATIVE_ACTIVITY_ONDESTROY = 83, ANDROID_NATIVE_ACTIVITY_DONE = 84, ANDROID_NATIVE_ACTIVITY_ONCREATE = 85, ANDROID_CREATE_THREAD_PIPE_FAILED = 86, ANDROID_NATIVE_ACTIVITY_CREATE_SUCCESS = 87, ANDROID_CHOREOGRAPHER_ENABLED = 88, ANDROID_CHOREOGRAPHER_UNAVAILABLE = 89, WGPU_DEVICE_LOST = 90, WGPU_DEVICE_LOG = 91, WGPU_DEVICE_UNCAPTURED_ERROR = 92, WGPU_SWAPCHAIN_CREATE_SURFACE_FAILED = 93, WGPU_SWAPCHAIN_SURFACE_GET_CAPABILITIES_FAILED = 94, WGPU_SWAPCHAIN_CREATE_DEPTH_STENCIL_TEXTURE_FAILED = 95, WGPU_SWAPCHAIN_CREATE_DEPTH_STENCIL_VIEW_FAILED = 96, WGPU_SWAPCHAIN_CREATE_MSAA_TEXTURE_FAILED = 97, WGPU_SWAPCHAIN_CREATE_MSAA_VIEW_FAILED = 98, WGPU_SWAPCHAIN_GETCURRENTTEXTURE_FAILED = 99, WGPU_REQUEST_DEVICE_STATUS_ERROR = 100, WGPU_REQUEST_DEVICE_STATUS_UNKNOWN = 101, WGPU_REQUEST_ADAPTER_STATUS_UNAVAILABLE = 102, WGPU_REQUEST_ADAPTER_STATUS_ERROR = 103, WGPU_REQUEST_ADAPTER_STATUS_UNKNOWN = 104, WGPU_CREATE_INSTANCE_FAILED = 105, VULKAN_DEBUG_GENERAL = 106, VULKAN_DEBUG_VALIDATION = 107, VULKAN_DEBUG_PERFORMANCE = 108, VULKAN_REQUIRED_INSTANCE_EXTENSION_FUNCTION_MISSING = 109, VULKAN_ALLOC_DEVICE_MEMORY_NO_SUITABLE_MEMORY_TYPE = 110, VULKAN_ALLOCATE_MEMORY_FAILED = 111, VULKAN_CREATE_INSTANCE_FAILED = 112, VULKAN_ENUMERATE_PHYSICAL_DEVICES_FAILED = 113, VULKAN_NO_PHYSICAL_DEVICES_FOUND = 114, VULKAN_NO_SUITABLE_PHYSICAL_DEVICE_FOUND = 115, VULKAN_CREATE_DEVICE_FAILED_EXTENSION_NOT_PRESENT = 116, VULKAN_CREATE_DEVICE_FAILED_FEATURE_NOT_PRESENT = 117, VULKAN_CREATE_DEVICE_FAILED_INITIALIZATION_FAILED = 118, VULKAN_CREATE_DEVICE_FAILED_OTHER = 119, VULKAN_CREATE_SURFACE_FAILED = 120, VULKAN_CREATE_SWAPCHAIN_FAILED = 121, VULKAN_SWAPCHAIN_CREATE_IMAGE_VIEW_FAILED = 122, VULKAN_SWAPCHAIN_CREATE_IMAGE_FAILED = 123, VULKAN_SWAPCHAIN_ALLOC_IMAGE_DEVICE_MEMORY_FAILED = 124, VULKAN_SWAPCHAIN_BIND_IMAGE_MEMORY_FAILED = 125, VULKAN_ACQUIRE_NEXT_IMAGE_FAILED = 126, VULKAN_QUEUE_PRESENT_FAILED = 127, IMAGE_DATA_SIZE_MISMATCH = 128, DROPPED_FILE_PATH_TOO_LONG = 129, CLIPBOARD_STRING_TOO_BIG = 130, }Source

Logger

Logger :: struct { func: proc( a0: cstring, a1: u32, a2: u32, a3: cstring, a4: u32, a5: cstring, a6: rawptr, ), a0: cstring, a1: u32, a2: u32, a3: cstring, a4: u32, a5: cstring, a6: rawptr, user_data: rawptr, }Source

sapp_logger

Used in sapp_desc to provide a logging function. Please be aware that without logging function, sokol-app will be completely silent, e.g. it will not report errors or warnings. For maximum error verbosity, compile in debug mode (e.g. NDEBUG not defined) and install a logger (for instance the standard logging function from sokol_log.h).

Metal_Swapchain

Metal_Swapchain :: struct { current_drawable: rawptr, depth_stencil_texture: rawptr, msaa_color_texture: rawptr, }Source

sapp_swapchain

Provides swapchain information for the next swapchain render pass, result of sapp_acquire_swapchain()

NOTE: sapp_acquire_swapchain() must be called exactly once per frame, and ideally right before the swapchain render pass (e.g. not earlier in the frame).

NOTE: when using sokol_gfx.h, don't assume that the sapp_swapchain struct has the same memory layout as sg_swapchain! Use the sokol_log.h helper function sglue_swapchain() to translate sapp_swapchain into a sg_swapchain instead.

Mouse_Cursor

Mouse_Cursor :: enum i32 { DEFAULT = 0, ARROW = 1, IBEAM = 2, CROSSHAIR = 3, POINTING_HAND = 4, RESIZE_EW = 5, RESIZE_NS = 6, RESIZE_NWSE = 7, RESIZE_NESW = 8, RESIZE_ALL = 9, NOT_ALLOWED = 10, CUSTOM_0 = 11, CUSTOM_1 = 12, CUSTOM_2 = 13, CUSTOM_3 = 14, CUSTOM_4 = 15, CUSTOM_5 = 16, CUSTOM_6 = 17, CUSTOM_7 = 18, CUSTOM_8 = 19, CUSTOM_9 = 20, CUSTOM_10 = 21, CUSTOM_11 = 22, CUSTOM_12 = 23, CUSTOM_13 = 24, CUSTOM_14 = 25, CUSTOM_15 = 26, }Source

sapp_mouse_cursor

Predefined cursor image definitions, set with sapp_set_mouse_cursor(sapp_mouse_cursor cursor)

Mousebutton

Mousebutton :: enum i32 { LEFT = 0, RIGHT = 1, MIDDLE = 2, INVALID = 256, }Source

sapp_mousebutton

The currently pressed mouse button in the events MOUSE_DOWN and MOUSE_UP, stored in the struct field sapp_event.mouse_button.

Pixel_Format

Pixel_Format :: enum i32 { DEFAULT = 0, NONE = 1, RGBA8 = 2, SRGB8A8 = 3, BGRA8 = 4, SBGR8A8 = 5, RGBA16F = 6, DEPTH = 7, DEPTH_STENCIL = 8, }Source

sapp_pixel_format

Defines the pixel format for swapchain surfaces.

NOTE: DO NOT directly cast this enum to sokol_gfx.h's sg_pixel_format, the enum values are totally different!

Range

Range :: struct { ptr: rawptr, size: c.size_t, }Source

sg_range

A general pointer/size-pair struct and constructor macros for passing binary blobs into sokol_app.h.

Touchpoint

Touchpoint :: struct { identifier: c.uintptr_t, pos_x: f32, pos_y: f32, android_tooltype: Android_Tooltype, changed: bool, }Source

sapp_touchpoint

Describes a single touchpoint in a multitouch event (TOUCHES_BEGAN, TOUCHES_MOVED, TOUCHES_ENDED).

Touch points are stored in the nested array sapp_event.touches[], and the number of touches is stored in sapp_event.num_touches.

Constants

15

Reference search

Find anything

Documentation preferences

Settings

System theme variants

Used only while Theme is set to System.