-
-
Save zacharycarter/52030f74296fc3662746b94ae1e87f70 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- /Users/zacharycarter/Desktop/nimterop_master.txt | |
+++ /Users/zacharycarter/Desktop/nimterop_head.txt | |
@@ -1,8 +1,8 @@ | |
# Overriding INNER_C_UNION_c2nim_5 sg_attachment_desc sg_image_content INNER_C_UNION_c2nim_8 sg_image_desc | |
# Importing /Users/zacharycarter/dev/junkers/lib/sokol/sokol_gfx.h | |
-# Generated at 2020-04-07T22:54:24-05:00 | |
+# Generated at 2020-04-07T22:49:41-05:00 | |
# Command line: | |
-# /Users/zacharycarter/.nimble/pkgs/nimterop-0.4.4/nimterop/toast --preprocess --pnim --symOverride=INNER_C_UNION_c2nim_5,sg_attachment_desc,sg_image_content,INNER_C_UNION_c2nim_8,sg_image_desc --nim:/Users/zacharycarter/.choosenim/toolchains/nim-#devel/bin/nim --pluginSourcePath=/Users/zacharycarter/.cache/nim/nimterop/cPlugins/nimterop_1344102793.nim /Users/zacharycarter/dev/junkers/lib/sokol/sokol_gfx.h | |
+# /Users/zacharycarter/.nimble/pkgs/nimterop-#head/nimterop/toast --preprocess --pnim --symOverride=INNER_C_UNION_c2nim_5,sg_attachment_desc,sg_image_content,INNER_C_UNION_c2nim_8,sg_image_desc --nim:/Users/zacharycarter/.choosenim/toolchains/nim-#devel/bin/nim --pluginSourcePath=/Users/zacharycarter/.cache/nim/nimterop/cPlugins/nimterop_1344102793.nim /Users/zacharycarter/dev/junkers/lib/sokol/sokol_gfx.h | |
{.hint[ConvFromXtoItselfNotNeeded]: off.} | |
@@ -346,7 +346,6 @@ | |
defineEnum(sg_action) | |
const | |
- headersokol_gfx {.used.} = "/Users/zacharycarter/dev/junkers/lib/sokol/sokol_gfx.h" | |
SG_INVALID_ID* = (0).Enum_sokol_gfxh1 | |
SG_NUM_SHADER_STAGES* = (2).Enum_sokol_gfxh1 | |
SG_NUM_INFLIGHT_FRAMES* = (2).Enum_sokol_gfxh1 | |
@@ -605,7 +604,7 @@ | |
SG_ACTION_NUM* = 4.sg_action | |
SG_ACTION_FORCE_U32* = (0x7FFFFFFF).sg_action | |
-{.pragma: impsokol_gfx, importc, header: headersokol_gfx.} | |
+{.pragma: impsokol_gfx, importc.} | |
{.pragma: impsokol_gfxC, impsokol_gfx, cdecl.} | |
type | |
@@ -1005,24 +1004,24 @@ | |
# The resource ids are wrapped into a struct so that the compiler | |
# can complain when the wrong resource type is used. | |
# | |
- sg_buffer* {.importc: "struct sg_buffer", header: headersokol_gfx, bycopy.} = object | |
+ sg_buffer* {.bycopy.} = object | |
id*: uint32 | |
- sg_image* {.importc: "struct sg_image", header: headersokol_gfx, bycopy.} = object | |
+ sg_image* {.bycopy.} = object | |
id*: uint32 | |
- sg_shader* {.importc: "struct sg_shader", header: headersokol_gfx, bycopy.} = object | |
+ sg_shader* {.bycopy.} = object | |
id*: uint32 | |
- sg_pipeline* {.importc: "struct sg_pipeline", header: headersokol_gfx, bycopy.} = object | |
+ sg_pipeline* {.bycopy.} = object | |
id*: uint32 | |
- sg_pass* {.importc: "struct sg_pass", header: headersokol_gfx, bycopy.} = object | |
+ sg_pass* {.bycopy.} = object | |
id*: uint32 | |
- sg_context* {.importc: "struct sg_context", header: headersokol_gfx, bycopy.} = object | |
+ sg_context* {.bycopy.} = object | |
id*: uint32 | |
# | |
# Runtime information about a pixel format, returned | |
# by sg_query_pixelformat(). | |
# | |
- sg_pixelformat_info* {.importc: "struct sg_pixelformat_info", header: headersokol_gfx, bycopy.} = object | |
+ sg_pixelformat_info* {.bycopy.} = object | |
sample*: bool | |
filter*: bool | |
render*: bool | |
@@ -1034,7 +1033,7 @@ | |
# Runtime information about available optional features, | |
# returned by sg_query_features() | |
# | |
- sg_features* {.importc: "struct sg_features", header: headersokol_gfx, bycopy.} = object | |
+ sg_features* {.bycopy.} = object | |
instancing*: bool | |
origin_top_left*: bool | |
multiple_render_targets*: bool | |
@@ -1046,7 +1045,7 @@ | |
# | |
# Runtime information about resource limits, returned by sg_query_limit() | |
# | |
- sg_limits* {.importc: "struct sg_limits", header: headersokol_gfx, bycopy.} = object | |
+ sg_limits* {.bycopy.} = object | |
max_image_size_2d*: uint32 | |
max_image_size_cube*: uint32 | |
max_image_size_3d*: uint32 | |
@@ -1069,16 +1068,16 @@ | |
# - SG_DEFAULT_CLEAR_DEPTH: 1.0f | |
# - SG_DEFAULT_CLEAR_STENCIL: 0 | |
# | |
- sg_color_attachment_action* {.importc: "struct sg_color_attachment_action", header: headersokol_gfx, bycopy.} = object | |
+ sg_color_attachment_action* {.bycopy.} = object | |
action*: sg_action | |
val*: array[4, cfloat] | |
- sg_depth_attachment_action* {.importc: "struct sg_depth_attachment_action", header: headersokol_gfx, bycopy.} = object | |
+ sg_depth_attachment_action* {.bycopy.} = object | |
action*: sg_action | |
val*: cfloat | |
- sg_stencil_attachment_action* {.importc: "struct sg_stencil_attachment_action", header: headersokol_gfx, bycopy.} = object | |
+ sg_stencil_attachment_action* {.bycopy.} = object | |
action*: sg_action | |
val*: uint8 | |
- sg_pass_action* {.importc: "struct sg_pass_action", header: headersokol_gfx, bycopy.} = object | |
+ sg_pass_action* {.bycopy.} = object | |
start_canary*: uint32 | |
colors*: array[SG_MAX_COLOR_ATTACHMENTS, sg_color_attachment_action] | |
depth*: sg_depth_attachment_action | |
@@ -1103,7 +1102,7 @@ | |
# The optional buffer offsets can be used to put different unrelated | |
# chunks of vertex- and/or index-data into the same buffer objects. | |
# | |
- sg_bindings* {.importc: "struct sg_bindings", header: headersokol_gfx, bycopy.} = object | |
+ sg_bindings* {.bycopy.} = object | |
start_canary*: uint32 | |
vertex_buffers*: array[SG_MAX_SHADERSTAGE_BUFFERS, sg_buffer] | |
vertex_buffer_offsets*: array[SG_MAX_SHADERSTAGE_BUFFERS, cint] | |
@@ -1144,7 +1143,7 @@ | |
# Also you need to call sg_reset_state_cache() after calling native 3D-API | |
# functions, and before calling any sokol_gfx function. | |
# | |
- sg_buffer_desc* {.importc: "struct sg_buffer_desc", header: headersokol_gfx, bycopy.} = object | |
+ sg_buffer_desc* {.bycopy.} = object | |
start_canary*: uint32 | |
size*: cint | |
`type`*: sg_buffer_type | |
@@ -1166,7 +1165,7 @@ | |
# 3D-slices of the mipmap level. It is only possible to update | |
# an entire mipmap level, not parts of it. | |
# | |
- sg_subimage_content* {.importc: "struct sg_subimage_content", header: headersokol_gfx, bycopy.} = object | |
+ sg_subimage_content* {.bycopy.} = object | |
`ptr`*: pointer | |
size*: cint | |
@@ -1275,28 +1274,28 @@ | |
# For D3D11, if source code is provided, the d3dcompiler_47.dll will be loaded | |
# on demand. If this fails, shader creation will fail. | |
# | |
- sg_shader_attr_desc* {.importc: "struct sg_shader_attr_desc", header: headersokol_gfx, bycopy.} = object | |
+ sg_shader_attr_desc* {.bycopy.} = object | |
name*: cstring | |
sem_name*: cstring | |
sem_index*: cint | |
- sg_shader_uniform_desc* {.importc: "struct sg_shader_uniform_desc", header: headersokol_gfx, bycopy.} = object | |
+ sg_shader_uniform_desc* {.bycopy.} = object | |
name*: cstring | |
`type`*: sg_uniform_type | |
array_count*: cint | |
- sg_shader_uniform_block_desc* {.importc: "struct sg_shader_uniform_block_desc", header: headersokol_gfx, bycopy.} = object | |
+ sg_shader_uniform_block_desc* {.bycopy.} = object | |
size*: cint | |
uniforms*: array[SG_MAX_UB_MEMBERS, sg_shader_uniform_desc] | |
- sg_shader_image_desc* {.importc: "struct sg_shader_image_desc", header: headersokol_gfx, bycopy.} = object | |
+ sg_shader_image_desc* {.bycopy.} = object | |
name*: cstring | |
`type`*: sg_image_type | |
- sg_shader_stage_desc* {.importc: "struct sg_shader_stage_desc", header: headersokol_gfx, bycopy.} = object | |
+ sg_shader_stage_desc* {.bycopy.} = object | |
source*: cstring | |
byte_code*: ptr uint8 | |
byte_code_size*: cint | |
entry*: cstring | |
uniform_blocks*: array[SG_MAX_SHADERSTAGE_UBS, sg_shader_uniform_block_desc] | |
images*: array[SG_MAX_SHADERSTAGE_IMAGES, sg_shader_image_desc] | |
- sg_shader_desc* {.importc: "struct sg_shader_desc", header: headersokol_gfx, bycopy.} = object | |
+ sg_shader_desc* {.bycopy.} = object | |
start_canary*: uint32 | |
attrs*: array[SG_MAX_VERTEX_ATTRIBUTES, sg_shader_attr_desc] | |
vs*: sg_shader_stage_desc | |
@@ -1370,23 +1369,23 @@ | |
# .depth_bias_clamp: 0.0f | |
# .label 0 (optional string label for trace hooks) | |
# | |
- sg_buffer_layout_desc* {.importc: "struct sg_buffer_layout_desc", header: headersokol_gfx, bycopy.} = object | |
+ sg_buffer_layout_desc* {.bycopy.} = object | |
stride*: cint | |
step_func*: sg_vertex_step | |
step_rate*: cint | |
- sg_vertex_attr_desc* {.importc: "struct sg_vertex_attr_desc", header: headersokol_gfx, bycopy.} = object | |
+ sg_vertex_attr_desc* {.bycopy.} = object | |
buffer_index*: cint | |
offset*: cint | |
format*: sg_vertex_format | |
- sg_layout_desc* {.importc: "struct sg_layout_desc", header: headersokol_gfx, bycopy.} = object | |
+ sg_layout_desc* {.bycopy.} = object | |
buffers*: array[SG_MAX_SHADERSTAGE_BUFFERS, sg_buffer_layout_desc] | |
attrs*: array[SG_MAX_VERTEX_ATTRIBUTES, sg_vertex_attr_desc] | |
- sg_stencil_state* {.importc: "struct sg_stencil_state", header: headersokol_gfx, bycopy.} = object | |
+ sg_stencil_state* {.bycopy.} = object | |
fail_op*: sg_stencil_op | |
depth_fail_op*: sg_stencil_op | |
pass_op*: sg_stencil_op | |
compare_func*: sg_compare_func | |
- sg_depth_stencil_state* {.importc: "struct sg_depth_stencil_state", header: headersokol_gfx, bycopy.} = object | |
+ sg_depth_stencil_state* {.bycopy.} = object | |
stencil_front*: sg_stencil_state | |
stencil_back*: sg_stencil_state | |
depth_compare_func*: sg_compare_func | |
@@ -1395,7 +1394,7 @@ | |
stencil_read_mask*: uint8 | |
stencil_write_mask*: uint8 | |
stencil_ref*: uint8 | |
- sg_blend_state* {.importc: "struct sg_blend_state", header: headersokol_gfx, bycopy.} = object | |
+ sg_blend_state* {.bycopy.} = object | |
enabled*: bool | |
src_factor_rgb*: sg_blend_factor | |
dst_factor_rgb*: sg_blend_factor | |
@@ -1408,7 +1407,7 @@ | |
color_format*: sg_pixel_format | |
depth_format*: sg_pixel_format | |
blend_color*: array[4, cfloat] | |
- sg_rasterizer_state* {.importc: "struct sg_rasterizer_state", header: headersokol_gfx, bycopy.} = object | |
+ sg_rasterizer_state* {.bycopy.} = object | |
alpha_to_coverage_enabled*: bool | |
cull_mode*: sg_cull_mode | |
face_winding*: sg_face_winding | |
@@ -1416,7 +1415,7 @@ | |
depth_bias*: cfloat | |
depth_bias_slope_scale*: cfloat | |
depth_bias_clamp*: cfloat | |
- sg_pipeline_desc* {.importc: "struct sg_pipeline_desc", header: headersokol_gfx, bycopy.} = object | |
+ sg_pipeline_desc* {.bycopy.} = object | |
start_canary*: uint32 | |
layout*: sg_layout_desc | |
shader*: sg_shader | |
@@ -1450,7 +1449,7 @@ | |
mip_level*: cint | |
ano_c2nim_8*: INNER_C_UNION_c2nim_5 | |
- sg_pass_desc* {.importc: "struct sg_pass_desc", header: headersokol_gfx, bycopy.} = object | |
+ sg_pass_desc* {.bycopy.} = object | |
start_canary*: uint32 | |
color_attachments*: array[SG_MAX_COLOR_ATTACHMENTS, sg_attachment_desc] | |
depth_stencil_attachment*: sg_attachment_desc | |
@@ -1467,7 +1466,7 @@ | |
# trace hook function pointers. These should be invoked by the | |
# new trace hooks to form a proper call chain. | |
# | |
- sg_trace_hooks* {.importc: "struct sg_trace_hooks", header: headersokol_gfx, bycopy.} = object | |
+ sg_trace_hooks* {.bycopy.} = object | |
user_data*: pointer | |
reset_state_cache*: proc(user_data: pointer) {.cdecl.} | |
make_buffer*: proc(desc: ptr sg_buffer_desc, result: sg_buffer, user_data: pointer) {.cdecl.} | |
@@ -1538,11 +1537,11 @@ | |
# sg_query_pipeline_info() | |
# sg_query_pass_info() | |
# | |
- sg_slot_info* {.importc: "struct sg_slot_info", header: headersokol_gfx, bycopy.} = object | |
+ sg_slot_info* {.bycopy.} = object | |
state*: sg_resource_state | |
res_id*: uint32 | |
ctx_id*: uint32 | |
- sg_buffer_info* {.importc: "struct sg_buffer_info", header: headersokol_gfx, bycopy.} = object | |
+ sg_buffer_info* {.bycopy.} = object | |
slot*: sg_slot_info | |
update_frame_index*: uint32 | |
append_frame_index*: uint32 | |
@@ -1550,16 +1549,16 @@ | |
append_overflow*: bool | |
num_slots*: cint | |
active_slot*: cint | |
- sg_image_info* {.importc: "struct sg_image_info", header: headersokol_gfx, bycopy.} = object | |
+ sg_image_info* {.bycopy.} = object | |
slot*: sg_slot_info | |
upd_frame_index*: uint32 | |
num_slots*: cint | |
active_slot*: cint | |
- sg_shader_info* {.importc: "struct sg_shader_info", header: headersokol_gfx, bycopy.} = object | |
+ sg_shader_info* {.bycopy.} = object | |
slot*: sg_slot_info | |
- sg_pipeline_info* {.importc: "struct sg_pipeline_info", header: headersokol_gfx, bycopy.} = object | |
+ sg_pipeline_info* {.bycopy.} = object | |
slot*: sg_slot_info | |
- sg_pass_info* {.importc: "struct sg_pass_info", header: headersokol_gfx, bycopy.} = object | |
+ sg_pass_info* {.bycopy.} = object | |
slot*: sg_slot_info | |
# | |
@@ -1620,7 +1619,7 @@ | |
# this function will be called in sg_begin_pass() when rendering | |
# to the default framebuffer | |
# | |
- sg_desc* {.importc: "struct sg_desc", header: headersokol_gfx, bycopy.} = object | |
+ sg_desc* {.bycopy.} = object | |
start_canary*: uint32 | |
buffer_pool_size*: cint | |
image_pool_size*: cint | |
@@ -1730,9 +1729,9 @@ | |
proc sg_discard_context*(ctx_id: sg_context) {.impsokol_gfxC.} | |
# Importing /Users/zacharycarter/dev/junkers/lib/sokol/sokol_app.h | |
-# Generated at 2020-04-07T22:54:24-05:00 | |
+# Generated at 2020-04-07T22:49:42-05:00 | |
# Command line: | |
-# /Users/zacharycarter/.nimble/pkgs/nimterop-0.4.4/nimterop/toast --preprocess --pnim --symOverride=INNER_C_UNION_c2nim_5,sg_attachment_desc,sg_image_content,INNER_C_UNION_c2nim_8,sg_image_desc --nim:/Users/zacharycarter/.choosenim/toolchains/nim-#devel/bin/nim --pluginSourcePath=/Users/zacharycarter/.cache/nim/nimterop/cPlugins/nimterop_2793949904.nim /Users/zacharycarter/dev/junkers/lib/sokol/sokol_app.h | |
+# /Users/zacharycarter/.nimble/pkgs/nimterop-#head/nimterop/toast --preprocess --pnim --symOverride=INNER_C_UNION_c2nim_5,sg_attachment_desc,sg_image_content,INNER_C_UNION_c2nim_8,sg_image_desc --nim:/Users/zacharycarter/.choosenim/toolchains/nim-#devel/bin/nim --pluginSourcePath=/Users/zacharycarter/.cache/nim/nimterop/cPlugins/nimterop_2793949904.nim /Users/zacharycarter/dev/junkers/lib/sokol/sokol_app.h | |
{.hint[ConvFromXtoItselfNotNeeded]: off.} | |
@@ -2208,7 +2207,6 @@ | |
defineEnum(Enum_sokol_apph2) | |
const | |
- headersokol_app {.used.} = "/Users/zacharycarter/dev/junkers/lib/sokol/sokol_app.h" | |
SAPP_MAX_TOUCHPOINTS* = (8).Enum_sokol_apph1 | |
SAPP_MAX_MOUSEBUTTONS* = (3).Enum_sokol_apph1 | |
SAPP_MAX_KEYCODES* = (512).Enum_sokol_apph1 | |
@@ -2366,16 +2364,16 @@ | |
SAPP_MODIFIER_ALT* = ((1 shl 2)).Enum_sokol_apph2 | |
SAPP_MODIFIER_SUPER* = ((1 shl 3)).Enum_sokol_apph2 | |
-{.pragma: impsokol_app, importc, header: headersokol_app.} | |
+{.pragma: impsokol_app, importc.} | |
{.pragma: impsokol_appC, impsokol_app, cdecl.} | |
type | |
- sapp_touchpoint* {.importc: "struct sapp_touchpoint", header: headersokol_app, bycopy.} = object | |
+ sapp_touchpoint* {.bycopy.} = object | |
identifier*: ptr uint | |
pos_x*: cfloat | |
pos_y*: cfloat | |
changed*: bool | |
- sapp_event* {.importc: "struct sapp_event", header: headersokol_app, bycopy.} = object | |
+ sapp_event* {.bycopy.} = object | |
frame_count*: uint64 | |
`type`*: sapp_event_type | |
key_code*: sapp_keycode | |
@@ -2393,7 +2391,7 @@ | |
window_height*: cint | |
framebuffer_width*: cint | |
framebuffer_height*: cint | |
- sapp_desc* {.importc: "struct sapp_desc", header: headersokol_app, bycopy.} = object | |
+ sapp_desc* {.bycopy.} = object | |
init_cb*: proc() {.cdecl.} | |
frame_cb*: proc() {.cdecl.} | |
cleanup_cb*: proc() {.cdecl.} | |
@@ -2541,6 +2539,6 @@ | |
CC: stdlib_os.nim | |
CC: stdlib_sets.nim | |
CC: stdlib_tables.nim | |
-CC: ../../../.nimble/pkgs/nimterop-0.4.4/nimterop/plugin.nim | |
+CC: ../../../.nimble/pkgs/nimterop-#head/nimterop/plugin.nim | |
CC: stdlib_cpuinfo.nim | |
CC: sokol.nim |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Overriding INNER_C_UNION_c2nim_5 sg_attachment_desc sg_image_content INNER_C_UNION_c2nim_8 sg_image_desc | |
# Importing /Users/zacharycarter/dev/junkers/lib/sokol/sokol_gfx.h | |
# Generated at 2020-04-07T22:49:41-05:00 | |
# Command line: | |
# /Users/zacharycarter/.nimble/pkgs/nimterop-#head/nimterop/toast --preprocess --pnim --symOverride=INNER_C_UNION_c2nim_5,sg_attachment_desc,sg_image_content,INNER_C_UNION_c2nim_8,sg_image_desc --nim:/Users/zacharycarter/.choosenim/toolchains/nim-#devel/bin/nim --pluginSourcePath=/Users/zacharycarter/.cache/nim/nimterop/cPlugins/nimterop_1344102793.nim /Users/zacharycarter/dev/junkers/lib/sokol/sokol_gfx.h | |
{.hint[ConvFromXtoItselfNotNeeded]: off.} | |
import nimterop/types | |
# | |
# various compile-time constants | |
# FIXME: it may make sense to convert some of those into defines so | |
# that the user code can override them. | |
# | |
defineEnum(Enum_sokol_gfxh1) | |
# | |
# sg_backend | |
# The active 3D-API backend, use the function sg_query_backend() | |
# to get the currently active backend. | |
# For returned value corresponds with the compile-time define to select | |
# a backend, with the only exception of SOKOL_GLES3: this may | |
# return SG_BACKEND_GLES2 if the backend has to fallback to GLES2 mode | |
# because GLES3 isn't supported. | |
# | |
defineEnum(sg_backend) | |
# | |
# sg_pixel_format | |
# sokol_gfx.h basically uses the same pixel formats as WebGPU, since these | |
# are supported on most newer GPUs. GLES2 and WebGL has a much smaller | |
# subset of available pixel formats. Call sg_query_pixelformat() to check | |
# at runtime if a pixel format supports the desired features. | |
# A pixelformat name consist of three parts: | |
# - components (R, RG, RGB or RGBA) | |
# - bit width per component (8, 16 or 32) | |
# - component data type: | |
# - unsigned normalized (no postfix) | |
# - signed normalized (SN postfix) | |
# - unsigned integer (UI postfix) | |
# - signed integer (SI postfix) | |
# - float (F postfix) | |
# Not all pixel formats can be used for everything, call sg_query_pixelformat() | |
# to inspect the capabilities of a given pixelformat. The function returns | |
# an sg_pixelformat_info struct with the following bool members: | |
# - sample: the pixelformat can be sampled as texture at least with | |
# nearest filtering | |
# - filter: the pixelformat can be samples as texture with linear | |
# filtering | |
# - render: the pixelformat can be used for render targets | |
# - blend: blending is supported when using the pixelformat for | |
# render targets | |
# - msaa: multisample-antialiasing is supported when using the | |
# pixelformat for render targets | |
# - depth: the pixelformat can be used for depth-stencil attachments | |
# When targeting GLES2/WebGL, the only safe formats to use | |
# as texture are SG_PIXELFORMAT_R8 and SG_PIXELFORMAT_RGBA8. For rendering | |
# in GLES2/WebGL, only SG_PIXELFORMAT_RGBA8 is safe. All other formats | |
# must be checked via sg_query_pixelformats(). | |
# The default pixel format for texture images is SG_PIXELFORMAT_RGBA8. | |
# The default pixel format for render target images is platform-dependent: | |
# - for Metal and D3D11 it is SG_PIXELFORMAT_BGRA8 | |
# - for GL backends it is SG_PIXELFORMAT_RGBA8 | |
# This is mainly because of the default framebuffer which is setup outside | |
# of sokol_gfx.h. On some backends, using BGRA for the default frame buffer | |
# allows more efficient frame flips. For your own offscreen-render-targets, | |
# use whatever renderable pixel format is convenient for you. | |
# | |
defineEnum(sg_pixel_format) | |
# | |
# sg_resource_state | |
# The current state of a resource in its resource pool. | |
# Resources start in the INITIAL state, which means the | |
# pool slot is unoccupied and can be allocated. When a resource is | |
# created, first an id is allocated, and the resource pool slot | |
# is set to state ALLOC. After allocation, the resource is | |
# initialized, which may result in the VALID or FAILED state. The | |
# reason why allocation and initialization are separate is because | |
# some resource types (e.g. buffers and images) might be asynchronously | |
# initialized by the user application. If a resource which is not | |
# in the VALID state is attempted to be used for rendering, rendering | |
# operations will silently be dropped. | |
# The special INVALID state is returned in sg_query_xxx_state() if no | |
# resource object exists for the provided resource id. | |
# | |
defineEnum(sg_resource_state) | |
# | |
# sg_usage | |
# A resource usage hint describing the update strategy of | |
# buffers and images. This is used in the sg_buffer_desc.usage | |
# and sg_image_desc.usage members when creating buffers | |
# and images: | |
# SG_USAGE_IMMUTABLE: the resource will never be updated with | |
# new data, instead the content of the | |
# resource must be provided on creation | |
# SG_USAGE_DYNAMIC: the resource will be updated infrequently | |
# with new data (this could range from "once | |
# after creation", to "quite often but not | |
# every frame") | |
# SG_USAGE_STREAM: the resource will be updated each frame | |
# with new content | |
# The rendering backends use this hint to prevent that the | |
# CPU needs to wait for the GPU when attempting to update | |
# a resource that might be currently accessed by the GPU. | |
# Resource content is updated with the function sg_update_buffer() for | |
# buffer objects, and sg_update_image() for image objects. Only | |
# one update is allowed per frame and resource object. The | |
# application must update all data required for rendering (this | |
# means that the update data can be smaller than the resource size, | |
# if only a part of the overall resource size is used for rendering, | |
# you only need to make sure that the data that *is* used is valid). | |
# The default usage is SG_USAGE_IMMUTABLE. | |
# | |
defineEnum(sg_usage) | |
# | |
# sg_buffer_type | |
# This indicates whether a buffer contains vertex- or index-data, | |
# used in the sg_buffer_desc.type member when creating a buffer. | |
# The default value is SG_BUFFERTYPE_VERTEXBUFFER. | |
# | |
defineEnum(sg_buffer_type) | |
# | |
# sg_index_type | |
# Indicates whether indexed rendering (fetching vertex-indices from an | |
# index buffer) is used, and if yes, the index data type (16- or 32-bits). | |
# This is used in the sg_pipeline_desc.index_type member when creating a | |
# pipeline object. | |
# The default index type is SG_INDEXTYPE_NONE. | |
# | |
defineEnum(sg_index_type) | |
# | |
# sg_image_type | |
# Indicates the basic type of an image object (2D-texture, cubemap, | |
# 3D-texture or 2D-array-texture). 3D- and array-textures are not supported | |
# on the GLES2/WebGL backend (use sg_query_features().imagetype_3d and | |
# sg_query_features().imagetype_array to check for support). The image type | |
# is used in the sg_image_desc.type member when creating an image. | |
# The default image type when creating an image is SG_IMAGETYPE_2D. | |
# | |
defineEnum(sg_image_type) | |
# | |
# sg_cube_face | |
# The cubemap faces. Use these as indices in the sg_image_desc.content | |
# array. | |
# | |
defineEnum(sg_cube_face) | |
# | |
# sg_shader_stage | |
# There are 2 shader stages: vertex- and fragment-shader-stage. | |
# Each shader stage consists of: | |
# - one slot for a shader function (provided as source- or byte-code) | |
# - SG_MAX_SHADERSTAGE_UBS slots for uniform blocks | |
# - SG_MAX_SHADERSTAGE_IMAGES slots for images used as textures by | |
# the shader function | |
# | |
defineEnum(sg_shader_stage) | |
# | |
# sg_primitive_type | |
# This is the common subset of 3D primitive types supported across all 3D | |
# APIs. This is used in the sg_pipeline_desc.primitive_type member when | |
# creating a pipeline object. | |
# The default primitive type is SG_PRIMITIVETYPE_TRIANGLES. | |
# | |
defineEnum(sg_primitive_type) | |
# | |
# sg_filter | |
# The filtering mode when sampling a texture image. This is | |
# used in the sg_image_desc.min_filter and sg_image_desc.mag_filter | |
# members when creating an image object. | |
# The default filter mode is SG_FILTER_NEAREST. | |
# | |
defineEnum(sg_filter) | |
# | |
# sg_wrap | |
# The texture coordinates wrapping mode when sampling a texture | |
# image. This is used in the sg_image_desc.wrap_u, .wrap_v | |
# and .wrap_w members when creating an image. | |
# The default wrap mode is SG_WRAP_REPEAT. | |
# NOTE: SG_WRAP_CLAMP_TO_BORDER is not supported on all backends | |
# and platforms. To check for support, call sg_query_features() | |
# and check the "clamp_to_border" boolean in the returned | |
# sg_features struct. | |
# Platforms which don't support SG_WRAP_CLAMP_TO_BORDER will silently fall back | |
# to SG_WRAP_CLAMP_TO_EDGE without a validation error. | |
# Platforms which support clamp-to-border are: | |
# - all desktop GL platforms | |
# - Metal on macOS | |
# - D3D11 | |
# Platforms which do not support clamp-to-border: | |
# - GLES2/3 and WebGL/WebGL2 | |
# - Metal on iOS | |
# | |
defineEnum(sg_wrap) | |
# | |
# sg_border_color | |
# The border color to use when sampling a texture, and the UV wrap | |
# mode is SG_WRAP_CLAMP_TO_BORDER. | |
# The default border color is SG_BORDERCOLOR_OPAQUE_BLACK | |
# | |
defineEnum(sg_border_color) | |
# | |
# sg_vertex_format | |
# The data type of a vertex component. This is used to describe | |
# the layout of vertex data when creating a pipeline object. | |
# | |
defineEnum(sg_vertex_format) | |
# | |
# sg_vertex_step | |
# Defines whether the input pointer of a vertex input stream is advanced | |
# 'per vertex' or 'per instance'. The default step-func is | |
# SG_VERTEXSTEP_PER_VERTEX. SG_VERTEXSTEP_PER_INSTANCE is used with | |
# instanced-rendering. | |
# The vertex-step is part of the vertex-layout definition | |
# when creating pipeline objects. | |
# | |
defineEnum(sg_vertex_step) | |
# | |
# sg_uniform_type | |
# The data type of a uniform block member. This is used to | |
# describe the internal layout of uniform blocks when creating | |
# a shader object. | |
# | |
defineEnum(sg_uniform_type) | |
# | |
# sg_cull_mode | |
# The face-culling mode, this is used in the | |
# sg_pipeline_desc.rasterizer.cull_mode member when creating a | |
# pipeline object. | |
# The default cull mode is SG_CULLMODE_NONE | |
# | |
defineEnum(sg_cull_mode) | |
# | |
# sg_face_winding | |
# The vertex-winding rule that determines a front-facing primitive. This | |
# is used in the member sg_pipeline_desc.rasterizer.face_winding | |
# when creating a pipeline object. | |
# The default winding is SG_FACEWINDING_CW (clockwise) | |
# | |
defineEnum(sg_face_winding) | |
# | |
# sg_compare_func | |
# The compare-function for depth- and stencil-ref tests. | |
# This is used when creating pipeline objects in the members: | |
# sg_pipeline_desc | |
# .depth_stencil | |
# .depth_compare_func | |
# .stencil_front.compare_func | |
# .stencil_back.compare_func | |
# The default compare func for depth- and stencil-tests is | |
# SG_COMPAREFUNC_ALWAYS. | |
# | |
defineEnum(sg_compare_func) | |
# | |
# sg_stencil_op | |
# The operation performed on a currently stored stencil-value when a | |
# comparison test passes or fails. This is used when creating a pipeline | |
# object in the members: | |
# sg_pipeline_desc | |
# .depth_stencil | |
# .stencil_front | |
# .fail_op | |
# .depth_fail_op | |
# .pass_op | |
# .stencil_back | |
# .fail_op | |
# .depth_fail_op | |
# .pass_op | |
# The default value is SG_STENCILOP_KEEP. | |
# | |
defineEnum(sg_stencil_op) | |
# | |
# sg_blend_factor | |
# The source and destination factors in blending operations. | |
# This is used in the following members when creating a pipeline object: | |
# sg_pipeline_desc | |
# .blend | |
# .src_factor_rgb | |
# .dst_factor_rgb | |
# .src_factor_alpha | |
# .dst_factor_alpha | |
# The default value is SG_BLENDFACTOR_ONE for source | |
# factors, and SG_BLENDFACTOR_ZERO for destination factors. | |
# | |
defineEnum(sg_blend_factor) | |
# | |
# sg_blend_op | |
# Describes how the source and destination values are combined in the | |
# fragment blending operation. It is used in the following members when | |
# creating a pipeline object: | |
# sg_pipeline_desc | |
# .blend | |
# .op_rgb | |
# .op_alpha | |
# The default value is SG_BLENDOP_ADD. | |
# | |
defineEnum(sg_blend_op) | |
# | |
# sg_color_mask | |
# Selects the color channels when writing a fragment color to the | |
# framebuffer. This is used in the members | |
# sg_pipeline_desc.blend.color_write_mask when creating a pipeline object. | |
# The default colormask is SG_COLORMASK_RGBA (write all colors channels) | |
# NOTE: since the color mask value 0 is reserved for the default value | |
# (SG_COLORMASK_RGBA), use SG_COLORMASK_NONE if all color channels | |
# should be disabled. | |
# | |
defineEnum(sg_color_mask) | |
# | |
# sg_action | |
# Defines what action should be performed at the start of a render pass: | |
# SG_ACTION_CLEAR: clear the render target image | |
# SG_ACTION_LOAD: load the previous content of the render target image | |
# SG_ACTION_DONTCARE: leave the render target image content undefined | |
# This is used in the sg_pass_action structure. | |
# The default action for all pass attachments is SG_ACTION_CLEAR, with the | |
# clear color rgba = {0.5f, 0.5f, 0.5f, 1.0f], depth=1.0 and stencil=0. | |
# If you want to override the default behaviour, it is important to not | |
# only set the clear color, but the 'action' field as well (as long as this | |
# is in its _SG_ACTION_DEFAULT, the value fields will be ignored). | |
# | |
defineEnum(sg_action) | |
const | |
SG_INVALID_ID* = (0).Enum_sokol_gfxh1 | |
SG_NUM_SHADER_STAGES* = (2).Enum_sokol_gfxh1 | |
SG_NUM_INFLIGHT_FRAMES* = (2).Enum_sokol_gfxh1 | |
SG_MAX_COLOR_ATTACHMENTS* = (4).Enum_sokol_gfxh1 | |
SG_MAX_SHADERSTAGE_BUFFERS* = (8).Enum_sokol_gfxh1 | |
SG_MAX_SHADERSTAGE_IMAGES* = (12).Enum_sokol_gfxh1 | |
SG_MAX_SHADERSTAGE_UBS* = (4).Enum_sokol_gfxh1 | |
SG_MAX_UB_MEMBERS* = (16).Enum_sokol_gfxh1 | |
SG_MAX_VERTEX_ATTRIBUTES* = (16).Enum_sokol_gfxh1 | |
SG_MAX_MIPMAPS* = (16).Enum_sokol_gfxh1 | |
SG_MAX_TEXTUREARRAY_LAYERS* = (128).Enum_sokol_gfxh1 | |
SG_BACKEND_GLCORE33* = 0.sg_backend | |
SG_BACKEND_GLES2* = 1.sg_backend | |
SG_BACKEND_GLES3* = 2.sg_backend | |
SG_BACKEND_D3D11* = 3.sg_backend | |
SG_BACKEND_METAL_IOS* = 4.sg_backend | |
SG_BACKEND_METAL_MACOS* = 5.sg_backend | |
SG_BACKEND_METAL_SIMULATOR* = 6.sg_backend | |
SG_BACKEND_DUMMY* = 7.sg_backend | |
SG_PIXELFORMAT_DEFAULT* = 0.sg_pixel_format | |
SG_PIXELFORMAT_NONE* = 1.sg_pixel_format | |
SG_PIXELFORMAT_R8* = 2.sg_pixel_format | |
SG_PIXELFORMAT_R8SN* = 3.sg_pixel_format | |
SG_PIXELFORMAT_R8UI* = 4.sg_pixel_format | |
SG_PIXELFORMAT_R8SI* = 5.sg_pixel_format | |
SG_PIXELFORMAT_R16* = 6.sg_pixel_format | |
SG_PIXELFORMAT_R16SN* = 7.sg_pixel_format | |
SG_PIXELFORMAT_R16UI* = 8.sg_pixel_format | |
SG_PIXELFORMAT_R16SI* = 9.sg_pixel_format | |
SG_PIXELFORMAT_R16F* = 10.sg_pixel_format | |
SG_PIXELFORMAT_RG8* = 11.sg_pixel_format | |
SG_PIXELFORMAT_RG8SN* = 12.sg_pixel_format | |
SG_PIXELFORMAT_RG8UI* = 13.sg_pixel_format | |
SG_PIXELFORMAT_RG8SI* = 14.sg_pixel_format | |
SG_PIXELFORMAT_R32UI* = 15.sg_pixel_format | |
SG_PIXELFORMAT_R32SI* = 16.sg_pixel_format | |
SG_PIXELFORMAT_R32F* = 17.sg_pixel_format | |
SG_PIXELFORMAT_RG16* = 18.sg_pixel_format | |
SG_PIXELFORMAT_RG16SN* = 19.sg_pixel_format | |
SG_PIXELFORMAT_RG16UI* = 20.sg_pixel_format | |
SG_PIXELFORMAT_RG16SI* = 21.sg_pixel_format | |
SG_PIXELFORMAT_RG16F* = 22.sg_pixel_format | |
SG_PIXELFORMAT_RGBA8* = 23.sg_pixel_format | |
SG_PIXELFORMAT_RGBA8SN* = 24.sg_pixel_format | |
SG_PIXELFORMAT_RGBA8UI* = 25.sg_pixel_format | |
SG_PIXELFORMAT_RGBA8SI* = 26.sg_pixel_format | |
SG_PIXELFORMAT_BGRA8* = 27.sg_pixel_format | |
SG_PIXELFORMAT_RGB10A2* = 28.sg_pixel_format | |
SG_PIXELFORMAT_RG11B10F* = 29.sg_pixel_format | |
SG_PIXELFORMAT_RG32UI* = 30.sg_pixel_format | |
SG_PIXELFORMAT_RG32SI* = 31.sg_pixel_format | |
SG_PIXELFORMAT_RG32F* = 32.sg_pixel_format | |
SG_PIXELFORMAT_RGBA16* = 33.sg_pixel_format | |
SG_PIXELFORMAT_RGBA16SN* = 34.sg_pixel_format | |
SG_PIXELFORMAT_RGBA16UI* = 35.sg_pixel_format | |
SG_PIXELFORMAT_RGBA16SI* = 36.sg_pixel_format | |
SG_PIXELFORMAT_RGBA16F* = 37.sg_pixel_format | |
SG_PIXELFORMAT_RGBA32UI* = 38.sg_pixel_format | |
SG_PIXELFORMAT_RGBA32SI* = 39.sg_pixel_format | |
SG_PIXELFORMAT_RGBA32F* = 40.sg_pixel_format | |
SG_PIXELFORMAT_DEPTH* = 41.sg_pixel_format | |
SG_PIXELFORMAT_DEPTH_STENCIL* = 42.sg_pixel_format | |
SG_PIXELFORMAT_BC1_RGBA* = 43.sg_pixel_format | |
SG_PIXELFORMAT_BC2_RGBA* = 44.sg_pixel_format | |
SG_PIXELFORMAT_BC3_RGBA* = 45.sg_pixel_format | |
SG_PIXELFORMAT_BC4_R* = 46.sg_pixel_format | |
SG_PIXELFORMAT_BC4_RSN* = 47.sg_pixel_format | |
SG_PIXELFORMAT_BC5_RG* = 48.sg_pixel_format | |
SG_PIXELFORMAT_BC5_RGSN* = 49.sg_pixel_format | |
SG_PIXELFORMAT_BC6H_RGBF* = 50.sg_pixel_format | |
SG_PIXELFORMAT_BC6H_RGBUF* = 51.sg_pixel_format | |
SG_PIXELFORMAT_BC7_RGBA* = 52.sg_pixel_format | |
SG_PIXELFORMAT_PVRTC_RGB_2BPP* = 53.sg_pixel_format | |
SG_PIXELFORMAT_PVRTC_RGB_4BPP* = 54.sg_pixel_format | |
SG_PIXELFORMAT_PVRTC_RGBA_2BPP* = 55.sg_pixel_format | |
SG_PIXELFORMAT_PVRTC_RGBA_4BPP* = 56.sg_pixel_format | |
SG_PIXELFORMAT_ETC2_RGB8* = 57.sg_pixel_format | |
SG_PIXELFORMAT_ETC2_RGB8A1* = 58.sg_pixel_format | |
SG_PIXELFORMAT_ETC2_RGBA8* = 59.sg_pixel_format | |
SG_PIXELFORMAT_ETC2_RG11* = 60.sg_pixel_format | |
SG_PIXELFORMAT_ETC2_RG11SN* = 61.sg_pixel_format | |
SG_PIXELFORMAT_NUM* = 62.sg_pixel_format | |
SG_PIXELFORMAT_FORCE_U32* = (0x7FFFFFFF).sg_pixel_format | |
SG_RESOURCESTATE_INITIAL* = 0.sg_resource_state | |
SG_RESOURCESTATE_ALLOC* = 1.sg_resource_state | |
SG_RESOURCESTATE_VALID* = 2.sg_resource_state | |
SG_RESOURCESTATE_FAILED* = 3.sg_resource_state | |
SG_RESOURCESTATE_INVALID* = 4.sg_resource_state | |
SG_RESOURCESTATE_FORCE_U32* = (0x7FFFFFFF).sg_resource_state | |
SG_USAGE_DEFAULT* = 0.sg_usage | |
SG_USAGE_IMMUTABLE* = 1.sg_usage | |
SG_USAGE_DYNAMIC* = 2.sg_usage | |
SG_USAGE_STREAM* = 3.sg_usage | |
SG_USAGE_NUM* = 4.sg_usage | |
SG_USAGE_FORCE_U32* = (0x7FFFFFFF).sg_usage | |
SG_BUFFERTYPE_DEFAULT* = 0.sg_buffer_type | |
SG_BUFFERTYPE_VERTEXBUFFER* = 1.sg_buffer_type | |
SG_BUFFERTYPE_INDEXBUFFER* = 2.sg_buffer_type | |
SG_BUFFERTYPE_NUM* = 3.sg_buffer_type | |
SG_BUFFERTYPE_FORCE_U32* = (0x7FFFFFFF).sg_buffer_type | |
SG_INDEXTYPE_DEFAULT* = 0.sg_index_type | |
SG_INDEXTYPE_NONE* = 1.sg_index_type | |
SG_INDEXTYPE_UINT16* = 2.sg_index_type | |
SG_INDEXTYPE_UINT32* = 3.sg_index_type | |
SG_INDEXTYPE_NUM* = 4.sg_index_type | |
SG_INDEXTYPE_FORCE_U32* = (0x7FFFFFFF).sg_index_type | |
SG_IMAGETYPE_DEFAULT* = 0.sg_image_type | |
SG_IMAGETYPE_2D* = 1.sg_image_type | |
SG_IMAGETYPE_CUBE* = 2.sg_image_type | |
SG_IMAGETYPE_3D* = 3.sg_image_type | |
SG_IMAGETYPE_ARRAY* = 4.sg_image_type | |
SG_IMAGETYPE_NUM* = 5.sg_image_type | |
SG_IMAGETYPE_FORCE_U32* = (0x7FFFFFFF).sg_image_type | |
SG_CUBEFACE_POS_X* = 0.sg_cube_face | |
SG_CUBEFACE_NEG_X* = 1.sg_cube_face | |
SG_CUBEFACE_POS_Y* = 2.sg_cube_face | |
SG_CUBEFACE_NEG_Y* = 3.sg_cube_face | |
SG_CUBEFACE_POS_Z* = 4.sg_cube_face | |
SG_CUBEFACE_NEG_Z* = 5.sg_cube_face | |
SG_CUBEFACE_NUM* = 6.sg_cube_face | |
SG_CUBEFACE_FORCE_U32* = (0x7FFFFFFF).sg_cube_face | |
SG_SHADERSTAGE_VS* = 0.sg_shader_stage | |
SG_SHADERSTAGE_FS* = 1.sg_shader_stage | |
SG_SHADERSTAGE_FORCE_U32* = (0x7FFFFFFF).sg_shader_stage | |
SG_PRIMITIVETYPE_DEFAULT* = 0.sg_primitive_type | |
SG_PRIMITIVETYPE_POINTS* = 1.sg_primitive_type | |
SG_PRIMITIVETYPE_LINES* = 2.sg_primitive_type | |
SG_PRIMITIVETYPE_LINE_STRIP* = 3.sg_primitive_type | |
SG_PRIMITIVETYPE_TRIANGLES* = 4.sg_primitive_type | |
SG_PRIMITIVETYPE_TRIANGLE_STRIP* = 5.sg_primitive_type | |
SG_PRIMITIVETYPE_NUM* = 6.sg_primitive_type | |
SG_PRIMITIVETYPE_FORCE_U32* = (0x7FFFFFFF).sg_primitive_type | |
SG_FILTER_DEFAULT* = 0.sg_filter | |
SG_FILTER_NEAREST* = 1.sg_filter | |
SG_FILTER_LINEAR* = 2.sg_filter | |
SG_FILTER_NEAREST_MIPMAP_NEAREST* = 3.sg_filter | |
SG_FILTER_NEAREST_MIPMAP_LINEAR* = 4.sg_filter | |
SG_FILTER_LINEAR_MIPMAP_NEAREST* = 5.sg_filter | |
SG_FILTER_LINEAR_MIPMAP_LINEAR* = 6.sg_filter | |
SG_FILTER_NUM* = 7.sg_filter | |
SG_FILTER_FORCE_U32* = (0x7FFFFFFF).sg_filter | |
SG_WRAP_DEFAULT* = 0.sg_wrap | |
SG_WRAP_REPEAT* = 1.sg_wrap | |
SG_WRAP_CLAMP_TO_EDGE* = 2.sg_wrap | |
SG_WRAP_CLAMP_TO_BORDER* = 3.sg_wrap | |
SG_WRAP_MIRRORED_REPEAT* = 4.sg_wrap | |
SG_WRAP_NUM* = 5.sg_wrap | |
SG_WRAP_FORCE_U32* = (0x7FFFFFFF).sg_wrap | |
SG_BORDERCOLOR_DEFAULT* = 0.sg_border_color | |
SG_BORDERCOLOR_TRANSPARENT_BLACK* = 1.sg_border_color | |
SG_BORDERCOLOR_OPAQUE_BLACK* = 2.sg_border_color | |
SG_BORDERCOLOR_OPAQUE_WHITE* = 3.sg_border_color | |
SG_BORDERCOLOR_NUM* = 4.sg_border_color | |
SG_BORDERCOLOR_FORCE_U32* = (0x7FFFFFFF).sg_border_color | |
SG_VERTEXFORMAT_INVALID* = 0.sg_vertex_format | |
SG_VERTEXFORMAT_FLOAT* = 1.sg_vertex_format | |
SG_VERTEXFORMAT_FLOAT2* = 2.sg_vertex_format | |
SG_VERTEXFORMAT_FLOAT3* = 3.sg_vertex_format | |
SG_VERTEXFORMAT_FLOAT4* = 4.sg_vertex_format | |
SG_VERTEXFORMAT_BYTE4* = 5.sg_vertex_format | |
SG_VERTEXFORMAT_BYTE4N* = 6.sg_vertex_format | |
SG_VERTEXFORMAT_UBYTE4* = 7.sg_vertex_format | |
SG_VERTEXFORMAT_UBYTE4N* = 8.sg_vertex_format | |
SG_VERTEXFORMAT_SHORT2* = 9.sg_vertex_format | |
SG_VERTEXFORMAT_SHORT2N* = 10.sg_vertex_format | |
SG_VERTEXFORMAT_USHORT2N* = 11.sg_vertex_format | |
SG_VERTEXFORMAT_SHORT4* = 12.sg_vertex_format | |
SG_VERTEXFORMAT_SHORT4N* = 13.sg_vertex_format | |
SG_VERTEXFORMAT_USHORT4N* = 14.sg_vertex_format | |
SG_VERTEXFORMAT_UINT10_N2* = 15.sg_vertex_format | |
SG_VERTEXFORMAT_NUM* = 16.sg_vertex_format | |
SG_VERTEXFORMAT_FORCE_U32* = (0x7FFFFFFF).sg_vertex_format | |
SG_VERTEXSTEP_DEFAULT* = 0.sg_vertex_step | |
SG_VERTEXSTEP_PER_VERTEX* = 1.sg_vertex_step | |
SG_VERTEXSTEP_PER_INSTANCE* = 2.sg_vertex_step | |
SG_VERTEXSTEP_NUM* = 3.sg_vertex_step | |
SG_VERTEXSTEP_FORCE_U32* = (0x7FFFFFFF).sg_vertex_step | |
SG_UNIFORMTYPE_INVALID* = 0.sg_uniform_type | |
SG_UNIFORMTYPE_FLOAT* = 1.sg_uniform_type | |
SG_UNIFORMTYPE_FLOAT2* = 2.sg_uniform_type | |
SG_UNIFORMTYPE_FLOAT3* = 3.sg_uniform_type | |
SG_UNIFORMTYPE_FLOAT4* = 4.sg_uniform_type | |
SG_UNIFORMTYPE_MAT4* = 5.sg_uniform_type | |
SG_UNIFORMTYPE_NUM* = 6.sg_uniform_type | |
SG_UNIFORMTYPE_FORCE_U32* = (0x7FFFFFFF).sg_uniform_type | |
SG_CULLMODE_DEFAULT* = 0.sg_cull_mode | |
SG_CULLMODE_NONE* = 1.sg_cull_mode | |
SG_CULLMODE_FRONT* = 2.sg_cull_mode | |
SG_CULLMODE_BACK* = 3.sg_cull_mode | |
SG_CULLMODE_NUM* = 4.sg_cull_mode | |
SG_CULLMODE_FORCE_U32* = (0x7FFFFFFF).sg_cull_mode | |
SG_FACEWINDING_DEFAULT* = 0.sg_face_winding | |
SG_FACEWINDING_CCW* = 1.sg_face_winding | |
SG_FACEWINDING_CW* = 2.sg_face_winding | |
SG_FACEWINDING_NUM* = 3.sg_face_winding | |
SG_FACEWINDING_FORCE_U32* = (0x7FFFFFFF).sg_face_winding | |
SG_COMPAREFUNC_DEFAULT* = 0.sg_compare_func | |
SG_COMPAREFUNC_NEVER* = 1.sg_compare_func | |
SG_COMPAREFUNC_LESS* = 2.sg_compare_func | |
SG_COMPAREFUNC_EQUAL* = 3.sg_compare_func | |
SG_COMPAREFUNC_LESS_EQUAL* = 4.sg_compare_func | |
SG_COMPAREFUNC_GREATER* = 5.sg_compare_func | |
SG_COMPAREFUNC_NOT_EQUAL* = 6.sg_compare_func | |
SG_COMPAREFUNC_GREATER_EQUAL* = 7.sg_compare_func | |
SG_COMPAREFUNC_ALWAYS* = 8.sg_compare_func | |
SG_COMPAREFUNC_NUM* = 9.sg_compare_func | |
SG_COMPAREFUNC_FORCE_U32* = (0x7FFFFFFF).sg_compare_func | |
SG_STENCILOP_DEFAULT* = 0.sg_stencil_op | |
SG_STENCILOP_KEEP* = 1.sg_stencil_op | |
SG_STENCILOP_ZERO* = 2.sg_stencil_op | |
SG_STENCILOP_REPLACE* = 3.sg_stencil_op | |
SG_STENCILOP_INCR_CLAMP* = 4.sg_stencil_op | |
SG_STENCILOP_DECR_CLAMP* = 5.sg_stencil_op | |
SG_STENCILOP_INVERT* = 6.sg_stencil_op | |
SG_STENCILOP_INCR_WRAP* = 7.sg_stencil_op | |
SG_STENCILOP_DECR_WRAP* = 8.sg_stencil_op | |
SG_STENCILOP_NUM* = 9.sg_stencil_op | |
SG_STENCILOP_FORCE_U32* = (0x7FFFFFFF).sg_stencil_op | |
SG_BLENDFACTOR_DEFAULT* = 0.sg_blend_factor | |
SG_BLENDFACTOR_ZERO* = 1.sg_blend_factor | |
SG_BLENDFACTOR_ONE* = 2.sg_blend_factor | |
SG_BLENDFACTOR_SRC_COLOR* = 3.sg_blend_factor | |
SG_BLENDFACTOR_ONE_MINUS_SRC_COLOR* = 4.sg_blend_factor | |
SG_BLENDFACTOR_SRC_ALPHA* = 5.sg_blend_factor | |
SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA* = 6.sg_blend_factor | |
SG_BLENDFACTOR_DST_COLOR* = 7.sg_blend_factor | |
SG_BLENDFACTOR_ONE_MINUS_DST_COLOR* = 8.sg_blend_factor | |
SG_BLENDFACTOR_DST_ALPHA* = 9.sg_blend_factor | |
SG_BLENDFACTOR_ONE_MINUS_DST_ALPHA* = 10.sg_blend_factor | |
SG_BLENDFACTOR_SRC_ALPHA_SATURATED* = 11.sg_blend_factor | |
SG_BLENDFACTOR_BLEND_COLOR* = 12.sg_blend_factor | |
SG_BLENDFACTOR_ONE_MINUS_BLEND_COLOR* = 13.sg_blend_factor | |
SG_BLENDFACTOR_BLEND_ALPHA* = 14.sg_blend_factor | |
SG_BLENDFACTOR_ONE_MINUS_BLEND_ALPHA* = 15.sg_blend_factor | |
SG_BLENDFACTOR_NUM* = 16.sg_blend_factor | |
SG_BLENDFACTOR_FORCE_U32* = (0x7FFFFFFF).sg_blend_factor | |
SG_BLENDOP_DEFAULT* = 0.sg_blend_op | |
SG_BLENDOP_ADD* = 1.sg_blend_op | |
SG_BLENDOP_SUBTRACT* = 2.sg_blend_op | |
SG_BLENDOP_REVERSE_SUBTRACT* = 3.sg_blend_op | |
SG_BLENDOP_NUM* = 4.sg_blend_op | |
SG_BLENDOP_FORCE_U32* = (0x7FFFFFFF).sg_blend_op | |
SG_COLORMASK_DEFAULT* = (0).sg_color_mask | |
SG_COLORMASK_NONE* = ((0x10)).sg_color_mask | |
SG_COLORMASK_R* = ((1 shl 0)).sg_color_mask | |
SG_COLORMASK_G* = ((1 shl 1)).sg_color_mask | |
SG_COLORMASK_B* = ((1 shl 2)).sg_color_mask | |
SG_COLORMASK_A* = ((1 shl 3)).sg_color_mask | |
SG_COLORMASK_RGB* = (0x7).sg_color_mask | |
SG_COLORMASK_RGBA* = (0xF).sg_color_mask | |
SG_COLORMASK_FORCE_U32* = (0x7FFFFFFF).sg_color_mask | |
SG_ACTION_DEFAULT* = 0.sg_action | |
SG_ACTION_CLEAR* = 1.sg_action | |
SG_ACTION_LOAD* = 2.sg_action | |
SG_ACTION_DONTCARE* = 3.sg_action | |
SG_ACTION_NUM* = 4.sg_action | |
SG_ACTION_FORCE_U32* = (0x7FFFFFFF).sg_action | |
{.pragma: impsokol_gfx, importc.} | |
{.pragma: impsokol_gfxC, impsokol_gfx, cdecl.} | |
type | |
INNER_C_UNION_c2nim_5* {.bycopy.} = object {.union.} | |
face*: cint | |
layer*: cint | |
slice*: cint | |
INNER_C_UNION_c2nim_8* {.bycopy.} = object {.union.} | |
depth*: cint | |
layers*: cint | |
# | |
# sokol_gfx.h -- simple 3D API wrapper | |
# Project URL: https:github.com/floooh/sokol | |
# Do this: | |
# #define SOKOL_IMPL | |
# before you include this file in *one* C or C++ file to create the | |
# implementation. | |
# In the same place define one of the following to select the rendering | |
# backend: | |
# #define SOKOL_GLCORE33 | |
# #define SOKOL_GLES2 | |
# #define SOKOL_GLES3 | |
# #define SOKOL_D3D11 | |
# #define SOKOL_METAL | |
# #define SOKOL_DUMMY_BACKEND | |
# I.e. for the GL 3.3 Core Profile it should look like this: | |
# #include ... | |
# #include ... | |
# #define SOKOL_IMPL | |
# #define SOKOL_GLCORE33 | |
# #include "sokol_gfx.h" | |
# The dummy backend replaces the platform-specific backend code with empty | |
# stub functions. This is useful for writing tests that need to run on the | |
# command line. | |
# Optionally provide the following defines with your own implementations: | |
# SOKOL_ASSERT(c) - your own assert macro (default: assert(c)) | |
# SOKOL_MALLOC(s) - your own malloc function (default: malloc(s)) | |
# SOKOL_FREE(p) - your own free function (default: free(p)) | |
# SOKOL_LOG(msg) - your own logging function (default: puts(msg)) | |
# SOKOL_UNREACHABLE() - a guard macro for unreachable code (default: assert(false)) | |
# SOKOL_API_DECL - public function declaration prefix (default: extern) | |
# SOKOL_API_IMPL - public function implementation prefix (default: -) | |
# SOKOL_TRACE_HOOKS - enable trace hook callbacks (search below for TRACE HOOKS) | |
# If sokol_gfx.h is compiled as a DLL, define the following before | |
# including the declaration or implementation: | |
# SOKOL_DLL | |
# On Windows, SOKOL_DLL will define SOKOL_API_DECL as __declspec(dllexport) | |
# or __declspec(dllimport) as needed. | |
# If you want to compile without deprecated structs and functions, | |
# define: | |
# SOKOL_NO_DEPRECATED | |
# API usage validation macros: | |
# SOKOL_VALIDATE_BEGIN() - begin a validation block (default:_sg_validate_begin()) | |
# SOKOL_VALIDATE(cond, err) - like assert but for API validation (default: _sg_validate(cond, err)) | |
# SOKOL_VALIDATE_END() - end a validation block, return true if all checks in block passed (default: bool _sg_validate()) | |
# If you don't want validation errors to be fatal, define SOKOL_VALIDATE_NON_FATAL, | |
# be aware though that this may spam SOKOL_LOG messages. | |
# Optionally define the following to force debug checks and validations | |
# even in release mode: | |
# SOKOL_DEBUG - by default this is defined if _DEBUG is defined | |
# sokol_gfx DOES NOT: | |
# =================== | |
# - create a window or the 3D-API context/device, you must do this | |
# before sokol_gfx is initialized, and pass any required information | |
# (like 3D device pointers) to the sokol_gfx initialization call | |
# - present the rendered frame, how this is done exactly usually depends | |
# on how the window and 3D-API context/device was created | |
# - provide a unified shader language, instead 3D-API-specific shader | |
# source-code or shader-bytecode must be provided | |
# For complete code examples using the various backend 3D-APIs, see: | |
# https:github.com/floooh/sokol-samples | |
# For an optional shader-cross-compile solution, see: | |
# https:github.com/floooh/sokol-tools/blob/master/docs/sokol-shdc.md | |
# STEP BY STEP | |
# ============ | |
# --- to initialize sokol_gfx, after creating a window and a 3D-API | |
# context/device, call: | |
# sg_setup(const sg_desc*) | |
# --- create resource objects (at least buffers, shaders and pipelines, | |
# and optionally images and passes): | |
# sg_buffer sg_make_buffer(const sg_buffer_desc*) | |
# sg_image sg_make_image(const sg_image_desc*) | |
# sg_shader sg_make_shader(const sg_shader_desc*) | |
# sg_pipeline sg_make_pipeline(const sg_pipeline_desc*) | |
# sg_pass sg_make_pass(const sg_pass_desc*) | |
# --- start rendering to the default frame buffer with: | |
# sg_begin_default_pass(const sg_pass_action* actions, int width, int height) | |
# --- or start rendering to an offscreen framebuffer with: | |
# sg_begin_pass(sg_pass pass, const sg_pass_action* actions) | |
# --- set the pipeline state for the next draw call with: | |
# sg_apply_pipeline(sg_pipeline pip) | |
# --- fill an sg_bindings struct with the resource bindings for the next | |
# draw call (1..N vertex buffers, 0 or 1 index buffer, 0..N image objects | |
# to use as textures each on the vertex-shader- and fragment-shader-stage | |
# and then call | |
# sg_apply_bindings(const sg_bindings* bindings) | |
# to update the resource bindings | |
# --- optionally update shader uniform data with: | |
# sg_apply_uniforms(sg_shader_stage stage, int ub_index, const void* data, int num_bytes) | |
# --- kick off a draw call with: | |
# sg_draw(int base_element, int num_elements, int num_instances) | |
# --- finish the current rendering pass with: | |
# sg_end_pass() | |
# --- when done with the current frame, call | |
# sg_commit() | |
# --- at the end of your program, shutdown sokol_gfx with: | |
# sg_shutdown() | |
# --- if you need to destroy resources before sg_shutdown(), call: | |
# sg_destroy_buffer(sg_buffer buf) | |
# sg_destroy_image(sg_image img) | |
# sg_destroy_shader(sg_shader shd) | |
# sg_destroy_pipeline(sg_pipeline pip) | |
# sg_destroy_pass(sg_pass pass) | |
# --- to set a new viewport rectangle, call | |
# sg_apply_viewport(int x, int y, int width, int height, bool origin_top_left) | |
# --- to set a new scissor rect, call: | |
# sg_apply_scissor_rect(int x, int y, int width, int height, bool origin_top_left) | |
# both sg_apply_viewport() and sg_apply_scissor_rect() must be called | |
# inside a rendering pass | |
# beginning a pass will reset the viewport to the size of the framebuffer used | |
# in the new pass, | |
# --- to update (overwrite) the content of buffer and image resources, call: | |
# sg_update_buffer(sg_buffer buf, const void* ptr, int num_bytes) | |
# sg_update_image(sg_image img, const sg_image_content* content) | |
# Buffers and images to be updated must have been created with | |
# SG_USAGE_DYNAMIC or SG_USAGE_STREAM | |
# Only one update per frame is allowed for buffer and image resources. | |
# The rationale is to have a simple countermeasure to avoid the CPU | |
# scribbling over data the GPU is currently using, or the CPU having to | |
# wait for the GPU | |
# Buffer and image updates can be partial, as long as a rendering | |
# operation only references the valid (updated) data in the | |
# buffer or image. | |
# --- to append a chunk of data to a buffer resource, call: | |
# int sg_append_buffer(sg_buffer buf, const void* ptr, int num_bytes) | |
# The difference to sg_update_buffer() is that sg_append_buffer() | |
# can be called multiple times per frame to append new data to the | |
# buffer piece by piece, optionally interleaved with draw calls referencing | |
# the previously written data. | |
# sg_append_buffer() returns a byte offset to the start of the | |
# written data, this offset can be assigned to | |
# sg_bindings.vertex_buffer_offsets[n] or | |
# sg_bindings.index_buffer_offset | |
# Code example: | |
# for (...) { | |
# const void* data = ...; | |
# const int num_bytes = ...; | |
# int offset = sg_append_buffer(buf, data, num_bytes); | |
# bindings.vertex_buffer_offsets[0] = offset; | |
# sg_apply_pipeline(pip); | |
# sg_apply_bindings(&bindings); | |
# sg_apply_uniforms(...); | |
# sg_draw(...); | |
# } | |
# A buffer to be used with sg_append_buffer() must have been created | |
# with SG_USAGE_DYNAMIC or SG_USAGE_STREAM. | |
# If the application appends more data to the buffer then fits into | |
# the buffer, the buffer will go into the "overflow" state for the | |
# rest of the frame. | |
# Any draw calls attempting to render an overflown buffer will be | |
# silently dropped (in debug mode this will also result in a | |
# validation error). | |
# You can also check manually if a buffer is in overflow-state by calling | |
# bool sg_query_buffer_overflow(sg_buffer buf) | |
# --- to check at runtime for optional features, limits and pixelformat support, | |
# call: | |
# sg_features sg_query_features() | |
# sg_limits sg_query_limits() | |
# sg_pixelformat_info sg_query_pixelformat(sg_pixel_format fmt) | |
# --- if you need to call into the underlying 3D-API directly, you must call: | |
# sg_reset_state_cache() | |
# ...before calling sokol_gfx functions again | |
# --- you can inspect the original sg_desc structure handed to sg_setup() | |
# by calling sg_query_desc(). This will return an sg_desc struct with | |
# the default values patched in instead of any zero-initialized values | |
# --- you can inspect various internal resource attributes via: | |
# sg_buffer_info sg_query_buffer_info(sg_buffer buf) | |
# sg_image_info sg_query_image_info(sg_image img) | |
# sg_shader_info sg_query_shader_info(sg_shader shd) | |
# sg_pipeline_info sg_query_pipeline_info(sg_pipeline pip) | |
# sg_pass_info sg_query_pass_info(sg_pass pass) | |
# ...please note that the returned info-structs are tied quite closely | |
# to sokol_gfx.h internals, and may change more often than other | |
# public API functions and structs. | |
# --- you can ask at runtime what backend sokol_gfx.h has been compiled | |
# for, or whether the GLES3 backend had to fall back to GLES2 with: | |
# sg_backend sg_query_backend(void) | |
# --- you can query the default resource creation parameters through the functions | |
# sg_buffer_desc sg_query_buffer_defaults(const sg_buffer_desc* desc) | |
# sg_image_desc sg_query_image_defaults(const sg_image_desc* desc) | |
# sg_shader_desc sg_query_shader_defaults(const sg_shader_desc* desc) | |
# sg_pipeline_desc sg_query_pipeline_defaults(const sg_pipeline_desc* desc) | |
# sg_pass_desc sg_query_pass_defaults(const sg_pass_desc* desc) | |
# These functions take a pointer to a desc structure which may contain | |
# zero-initialized items for default values. These zero-init values | |
# will be replaced with their concrete values in the returned desc | |
# struct. | |
# BACKEND-SPECIFIC TOPICS: | |
# ======================== | |
# --- the GL backends need to know about the internal structure of uniform | |
# blocks, and the texture sampler-name and -type: | |
# typedef struct { | |
# float mvp[16]; model-view-projection matrix | |
# float offset0[2]; some 2D vectors | |
# float offset1[2]; | |
# float offset2[2]; | |
# } params_t; | |
# uniform block structure and texture image definition in sg_shader_desc: | |
# sg_shader_desc desc = { | |
# uniform block description (size and internal structure) | |
# .vs.uniform_blocks[0] = { | |
# .size = sizeof(params_t), | |
# .uniforms = { | |
# [0] = { .name="mvp", .type=SG_UNIFORMTYPE_MAT4 }, | |
# [1] = { .name="offset0", .type=SG_UNIFORMTYPE_VEC2 }, | |
# ... | |
# } | |
# }, | |
# one texture on the fragment-shader-stage, GLES2/WebGL needs name and image type | |
# .fs.images[0] = { .name="tex", .type=SG_IMAGETYPE_ARRAY } | |
# ... | |
# }; | |
# --- the Metal and D3D11 backends only need to know the size of uniform blocks, | |
# not their internal member structure, and they only need to know | |
# the type of a texture sampler, not its name: | |
# sg_shader_desc desc = { | |
# .vs.uniform_blocks[0].size = sizeof(params_t), | |
# .fs.images[0].type = SG_IMAGETYPE_ARRAY, | |
# ... | |
# }; | |
# --- when creating a shader object, GLES2/WebGL need to know the vertex | |
# attribute names as used in the vertex shader: | |
# sg_shader_desc desc = { | |
# .attrs = { | |
# [0] = { .name="position" }, | |
# [1] = { .name="color1" } | |
# } | |
# }; | |
# The vertex attribute names provided when creating a shader will be | |
# used later in sg_create_pipeline() for matching the vertex layout | |
# to vertex shader inputs. | |
# --- on D3D11 you need to provide a semantic name and semantic index in the | |
# shader description struct instead (see the D3D11 documentation on | |
# D3D11_INPUT_ELEMENT_DESC for details): | |
# sg_shader_desc desc = { | |
# .attrs = { | |
# [0] = { .sem_name="POSITION", .sem_index=0 } | |
# [1] = { .sem_name="COLOR", .sem_index=1 } | |
# } | |
# }; | |
# The provided semantic information will be used later in sg_create_pipeline() | |
# to match the vertex layout to vertex shader inputs. | |
# --- on Metal, GL 3.3 or GLES3/WebGL2, you don't need to provide an attribute | |
# name or semantic name, since vertex attributes can be bound by their slot index | |
# (this is mandatory in Metal, and optional in GL): | |
# sg_pipeline_desc desc = { | |
# .layout = { | |
# .attrs = { | |
# [0] = { .format=SG_VERTEXFORMAT_FLOAT3 }, | |
# [1] = { .format=SG_VERTEXFORMAT_FLOAT4 } | |
# } | |
# } | |
# }; | |
# WORKING WITH CONTEXTS | |
# ===================== | |
# sokol-gfx allows to switch between different rendering contexts and | |
# associate resource objects with contexts. This is useful to | |
# create GL applications that render into multiple windows. | |
# A rendering context keeps track of all resources created while | |
# the context is active. When the context is destroyed, all resources | |
# "belonging to the context" are destroyed as well. | |
# A default context will be created and activated implicitly in | |
# sg_setup(), and destroyed in sg_shutdown(). So for a typical application | |
# which *doesn't* use multiple contexts, nothing changes, and calling | |
# the context functions isn't necessary. | |
# Three functions have been added to work with contexts: | |
# --- sg_context sg_setup_context(): | |
# This must be called once after a GL context has been created and | |
# made active. | |
# --- void sg_activate_context(sg_context ctx) | |
# This must be called after making a different GL context active. | |
# Apart from 3D-API-specific actions, the call to sg_activate_context() | |
# will internally call sg_reset_state_cache(). | |
# --- void sg_discard_context(sg_context ctx) | |
# This must be called right before a GL context is destroyed and | |
# will destroy all resources associated with the context (that | |
# have been created while the context was active) The GL context must be | |
# active at the time sg_discard_context(sg_context ctx) is called. | |
# Also note that resources (buffers, images, shaders and pipelines) must | |
# only be used or destroyed while the same GL context is active that | |
# was also active while the resource was created (an exception is | |
# resource sharing on GL, such resources can be used while | |
# another context is active, but must still be destroyed under | |
# the same context that was active during creation). | |
# For more information, check out the multiwindow-glfw sample: | |
# https:github.com/floooh/sokol-samples/blob/master/glfw/multiwindow-glfw.c | |
# TRACE HOOKS: | |
# ============ | |
# sokol_gfx.h optionally allows to install "trace hook" callbacks for | |
# each public API functions. When a public API function is called, and | |
# a trace hook callback has been installed for this function, the | |
# callback will be invoked with the parameters and result of the function. | |
# This is useful for things like debugging- and profiling-tools, or | |
# keeping track of resource creation and destruction. | |
# To use the trace hook feature: | |
# --- Define SOKOL_TRACE_HOOKS before including the implementation. | |
# --- Setup an sg_trace_hooks structure with your callback function | |
# pointers (keep all function pointers you're not interested | |
# in zero-initialized), optionally set the user_data member | |
# in the sg_trace_hooks struct. | |
# --- Install the trace hooks by calling sg_install_trace_hooks(), | |
# the return value of this function is another sg_trace_hooks | |
# struct which contains the previously set of trace hooks. | |
# You should keep this struct around, and call those previous | |
# functions pointers from your own trace callbacks for proper | |
# chaining. | |
# As an example of how trace hooks are used, have a look at the | |
# imgui/sokol_gfx_imgui.h header which implements a realtime | |
# debugging UI for sokol_gfx.h on top of Dear ImGui. | |
# A NOTE ON PORTABLE PACKED VERTEX FORMATS: | |
# ========================================= | |
# There are two things to consider when using packed | |
# vertex formats like UBYTE4, SHORT2, etc which need to work | |
# across all backends: | |
# - D3D11 can only convert *normalized* vertex formats to | |
# floating point during vertex fetch, normalized formats | |
# have a trailing 'N', and are "normalized" to a range | |
# -1.0..+1.0 (for the signed formats) or 0.0..1.0 (for the | |
# unsigned formats): | |
# - SG_VERTEXFORMAT_BYTE4N | |
# - SG_VERTEXFORMAT_UBYTE4N | |
# - SG_VERTEXFORMAT_SHORT2N | |
# - SG_VERTEXFORMAT_USHORT2N | |
# - SG_VERTEXFORMAT_SHORT4N | |
# - SG_VERTEXFORMAT_USHORT4N | |
# D3D11 will not convert *non-normalized* vertex formats to floating point | |
# vertex shader inputs, those can only be uses with the *ivecn* vertex shader | |
# input types when D3D11 is used as backend (GL and Metal can use both formats) | |
# - SG_VERTEXFORMAT_BYTE4, | |
# - SG_VERTEXFORMAT_UBYTE4 | |
# - SG_VERTEXFORMAT_SHORT2 | |
# - SG_VERTEXFORMAT_SHORT4 | |
# - WebGL/GLES2 cannot use integer vertex shader inputs (int or ivecn) | |
# - SG_VERTEXFORMAT_UINT10_N2 is not supported on WebGL/GLES2 | |
# So for a vertex input layout which works on all platforms, only use the following | |
# vertex formats, and if needed "expand" the normalized vertex shader | |
# inputs in the vertex shader by multiplying with 127.0, 255.0, 32767.0 or | |
# 65535.0: | |
# - SG_VERTEXFORMAT_FLOAT, | |
# - SG_VERTEXFORMAT_FLOAT2, | |
# - SG_VERTEXFORMAT_FLOAT3, | |
# - SG_VERTEXFORMAT_FLOAT4, | |
# - SG_VERTEXFORMAT_BYTE4N, | |
# - SG_VERTEXFORMAT_UBYTE4N, | |
# - SG_VERTEXFORMAT_SHORT2N, | |
# - SG_VERTEXFORMAT_USHORT2N | |
# - SG_VERTEXFORMAT_SHORT4N, | |
# - SG_VERTEXFORMAT_USHORT4N | |
# TODO: | |
# ==== | |
# - talk about asynchronous resource creation | |
# zlib/libpng license | |
# Copyright (c) 2018 Andre Weissflog | |
# This software is provided 'as-is', without any express or implied warranty. | |
# In no event will the authors be held liable for any damages arising from the | |
# use of this software. | |
# Permission is granted to anyone to use this software for any purpose, | |
# including commercial applications, and to alter it and redistribute it | |
# freely, subject to the following restrictions: | |
# 1. The origin of this software must not be misrepresented; you must not | |
# claim that you wrote the original software. If you use this software in a | |
# product, an acknowledgment in the product documentation would be | |
# appreciated but is not required. | |
# 2. Altered source versions must be plainly marked as such, and must not | |
# be misrepresented as being the original software. | |
# 3. This notice may not be removed or altered from any source | |
# distribution. | |
# | |
# | |
# Resource id typedefs: | |
# sg_buffer: vertex- and index-buffers | |
# sg_image: textures and render targets | |
# sg_shader: vertex- and fragment-shaders, uniform blocks | |
# sg_pipeline: associated shader and vertex-layouts, and render states | |
# sg_pass: a bundle of render targets and actions on them | |
# sg_context: a 'context handle' for switching between 3D-API contexts | |
# Instead of pointers, resource creation functions return a 32-bit | |
# number which uniquely identifies the resource object. | |
# The 32-bit resource id is split into a 16-bit pool index in the lower bits, | |
# and a 16-bit 'unique counter' in the upper bits. The index allows fast | |
# pool lookups, and combined with the unique-mask it allows to detect | |
# 'dangling accesses' (trying to use an object which no longer exists, and | |
# its pool slot has been reused for a new object) | |
# The resource ids are wrapped into a struct so that the compiler | |
# can complain when the wrong resource type is used. | |
# | |
sg_buffer* {.bycopy.} = object | |
id*: uint32 | |
sg_image* {.bycopy.} = object | |
id*: uint32 | |
sg_shader* {.bycopy.} = object | |
id*: uint32 | |
sg_pipeline* {.bycopy.} = object | |
id*: uint32 | |
sg_pass* {.bycopy.} = object | |
id*: uint32 | |
sg_context* {.bycopy.} = object | |
id*: uint32 | |
# | |
# Runtime information about a pixel format, returned | |
# by sg_query_pixelformat(). | |
# | |
sg_pixelformat_info* {.bycopy.} = object | |
sample*: bool | |
filter*: bool | |
render*: bool | |
blend*: bool | |
msaa*: bool | |
depth*: bool | |
# | |
# Runtime information about available optional features, | |
# returned by sg_query_features() | |
# | |
sg_features* {.bycopy.} = object | |
instancing*: bool | |
origin_top_left*: bool | |
multiple_render_targets*: bool | |
msaa_render_targets*: bool | |
imagetype_3d*: bool | |
imagetype_array*: bool | |
image_clamp_to_border*: bool | |
# | |
# Runtime information about resource limits, returned by sg_query_limit() | |
# | |
sg_limits* {.bycopy.} = object | |
max_image_size_2d*: uint32 | |
max_image_size_cube*: uint32 | |
max_image_size_3d*: uint32 | |
max_image_size_array*: uint32 | |
max_image_array_layers*: uint32 | |
max_vertex_attrs*: uint32 | |
# | |
# sg_pass_action | |
# The sg_pass_action struct defines the actions to be performed | |
# at the start of a rendering pass in the functions sg_begin_pass() | |
# and sg_begin_default_pass(). | |
# A separate action and clear values can be defined for each | |
# color attachment, and for the depth-stencil attachment. | |
# The default clear values are defined by the macros: | |
# - SG_DEFAULT_CLEAR_RED: 0.5f | |
# - SG_DEFAULT_CLEAR_GREEN: 0.5f | |
# - SG_DEFAULT_CLEAR_BLUE: 0.5f | |
# - SG_DEFAULT_CLEAR_ALPHA: 1.0f | |
# - SG_DEFAULT_CLEAR_DEPTH: 1.0f | |
# - SG_DEFAULT_CLEAR_STENCIL: 0 | |
# | |
sg_color_attachment_action* {.bycopy.} = object | |
action*: sg_action | |
val*: array[4, cfloat] | |
sg_depth_attachment_action* {.bycopy.} = object | |
action*: sg_action | |
val*: cfloat | |
sg_stencil_attachment_action* {.bycopy.} = object | |
action*: sg_action | |
val*: uint8 | |
sg_pass_action* {.bycopy.} = object | |
start_canary*: uint32 | |
colors*: array[SG_MAX_COLOR_ATTACHMENTS, sg_color_attachment_action] | |
depth*: sg_depth_attachment_action | |
stencil*: sg_stencil_attachment_action | |
end_canary*: uint32 | |
# | |
# sg_bindings | |
# The sg_bindings structure defines the resource binding slots | |
# of the sokol_gfx render pipeline, used as argument to the | |
# sg_apply_bindings() function. | |
# A resource binding struct contains: | |
# - 1..N vertex buffers | |
# - 0..N vertex buffer offsets | |
# - 0..1 index buffers | |
# - 0..1 index buffer offsets | |
# - 0..N vertex shader stage images | |
# - 0..N fragment shader stage images | |
# The max number of vertex buffer and shader stage images | |
# are defined by the SG_MAX_SHADERSTAGE_BUFFERS and | |
# SG_MAX_SHADERSTAGE_IMAGES configuration constants. | |
# The optional buffer offsets can be used to put different unrelated | |
# chunks of vertex- and/or index-data into the same buffer objects. | |
# | |
sg_bindings* {.bycopy.} = object | |
start_canary*: uint32 | |
vertex_buffers*: array[SG_MAX_SHADERSTAGE_BUFFERS, sg_buffer] | |
vertex_buffer_offsets*: array[SG_MAX_SHADERSTAGE_BUFFERS, cint] | |
index_buffer*: sg_buffer | |
index_buffer_offset*: cint | |
vs_images*: array[SG_MAX_SHADERSTAGE_IMAGES, sg_image] | |
fs_images*: array[SG_MAX_SHADERSTAGE_IMAGES, sg_image] | |
end_canary*: uint32 | |
# | |
# sg_buffer_desc | |
# Creation parameters for sg_buffer objects, used in the | |
# sg_make_buffer() call. | |
# The default configuration is: | |
# .size: 0 (this *must* be set to a valid size in bytes) | |
# .type: SG_BUFFERTYPE_VERTEXBUFFER | |
# .usage: SG_USAGE_IMMUTABLE | |
# .content 0 | |
# .label 0 (optional string label for trace hooks) | |
# The label will be ignored by sokol_gfx.h, it is only useful | |
# when hooking into sg_make_buffer() or sg_init_buffer() via | |
# the sg_install_trace_hooks() function. | |
# ADVANCED TOPIC: Injecting native 3D-API buffers: | |
# The following struct members allow to inject your own GL, Metal | |
# or D3D11 buffers into sokol_gfx: | |
# .gl_buffers[SG_NUM_INFLIGHT_FRAMES] | |
# .mtl_buffers[SG_NUM_INFLIGHT_FRAMES] | |
# .d3d11_buffer | |
# You must still provide all other members except the .content member, and | |
# these must match the creation parameters of the native buffers you | |
# provide. For SG_USAGE_IMMUTABLE, only provide a single native 3D-API | |
# buffer, otherwise you need to provide SG_NUM_INFLIGHT_FRAMES buffers | |
# (only for GL and Metal, not D3D11). Providing multiple buffers for GL and | |
# Metal is necessary because sokol_gfx will rotate through them when | |
# calling sg_update_buffer() to prevent lock-stalls. | |
# Note that it is expected that immutable injected buffer have already been | |
# initialized with content, and the .content member must be 0! | |
# Also you need to call sg_reset_state_cache() after calling native 3D-API | |
# functions, and before calling any sokol_gfx function. | |
# | |
sg_buffer_desc* {.bycopy.} = object | |
start_canary*: uint32 | |
size*: cint | |
`type`*: sg_buffer_type | |
usage*: sg_usage | |
content*: pointer | |
label*: cstring | |
gl_buffers*: array[SG_NUM_INFLIGHT_FRAMES, uint32] | |
mtl_buffers*: array[SG_NUM_INFLIGHT_FRAMES, pointer] | |
d3d11_buffer*: pointer | |
end_canary*: uint32 | |
# | |
# sg_subimage_content | |
# Pointer to and size of a subimage-surface data, this is | |
# used to describe the initial content of immutable-usage images, | |
# or for updating a dynamic- or stream-usage images. | |
# For 3D- or array-textures, one sg_subimage_content item | |
# describes an entire mipmap level consisting of all array- or | |
# 3D-slices of the mipmap level. It is only possible to update | |
# an entire mipmap level, not parts of it. | |
# | |
sg_subimage_content* {.bycopy.} = object | |
`ptr`*: pointer | |
size*: cint | |
# | |
# sg_image_content | |
# Defines the content of an image through a 2D array | |
# of sg_subimage_content structs. The first array dimension | |
# is the cubemap face, and the second array dimension the | |
# mipmap level. | |
# | |
sg_image_content* {.bycopy.} = object | |
subimage: array[SG_CUBEFACE_NUM, array[SG_MAX_MIPMAPS, sg_subimage_content]] | |
# | |
# sg_image_desc | |
# Creation parameters for sg_image objects, used in the | |
# sg_make_image() call. | |
# The default configuration is: | |
# .type: SG_IMAGETYPE_2D | |
# .render_target: false | |
# .width 0 (must be set to >0) | |
# .height 0 (must be set to >0) | |
# .depth/.layers: 1 | |
# .num_mipmaps: 1 | |
# .usage: SG_USAGE_IMMUTABLE | |
# .pixel_format: SG_PIXELFORMAT_RGBA8 for textures, backend-dependent | |
# for render targets (RGBA8 or BGRA8) | |
# .sample_count: 1 (only used in render_targets) | |
# .min_filter: SG_FILTER_NEAREST | |
# .mag_filter: SG_FILTER_NEAREST | |
# .wrap_u: SG_WRAP_REPEAT | |
# .wrap_v: SG_WRAP_REPEAT | |
# .wrap_w: SG_WRAP_REPEAT (only SG_IMAGETYPE_3D) | |
# .border_color SG_BORDERCOLOR_OPAQUE_BLACK | |
# .max_anisotropy 1 (must be 1..16) | |
# .min_lod 0.0f | |
# .max_lod FLT_MAX | |
# .content an sg_image_content struct to define the initial content | |
# .label 0 (optional string label for trace hooks) | |
# SG_IMAGETYPE_ARRAY and SG_IMAGETYPE_3D are not supported on | |
# WebGL/GLES2, use sg_query_features().imagetype_array and | |
# sg_query_features().imagetype_3d at runtime to check | |
# if array- and 3D-textures are supported. | |
# Images with usage SG_USAGE_IMMUTABLE must be fully initialized by | |
# providing a valid .content member which points to | |
# initialization data. | |
# ADVANCED TOPIC: Injecting native 3D-API textures: | |
# The following struct members allow to inject your own GL, Metal | |
# or D3D11 textures into sokol_gfx: | |
# .gl_textures[SG_NUM_INFLIGHT_FRAMES] | |
# .mtl_textures[SG_NUM_INFLIGHT_FRAMES] | |
# .d3d11_texture | |
# The same rules apply as for injecting native buffers | |
# (see sg_buffer_desc documentation for more details). | |
# | |
sg_image_desc* {.bycopy.} = object | |
start_canary*: uint32 | |
`type`*: sg_image_type | |
render_target*: bool | |
width*: cint | |
height*: cint | |
ano_c2nim_10*: INNER_C_UNION_c2nim_8 | |
num_mipmaps*: cint | |
usage*: sg_usage | |
pixel_format*: sg_pixel_format | |
sample_count*: cint | |
min_filter*: sg_filter | |
mag_filter*: sg_filter | |
wrap_u*: sg_wrap | |
wrap_v*: sg_wrap | |
wrap_w*: sg_wrap | |
border_color*: sg_border_color | |
max_anisotropy*: uint32 | |
min_lod*: cfloat | |
max_lod*: cfloat | |
content*: sg_image_content | |
label*: cstring ## GL specific | |
gl_textures*: array[SG_NUM_INFLIGHT_FRAMES, uint32] ## Metal specific | |
mtl_textures*: array[SG_NUM_INFLIGHT_FRAMES, pointer] ## D3D11 specific | |
d3d11_texture*: pointer | |
end_canary*: uint32 | |
# | |
# sg_shader_desc | |
# The structure sg_shader_desc defines all creation parameters | |
# for shader programs, used as input to the sg_make_shader() function: | |
# - reflection information for vertex attributes (vertex shader inputs): | |
# - vertex attribute name (required for GLES2, optional for GLES3 and GL) | |
# - a semantic name and index (required for D3D11) | |
# - for each vertex- and fragment-shader-stage: | |
# - the shader source or bytecode | |
# - an optional entry function name | |
# - reflection info for each uniform block used by the shader stage: | |
# - the size of the uniform block in bytes | |
# - reflection info for each uniform block member (only required for GL backends): | |
# - member name | |
# - member type (SG_UNIFORMTYPE_xxx) | |
# - if the member is an array, the number of array items | |
# - reflection info for the texture images used by the shader stage: | |
# - the image type (SG_IMAGETYPE_xxx) | |
# - the name of the texture sampler (required for GLES2, optional everywhere else) | |
# For all GL backends, shader source-code must be provided. For D3D11 and Metal, | |
# either shader source-code or byte-code can be provided. | |
# For D3D11, if source code is provided, the d3dcompiler_47.dll will be loaded | |
# on demand. If this fails, shader creation will fail. | |
# | |
sg_shader_attr_desc* {.bycopy.} = object | |
name*: cstring | |
sem_name*: cstring | |
sem_index*: cint | |
sg_shader_uniform_desc* {.bycopy.} = object | |
name*: cstring | |
`type`*: sg_uniform_type | |
array_count*: cint | |
sg_shader_uniform_block_desc* {.bycopy.} = object | |
size*: cint | |
uniforms*: array[SG_MAX_UB_MEMBERS, sg_shader_uniform_desc] | |
sg_shader_image_desc* {.bycopy.} = object | |
name*: cstring | |
`type`*: sg_image_type | |
sg_shader_stage_desc* {.bycopy.} = object | |
source*: cstring | |
byte_code*: ptr uint8 | |
byte_code_size*: cint | |
entry*: cstring | |
uniform_blocks*: array[SG_MAX_SHADERSTAGE_UBS, sg_shader_uniform_block_desc] | |
images*: array[SG_MAX_SHADERSTAGE_IMAGES, sg_shader_image_desc] | |
sg_shader_desc* {.bycopy.} = object | |
start_canary*: uint32 | |
attrs*: array[SG_MAX_VERTEX_ATTRIBUTES, sg_shader_attr_desc] | |
vs*: sg_shader_stage_desc | |
fs*: sg_shader_stage_desc | |
label*: cstring | |
end_canary*: uint32 | |
# | |
# sg_pipeline_desc | |
# The sg_pipeline_desc struct defines all creation parameters | |
# for an sg_pipeline object, used as argument to the | |
# sg_make_pipeline() function: | |
# - the vertex layout for all input vertex buffers | |
# - a shader object | |
# - the 3D primitive type (points, lines, triangles, ...) | |
# - the index type (none, 16- or 32-bit) | |
# - depth-stencil state | |
# - alpha-blending state | |
# - rasterizer state | |
# If the vertex data has no gaps between vertex components, you can omit | |
# the .layout.buffers[].stride and layout.attrs[].offset items (leave them | |
# default-initialized to 0), sokol-gfx will then compute the offsets and strides | |
# from the vertex component formats (.layout.attrs[].format). Please note | |
# that ALL vertex attribute offsets must be 0 in order for the | |
# automatic offset computation to kick in. | |
# The default configuration is as follows: | |
# .layout: | |
# .buffers[]: vertex buffer layouts | |
# .stride: 0 (if no stride is given it will be computed) | |
# .step_func SG_VERTEXSTEP_PER_VERTEX | |
# .step_rate 1 | |
# .attrs[]: vertex attribute declarations | |
# .buffer_index 0 the vertex buffer bind slot | |
# .offset 0 (offsets can be omitted if the vertex layout has no gaps) | |
# .format SG_VERTEXFORMAT_INVALID (must be initialized!) | |
# .shader: 0 (must be initialized with a valid sg_shader id!) | |
# .primitive_type: SG_PRIMITIVETYPE_TRIANGLES | |
# .index_type: SG_INDEXTYPE_NONE | |
# .depth_stencil: | |
# .stencil_front, .stencil_back: | |
# .fail_op: SG_STENCILOP_KEEP | |
# .depth_fail_op: SG_STENCILOP_KEEP | |
# .pass_op: SG_STENCILOP_KEEP | |
# .compare_func SG_COMPAREFUNC_ALWAYS | |
# .depth_compare_func: SG_COMPAREFUNC_ALWAYS | |
# .depth_write_enabled: false | |
# .stencil_enabled: false | |
# .stencil_read_mask: 0 | |
# .stencil_write_mask: 0 | |
# .stencil_ref: 0 | |
# .blend: | |
# .enabled: false | |
# .src_factor_rgb: SG_BLENDFACTOR_ONE | |
# .dst_factor_rgb: SG_BLENDFACTOR_ZERO | |
# .op_rgb: SG_BLENDOP_ADD | |
# .src_factor_alpha: SG_BLENDFACTOR_ONE | |
# .dst_factor_alpha: SG_BLENDFACTOR_ZERO | |
# .op_alpha: SG_BLENDOP_ADD | |
# .color_write_mask: SG_COLORMASK_RGBA | |
# .color_attachment_count 1 | |
# .color_format SG_PIXELFORMAT_RGBA8 | |
# .depth_format SG_PIXELFORMAT_DEPTHSTENCIL | |
# .blend_color: { 0.0f, 0.0f, 0.0f, 0.0f } | |
# .rasterizer: | |
# .alpha_to_coverage_enabled: false | |
# .cull_mode: SG_CULLMODE_NONE | |
# .face_winding: SG_FACEWINDING_CW | |
# .sample_count: 1 | |
# .depth_bias: 0.0f | |
# .depth_bias_slope_scale: 0.0f | |
# .depth_bias_clamp: 0.0f | |
# .label 0 (optional string label for trace hooks) | |
# | |
sg_buffer_layout_desc* {.bycopy.} = object | |
stride*: cint | |
step_func*: sg_vertex_step | |
step_rate*: cint | |
sg_vertex_attr_desc* {.bycopy.} = object | |
buffer_index*: cint | |
offset*: cint | |
format*: sg_vertex_format | |
sg_layout_desc* {.bycopy.} = object | |
buffers*: array[SG_MAX_SHADERSTAGE_BUFFERS, sg_buffer_layout_desc] | |
attrs*: array[SG_MAX_VERTEX_ATTRIBUTES, sg_vertex_attr_desc] | |
sg_stencil_state* {.bycopy.} = object | |
fail_op*: sg_stencil_op | |
depth_fail_op*: sg_stencil_op | |
pass_op*: sg_stencil_op | |
compare_func*: sg_compare_func | |
sg_depth_stencil_state* {.bycopy.} = object | |
stencil_front*: sg_stencil_state | |
stencil_back*: sg_stencil_state | |
depth_compare_func*: sg_compare_func | |
depth_write_enabled*: bool | |
stencil_enabled*: bool | |
stencil_read_mask*: uint8 | |
stencil_write_mask*: uint8 | |
stencil_ref*: uint8 | |
sg_blend_state* {.bycopy.} = object | |
enabled*: bool | |
src_factor_rgb*: sg_blend_factor | |
dst_factor_rgb*: sg_blend_factor | |
op_rgb*: sg_blend_op | |
src_factor_alpha*: sg_blend_factor | |
dst_factor_alpha*: sg_blend_factor | |
op_alpha*: sg_blend_op | |
color_write_mask*: uint8 | |
color_attachment_count*: cint | |
color_format*: sg_pixel_format | |
depth_format*: sg_pixel_format | |
blend_color*: array[4, cfloat] | |
sg_rasterizer_state* {.bycopy.} = object | |
alpha_to_coverage_enabled*: bool | |
cull_mode*: sg_cull_mode | |
face_winding*: sg_face_winding | |
sample_count*: cint | |
depth_bias*: cfloat | |
depth_bias_slope_scale*: cfloat | |
depth_bias_clamp*: cfloat | |
sg_pipeline_desc* {.bycopy.} = object | |
start_canary*: uint32 | |
layout*: sg_layout_desc | |
shader*: sg_shader | |
primitive_type*: sg_primitive_type | |
index_type*: sg_index_type | |
depth_stencil*: sg_depth_stencil_state | |
blend*: sg_blend_state | |
rasterizer*: sg_rasterizer_state | |
label*: cstring | |
end_canary*: uint32 | |
# | |
# sg_pass_desc | |
# Creation parameters for an sg_pass object, used as argument | |
# to the sg_make_pass() function. | |
# A pass object contains 1..4 color-attachments and none, or one, | |
# depth-stencil-attachment. Each attachment consists of | |
# an image, and two additional indices describing | |
# which subimage the pass will render to: one mipmap index, and | |
# if the image is a cubemap, array-texture or 3D-texture, the | |
# face-index, array-layer or depth-slice. | |
# Pass images must fulfill the following requirements: | |
# All images must have: | |
# - been created as render target (sg_image_desc.render_target = true) | |
# - the same size | |
# - the same sample count | |
# In addition, all color-attachment images must have the same pixel format. | |
# | |
sg_attachment_desc* {.bycopy.} = object | |
image*: sg_image | |
mip_level*: cint | |
ano_c2nim_8*: INNER_C_UNION_c2nim_5 | |
sg_pass_desc* {.bycopy.} = object | |
start_canary*: uint32 | |
color_attachments*: array[SG_MAX_COLOR_ATTACHMENTS, sg_attachment_desc] | |
depth_stencil_attachment*: sg_attachment_desc | |
label*: cstring | |
end_canary*: uint32 | |
# | |
# sg_trace_hooks | |
# Installable callback functions to keep track of the sokol-gfx calls, | |
# this is useful for debugging, or keeping track of resource creation | |
# and destruction. | |
# Trace hooks are installed with sg_install_trace_hooks(), this returns | |
# another sg_trace_hooks struct with the previous set of | |
# trace hook function pointers. These should be invoked by the | |
# new trace hooks to form a proper call chain. | |
# | |
sg_trace_hooks* {.bycopy.} = object | |
user_data*: pointer | |
reset_state_cache*: proc(user_data: pointer) {.cdecl.} | |
make_buffer*: proc(desc: ptr sg_buffer_desc, result: sg_buffer, user_data: pointer) {.cdecl.} | |
make_image*: proc(desc: ptr sg_image_desc, result: sg_image, user_data: pointer) {.cdecl.} | |
make_shader*: proc(desc: ptr sg_shader_desc, result: sg_shader, user_data: pointer) {.cdecl.} | |
make_pipeline*: proc(desc: ptr sg_pipeline_desc, result: sg_pipeline, user_data: pointer) {.cdecl.} | |
make_pass*: proc(desc: ptr sg_pass_desc, result: sg_pass, user_data: pointer) {.cdecl.} | |
destroy_buffer*: proc(buf: sg_buffer, user_data: pointer) {.cdecl.} | |
destroy_image*: proc(img: sg_image, user_data: pointer) {.cdecl.} | |
destroy_shader*: proc(shd: sg_shader, user_data: pointer) {.cdecl.} | |
destroy_pipeline*: proc(pip: sg_pipeline, user_data: pointer) {.cdecl.} | |
destroy_pass*: proc(pass: sg_pass, user_data: pointer) {.cdecl.} | |
update_buffer*: proc(buf: sg_buffer, data_ptr: pointer, data_size: cint, user_data: pointer) {.cdecl.} | |
update_image*: proc(img: sg_image, data: ptr sg_image_content, user_data: pointer) {.cdecl.} | |
append_buffer*: proc(buf: sg_buffer, data_ptr: pointer, data_size: cint, result: cint, user_data: pointer) {.cdecl.} | |
begin_default_pass*: proc(pass_action: ptr sg_pass_action, width: cint, height: cint, user_data: pointer) {.cdecl.} | |
begin_pass*: proc(pass: sg_pass, pass_action: ptr sg_pass_action, user_data: pointer) {.cdecl.} | |
apply_viewport*: proc(x: cint, y: cint, width: cint, height: cint, origin_top_left: bool, user_data: pointer) {.cdecl.} | |
apply_scissor_rect*: proc(x: cint, y: cint, width: cint, height: cint, origin_top_left: bool, user_data: pointer) {.cdecl.} | |
apply_pipeline*: proc(pip: sg_pipeline, user_data: pointer) {.cdecl.} | |
apply_bindings*: proc(bindings: ptr sg_bindings, user_data: pointer) {.cdecl.} | |
apply_uniforms*: proc(stage: sg_shader_stage, ub_index: cint, data: pointer, num_bytes: cint, user_data: pointer) {.cdecl.} | |
draw*: proc(base_element: cint, num_elements: cint, num_instances: cint, user_data: pointer) {.cdecl.} | |
end_pass*: proc(user_data: pointer) {.cdecl.} | |
commit*: proc(user_data: pointer) {.cdecl.} | |
alloc_buffer*: proc(result: sg_buffer, user_data: pointer) {.cdecl.} | |
alloc_image*: proc(result: sg_image, user_data: pointer) {.cdecl.} | |
alloc_shader*: proc(result: sg_shader, user_data: pointer) {.cdecl.} | |
alloc_pipeline*: proc(result: sg_pipeline, user_data: pointer) {.cdecl.} | |
alloc_pass*: proc(result: sg_pass, user_data: pointer) {.cdecl.} | |
init_buffer*: proc(buf_id: sg_buffer, desc: ptr sg_buffer_desc, user_data: pointer) {.cdecl.} | |
init_image*: proc(img_id: sg_image, desc: ptr sg_image_desc, user_data: pointer) {.cdecl.} | |
init_shader*: proc(shd_id: sg_shader, desc: ptr sg_shader_desc, user_data: pointer) {.cdecl.} | |
init_pipeline*: proc(pip_id: sg_pipeline, desc: ptr sg_pipeline_desc, user_data: pointer) {.cdecl.} | |
init_pass*: proc(pass_id: sg_pass, desc: ptr sg_pass_desc, user_data: pointer) {.cdecl.} | |
fail_buffer*: proc(buf_id: sg_buffer, user_data: pointer) {.cdecl.} | |
fail_image*: proc(img_id: sg_image, user_data: pointer) {.cdecl.} | |
fail_shader*: proc(shd_id: sg_shader, user_data: pointer) {.cdecl.} | |
fail_pipeline*: proc(pip_id: sg_pipeline, user_data: pointer) {.cdecl.} | |
fail_pass*: proc(pass_id: sg_pass, user_data: pointer) {.cdecl.} | |
push_debug_group*: proc(name: cstring, user_data: pointer) {.cdecl.} | |
pop_debug_group*: proc(user_data: pointer) {.cdecl.} | |
err_buffer_pool_exhausted*: proc(user_data: pointer) {.cdecl.} | |
err_image_pool_exhausted*: proc(user_data: pointer) {.cdecl.} | |
err_shader_pool_exhausted*: proc(user_data: pointer) {.cdecl.} | |
err_pipeline_pool_exhausted*: proc(user_data: pointer) {.cdecl.} | |
err_pass_pool_exhausted*: proc(user_data: pointer) {.cdecl.} | |
err_context_mismatch*: proc(user_data: pointer) {.cdecl.} | |
err_pass_invalid*: proc(user_data: pointer) {.cdecl.} | |
err_draw_invalid*: proc(user_data: pointer) {.cdecl.} | |
err_bindings_invalid*: proc(user_data: pointer) {.cdecl.} | |
# | |
# sg_buffer_info | |
# sg_image_info | |
# sg_shader_info | |
# sg_pipeline_info | |
# sg_pass_info | |
# These structs contain various internal resource attributes which | |
# might be useful for debug-inspection. Please don't rely on the | |
# actual content of those structs too much, as they are quite closely | |
# tied to sokol_gfx.h internals and may change more frequently than | |
# the other public API elements. | |
# The *_info structs are used as the return values of the following functions: | |
# sg_query_buffer_info() | |
# sg_query_image_info() | |
# sg_query_shader_info() | |
# sg_query_pipeline_info() | |
# sg_query_pass_info() | |
# | |
sg_slot_info* {.bycopy.} = object | |
state*: sg_resource_state | |
res_id*: uint32 | |
ctx_id*: uint32 | |
sg_buffer_info* {.bycopy.} = object | |
slot*: sg_slot_info | |
update_frame_index*: uint32 | |
append_frame_index*: uint32 | |
append_pos*: cint | |
append_overflow*: bool | |
num_slots*: cint | |
active_slot*: cint | |
sg_image_info* {.bycopy.} = object | |
slot*: sg_slot_info | |
upd_frame_index*: uint32 | |
num_slots*: cint | |
active_slot*: cint | |
sg_shader_info* {.bycopy.} = object | |
slot*: sg_slot_info | |
sg_pipeline_info* {.bycopy.} = object | |
slot*: sg_slot_info | |
sg_pass_info* {.bycopy.} = object | |
slot*: sg_slot_info | |
# | |
# sg_desc | |
# The sg_desc struct contains configuration values for sokol_gfx, | |
# it is used as parameter to the sg_setup() call. | |
# The default configuration is: | |
# .buffer_pool_size: 128 | |
# .image_pool_size: 128 | |
# .shader_pool_size: 32 | |
# .pipeline_pool_size: 64 | |
# .pass_pool_size: 16 | |
# .context_pool_size: 16 | |
# GL specific: | |
# .gl_force_gles2 | |
# if this is true the GL backend will act in "GLES2 fallback mode" even | |
# when compiled with SOKOL_GLES3, this is useful to fall back | |
# to traditional WebGL if a browser doesn't support a WebGL2 context | |
# Metal specific: | |
# (NOTE: All Objective-C object references are transferred through | |
# a bridged (const void*) to sokol_gfx, which will use a unretained | |
# bridged cast (__bridged id<xxx>) to retrieve the Objective-C | |
# references back. Since the bridge cast is unretained, the caller | |
# must hold a strong reference to the Objective-C object for the | |
# duration of the sokol_gfx call! | |
# .mtl_device | |
# a pointer to the MTLDevice object | |
# .mtl_renderpass_descriptor_cb | |
# a C callback function to obtain the MTLRenderPassDescriptor for the | |
# current frame when rendering to the default framebuffer, will be called | |
# in sg_begin_default_pass() | |
# .mtl_drawable_cb | |
# a C callback function to obtain a MTLDrawable for the current | |
# frame when rendering to the default framebuffer, will be called in | |
# sg_end_pass() of the default pass | |
# .mtl_global_uniform_buffer_size | |
# the size of the global uniform buffer in bytes, this must be big | |
# enough to hold all uniform block updates for a single frame, | |
# the default value is 4 MByte (4 * 1024 * 1024) | |
# .mtl_sampler_cache_size | |
# the number of slots in the sampler cache, the Metal backend | |
# will share texture samplers with the same state in this | |
# cache, the default value is 64 | |
# D3D11 specific: | |
# .d3d11_device | |
# a pointer to the ID3D11Device object, this must have been created | |
# before sg_setup() is called | |
# .d3d11_device_context | |
# a pointer to the ID3D11DeviceContext object | |
# .d3d11_render_target_view_cb | |
# a C callback function to obtain a pointer to the current | |
# ID3D11RenderTargetView object of the default framebuffer, | |
# this function will be called in sg_begin_pass() when rendering | |
# to the default framebuffer | |
# .d3d11_depth_stencil_view_cb | |
# a C callback function to obtain a pointer to the current | |
# ID3D11DepthStencilView object of the default framebuffer, | |
# this function will be called in sg_begin_pass() when rendering | |
# to the default framebuffer | |
# | |
sg_desc* {.bycopy.} = object | |
start_canary*: uint32 | |
buffer_pool_size*: cint | |
image_pool_size*: cint | |
shader_pool_size*: cint | |
pipeline_pool_size*: cint | |
pass_pool_size*: cint | |
context_pool_size*: cint | |
gl_force_gles2*: bool | |
mtl_device*: pointer | |
mtl_renderpass_descriptor_cb*: proc(): pointer {.cdecl.} | |
mtl_drawable_cb*: proc(): pointer {.cdecl.} | |
mtl_global_uniform_buffer_size*: cint | |
mtl_sampler_cache_size*: cint | |
d3d11_device*: pointer | |
d3d11_device_context*: pointer | |
d3d11_render_target_view_cb*: proc(): pointer {.cdecl.} | |
d3d11_depth_stencil_view_cb*: proc(): pointer {.cdecl.} | |
end_canary*: uint32 | |
# setup and misc functions | |
proc sg_setup*(desc: ptr sg_desc) {.impsokol_gfxC.} | |
proc sg_shutdown*() {.impsokol_gfxC.} | |
proc sg_isvalid*(): bool {.impsokol_gfxC.} | |
proc sg_reset_state_cache*() {.impsokol_gfxC.} | |
proc sg_install_trace_hooks*(trace_hooks: ptr sg_trace_hooks): sg_trace_hooks {.impsokol_gfxC.} | |
proc sg_push_debug_group*(name: cstring) {.impsokol_gfxC.} | |
proc sg_pop_debug_group*() {.impsokol_gfxC.} | |
# resource creation, destruction and updating | |
proc sg_make_buffer*(desc: ptr sg_buffer_desc): sg_buffer {.impsokol_gfxC.} | |
proc sg_make_image*(desc: ptr sg_image_desc): sg_image {.impsokol_gfxC.} | |
proc sg_make_shader*(desc: ptr sg_shader_desc): sg_shader {.impsokol_gfxC.} | |
proc sg_make_pipeline*(desc: ptr sg_pipeline_desc): sg_pipeline {.impsokol_gfxC.} | |
proc sg_make_pass*(desc: ptr sg_pass_desc): sg_pass {.impsokol_gfxC.} | |
proc sg_destroy_buffer*(buf: sg_buffer) {.impsokol_gfxC.} | |
proc sg_destroy_image*(img: sg_image) {.impsokol_gfxC.} | |
proc sg_destroy_shader*(shd: sg_shader) {.impsokol_gfxC.} | |
proc sg_destroy_pipeline*(pip: sg_pipeline) {.impsokol_gfxC.} | |
proc sg_destroy_pass*(pass: sg_pass) {.impsokol_gfxC.} | |
proc sg_update_buffer*(buf: sg_buffer, data_ptr: pointer, data_size: cint) {.impsokol_gfxC.} | |
proc sg_update_image*(img: sg_image, data: ptr sg_image_content) {.impsokol_gfxC.} | |
proc sg_append_buffer*(buf: sg_buffer, data_ptr: pointer, data_size: cint): cint {.impsokol_gfxC.} | |
proc sg_query_buffer_overflow*(buf: sg_buffer): bool {.impsokol_gfxC.} | |
# rendering functions | |
proc sg_begin_default_pass*(pass_action: ptr sg_pass_action, width: cint, height: cint) {.impsokol_gfxC.} | |
proc sg_begin_pass*(pass: sg_pass, pass_action: ptr sg_pass_action) {.impsokol_gfxC.} | |
proc sg_apply_viewport*(x: cint, y: cint, width: cint, height: cint, origin_top_left: bool) {.impsokol_gfxC.} | |
proc sg_apply_scissor_rect*(x: cint, y: cint, width: cint, height: cint, origin_top_left: bool) {.impsokol_gfxC.} | |
proc sg_apply_pipeline*(pip: sg_pipeline) {.impsokol_gfxC.} | |
proc sg_apply_bindings*(bindings: ptr sg_bindings) {.impsokol_gfxC.} | |
proc sg_apply_uniforms*(stage: sg_shader_stage, ub_index: cint, data: pointer, num_bytes: cint) {.impsokol_gfxC.} | |
proc sg_draw*(base_element: cint, num_elements: cint, num_instances: cint) {.impsokol_gfxC.} | |
proc sg_end_pass*() {.impsokol_gfxC.} | |
proc sg_commit*() {.impsokol_gfxC.} | |
# getting information | |
proc sg_query_desc*(): sg_desc {.impsokol_gfxC.} | |
proc sg_query_backend*(): sg_backend {.impsokol_gfxC.} | |
proc sg_query_features*(): sg_features {.impsokol_gfxC.} | |
proc sg_query_limits*(): sg_limits {.impsokol_gfxC.} | |
proc sg_query_pixelformat*(fmt: sg_pixel_format): sg_pixelformat_info {.impsokol_gfxC.} | |
# get current state of a resource (INITIAL, ALLOC, VALID, FAILED, INVALID) | |
proc sg_query_buffer_state*(buf: sg_buffer): sg_resource_state {.impsokol_gfxC.} | |
proc sg_query_image_state*(img: sg_image): sg_resource_state {.impsokol_gfxC.} | |
proc sg_query_shader_state*(shd: sg_shader): sg_resource_state {.impsokol_gfxC.} | |
proc sg_query_pipeline_state*(pip: sg_pipeline): sg_resource_state {.impsokol_gfxC.} | |
proc sg_query_pass_state*(pass: sg_pass): sg_resource_state {.impsokol_gfxC.} | |
# get runtime information about a resource | |
proc sg_query_buffer_info*(buf: sg_buffer): sg_buffer_info {.impsokol_gfxC.} | |
proc sg_query_image_info*(img: sg_image): sg_image_info {.impsokol_gfxC.} | |
proc sg_query_shader_info*(shd: sg_shader): sg_shader_info {.impsokol_gfxC.} | |
proc sg_query_pipeline_info*(pip: sg_pipeline): sg_pipeline_info {.impsokol_gfxC.} | |
proc sg_query_pass_info*(pass: sg_pass): sg_pass_info {.impsokol_gfxC.} | |
# get resource creation desc struct with their default values replaced | |
proc sg_query_buffer_defaults*(desc: ptr sg_buffer_desc): sg_buffer_desc {.impsokol_gfxC.} | |
proc sg_query_image_defaults*(desc: ptr sg_image_desc): sg_image_desc {.impsokol_gfxC.} | |
proc sg_query_shader_defaults*(desc: ptr sg_shader_desc): sg_shader_desc {.impsokol_gfxC.} | |
proc sg_query_pipeline_defaults*(desc: ptr sg_pipeline_desc): sg_pipeline_desc {.impsokol_gfxC.} | |
proc sg_query_pass_defaults*(desc: ptr sg_pass_desc): sg_pass_desc {.impsokol_gfxC.} | |
# separate resource allocation and initialization (for async setup) | |
proc sg_alloc_buffer*(): sg_buffer {.impsokol_gfxC.} | |
proc sg_alloc_image*(): sg_image {.impsokol_gfxC.} | |
proc sg_alloc_shader*(): sg_shader {.impsokol_gfxC.} | |
proc sg_alloc_pipeline*(): sg_pipeline {.impsokol_gfxC.} | |
proc sg_alloc_pass*(): sg_pass {.impsokol_gfxC.} | |
proc sg_init_buffer*(buf_id: sg_buffer, desc: ptr sg_buffer_desc) {.impsokol_gfxC.} | |
proc sg_init_image*(img_id: sg_image, desc: ptr sg_image_desc) {.impsokol_gfxC.} | |
proc sg_init_shader*(shd_id: sg_shader, desc: ptr sg_shader_desc) {.impsokol_gfxC.} | |
proc sg_init_pipeline*(pip_id: sg_pipeline, desc: ptr sg_pipeline_desc) {.impsokol_gfxC.} | |
proc sg_init_pass*(pass_id: sg_pass, desc: ptr sg_pass_desc) {.impsokol_gfxC.} | |
proc sg_fail_buffer*(buf_id: sg_buffer) {.impsokol_gfxC.} | |
proc sg_fail_image*(img_id: sg_image) {.impsokol_gfxC.} | |
proc sg_fail_shader*(shd_id: sg_shader) {.impsokol_gfxC.} | |
proc sg_fail_pipeline*(pip_id: sg_pipeline) {.impsokol_gfxC.} | |
proc sg_fail_pass*(pass_id: sg_pass) {.impsokol_gfxC.} | |
# rendering contexts (optional) | |
proc sg_setup_context*(): sg_context {.impsokol_gfxC.} | |
proc sg_activate_context*(ctx_id: sg_context) {.impsokol_gfxC.} | |
proc sg_discard_context*(ctx_id: sg_context) {.impsokol_gfxC.} | |
# Importing /Users/zacharycarter/dev/junkers/lib/sokol/sokol_app.h | |
# Generated at 2020-04-07T22:49:42-05:00 | |
# Command line: | |
# /Users/zacharycarter/.nimble/pkgs/nimterop-#head/nimterop/toast --preprocess --pnim --symOverride=INNER_C_UNION_c2nim_5,sg_attachment_desc,sg_image_content,INNER_C_UNION_c2nim_8,sg_image_desc --nim:/Users/zacharycarter/.choosenim/toolchains/nim-#devel/bin/nim --pluginSourcePath=/Users/zacharycarter/.cache/nim/nimterop/cPlugins/nimterop_2793949904.nim /Users/zacharycarter/dev/junkers/lib/sokol/sokol_app.h | |
{.hint[ConvFromXtoItselfNotNeeded]: off.} | |
import nimterop/types | |
# | |
# sokol_app.h -- cross-platform application wrapper | |
# Project URL: https:github.com/floooh/sokol | |
# Do this: | |
# #define SOKOL_IMPL | |
# before you include this file in *one* C or C++ file to create the | |
# implementation. | |
# Optionally provide the following defines with your own implementations: | |
# SOKOL_ASSERT(c) - your own assert macro (default: assert(c)) | |
# SOKOL_LOG(msg) - your own logging function (default: puts(msg)) | |
# SOKOL_UNREACHABLE() - a guard macro for unreachable code (default: assert(false)) | |
# SOKOL_ABORT() - called after an unrecoverable error (default: abort()) | |
# SOKOL_WIN32_FORCE_MAIN - define this on Win32 to use a main() entry point instead of WinMain | |
# SOKOL_NO_ENTRY - define this if sokol_app.h shouldn't "hijack" the main() function | |
# SOKOL_API_DECL - public function declaration prefix (default: extern) | |
# SOKOL_API_IMPL - public function implementation prefix (default: -) | |
# SOKOL_CALLOC - your own calloc function (default: calloc(n, s)) | |
# SOKOL_FREE - your own free function (default: free(p)) | |
# Optionally define the following to force debug checks and validations | |
# even in release mode: | |
# SOKOL_DEBUG - by default this is defined if _DEBUG is defined | |
# If sokol_app.h is compiled as a DLL, define the following before | |
# including the declaration or implementation: | |
# SOKOL_DLL | |
# On Windows, SOKOL_DLL will define SOKOL_API_DECL as __declspec(dllexport) | |
# or __declspec(dllimport) as needed. | |
# Portions of the Windows and Linux GL initialization and event code have been | |
# taken from GLFW (http:www.glfw.org/) | |
# iOS onscreen keyboard support 'inspired' by libgdx. | |
# If you use sokol_app.h together with sokol_gfx.h, include both headers | |
# in the implementation source file, and include sokol_app.h before | |
# sokol_gfx.h since sokol_app.h will also include the required 3D-API | |
# headers. | |
# On Windows, a minimal 'GL header' and function loader is integrated which | |
# contains just enough of GL for sokol_gfx.h. If you want to use your own | |
# GL header-generator/loader instead, define SOKOL_WIN32_NO_GL_LOADER | |
# before including the implementation part of sokol_app.h. | |
# For example code, see https:github.com/floooh/sokol-samples/tree/master/sapp | |
# FEATURE OVERVIEW | |
# ================ | |
# sokol_app.h provides a minimalistic cross-platform API which | |
# implements the 'application-wrapper' parts of a 3D application: | |
# - a common application entry function | |
# - creates a window and 3D-API context/device with a 'default framebuffer' | |
# - makes the rendered frame visible | |
# - provides keyboard-, mouse- and low-level touch-events | |
# - platforms: MacOS, iOS, HTML5, Win32, Linux, Android (TODO: RaspberryPi) | |
# - 3D-APIs: Metal, D3D11, GL3.2, GLES2, GLES3, WebGL, WebGL2 | |
# FEATURE/PLATFORM MATRIX | |
# ======================= | |
# | Windows | macOS | Linux | iOS | Android | Raspi | HTML5 | |
# --------------------+---------+-------+-------+-------+---------+-------+------- | |
# gl 3.x | YES | YES | YES | --- | --- | --- | --- | |
# gles2/webgl | --- | --- | --- | YES | YES | TODO | YES | |
# gles3/webgl2 | --- | --- | --- | YES | YES | --- | YES | |
# metal | --- | YES | --- | YES | --- | --- | --- | |
# d3d11 | YES | --- | --- | --- | --- | --- | --- | |
# KEY_DOWN | YES | YES | YES | SOME | TODO | TODO | YES | |
# KEY_UP | YES | YES | YES | SOME | TODO | TODO | YES | |
# CHAR | YES | YES | YES | YES | TODO | TODO | YES | |
# MOUSE_DOWN | YES | YES | YES | --- | --- | TODO | YES | |
# MOUSE_UP | YES | YES | YES | --- | --- | TODO | YES | |
# MOUSE_SCROLL | YES | YES | YES | --- | --- | TODO | YES | |
# MOUSE_MOVE | YES | YES | YES | --- | --- | TODO | YES | |
# MOUSE_ENTER | YES | YES | YES | --- | --- | TODO | YES | |
# MOUSE_LEAVE | YES | YES | YES | --- | --- | TODO | YES | |
# TOUCHES_BEGAN | --- | --- | --- | YES | YES | --- | YES | |
# TOUCHES_MOVED | --- | --- | --- | YES | YES | --- | YES | |
# TOUCHES_ENDED | --- | --- | --- | YES | YES | --- | YES | |
# TOUCHES_CANCELLED | --- | --- | --- | YES | YES | --- | YES | |
# RESIZED | YES | YES | YES | YES | YES | --- | YES | |
# ICONIFIED | YES | YES | YES | --- | --- | --- | --- | |
# RESTORED | YES | YES | YES | --- | --- | --- | --- | |
# SUSPENDED | --- | --- | --- | YES | YES | --- | TODO | |
# RESUMED | --- | --- | --- | YES | YES | --- | TODO | |
# QUIT_REQUESTED | YES | YES | YES | --- | --- | TODO | --- | |
# UPDATE_CURSOR | YES | YES | TODO | --- | --- | --- | TODO | |
# IME | TODO | TODO? | TODO | ??? | TODO | ??? | ??? | |
# key repeat flag | YES | YES | YES | --- | --- | TODO | YES | |
# windowed | YES | YES | YES | --- | --- | TODO | YES | |
# fullscreen | YES | YES | TODO | YES | YES | TODO | --- | |
# pointer lock | TODO | TODO | TODO | --- | --- | TODO | TODO | |
# screen keyboard | --- | --- | --- | YES | TODO | --- | YES | |
# swap interval | YES | YES | YES | YES | TODO | TODO | YES | |
# high-dpi | YES | YES | TODO | YES | YES | TODO | YES | |
# clipboard | YES | YES | TODO | --- | --- | --- | YES | |
# TODO | |
# ==== | |
# - Linux clipboard support | |
# - sapp_consume_event() on non-web platforms? | |
# STEP BY STEP | |
# ============ | |
# --- Add a sokol_main() function to your code which returns a sapp_desc structure | |
# with initialization parameters and callback function pointers. This | |
# function is called very early, usually at the start of the | |
# platform's entry function (e.g. main or WinMain). You should do as | |
# little as possible here, since the rest of your code might be called | |
# from another thread (this depends on the platform): | |
# sapp_desc sokol_main(int argc, char* argv[]) { | |
# return (sapp_desc) { | |
# .width = 640, | |
# .height = 480, | |
# .init_cb = my_init_func, | |
# .frame_cb = my_frame_func, | |
# .cleanup_cb = my_cleanup_func, | |
# .event_cb = my_event_func, | |
# ... | |
# }; | |
# } | |
# There are many more setup parameters, but these are the most important. | |
# For a complete list search for the sapp_desc structure declaration | |
# below. | |
# DO NOT call any sokol-app function from inside sokol_main(), since | |
# sokol-app will not be initialized at this point. | |
# The .width and .height parameters are the preferred size of the 3D | |
# rendering canvas. The actual size may differ from this depending on | |
# platform and other circumstances. Also the canvas size may change at | |
# any time (for instance when the user resizes the application window, | |
# or rotates the mobile device). | |
# All provided function callbacks will be called from the same thread, | |
# but this may be different from the thread where sokol_main() was called. | |
# .init_cb (void (*)(void)) | |
# This function is called once after the application window, | |
# 3D rendering context and swap chain have been created. The | |
# function takes no arguments and has no return value. | |
# .frame_cb (void (*)(void)) | |
# This is the per-frame callback, which is usually called 60 | |
# times per second. This is where your application would update | |
# most of its state and perform all rendering. | |
# .cleanup_cb (void (*)(void)) | |
# The cleanup callback is called once right before the application | |
# quits. | |
# .event_cb (void (*)(const sapp_event* event)) | |
# The event callback is mainly for input handling, but in the | |
# future may also be used to communicate other types of events | |
# to the application. Keep the event_cb struct member zero-initialized | |
# if your application doesn't require event handling. | |
# .fail_cb (void (*)(const char* msg)) | |
# The fail callback is called when a fatal error is encountered | |
# during start which doesn't allow the program to continue. | |
# Providing a callback here gives you a chance to show an error message | |
# to the user. The default behaviour is SOKOL_LOG(msg) | |
# As you can see, those 'standard callbacks' don't have a user_data | |
# argument, so any data that needs to be preserved between callbacks | |
# must live in global variables. If you're allergic to global variables | |
# or cannot use them for other reasons, an alternative set of callbacks | |
# can be defined in sapp_desc, together with a user_data pointer: | |
# .user_data (void*) | |
# The user-data argument for the callbacks below | |
# .init_userdata_cb (void (*)(void* user_data)) | |
# .frame_userdata_cb (void (*)(void* user_data)) | |
# .cleanup_userdata_cb (void (*)(void* user_data)) | |
# .event_cb (void(*)(const sapp_event* event, void* user_data)) | |
# .fail_cb (void(*)(const char* msg, void* user_data)) | |
# These are the user-data versions of the callback functions. You | |
# can mix those with the standard callbacks that don't have the | |
# user_data argument. | |
# The function sapp_userdata() can be used to query the user_data | |
# pointer provided in the sapp_desc struct. | |
# You can call sapp_query_desc() to get a copy of the | |
# original sapp_desc structure. | |
# NOTE that there's also an alternative compile mode where sokol_app.h | |
# doesn't "hijack" the main() function. Search below for SOKOL_NO_ENTRY. | |
# --- Implement the initialization callback function (init_cb), this is called | |
# once after the rendering surface, 3D API and swap chain have been | |
# initialized by sokol_app. All sokol-app functions can be called | |
# from inside the initialization callback, the most useful functions | |
# at this point are: | |
# int sapp_width(void) | |
# Returns the current width of the default framebuffer, this may change | |
# from one frame to the next. | |
# int sapp_height(void) | |
# Likewise, returns the current height of the default framebuffer. | |
# bool sapp_gles2(void) | |
# Returns true if a GLES2 or WebGL context has been created. This | |
# is useful when a GLES3/WebGL2 context was requested but is not | |
# available so that sokol_app.h had to fallback to GLES2/WebGL. | |
# const void* sapp_metal_get_device(void) | |
# const void* sapp_metal_get_renderpass_descriptor(void) | |
# const void* sapp_metal_get_drawable(void) | |
# If the Metal backend has been selected, these functions return pointers | |
# to various Metal API objects required for rendering, otherwise | |
# they return a null pointer. These void pointers are actually | |
# Objective-C ids converted with an ARC __bridge cast so that | |
# they ids can be tunnel through C code. Also note that the returned | |
# pointers to the renderpass-descriptor and drawable may change from one | |
# frame to the next, only the Metal device object is guaranteed to | |
# stay the same. | |
# const void* sapp_macos_get_window(void) | |
# On macOS, get the NSWindow object pointer, otherwise a null pointer. | |
# Before being used as Objective-C object, the void* must be converted | |
# back with an ARC __bridge cast. | |
# const void* sapp_ios_get_window(void) | |
# On iOS, get the UIWindow object pointer, otherwise a null pointer. | |
# Before being used as Objective-C object, the void* must be converted | |
# back with an ARC __bridge cast. | |
# const void* sapp_win32_get_hwnd(void) | |
# On Windows, get the window's HWND, otherwise a null pointer. The | |
# HWND has been cast to a void pointer in order to be tunneled | |
# through code which doesn't include Windows.h. | |
# const void* sapp_d3d11_get_device(void); | |
# const void* sapp_d3d11_get_device_context(void); | |
# const void* sapp_d3d11_get_render_target_view(void); | |
# const void* sapp_d3d11_get_depth_stencil_view(void); | |
# Similar to the sapp_metal_* functions, the sapp_d3d11_* functions | |
# return pointers to D3D11 API objects required for rendering, | |
# only if the D3D11 backend has been selected. Otherwise they | |
# return a null pointer. Note that the returned pointers to the | |
# render-target-view and depth-stencil-view may change from one | |
# frame to the next! | |
# const void* sapp_android_get_native_activity(void); | |
# On Android, get the native activity ANativeActivity pointer, otherwise | |
# a null pointer. | |
# --- Implement the frame-callback function, this function will be called | |
# on the same thread as the init callback, but might be on a different | |
# thread than the sokol_main() function. Note that the size of | |
# the rendering framebuffer might have changed since the frame callback | |
# was called last. Call the functions sapp_width() and sapp_height() | |
# each frame to get the current size. | |
# --- Optionally implement the event-callback to handle input events. | |
# sokol-app provides the following type of input events: | |
# - a 'virtual key' was pressed down or released | |
# - a single text character was entered (provided as UTF-32 code point) | |
# - a mouse button was pressed down or released (left, right, middle) | |
# - mouse-wheel or 2D scrolling events | |
# - the mouse was moved | |
# - the mouse has entered or left the application window boundaries | |
# - low-level, portable multi-touch events (began, moved, ended, cancelled) | |
# - the application window was resized, iconified or restored | |
# - the application was suspended or restored (on mobile platforms) | |
# - the user or application code has asked to quit the application | |
# - a string was pasted to the system clipboard | |
# To explicitly 'consume' an event and prevent that the event is | |
# forwarded for further handling to the operating system, call | |
# sapp_consume_event() from inside the event handler (NOTE that | |
# this behaviour is currently only implemented for some HTML5 | |
# events, support for other platforms and event types will | |
# be added as needed, please open a github ticket and/or provide | |
# a PR if needed). | |
# NOTE: Do *not* call any 3D API functions in the event callback | |
# function, since the 3D API context may not be active when the | |
# event callback is called (it may work on some platforms and | |
# 3D APIs, but not others, and the exact behaviour may change | |
# between sokol-app versions). | |
# --- Implement the cleanup-callback function, this is called once | |
# after the user quits the application (see the section | |
# "APPLICATION QUIT" for detailed information on quitting | |
# behaviour, and how to intercept a pending quit (for instance to show a | |
# "Really Quit?" dialog box). Note that the cleanup-callback isn't | |
# called on the web and mobile platforms. | |
# CLIPBOARD SUPPORT | |
# ================= | |
# Applications can send and receive UTF-8 encoded text data from and to the | |
# system clipboard. By default, clipboard support is disabled and | |
# must be enabled at startup via the following sapp_desc struct | |
# members: | |
# sapp_desc.enable_clipboard - set to true to enable clipboard support | |
# sapp_desc.clipboard_size - size of the internal clipboard buffer in bytes | |
# Enabling the clipboard will dynamically allocate a clipboard buffer | |
# for UTF-8 encoded text data of the requested size in bytes, the default | |
# size if 8 KBytes. Strings that don't fit into the clipboard buffer | |
# (including the terminating zero) will be silently clipped, so it's | |
# important that you provide a big enough clipboard size for your | |
# use case. | |
# To send data to the clipboard, call sapp_set_clipboard_string() with | |
# a pointer to an UTF-8 encoded, null-terminated C-string. | |
# NOTE that on the HTML5 platform, sapp_set_clipboard_string() must be | |
# called from inside a 'short-lived event handler', and there are a few | |
# other HTML5-specific caveats to workaround. You'll basically have to | |
# tinker until it works in all browsers :/ (maybe the situation will | |
# improve when all browsers agree on and implement the new | |
# HTML5 navigator.clipboard API). | |
# To get data from the clipboard, check for the SAPP_EVENTTYPE_CLIPBOARD_PASTED | |
# event in your event handler function, and then call sapp_get_clipboard_string() | |
# to obtain the updated UTF-8 encoded text. | |
# NOTE that behaviour of sapp_get_clipboard_string() is slightly different | |
# depending on platform: | |
# - on the HTML5 platform, the internal clipboard buffer will only be updated | |
# right before the SAPP_EVENTTYPE_CLIPBOARD_PASTED event is sent, | |
# and sapp_get_clipboard_string() will simply return the current content | |
# of the clipboard buffer | |
# - on 'native' platforms, the call to sapp_get_clipboard_string() will | |
# update the internal clipboard buffer with the most recent data | |
# from the system clipboard | |
# Portable code should check for the SAPP_EVENTTYPE_CLIPBOARD_PASTED event, | |
# and then call sapp_get_clipboard_string() right in the event handler. | |
# The SAPP_EVENTTYPE_CLIPBOARD_PASTED event will be generated by sokol-app | |
# as follows: | |
# - on macOS: when the Cmd+V key is pressed down | |
# - on HTML5: when the browser sends a 'paste' event to the global 'window' object | |
# - on all other platforms: when the Ctrl+V key is pressed down | |
# HIGH-DPI RENDERING | |
# ================== | |
# You can set the sapp_desc.high_dpi flag during initialization to request | |
# a full-resolution framebuffer on HighDPI displays. The default behaviour | |
# is sapp_desc.high_dpi=false, this means that the application will | |
# render to a lower-resolution framebuffer on HighDPI displays and the | |
# rendered content will be upscaled by the window system composer. | |
# In a HighDPI scenario, you still request the same window size during | |
# sokol_main(), but the framebuffer sizes returned by sapp_width() | |
# and sapp_height() will be scaled up according to the DPI scaling | |
# ratio. You can also get a DPI scaling factor with the function | |
# sapp_dpi_scale(). | |
# Here's an example on a Mac with Retina display: | |
# sapp_desc sokol_main() { | |
# return (sapp_desc) { | |
# .width = 640, | |
# .height = 480, | |
# .high_dpi = true, | |
# ... | |
# }; | |
# } | |
# The functions sapp_width(), sapp_height() and sapp_dpi_scale() will | |
# return the following values: | |
# sapp_width -> 1280 | |
# sapp_height -> 960 | |
# sapp_dpi_scale -> 2.0 | |
# If the high_dpi flag is false, or you're not running on a Retina display, | |
# the values would be: | |
# sapp_width -> 640 | |
# sapp_height -> 480 | |
# sapp_dpi_scale -> 1.0 | |
# APPLICATION QUIT | |
# ================ | |
# Without special quit handling, a sokol_app.h application will exist | |
# 'gracefully' when the user clicks the window close-button. 'Graceful | |
# exit' means that the application-provided cleanup callback will be | |
# called. | |
# This 'graceful exit' is only supported on native desktop platforms, on | |
# the web and mobile platforms an application may be terminated at any time | |
# by the user or browser/OS runtime environment without a chance to run | |
# custom shutdown code. | |
# On the web platform, you can call the following function to let the | |
# browser open a standard popup dialog before the user wants to leave a site: | |
# sapp_html5_ask_leave_site(bool ask); | |
# The initial state of the associated internal flag can be provided | |
# at startup via sapp_desc.html5_ask_leave_site. | |
# This feature should only be used sparingly in critical situations - for | |
# instance when the user would loose data - since popping up modal dialog | |
# boxes is considered quite rude in the web world. Note that there's no way | |
# to customize the content of this dialog box or run any code as a result | |
# of the user's decision. Also note that the user must have interacted with | |
# the site before the dialog box will appear. These are all security measures | |
# to prevent fishing. | |
# On native desktop platforms, sokol_app.h provides more control over the | |
# application-quit-process. It's possible to initiate a 'programmatic quit' | |
# from the application code, and a quit initiated by the application user | |
# can be intercepted (for instance to show a custom dialog box). | |
# This 'programmatic quit protocol' is implemented trough 3 functions | |
# and 1 event: | |
# - sapp_quit(): This function simply quits the application without | |
# giving the user a chance to intervene. Usually this might | |
# be called when the user clicks the 'Ok' button in a 'Really Quit?' | |
# dialog box | |
# - sapp_request_quit(): Calling sapp_request_quit() will send the | |
# event SAPP_EVENTTYPE_QUIT_REQUESTED to the applications event handler | |
# callback, giving the user code a chance to intervene and cancel the | |
# pending quit process (for instance to show a 'Really Quit?' dialog | |
# box). If the event handler callback does nothing, the application | |
# will be quit as usual. To prevent this, call the function | |
# sapp_cancel_quit() from inside the event handler. | |
# - sapp_cancel_quit(): Cancels a pending quit request, either initiated | |
# by the user clicking the window close button, or programmatically | |
# by calling sapp_request_quit(). The only place where calling this | |
# function makes sense is from inside the event handler callback when | |
# the SAPP_EVENTTYPE_QUIT_REQUESTED event has been received. | |
# - SAPP_EVENTTYPE_QUIT_REQUESTED: this event is sent when the user | |
# clicks the window's close button or application code calls the | |
# sapp_request_quit() function. The event handler callback code can handle | |
# this event by calling sapp_cancel_quit() to cancel the quit. | |
# If the event is ignored, the application will quit as usual. | |
# The Dear ImGui HighDPI sample contains example code of how to | |
# implement a 'Really Quit?' dialog box with Dear ImGui (native desktop | |
# platforms only), and for showing the hardwired "Leave Site?" dialog box | |
# when running on the web platform: | |
# https:floooh.github.io/sokol-html5/wasm/imgui-highdpi-sapp.html | |
# FULLSCREEN | |
# ========== | |
# If the sapp_desc.fullscreen flag is true, sokol-app will try to create | |
# a fullscreen window on platforms with a 'proper' window system | |
# (mobile devices will always use fullscreen). The implementation details | |
# depend on the target platform, in general sokol-app will use a | |
# 'soft approach' which doesn't interfere too much with the platform's | |
# window system (for instance borderless fullscreen window instead of | |
# a 'real' fullscreen mode). Such details might change over time | |
# as sokol-app is adapted for different needs. | |
# The most important effect of fullscreen mode to keep in mind is that | |
# the requested canvas width and height will be ignored for the initial | |
# window size, calling sapp_width() and sapp_height() will instead return | |
# the resolution of the fullscreen canvas (however the provided size | |
# might still be used for the non-fullscreen window, in case the user can | |
# switch back from fullscreen- to windowed-mode). | |
# ONSCREEN KEYBOARD | |
# ================= | |
# On some platforms which don't provide a physical keyboard, sokol-app | |
# can display the platform's integrated onscreen keyboard for text | |
# input. To request that the onscreen keyboard is shown, call | |
# sapp_show_keyboard(true); | |
# Likewise, to hide the keyboard call: | |
# sapp_show_keyboard(false); | |
# Note that on the web platform, the keyboard can only be shown from | |
# inside an input handler. On such platforms, sapp_show_keyboard() | |
# will only work as expected when it is called from inside the | |
# sokol-app event callback function. When called from other places, | |
# an internal flag will be set, and the onscreen keyboard will be | |
# called at the next 'legal' opportunity (when the next input event | |
# is handled). | |
# OPTIONAL: DON'T HIJACK main() (#define SOKOL_NO_ENTRY) | |
# ====================================================== | |
# In its default configuration, sokol_app.h "hijacks" the platform's | |
# standard main() function. This was done because different platforms | |
# have different main functions which are not compatible with | |
# C's main() (for instance WinMain on Windows has completely different | |
# arguments). However, this "main hijacking" posed a problem for | |
# usage scenarios like integrating sokol_app.h with other languages than | |
# C or C++, so an alternative SOKOL_NO_ENTRY mode has been added | |
# in which the user code provides the platform's main function: | |
# - define SOKOL_NO_ENTRY before including the sokol_app.h implementation | |
# - do *not* provide a sokol_main() function | |
# - instead provide the standard main() function of the platform | |
# - from the main function, call the function ```sapp_run()``` which | |
# takes a pointer to an ```sapp_desc``` structure. | |
# - ```sapp_run()``` takes over control and calls the provided init-, frame-, | |
# shutdown- and event-callbacks just like in the default model, it | |
# will only return when the application quits (or not at all on some | |
# platforms, like emscripten) | |
# NOTE: SOKOL_NO_ENTRY is currently not supported on Android. | |
# TEMP NOTE DUMP | |
# ============== | |
# - onscreen keyboard support on Android requires Java :(, should we even bother? | |
# - sapp_desc needs a bool whether to initialize depth-stencil surface | |
# - GL context initialization needs more control (at least what GL version to initialize) | |
# - application icon | |
# - mouse pointer visibility(?) | |
# - the UPDATE_CURSOR event currently behaves differently between Win32 and OSX | |
# (Win32 sends the event each frame when the mouse moves and is inside the window | |
# client area, OSX sends it only once when the mouse enters the client area) | |
# - the Android implementation calls cleanup_cb() and destroys the egl context in onDestroy | |
# at the latest but should do it earlier, in onStop, as an app is "killable" after onStop | |
# on Android Honeycomb and later (it can't be done at the moment as the app may be started | |
# again after onStop and the sokol lifecycle does not yet handle context teardown/bringup) | |
# FIXME: ERROR HANDLING (this will need an error callback function) | |
# zlib/libpng license | |
# Copyright (c) 2018 Andre Weissflog | |
# This software is provided 'as-is', without any express or implied warranty. | |
# In no event will the authors be held liable for any damages arising from the | |
# use of this software. | |
# Permission is granted to anyone to use this software for any purpose, | |
# including commercial applications, and to alter it and redistribute it | |
# freely, subject to the following restrictions: | |
# 1. The origin of this software must not be misrepresented; you must not | |
# claim that you wrote the original software. If you use this software in a | |
# product, an acknowledgment in the product documentation would be | |
# appreciated but is not required. | |
# 2. Altered source versions must be plainly marked as such, and must not | |
# be misrepresented as being the original software. | |
# 3. This notice may not be removed or altered from any source | |
# distribution. | |
# | |
defineEnum(Enum_sokol_apph1) | |
defineEnum(sapp_event_type) | |
# key codes are the same names and values as GLFW | |
defineEnum(sapp_keycode) | |
defineEnum(sapp_mousebutton) | |
defineEnum(Enum_sokol_apph2) | |
const | |
SAPP_MAX_TOUCHPOINTS* = (8).Enum_sokol_apph1 | |
SAPP_MAX_MOUSEBUTTONS* = (3).Enum_sokol_apph1 | |
SAPP_MAX_KEYCODES* = (512).Enum_sokol_apph1 | |
SAPP_EVENTTYPE_INVALID* = 0.sapp_event_type | |
SAPP_EVENTTYPE_KEY_DOWN* = 1.sapp_event_type | |
SAPP_EVENTTYPE_KEY_UP* = 2.sapp_event_type | |
SAPP_EVENTTYPE_CHAR* = 3.sapp_event_type | |
SAPP_EVENTTYPE_MOUSE_DOWN* = 4.sapp_event_type | |
SAPP_EVENTTYPE_MOUSE_UP* = 5.sapp_event_type | |
SAPP_EVENTTYPE_MOUSE_SCROLL* = 6.sapp_event_type | |
SAPP_EVENTTYPE_MOUSE_MOVE* = 7.sapp_event_type | |
SAPP_EVENTTYPE_MOUSE_ENTER* = 8.sapp_event_type | |
SAPP_EVENTTYPE_MOUSE_LEAVE* = 9.sapp_event_type | |
SAPP_EVENTTYPE_TOUCHES_BEGAN* = 10.sapp_event_type | |
SAPP_EVENTTYPE_TOUCHES_MOVED* = 11.sapp_event_type | |
SAPP_EVENTTYPE_TOUCHES_ENDED* = 12.sapp_event_type | |
SAPP_EVENTTYPE_TOUCHES_CANCELLED* = 13.sapp_event_type | |
SAPP_EVENTTYPE_RESIZED* = 14.sapp_event_type | |
SAPP_EVENTTYPE_ICONIFIED* = 15.sapp_event_type | |
SAPP_EVENTTYPE_RESTORED* = 16.sapp_event_type | |
SAPP_EVENTTYPE_SUSPENDED* = 17.sapp_event_type | |
SAPP_EVENTTYPE_RESUMED* = 18.sapp_event_type | |
SAPP_EVENTTYPE_UPDATE_CURSOR* = 19.sapp_event_type | |
SAPP_EVENTTYPE_QUIT_REQUESTED* = 20.sapp_event_type | |
SAPP_EVENTTYPE_CLIPBOARD_PASTED* = 21.sapp_event_type | |
SAPP_EVENTTYPE_NUM* = 22.sapp_event_type | |
SAPP_EVENTTYPE_FORCE_U32* = (0x7FFFFFFF).sapp_event_type | |
SAPP_KEYCODE_INVALID* = (0).sapp_keycode | |
SAPP_KEYCODE_SPACE* = (32).sapp_keycode | |
SAPP_KEYCODE_APOSTROPHE* = (39).sapp_keycode | |
SAPP_KEYCODE_COMMA* = (44).sapp_keycode | |
SAPP_KEYCODE_MINUS* = (45).sapp_keycode | |
SAPP_KEYCODE_PERIOD* = (46).sapp_keycode | |
SAPP_KEYCODE_SLASH* = (47).sapp_keycode | |
SAPP_KEYCODE_0* = (48).sapp_keycode | |
SAPP_KEYCODE_1* = (49).sapp_keycode | |
SAPP_KEYCODE_2* = (50).sapp_keycode | |
SAPP_KEYCODE_3* = (51).sapp_keycode | |
SAPP_KEYCODE_4* = (52).sapp_keycode | |
SAPP_KEYCODE_5* = (53).sapp_keycode | |
SAPP_KEYCODE_6* = (54).sapp_keycode | |
SAPP_KEYCODE_7* = (55).sapp_keycode | |
SAPP_KEYCODE_8* = (56).sapp_keycode | |
SAPP_KEYCODE_9* = (57).sapp_keycode | |
SAPP_KEYCODE_SEMICOLON* = (59).sapp_keycode | |
SAPP_KEYCODE_EQUAL* = (61).sapp_keycode | |
SAPP_KEYCODE_A* = (65).sapp_keycode | |
SAPP_KEYCODE_B* = (66).sapp_keycode | |
SAPP_KEYCODE_C* = (67).sapp_keycode | |
SAPP_KEYCODE_D* = (68).sapp_keycode | |
SAPP_KEYCODE_E* = (69).sapp_keycode | |
SAPP_KEYCODE_F* = (70).sapp_keycode | |
SAPP_KEYCODE_G* = (71).sapp_keycode | |
SAPP_KEYCODE_H* = (72).sapp_keycode | |
SAPP_KEYCODE_I* = (73).sapp_keycode | |
SAPP_KEYCODE_J* = (74).sapp_keycode | |
SAPP_KEYCODE_K* = (75).sapp_keycode | |
SAPP_KEYCODE_L* = (76).sapp_keycode | |
SAPP_KEYCODE_M* = (77).sapp_keycode | |
SAPP_KEYCODE_N* = (78).sapp_keycode | |
SAPP_KEYCODE_O* = (79).sapp_keycode | |
SAPP_KEYCODE_P* = (80).sapp_keycode | |
SAPP_KEYCODE_Q* = (81).sapp_keycode | |
SAPP_KEYCODE_R* = (82).sapp_keycode | |
SAPP_KEYCODE_S* = (83).sapp_keycode | |
SAPP_KEYCODE_T* = (84).sapp_keycode | |
SAPP_KEYCODE_U* = (85).sapp_keycode | |
SAPP_KEYCODE_V* = (86).sapp_keycode | |
SAPP_KEYCODE_W* = (87).sapp_keycode | |
SAPP_KEYCODE_X* = (88).sapp_keycode | |
SAPP_KEYCODE_Y* = (89).sapp_keycode | |
SAPP_KEYCODE_Z* = (90).sapp_keycode | |
SAPP_KEYCODE_LEFT_BRACKET* = (91).sapp_keycode | |
SAPP_KEYCODE_BACKSLASH* = (92).sapp_keycode | |
SAPP_KEYCODE_RIGHT_BRACKET* = (93).sapp_keycode | |
SAPP_KEYCODE_GRAVE_ACCENT* = (96).sapp_keycode | |
SAPP_KEYCODE_WORLD_1* = (161).sapp_keycode | |
SAPP_KEYCODE_WORLD_2* = (162).sapp_keycode | |
SAPP_KEYCODE_ESCAPE* = (256).sapp_keycode | |
SAPP_KEYCODE_ENTER* = (257).sapp_keycode | |
SAPP_KEYCODE_TAB* = (258).sapp_keycode | |
SAPP_KEYCODE_BACKSPACE* = (259).sapp_keycode | |
SAPP_KEYCODE_INSERT* = (260).sapp_keycode | |
SAPP_KEYCODE_DELETE* = (261).sapp_keycode | |
SAPP_KEYCODE_RIGHT* = (262).sapp_keycode | |
SAPP_KEYCODE_LEFT* = (263).sapp_keycode | |
SAPP_KEYCODE_DOWN* = (264).sapp_keycode | |
SAPP_KEYCODE_UP* = (265).sapp_keycode | |
SAPP_KEYCODE_PAGE_UP* = (266).sapp_keycode | |
SAPP_KEYCODE_PAGE_DOWN* = (267).sapp_keycode | |
SAPP_KEYCODE_HOME* = (268).sapp_keycode | |
SAPP_KEYCODE_END* = (269).sapp_keycode | |
SAPP_KEYCODE_CAPS_LOCK* = (280).sapp_keycode | |
SAPP_KEYCODE_SCROLL_LOCK* = (281).sapp_keycode | |
SAPP_KEYCODE_NUM_LOCK* = (282).sapp_keycode | |
SAPP_KEYCODE_PRINT_SCREEN* = (283).sapp_keycode | |
SAPP_KEYCODE_PAUSE* = (284).sapp_keycode | |
SAPP_KEYCODE_F1* = (290).sapp_keycode | |
SAPP_KEYCODE_F2* = (291).sapp_keycode | |
SAPP_KEYCODE_F3* = (292).sapp_keycode | |
SAPP_KEYCODE_F4* = (293).sapp_keycode | |
SAPP_KEYCODE_F5* = (294).sapp_keycode | |
SAPP_KEYCODE_F6* = (295).sapp_keycode | |
SAPP_KEYCODE_F7* = (296).sapp_keycode | |
SAPP_KEYCODE_F8* = (297).sapp_keycode | |
SAPP_KEYCODE_F9* = (298).sapp_keycode | |
SAPP_KEYCODE_F10* = (299).sapp_keycode | |
SAPP_KEYCODE_F11* = (300).sapp_keycode | |
SAPP_KEYCODE_F12* = (301).sapp_keycode | |
SAPP_KEYCODE_F13* = (302).sapp_keycode | |
SAPP_KEYCODE_F14* = (303).sapp_keycode | |
SAPP_KEYCODE_F15* = (304).sapp_keycode | |
SAPP_KEYCODE_F16* = (305).sapp_keycode | |
SAPP_KEYCODE_F17* = (306).sapp_keycode | |
SAPP_KEYCODE_F18* = (307).sapp_keycode | |
SAPP_KEYCODE_F19* = (308).sapp_keycode | |
SAPP_KEYCODE_F20* = (309).sapp_keycode | |
SAPP_KEYCODE_F21* = (310).sapp_keycode | |
SAPP_KEYCODE_F22* = (311).sapp_keycode | |
SAPP_KEYCODE_F23* = (312).sapp_keycode | |
SAPP_KEYCODE_F24* = (313).sapp_keycode | |
SAPP_KEYCODE_F25* = (314).sapp_keycode | |
SAPP_KEYCODE_KP_0* = (320).sapp_keycode | |
SAPP_KEYCODE_KP_1* = (321).sapp_keycode | |
SAPP_KEYCODE_KP_2* = (322).sapp_keycode | |
SAPP_KEYCODE_KP_3* = (323).sapp_keycode | |
SAPP_KEYCODE_KP_4* = (324).sapp_keycode | |
SAPP_KEYCODE_KP_5* = (325).sapp_keycode | |
SAPP_KEYCODE_KP_6* = (326).sapp_keycode | |
SAPP_KEYCODE_KP_7* = (327).sapp_keycode | |
SAPP_KEYCODE_KP_8* = (328).sapp_keycode | |
SAPP_KEYCODE_KP_9* = (329).sapp_keycode | |
SAPP_KEYCODE_KP_DECIMAL* = (330).sapp_keycode | |
SAPP_KEYCODE_KP_DIVIDE* = (331).sapp_keycode | |
SAPP_KEYCODE_KP_MULTIPLY* = (332).sapp_keycode | |
SAPP_KEYCODE_KP_SUBTRACT* = (333).sapp_keycode | |
SAPP_KEYCODE_KP_ADD* = (334).sapp_keycode | |
SAPP_KEYCODE_KP_ENTER* = (335).sapp_keycode | |
SAPP_KEYCODE_KP_EQUAL* = (336).sapp_keycode | |
SAPP_KEYCODE_LEFT_SHIFT* = (340).sapp_keycode | |
SAPP_KEYCODE_LEFT_CONTROL* = (341).sapp_keycode | |
SAPP_KEYCODE_LEFT_ALT* = (342).sapp_keycode | |
SAPP_KEYCODE_LEFT_SUPER* = (343).sapp_keycode | |
SAPP_KEYCODE_RIGHT_SHIFT* = (344).sapp_keycode | |
SAPP_KEYCODE_RIGHT_CONTROL* = (345).sapp_keycode | |
SAPP_KEYCODE_RIGHT_ALT* = (346).sapp_keycode | |
SAPP_KEYCODE_RIGHT_SUPER* = (347).sapp_keycode | |
SAPP_KEYCODE_MENU* = (348).sapp_keycode | |
SAPP_MOUSEBUTTON_INVALID* = (-1).sapp_mousebutton | |
SAPP_MOUSEBUTTON_LEFT* = (0).sapp_mousebutton | |
SAPP_MOUSEBUTTON_RIGHT* = (1).sapp_mousebutton | |
SAPP_MOUSEBUTTON_MIDDLE* = (2).sapp_mousebutton | |
SAPP_MODIFIER_SHIFT* = ((1 shl 0)).Enum_sokol_apph2 | |
SAPP_MODIFIER_CTRL* = ((1 shl 1)).Enum_sokol_apph2 | |
SAPP_MODIFIER_ALT* = ((1 shl 2)).Enum_sokol_apph2 | |
SAPP_MODIFIER_SUPER* = ((1 shl 3)).Enum_sokol_apph2 | |
{.pragma: impsokol_app, importc.} | |
{.pragma: impsokol_appC, impsokol_app, cdecl.} | |
type | |
sapp_touchpoint* {.bycopy.} = object | |
identifier*: ptr uint | |
pos_x*: cfloat | |
pos_y*: cfloat | |
changed*: bool | |
sapp_event* {.bycopy.} = object | |
frame_count*: uint64 | |
`type`*: sapp_event_type | |
key_code*: sapp_keycode | |
char_code*: uint32 | |
key_repeat*: bool | |
modifiers*: uint32 | |
mouse_button*: sapp_mousebutton | |
mouse_x*: cfloat | |
mouse_y*: cfloat | |
scroll_x*: cfloat | |
scroll_y*: cfloat | |
num_touches*: cint | |
touches*: array[SAPP_MAX_TOUCHPOINTS, sapp_touchpoint] | |
window_width*: cint | |
window_height*: cint | |
framebuffer_width*: cint | |
framebuffer_height*: cint | |
sapp_desc* {.bycopy.} = object | |
init_cb*: proc() {.cdecl.} | |
frame_cb*: proc() {.cdecl.} | |
cleanup_cb*: proc() {.cdecl.} | |
event_cb*: proc(a1: ptr sapp_event) {.cdecl.} | |
fail_cb*: proc(a1: cstring) {.cdecl.} | |
user_data*: pointer | |
init_userdata_cb*: proc(a1: pointer) {.cdecl.} | |
frame_userdata_cb*: proc(a1: pointer) {.cdecl.} | |
cleanup_userdata_cb*: proc(a1: pointer) {.cdecl.} | |
event_userdata_cb*: proc(a1: ptr sapp_event, a2: pointer) {.cdecl.} | |
fail_userdata_cb*: proc(a1: cstring, a2: pointer) {.cdecl.} | |
width*: cint | |
height*: cint | |
sample_count*: cint | |
swap_interval*: cint | |
high_dpi*: bool | |
fullscreen*: bool | |
alpha*: bool | |
window_title*: cstring | |
user_cursor*: bool | |
enable_clipboard*: bool | |
clipboard_size*: cint | |
html5_canvas_name*: cstring | |
html5_canvas_resize*: bool | |
html5_preserve_drawing_buffer*: bool | |
html5_premultiplied_alpha*: bool | |
html5_ask_leave_site*: bool | |
ios_keyboard_resizes_canvas*: bool | |
gl_force_gles2*: bool | |
# user-provided functions | |
# Declaration 'sokol_main' skipped | |
# Declaration 'argc' skipped | |
# Declaration 'sokol_main' skipped | |
# Declaration 'argc' skipped | |
# Declaration 'argv' skipped | |
# returns true after sokol-app has been initialized | |
proc sapp_isvalid*(): bool {.impsokol_appC.} | |
# returns the current framebuffer width in pixels | |
proc sapp_width*(): cint {.impsokol_appC.} | |
# returns the current framebuffer height in pixels | |
proc sapp_height*(): cint {.impsokol_appC.} | |
# returns true when high_dpi was requested and actually running in a high-dpi scenario | |
proc sapp_high_dpi*(): bool {.impsokol_appC.} | |
# returns the dpi scaling factor (window pixels to framebuffer pixels) | |
proc sapp_dpi_scale*(): cfloat {.impsokol_appC.} | |
# show or hide the mobile device onscreen keyboard | |
proc sapp_show_keyboard*(visible: bool) {.impsokol_appC.} | |
# return true if the mobile device onscreen keyboard is currently shown | |
proc sapp_keyboard_shown*(): bool {.impsokol_appC.} | |
# show or hide the mouse cursor | |
proc sapp_show_mouse*(visible: bool) {.impsokol_appC.} | |
# show or hide the mouse cursor | |
proc sapp_mouse_shown*(): bool {.impsokol_appC.} | |
# return the userdata pointer optionally provided in sapp_desc | |
proc sapp_userdata*(): pointer {.impsokol_appC.} | |
# return a copy of the sapp_desc structure | |
proc sapp_query_desc*(): sapp_desc {.impsokol_appC.} | |
# initiate a "soft quit" (sends SAPP_EVENTTYPE_QUIT_REQUESTED) | |
proc sapp_request_quit*() {.impsokol_appC.} | |
# cancel a pending quit (when SAPP_EVENTTYPE_QUIT_REQUESTED has been received) | |
proc sapp_cancel_quit*() {.impsokol_appC.} | |
# initiate a "hard quit" (quit application without sending SAPP_EVENTTYPE_QUIT_REQUSTED) | |
proc sapp_quit*() {.impsokol_appC.} | |
# call from inside event callback to consume the current event (don't forward to platform) | |
proc sapp_consume_event*() {.impsokol_appC.} | |
# get the current frame counter (for comparison with sapp_event.frame_count) | |
proc sapp_frame_count*(): uint64 {.impsokol_appC.} | |
# write string into clipboard | |
proc sapp_set_clipboard_string*(str: cstring) {.impsokol_appC.} | |
# read string from clipboard (usually during SAPP_EVENTTYPE_CLIPBOARD_PASTED) | |
proc sapp_get_clipboard_string*(): cstring {.impsokol_appC.} | |
# special run-function for SOKOL_NO_ENTRY (in standard mode this is an empty stub) | |
proc sapp_run*(desc: ptr sapp_desc): cint {.impsokol_appC.} | |
# GL: return true when GLES2 fallback is active (to detect fallback from GLES3) | |
proc sapp_gles2*(): bool {.impsokol_appC.} | |
# HTML5: enable or disable the hardwired "Leave Site?" dialog box | |
proc sapp_html5_ask_leave_site*(ask: bool) {.impsokol_appC.} | |
# Metal: get ARC-bridged pointer to Metal device object | |
proc sapp_metal_get_device*(): pointer {.impsokol_appC.} | |
# Metal: get ARC-bridged pointer to this frame's renderpass descriptor | |
proc sapp_metal_get_renderpass_descriptor*(): pointer {.impsokol_appC.} | |
# Metal: get ARC-bridged pointer to current drawable | |
proc sapp_metal_get_drawable*(): pointer {.impsokol_appC.} | |
# macOS: get ARC-bridged pointer to macOS NSWindow | |
proc sapp_macos_get_window*(): pointer {.impsokol_appC.} | |
# iOS: get ARC-bridged pointer to iOS UIWindow | |
proc sapp_ios_get_window*(): pointer {.impsokol_appC.} | |
# D3D11: get pointer to ID3D11Device object | |
proc sapp_d3d11_get_device*(): pointer {.impsokol_appC.} | |
# D3D11: get pointer to ID3D11DeviceContext object | |
proc sapp_d3d11_get_device_context*(): pointer {.impsokol_appC.} | |
# D3D11: get pointer to ID3D11RenderTargetView object | |
proc sapp_d3d11_get_render_target_view*(): pointer {.impsokol_appC.} | |
# D3D11: get pointer to ID3D11DepthStencilView | |
proc sapp_d3d11_get_depth_stencil_view*(): pointer {.impsokol_appC.} | |
# Win32: get the HWND window handle | |
proc sapp_win32_get_hwnd*(): pointer {.impsokol_appC.} | |
# Android: get native activity handle | |
proc sapp_android_get_native_activity*(): pointer {.impsokol_appC.} | |
{.compile: "/Users/zacharycarter/dev/junkers/lib/sokol.m".} | |
CC: sokol | |
CC: stdlib_assertions.nim | |
CC: stdlib_system.nim | |
CC: stdlib_hashes.nim | |
CC: stdlib_math.nim | |
CC: stdlib_posix.nim | |
CC: stdlib_times.nim | |
CC: stdlib_os.nim | |
CC: stdlib_sets.nim | |
CC: stdlib_tables.nim | |
CC: ../../../.nimble/pkgs/nimterop-#head/nimterop/plugin.nim | |
CC: stdlib_cpuinfo.nim | |
CC: sokol.nim |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Overriding INNER_C_UNION_c2nim_5 sg_attachment_desc sg_image_content INNER_C_UNION_c2nim_8 sg_image_desc | |
# Importing /Users/zacharycarter/dev/junkers/lib/sokol/sokol_gfx.h | |
# Generated at 2020-04-07T22:54:24-05:00 | |
# Command line: | |
# /Users/zacharycarter/.nimble/pkgs/nimterop-0.4.4/nimterop/toast --preprocess --pnim --symOverride=INNER_C_UNION_c2nim_5,sg_attachment_desc,sg_image_content,INNER_C_UNION_c2nim_8,sg_image_desc --nim:/Users/zacharycarter/.choosenim/toolchains/nim-#devel/bin/nim --pluginSourcePath=/Users/zacharycarter/.cache/nim/nimterop/cPlugins/nimterop_1344102793.nim /Users/zacharycarter/dev/junkers/lib/sokol/sokol_gfx.h | |
{.hint[ConvFromXtoItselfNotNeeded]: off.} | |
import nimterop/types | |
# | |
# various compile-time constants | |
# FIXME: it may make sense to convert some of those into defines so | |
# that the user code can override them. | |
# | |
defineEnum(Enum_sokol_gfxh1) | |
# | |
# sg_backend | |
# The active 3D-API backend, use the function sg_query_backend() | |
# to get the currently active backend. | |
# For returned value corresponds with the compile-time define to select | |
# a backend, with the only exception of SOKOL_GLES3: this may | |
# return SG_BACKEND_GLES2 if the backend has to fallback to GLES2 mode | |
# because GLES3 isn't supported. | |
# | |
defineEnum(sg_backend) | |
# | |
# sg_pixel_format | |
# sokol_gfx.h basically uses the same pixel formats as WebGPU, since these | |
# are supported on most newer GPUs. GLES2 and WebGL has a much smaller | |
# subset of available pixel formats. Call sg_query_pixelformat() to check | |
# at runtime if a pixel format supports the desired features. | |
# A pixelformat name consist of three parts: | |
# - components (R, RG, RGB or RGBA) | |
# - bit width per component (8, 16 or 32) | |
# - component data type: | |
# - unsigned normalized (no postfix) | |
# - signed normalized (SN postfix) | |
# - unsigned integer (UI postfix) | |
# - signed integer (SI postfix) | |
# - float (F postfix) | |
# Not all pixel formats can be used for everything, call sg_query_pixelformat() | |
# to inspect the capabilities of a given pixelformat. The function returns | |
# an sg_pixelformat_info struct with the following bool members: | |
# - sample: the pixelformat can be sampled as texture at least with | |
# nearest filtering | |
# - filter: the pixelformat can be samples as texture with linear | |
# filtering | |
# - render: the pixelformat can be used for render targets | |
# - blend: blending is supported when using the pixelformat for | |
# render targets | |
# - msaa: multisample-antialiasing is supported when using the | |
# pixelformat for render targets | |
# - depth: the pixelformat can be used for depth-stencil attachments | |
# When targeting GLES2/WebGL, the only safe formats to use | |
# as texture are SG_PIXELFORMAT_R8 and SG_PIXELFORMAT_RGBA8. For rendering | |
# in GLES2/WebGL, only SG_PIXELFORMAT_RGBA8 is safe. All other formats | |
# must be checked via sg_query_pixelformats(). | |
# The default pixel format for texture images is SG_PIXELFORMAT_RGBA8. | |
# The default pixel format for render target images is platform-dependent: | |
# - for Metal and D3D11 it is SG_PIXELFORMAT_BGRA8 | |
# - for GL backends it is SG_PIXELFORMAT_RGBA8 | |
# This is mainly because of the default framebuffer which is setup outside | |
# of sokol_gfx.h. On some backends, using BGRA for the default frame buffer | |
# allows more efficient frame flips. For your own offscreen-render-targets, | |
# use whatever renderable pixel format is convenient for you. | |
# | |
defineEnum(sg_pixel_format) | |
# | |
# sg_resource_state | |
# The current state of a resource in its resource pool. | |
# Resources start in the INITIAL state, which means the | |
# pool slot is unoccupied and can be allocated. When a resource is | |
# created, first an id is allocated, and the resource pool slot | |
# is set to state ALLOC. After allocation, the resource is | |
# initialized, which may result in the VALID or FAILED state. The | |
# reason why allocation and initialization are separate is because | |
# some resource types (e.g. buffers and images) might be asynchronously | |
# initialized by the user application. If a resource which is not | |
# in the VALID state is attempted to be used for rendering, rendering | |
# operations will silently be dropped. | |
# The special INVALID state is returned in sg_query_xxx_state() if no | |
# resource object exists for the provided resource id. | |
# | |
defineEnum(sg_resource_state) | |
# | |
# sg_usage | |
# A resource usage hint describing the update strategy of | |
# buffers and images. This is used in the sg_buffer_desc.usage | |
# and sg_image_desc.usage members when creating buffers | |
# and images: | |
# SG_USAGE_IMMUTABLE: the resource will never be updated with | |
# new data, instead the content of the | |
# resource must be provided on creation | |
# SG_USAGE_DYNAMIC: the resource will be updated infrequently | |
# with new data (this could range from "once | |
# after creation", to "quite often but not | |
# every frame") | |
# SG_USAGE_STREAM: the resource will be updated each frame | |
# with new content | |
# The rendering backends use this hint to prevent that the | |
# CPU needs to wait for the GPU when attempting to update | |
# a resource that might be currently accessed by the GPU. | |
# Resource content is updated with the function sg_update_buffer() for | |
# buffer objects, and sg_update_image() for image objects. Only | |
# one update is allowed per frame and resource object. The | |
# application must update all data required for rendering (this | |
# means that the update data can be smaller than the resource size, | |
# if only a part of the overall resource size is used for rendering, | |
# you only need to make sure that the data that *is* used is valid). | |
# The default usage is SG_USAGE_IMMUTABLE. | |
# | |
defineEnum(sg_usage) | |
# | |
# sg_buffer_type | |
# This indicates whether a buffer contains vertex- or index-data, | |
# used in the sg_buffer_desc.type member when creating a buffer. | |
# The default value is SG_BUFFERTYPE_VERTEXBUFFER. | |
# | |
defineEnum(sg_buffer_type) | |
# | |
# sg_index_type | |
# Indicates whether indexed rendering (fetching vertex-indices from an | |
# index buffer) is used, and if yes, the index data type (16- or 32-bits). | |
# This is used in the sg_pipeline_desc.index_type member when creating a | |
# pipeline object. | |
# The default index type is SG_INDEXTYPE_NONE. | |
# | |
defineEnum(sg_index_type) | |
# | |
# sg_image_type | |
# Indicates the basic type of an image object (2D-texture, cubemap, | |
# 3D-texture or 2D-array-texture). 3D- and array-textures are not supported | |
# on the GLES2/WebGL backend (use sg_query_features().imagetype_3d and | |
# sg_query_features().imagetype_array to check for support). The image type | |
# is used in the sg_image_desc.type member when creating an image. | |
# The default image type when creating an image is SG_IMAGETYPE_2D. | |
# | |
defineEnum(sg_image_type) | |
# | |
# sg_cube_face | |
# The cubemap faces. Use these as indices in the sg_image_desc.content | |
# array. | |
# | |
defineEnum(sg_cube_face) | |
# | |
# sg_shader_stage | |
# There are 2 shader stages: vertex- and fragment-shader-stage. | |
# Each shader stage consists of: | |
# - one slot for a shader function (provided as source- or byte-code) | |
# - SG_MAX_SHADERSTAGE_UBS slots for uniform blocks | |
# - SG_MAX_SHADERSTAGE_IMAGES slots for images used as textures by | |
# the shader function | |
# | |
defineEnum(sg_shader_stage) | |
# | |
# sg_primitive_type | |
# This is the common subset of 3D primitive types supported across all 3D | |
# APIs. This is used in the sg_pipeline_desc.primitive_type member when | |
# creating a pipeline object. | |
# The default primitive type is SG_PRIMITIVETYPE_TRIANGLES. | |
# | |
defineEnum(sg_primitive_type) | |
# | |
# sg_filter | |
# The filtering mode when sampling a texture image. This is | |
# used in the sg_image_desc.min_filter and sg_image_desc.mag_filter | |
# members when creating an image object. | |
# The default filter mode is SG_FILTER_NEAREST. | |
# | |
defineEnum(sg_filter) | |
# | |
# sg_wrap | |
# The texture coordinates wrapping mode when sampling a texture | |
# image. This is used in the sg_image_desc.wrap_u, .wrap_v | |
# and .wrap_w members when creating an image. | |
# The default wrap mode is SG_WRAP_REPEAT. | |
# NOTE: SG_WRAP_CLAMP_TO_BORDER is not supported on all backends | |
# and platforms. To check for support, call sg_query_features() | |
# and check the "clamp_to_border" boolean in the returned | |
# sg_features struct. | |
# Platforms which don't support SG_WRAP_CLAMP_TO_BORDER will silently fall back | |
# to SG_WRAP_CLAMP_TO_EDGE without a validation error. | |
# Platforms which support clamp-to-border are: | |
# - all desktop GL platforms | |
# - Metal on macOS | |
# - D3D11 | |
# Platforms which do not support clamp-to-border: | |
# - GLES2/3 and WebGL/WebGL2 | |
# - Metal on iOS | |
# | |
defineEnum(sg_wrap) | |
# | |
# sg_border_color | |
# The border color to use when sampling a texture, and the UV wrap | |
# mode is SG_WRAP_CLAMP_TO_BORDER. | |
# The default border color is SG_BORDERCOLOR_OPAQUE_BLACK | |
# | |
defineEnum(sg_border_color) | |
# | |
# sg_vertex_format | |
# The data type of a vertex component. This is used to describe | |
# the layout of vertex data when creating a pipeline object. | |
# | |
defineEnum(sg_vertex_format) | |
# | |
# sg_vertex_step | |
# Defines whether the input pointer of a vertex input stream is advanced | |
# 'per vertex' or 'per instance'. The default step-func is | |
# SG_VERTEXSTEP_PER_VERTEX. SG_VERTEXSTEP_PER_INSTANCE is used with | |
# instanced-rendering. | |
# The vertex-step is part of the vertex-layout definition | |
# when creating pipeline objects. | |
# | |
defineEnum(sg_vertex_step) | |
# | |
# sg_uniform_type | |
# The data type of a uniform block member. This is used to | |
# describe the internal layout of uniform blocks when creating | |
# a shader object. | |
# | |
defineEnum(sg_uniform_type) | |
# | |
# sg_cull_mode | |
# The face-culling mode, this is used in the | |
# sg_pipeline_desc.rasterizer.cull_mode member when creating a | |
# pipeline object. | |
# The default cull mode is SG_CULLMODE_NONE | |
# | |
defineEnum(sg_cull_mode) | |
# | |
# sg_face_winding | |
# The vertex-winding rule that determines a front-facing primitive. This | |
# is used in the member sg_pipeline_desc.rasterizer.face_winding | |
# when creating a pipeline object. | |
# The default winding is SG_FACEWINDING_CW (clockwise) | |
# | |
defineEnum(sg_face_winding) | |
# | |
# sg_compare_func | |
# The compare-function for depth- and stencil-ref tests. | |
# This is used when creating pipeline objects in the members: | |
# sg_pipeline_desc | |
# .depth_stencil | |
# .depth_compare_func | |
# .stencil_front.compare_func | |
# .stencil_back.compare_func | |
# The default compare func for depth- and stencil-tests is | |
# SG_COMPAREFUNC_ALWAYS. | |
# | |
defineEnum(sg_compare_func) | |
# | |
# sg_stencil_op | |
# The operation performed on a currently stored stencil-value when a | |
# comparison test passes or fails. This is used when creating a pipeline | |
# object in the members: | |
# sg_pipeline_desc | |
# .depth_stencil | |
# .stencil_front | |
# .fail_op | |
# .depth_fail_op | |
# .pass_op | |
# .stencil_back | |
# .fail_op | |
# .depth_fail_op | |
# .pass_op | |
# The default value is SG_STENCILOP_KEEP. | |
# | |
defineEnum(sg_stencil_op) | |
# | |
# sg_blend_factor | |
# The source and destination factors in blending operations. | |
# This is used in the following members when creating a pipeline object: | |
# sg_pipeline_desc | |
# .blend | |
# .src_factor_rgb | |
# .dst_factor_rgb | |
# .src_factor_alpha | |
# .dst_factor_alpha | |
# The default value is SG_BLENDFACTOR_ONE for source | |
# factors, and SG_BLENDFACTOR_ZERO for destination factors. | |
# | |
defineEnum(sg_blend_factor) | |
# | |
# sg_blend_op | |
# Describes how the source and destination values are combined in the | |
# fragment blending operation. It is used in the following members when | |
# creating a pipeline object: | |
# sg_pipeline_desc | |
# .blend | |
# .op_rgb | |
# .op_alpha | |
# The default value is SG_BLENDOP_ADD. | |
# | |
defineEnum(sg_blend_op) | |
# | |
# sg_color_mask | |
# Selects the color channels when writing a fragment color to the | |
# framebuffer. This is used in the members | |
# sg_pipeline_desc.blend.color_write_mask when creating a pipeline object. | |
# The default colormask is SG_COLORMASK_RGBA (write all colors channels) | |
# NOTE: since the color mask value 0 is reserved for the default value | |
# (SG_COLORMASK_RGBA), use SG_COLORMASK_NONE if all color channels | |
# should be disabled. | |
# | |
defineEnum(sg_color_mask) | |
# | |
# sg_action | |
# Defines what action should be performed at the start of a render pass: | |
# SG_ACTION_CLEAR: clear the render target image | |
# SG_ACTION_LOAD: load the previous content of the render target image | |
# SG_ACTION_DONTCARE: leave the render target image content undefined | |
# This is used in the sg_pass_action structure. | |
# The default action for all pass attachments is SG_ACTION_CLEAR, with the | |
# clear color rgba = {0.5f, 0.5f, 0.5f, 1.0f], depth=1.0 and stencil=0. | |
# If you want to override the default behaviour, it is important to not | |
# only set the clear color, but the 'action' field as well (as long as this | |
# is in its _SG_ACTION_DEFAULT, the value fields will be ignored). | |
# | |
defineEnum(sg_action) | |
const | |
headersokol_gfx {.used.} = "/Users/zacharycarter/dev/junkers/lib/sokol/sokol_gfx.h" | |
SG_INVALID_ID* = (0).Enum_sokol_gfxh1 | |
SG_NUM_SHADER_STAGES* = (2).Enum_sokol_gfxh1 | |
SG_NUM_INFLIGHT_FRAMES* = (2).Enum_sokol_gfxh1 | |
SG_MAX_COLOR_ATTACHMENTS* = (4).Enum_sokol_gfxh1 | |
SG_MAX_SHADERSTAGE_BUFFERS* = (8).Enum_sokol_gfxh1 | |
SG_MAX_SHADERSTAGE_IMAGES* = (12).Enum_sokol_gfxh1 | |
SG_MAX_SHADERSTAGE_UBS* = (4).Enum_sokol_gfxh1 | |
SG_MAX_UB_MEMBERS* = (16).Enum_sokol_gfxh1 | |
SG_MAX_VERTEX_ATTRIBUTES* = (16).Enum_sokol_gfxh1 | |
SG_MAX_MIPMAPS* = (16).Enum_sokol_gfxh1 | |
SG_MAX_TEXTUREARRAY_LAYERS* = (128).Enum_sokol_gfxh1 | |
SG_BACKEND_GLCORE33* = 0.sg_backend | |
SG_BACKEND_GLES2* = 1.sg_backend | |
SG_BACKEND_GLES3* = 2.sg_backend | |
SG_BACKEND_D3D11* = 3.sg_backend | |
SG_BACKEND_METAL_IOS* = 4.sg_backend | |
SG_BACKEND_METAL_MACOS* = 5.sg_backend | |
SG_BACKEND_METAL_SIMULATOR* = 6.sg_backend | |
SG_BACKEND_DUMMY* = 7.sg_backend | |
SG_PIXELFORMAT_DEFAULT* = 0.sg_pixel_format | |
SG_PIXELFORMAT_NONE* = 1.sg_pixel_format | |
SG_PIXELFORMAT_R8* = 2.sg_pixel_format | |
SG_PIXELFORMAT_R8SN* = 3.sg_pixel_format | |
SG_PIXELFORMAT_R8UI* = 4.sg_pixel_format | |
SG_PIXELFORMAT_R8SI* = 5.sg_pixel_format | |
SG_PIXELFORMAT_R16* = 6.sg_pixel_format | |
SG_PIXELFORMAT_R16SN* = 7.sg_pixel_format | |
SG_PIXELFORMAT_R16UI* = 8.sg_pixel_format | |
SG_PIXELFORMAT_R16SI* = 9.sg_pixel_format | |
SG_PIXELFORMAT_R16F* = 10.sg_pixel_format | |
SG_PIXELFORMAT_RG8* = 11.sg_pixel_format | |
SG_PIXELFORMAT_RG8SN* = 12.sg_pixel_format | |
SG_PIXELFORMAT_RG8UI* = 13.sg_pixel_format | |
SG_PIXELFORMAT_RG8SI* = 14.sg_pixel_format | |
SG_PIXELFORMAT_R32UI* = 15.sg_pixel_format | |
SG_PIXELFORMAT_R32SI* = 16.sg_pixel_format | |
SG_PIXELFORMAT_R32F* = 17.sg_pixel_format | |
SG_PIXELFORMAT_RG16* = 18.sg_pixel_format | |
SG_PIXELFORMAT_RG16SN* = 19.sg_pixel_format | |
SG_PIXELFORMAT_RG16UI* = 20.sg_pixel_format | |
SG_PIXELFORMAT_RG16SI* = 21.sg_pixel_format | |
SG_PIXELFORMAT_RG16F* = 22.sg_pixel_format | |
SG_PIXELFORMAT_RGBA8* = 23.sg_pixel_format | |
SG_PIXELFORMAT_RGBA8SN* = 24.sg_pixel_format | |
SG_PIXELFORMAT_RGBA8UI* = 25.sg_pixel_format | |
SG_PIXELFORMAT_RGBA8SI* = 26.sg_pixel_format | |
SG_PIXELFORMAT_BGRA8* = 27.sg_pixel_format | |
SG_PIXELFORMAT_RGB10A2* = 28.sg_pixel_format | |
SG_PIXELFORMAT_RG11B10F* = 29.sg_pixel_format | |
SG_PIXELFORMAT_RG32UI* = 30.sg_pixel_format | |
SG_PIXELFORMAT_RG32SI* = 31.sg_pixel_format | |
SG_PIXELFORMAT_RG32F* = 32.sg_pixel_format | |
SG_PIXELFORMAT_RGBA16* = 33.sg_pixel_format | |
SG_PIXELFORMAT_RGBA16SN* = 34.sg_pixel_format | |
SG_PIXELFORMAT_RGBA16UI* = 35.sg_pixel_format | |
SG_PIXELFORMAT_RGBA16SI* = 36.sg_pixel_format | |
SG_PIXELFORMAT_RGBA16F* = 37.sg_pixel_format | |
SG_PIXELFORMAT_RGBA32UI* = 38.sg_pixel_format | |
SG_PIXELFORMAT_RGBA32SI* = 39.sg_pixel_format | |
SG_PIXELFORMAT_RGBA32F* = 40.sg_pixel_format | |
SG_PIXELFORMAT_DEPTH* = 41.sg_pixel_format | |
SG_PIXELFORMAT_DEPTH_STENCIL* = 42.sg_pixel_format | |
SG_PIXELFORMAT_BC1_RGBA* = 43.sg_pixel_format | |
SG_PIXELFORMAT_BC2_RGBA* = 44.sg_pixel_format | |
SG_PIXELFORMAT_BC3_RGBA* = 45.sg_pixel_format | |
SG_PIXELFORMAT_BC4_R* = 46.sg_pixel_format | |
SG_PIXELFORMAT_BC4_RSN* = 47.sg_pixel_format | |
SG_PIXELFORMAT_BC5_RG* = 48.sg_pixel_format | |
SG_PIXELFORMAT_BC5_RGSN* = 49.sg_pixel_format | |
SG_PIXELFORMAT_BC6H_RGBF* = 50.sg_pixel_format | |
SG_PIXELFORMAT_BC6H_RGBUF* = 51.sg_pixel_format | |
SG_PIXELFORMAT_BC7_RGBA* = 52.sg_pixel_format | |
SG_PIXELFORMAT_PVRTC_RGB_2BPP* = 53.sg_pixel_format | |
SG_PIXELFORMAT_PVRTC_RGB_4BPP* = 54.sg_pixel_format | |
SG_PIXELFORMAT_PVRTC_RGBA_2BPP* = 55.sg_pixel_format | |
SG_PIXELFORMAT_PVRTC_RGBA_4BPP* = 56.sg_pixel_format | |
SG_PIXELFORMAT_ETC2_RGB8* = 57.sg_pixel_format | |
SG_PIXELFORMAT_ETC2_RGB8A1* = 58.sg_pixel_format | |
SG_PIXELFORMAT_ETC2_RGBA8* = 59.sg_pixel_format | |
SG_PIXELFORMAT_ETC2_RG11* = 60.sg_pixel_format | |
SG_PIXELFORMAT_ETC2_RG11SN* = 61.sg_pixel_format | |
SG_PIXELFORMAT_NUM* = 62.sg_pixel_format | |
SG_PIXELFORMAT_FORCE_U32* = (0x7FFFFFFF).sg_pixel_format | |
SG_RESOURCESTATE_INITIAL* = 0.sg_resource_state | |
SG_RESOURCESTATE_ALLOC* = 1.sg_resource_state | |
SG_RESOURCESTATE_VALID* = 2.sg_resource_state | |
SG_RESOURCESTATE_FAILED* = 3.sg_resource_state | |
SG_RESOURCESTATE_INVALID* = 4.sg_resource_state | |
SG_RESOURCESTATE_FORCE_U32* = (0x7FFFFFFF).sg_resource_state | |
SG_USAGE_DEFAULT* = 0.sg_usage | |
SG_USAGE_IMMUTABLE* = 1.sg_usage | |
SG_USAGE_DYNAMIC* = 2.sg_usage | |
SG_USAGE_STREAM* = 3.sg_usage | |
SG_USAGE_NUM* = 4.sg_usage | |
SG_USAGE_FORCE_U32* = (0x7FFFFFFF).sg_usage | |
SG_BUFFERTYPE_DEFAULT* = 0.sg_buffer_type | |
SG_BUFFERTYPE_VERTEXBUFFER* = 1.sg_buffer_type | |
SG_BUFFERTYPE_INDEXBUFFER* = 2.sg_buffer_type | |
SG_BUFFERTYPE_NUM* = 3.sg_buffer_type | |
SG_BUFFERTYPE_FORCE_U32* = (0x7FFFFFFF).sg_buffer_type | |
SG_INDEXTYPE_DEFAULT* = 0.sg_index_type | |
SG_INDEXTYPE_NONE* = 1.sg_index_type | |
SG_INDEXTYPE_UINT16* = 2.sg_index_type | |
SG_INDEXTYPE_UINT32* = 3.sg_index_type | |
SG_INDEXTYPE_NUM* = 4.sg_index_type | |
SG_INDEXTYPE_FORCE_U32* = (0x7FFFFFFF).sg_index_type | |
SG_IMAGETYPE_DEFAULT* = 0.sg_image_type | |
SG_IMAGETYPE_2D* = 1.sg_image_type | |
SG_IMAGETYPE_CUBE* = 2.sg_image_type | |
SG_IMAGETYPE_3D* = 3.sg_image_type | |
SG_IMAGETYPE_ARRAY* = 4.sg_image_type | |
SG_IMAGETYPE_NUM* = 5.sg_image_type | |
SG_IMAGETYPE_FORCE_U32* = (0x7FFFFFFF).sg_image_type | |
SG_CUBEFACE_POS_X* = 0.sg_cube_face | |
SG_CUBEFACE_NEG_X* = 1.sg_cube_face | |
SG_CUBEFACE_POS_Y* = 2.sg_cube_face | |
SG_CUBEFACE_NEG_Y* = 3.sg_cube_face | |
SG_CUBEFACE_POS_Z* = 4.sg_cube_face | |
SG_CUBEFACE_NEG_Z* = 5.sg_cube_face | |
SG_CUBEFACE_NUM* = 6.sg_cube_face | |
SG_CUBEFACE_FORCE_U32* = (0x7FFFFFFF).sg_cube_face | |
SG_SHADERSTAGE_VS* = 0.sg_shader_stage | |
SG_SHADERSTAGE_FS* = 1.sg_shader_stage | |
SG_SHADERSTAGE_FORCE_U32* = (0x7FFFFFFF).sg_shader_stage | |
SG_PRIMITIVETYPE_DEFAULT* = 0.sg_primitive_type | |
SG_PRIMITIVETYPE_POINTS* = 1.sg_primitive_type | |
SG_PRIMITIVETYPE_LINES* = 2.sg_primitive_type | |
SG_PRIMITIVETYPE_LINE_STRIP* = 3.sg_primitive_type | |
SG_PRIMITIVETYPE_TRIANGLES* = 4.sg_primitive_type | |
SG_PRIMITIVETYPE_TRIANGLE_STRIP* = 5.sg_primitive_type | |
SG_PRIMITIVETYPE_NUM* = 6.sg_primitive_type | |
SG_PRIMITIVETYPE_FORCE_U32* = (0x7FFFFFFF).sg_primitive_type | |
SG_FILTER_DEFAULT* = 0.sg_filter | |
SG_FILTER_NEAREST* = 1.sg_filter | |
SG_FILTER_LINEAR* = 2.sg_filter | |
SG_FILTER_NEAREST_MIPMAP_NEAREST* = 3.sg_filter | |
SG_FILTER_NEAREST_MIPMAP_LINEAR* = 4.sg_filter | |
SG_FILTER_LINEAR_MIPMAP_NEAREST* = 5.sg_filter | |
SG_FILTER_LINEAR_MIPMAP_LINEAR* = 6.sg_filter | |
SG_FILTER_NUM* = 7.sg_filter | |
SG_FILTER_FORCE_U32* = (0x7FFFFFFF).sg_filter | |
SG_WRAP_DEFAULT* = 0.sg_wrap | |
SG_WRAP_REPEAT* = 1.sg_wrap | |
SG_WRAP_CLAMP_TO_EDGE* = 2.sg_wrap | |
SG_WRAP_CLAMP_TO_BORDER* = 3.sg_wrap | |
SG_WRAP_MIRRORED_REPEAT* = 4.sg_wrap | |
SG_WRAP_NUM* = 5.sg_wrap | |
SG_WRAP_FORCE_U32* = (0x7FFFFFFF).sg_wrap | |
SG_BORDERCOLOR_DEFAULT* = 0.sg_border_color | |
SG_BORDERCOLOR_TRANSPARENT_BLACK* = 1.sg_border_color | |
SG_BORDERCOLOR_OPAQUE_BLACK* = 2.sg_border_color | |
SG_BORDERCOLOR_OPAQUE_WHITE* = 3.sg_border_color | |
SG_BORDERCOLOR_NUM* = 4.sg_border_color | |
SG_BORDERCOLOR_FORCE_U32* = (0x7FFFFFFF).sg_border_color | |
SG_VERTEXFORMAT_INVALID* = 0.sg_vertex_format | |
SG_VERTEXFORMAT_FLOAT* = 1.sg_vertex_format | |
SG_VERTEXFORMAT_FLOAT2* = 2.sg_vertex_format | |
SG_VERTEXFORMAT_FLOAT3* = 3.sg_vertex_format | |
SG_VERTEXFORMAT_FLOAT4* = 4.sg_vertex_format | |
SG_VERTEXFORMAT_BYTE4* = 5.sg_vertex_format | |
SG_VERTEXFORMAT_BYTE4N* = 6.sg_vertex_format | |
SG_VERTEXFORMAT_UBYTE4* = 7.sg_vertex_format | |
SG_VERTEXFORMAT_UBYTE4N* = 8.sg_vertex_format | |
SG_VERTEXFORMAT_SHORT2* = 9.sg_vertex_format | |
SG_VERTEXFORMAT_SHORT2N* = 10.sg_vertex_format | |
SG_VERTEXFORMAT_USHORT2N* = 11.sg_vertex_format | |
SG_VERTEXFORMAT_SHORT4* = 12.sg_vertex_format | |
SG_VERTEXFORMAT_SHORT4N* = 13.sg_vertex_format | |
SG_VERTEXFORMAT_USHORT4N* = 14.sg_vertex_format | |
SG_VERTEXFORMAT_UINT10_N2* = 15.sg_vertex_format | |
SG_VERTEXFORMAT_NUM* = 16.sg_vertex_format | |
SG_VERTEXFORMAT_FORCE_U32* = (0x7FFFFFFF).sg_vertex_format | |
SG_VERTEXSTEP_DEFAULT* = 0.sg_vertex_step | |
SG_VERTEXSTEP_PER_VERTEX* = 1.sg_vertex_step | |
SG_VERTEXSTEP_PER_INSTANCE* = 2.sg_vertex_step | |
SG_VERTEXSTEP_NUM* = 3.sg_vertex_step | |
SG_VERTEXSTEP_FORCE_U32* = (0x7FFFFFFF).sg_vertex_step | |
SG_UNIFORMTYPE_INVALID* = 0.sg_uniform_type | |
SG_UNIFORMTYPE_FLOAT* = 1.sg_uniform_type | |
SG_UNIFORMTYPE_FLOAT2* = 2.sg_uniform_type | |
SG_UNIFORMTYPE_FLOAT3* = 3.sg_uniform_type | |
SG_UNIFORMTYPE_FLOAT4* = 4.sg_uniform_type | |
SG_UNIFORMTYPE_MAT4* = 5.sg_uniform_type | |
SG_UNIFORMTYPE_NUM* = 6.sg_uniform_type | |
SG_UNIFORMTYPE_FORCE_U32* = (0x7FFFFFFF).sg_uniform_type | |
SG_CULLMODE_DEFAULT* = 0.sg_cull_mode | |
SG_CULLMODE_NONE* = 1.sg_cull_mode | |
SG_CULLMODE_FRONT* = 2.sg_cull_mode | |
SG_CULLMODE_BACK* = 3.sg_cull_mode | |
SG_CULLMODE_NUM* = 4.sg_cull_mode | |
SG_CULLMODE_FORCE_U32* = (0x7FFFFFFF).sg_cull_mode | |
SG_FACEWINDING_DEFAULT* = 0.sg_face_winding | |
SG_FACEWINDING_CCW* = 1.sg_face_winding | |
SG_FACEWINDING_CW* = 2.sg_face_winding | |
SG_FACEWINDING_NUM* = 3.sg_face_winding | |
SG_FACEWINDING_FORCE_U32* = (0x7FFFFFFF).sg_face_winding | |
SG_COMPAREFUNC_DEFAULT* = 0.sg_compare_func | |
SG_COMPAREFUNC_NEVER* = 1.sg_compare_func | |
SG_COMPAREFUNC_LESS* = 2.sg_compare_func | |
SG_COMPAREFUNC_EQUAL* = 3.sg_compare_func | |
SG_COMPAREFUNC_LESS_EQUAL* = 4.sg_compare_func | |
SG_COMPAREFUNC_GREATER* = 5.sg_compare_func | |
SG_COMPAREFUNC_NOT_EQUAL* = 6.sg_compare_func | |
SG_COMPAREFUNC_GREATER_EQUAL* = 7.sg_compare_func | |
SG_COMPAREFUNC_ALWAYS* = 8.sg_compare_func | |
SG_COMPAREFUNC_NUM* = 9.sg_compare_func | |
SG_COMPAREFUNC_FORCE_U32* = (0x7FFFFFFF).sg_compare_func | |
SG_STENCILOP_DEFAULT* = 0.sg_stencil_op | |
SG_STENCILOP_KEEP* = 1.sg_stencil_op | |
SG_STENCILOP_ZERO* = 2.sg_stencil_op | |
SG_STENCILOP_REPLACE* = 3.sg_stencil_op | |
SG_STENCILOP_INCR_CLAMP* = 4.sg_stencil_op | |
SG_STENCILOP_DECR_CLAMP* = 5.sg_stencil_op | |
SG_STENCILOP_INVERT* = 6.sg_stencil_op | |
SG_STENCILOP_INCR_WRAP* = 7.sg_stencil_op | |
SG_STENCILOP_DECR_WRAP* = 8.sg_stencil_op | |
SG_STENCILOP_NUM* = 9.sg_stencil_op | |
SG_STENCILOP_FORCE_U32* = (0x7FFFFFFF).sg_stencil_op | |
SG_BLENDFACTOR_DEFAULT* = 0.sg_blend_factor | |
SG_BLENDFACTOR_ZERO* = 1.sg_blend_factor | |
SG_BLENDFACTOR_ONE* = 2.sg_blend_factor | |
SG_BLENDFACTOR_SRC_COLOR* = 3.sg_blend_factor | |
SG_BLENDFACTOR_ONE_MINUS_SRC_COLOR* = 4.sg_blend_factor | |
SG_BLENDFACTOR_SRC_ALPHA* = 5.sg_blend_factor | |
SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA* = 6.sg_blend_factor | |
SG_BLENDFACTOR_DST_COLOR* = 7.sg_blend_factor | |
SG_BLENDFACTOR_ONE_MINUS_DST_COLOR* = 8.sg_blend_factor | |
SG_BLENDFACTOR_DST_ALPHA* = 9.sg_blend_factor | |
SG_BLENDFACTOR_ONE_MINUS_DST_ALPHA* = 10.sg_blend_factor | |
SG_BLENDFACTOR_SRC_ALPHA_SATURATED* = 11.sg_blend_factor | |
SG_BLENDFACTOR_BLEND_COLOR* = 12.sg_blend_factor | |
SG_BLENDFACTOR_ONE_MINUS_BLEND_COLOR* = 13.sg_blend_factor | |
SG_BLENDFACTOR_BLEND_ALPHA* = 14.sg_blend_factor | |
SG_BLENDFACTOR_ONE_MINUS_BLEND_ALPHA* = 15.sg_blend_factor | |
SG_BLENDFACTOR_NUM* = 16.sg_blend_factor | |
SG_BLENDFACTOR_FORCE_U32* = (0x7FFFFFFF).sg_blend_factor | |
SG_BLENDOP_DEFAULT* = 0.sg_blend_op | |
SG_BLENDOP_ADD* = 1.sg_blend_op | |
SG_BLENDOP_SUBTRACT* = 2.sg_blend_op | |
SG_BLENDOP_REVERSE_SUBTRACT* = 3.sg_blend_op | |
SG_BLENDOP_NUM* = 4.sg_blend_op | |
SG_BLENDOP_FORCE_U32* = (0x7FFFFFFF).sg_blend_op | |
SG_COLORMASK_DEFAULT* = (0).sg_color_mask | |
SG_COLORMASK_NONE* = ((0x10)).sg_color_mask | |
SG_COLORMASK_R* = ((1 shl 0)).sg_color_mask | |
SG_COLORMASK_G* = ((1 shl 1)).sg_color_mask | |
SG_COLORMASK_B* = ((1 shl 2)).sg_color_mask | |
SG_COLORMASK_A* = ((1 shl 3)).sg_color_mask | |
SG_COLORMASK_RGB* = (0x7).sg_color_mask | |
SG_COLORMASK_RGBA* = (0xF).sg_color_mask | |
SG_COLORMASK_FORCE_U32* = (0x7FFFFFFF).sg_color_mask | |
SG_ACTION_DEFAULT* = 0.sg_action | |
SG_ACTION_CLEAR* = 1.sg_action | |
SG_ACTION_LOAD* = 2.sg_action | |
SG_ACTION_DONTCARE* = 3.sg_action | |
SG_ACTION_NUM* = 4.sg_action | |
SG_ACTION_FORCE_U32* = (0x7FFFFFFF).sg_action | |
{.pragma: impsokol_gfx, importc, header: headersokol_gfx.} | |
{.pragma: impsokol_gfxC, impsokol_gfx, cdecl.} | |
type | |
INNER_C_UNION_c2nim_5* {.bycopy.} = object {.union.} | |
face*: cint | |
layer*: cint | |
slice*: cint | |
INNER_C_UNION_c2nim_8* {.bycopy.} = object {.union.} | |
depth*: cint | |
layers*: cint | |
# | |
# sokol_gfx.h -- simple 3D API wrapper | |
# Project URL: https:github.com/floooh/sokol | |
# Do this: | |
# #define SOKOL_IMPL | |
# before you include this file in *one* C or C++ file to create the | |
# implementation. | |
# In the same place define one of the following to select the rendering | |
# backend: | |
# #define SOKOL_GLCORE33 | |
# #define SOKOL_GLES2 | |
# #define SOKOL_GLES3 | |
# #define SOKOL_D3D11 | |
# #define SOKOL_METAL | |
# #define SOKOL_DUMMY_BACKEND | |
# I.e. for the GL 3.3 Core Profile it should look like this: | |
# #include ... | |
# #include ... | |
# #define SOKOL_IMPL | |
# #define SOKOL_GLCORE33 | |
# #include "sokol_gfx.h" | |
# The dummy backend replaces the platform-specific backend code with empty | |
# stub functions. This is useful for writing tests that need to run on the | |
# command line. | |
# Optionally provide the following defines with your own implementations: | |
# SOKOL_ASSERT(c) - your own assert macro (default: assert(c)) | |
# SOKOL_MALLOC(s) - your own malloc function (default: malloc(s)) | |
# SOKOL_FREE(p) - your own free function (default: free(p)) | |
# SOKOL_LOG(msg) - your own logging function (default: puts(msg)) | |
# SOKOL_UNREACHABLE() - a guard macro for unreachable code (default: assert(false)) | |
# SOKOL_API_DECL - public function declaration prefix (default: extern) | |
# SOKOL_API_IMPL - public function implementation prefix (default: -) | |
# SOKOL_TRACE_HOOKS - enable trace hook callbacks (search below for TRACE HOOKS) | |
# If sokol_gfx.h is compiled as a DLL, define the following before | |
# including the declaration or implementation: | |
# SOKOL_DLL | |
# On Windows, SOKOL_DLL will define SOKOL_API_DECL as __declspec(dllexport) | |
# or __declspec(dllimport) as needed. | |
# If you want to compile without deprecated structs and functions, | |
# define: | |
# SOKOL_NO_DEPRECATED | |
# API usage validation macros: | |
# SOKOL_VALIDATE_BEGIN() - begin a validation block (default:_sg_validate_begin()) | |
# SOKOL_VALIDATE(cond, err) - like assert but for API validation (default: _sg_validate(cond, err)) | |
# SOKOL_VALIDATE_END() - end a validation block, return true if all checks in block passed (default: bool _sg_validate()) | |
# If you don't want validation errors to be fatal, define SOKOL_VALIDATE_NON_FATAL, | |
# be aware though that this may spam SOKOL_LOG messages. | |
# Optionally define the following to force debug checks and validations | |
# even in release mode: | |
# SOKOL_DEBUG - by default this is defined if _DEBUG is defined | |
# sokol_gfx DOES NOT: | |
# =================== | |
# - create a window or the 3D-API context/device, you must do this | |
# before sokol_gfx is initialized, and pass any required information | |
# (like 3D device pointers) to the sokol_gfx initialization call | |
# - present the rendered frame, how this is done exactly usually depends | |
# on how the window and 3D-API context/device was created | |
# - provide a unified shader language, instead 3D-API-specific shader | |
# source-code or shader-bytecode must be provided | |
# For complete code examples using the various backend 3D-APIs, see: | |
# https:github.com/floooh/sokol-samples | |
# For an optional shader-cross-compile solution, see: | |
# https:github.com/floooh/sokol-tools/blob/master/docs/sokol-shdc.md | |
# STEP BY STEP | |
# ============ | |
# --- to initialize sokol_gfx, after creating a window and a 3D-API | |
# context/device, call: | |
# sg_setup(const sg_desc*) | |
# --- create resource objects (at least buffers, shaders and pipelines, | |
# and optionally images and passes): | |
# sg_buffer sg_make_buffer(const sg_buffer_desc*) | |
# sg_image sg_make_image(const sg_image_desc*) | |
# sg_shader sg_make_shader(const sg_shader_desc*) | |
# sg_pipeline sg_make_pipeline(const sg_pipeline_desc*) | |
# sg_pass sg_make_pass(const sg_pass_desc*) | |
# --- start rendering to the default frame buffer with: | |
# sg_begin_default_pass(const sg_pass_action* actions, int width, int height) | |
# --- or start rendering to an offscreen framebuffer with: | |
# sg_begin_pass(sg_pass pass, const sg_pass_action* actions) | |
# --- set the pipeline state for the next draw call with: | |
# sg_apply_pipeline(sg_pipeline pip) | |
# --- fill an sg_bindings struct with the resource bindings for the next | |
# draw call (1..N vertex buffers, 0 or 1 index buffer, 0..N image objects | |
# to use as textures each on the vertex-shader- and fragment-shader-stage | |
# and then call | |
# sg_apply_bindings(const sg_bindings* bindings) | |
# to update the resource bindings | |
# --- optionally update shader uniform data with: | |
# sg_apply_uniforms(sg_shader_stage stage, int ub_index, const void* data, int num_bytes) | |
# --- kick off a draw call with: | |
# sg_draw(int base_element, int num_elements, int num_instances) | |
# --- finish the current rendering pass with: | |
# sg_end_pass() | |
# --- when done with the current frame, call | |
# sg_commit() | |
# --- at the end of your program, shutdown sokol_gfx with: | |
# sg_shutdown() | |
# --- if you need to destroy resources before sg_shutdown(), call: | |
# sg_destroy_buffer(sg_buffer buf) | |
# sg_destroy_image(sg_image img) | |
# sg_destroy_shader(sg_shader shd) | |
# sg_destroy_pipeline(sg_pipeline pip) | |
# sg_destroy_pass(sg_pass pass) | |
# --- to set a new viewport rectangle, call | |
# sg_apply_viewport(int x, int y, int width, int height, bool origin_top_left) | |
# --- to set a new scissor rect, call: | |
# sg_apply_scissor_rect(int x, int y, int width, int height, bool origin_top_left) | |
# both sg_apply_viewport() and sg_apply_scissor_rect() must be called | |
# inside a rendering pass | |
# beginning a pass will reset the viewport to the size of the framebuffer used | |
# in the new pass, | |
# --- to update (overwrite) the content of buffer and image resources, call: | |
# sg_update_buffer(sg_buffer buf, const void* ptr, int num_bytes) | |
# sg_update_image(sg_image img, const sg_image_content* content) | |
# Buffers and images to be updated must have been created with | |
# SG_USAGE_DYNAMIC or SG_USAGE_STREAM | |
# Only one update per frame is allowed for buffer and image resources. | |
# The rationale is to have a simple countermeasure to avoid the CPU | |
# scribbling over data the GPU is currently using, or the CPU having to | |
# wait for the GPU | |
# Buffer and image updates can be partial, as long as a rendering | |
# operation only references the valid (updated) data in the | |
# buffer or image. | |
# --- to append a chunk of data to a buffer resource, call: | |
# int sg_append_buffer(sg_buffer buf, const void* ptr, int num_bytes) | |
# The difference to sg_update_buffer() is that sg_append_buffer() | |
# can be called multiple times per frame to append new data to the | |
# buffer piece by piece, optionally interleaved with draw calls referencing | |
# the previously written data. | |
# sg_append_buffer() returns a byte offset to the start of the | |
# written data, this offset can be assigned to | |
# sg_bindings.vertex_buffer_offsets[n] or | |
# sg_bindings.index_buffer_offset | |
# Code example: | |
# for (...) { | |
# const void* data = ...; | |
# const int num_bytes = ...; | |
# int offset = sg_append_buffer(buf, data, num_bytes); | |
# bindings.vertex_buffer_offsets[0] = offset; | |
# sg_apply_pipeline(pip); | |
# sg_apply_bindings(&bindings); | |
# sg_apply_uniforms(...); | |
# sg_draw(...); | |
# } | |
# A buffer to be used with sg_append_buffer() must have been created | |
# with SG_USAGE_DYNAMIC or SG_USAGE_STREAM. | |
# If the application appends more data to the buffer then fits into | |
# the buffer, the buffer will go into the "overflow" state for the | |
# rest of the frame. | |
# Any draw calls attempting to render an overflown buffer will be | |
# silently dropped (in debug mode this will also result in a | |
# validation error). | |
# You can also check manually if a buffer is in overflow-state by calling | |
# bool sg_query_buffer_overflow(sg_buffer buf) | |
# --- to check at runtime for optional features, limits and pixelformat support, | |
# call: | |
# sg_features sg_query_features() | |
# sg_limits sg_query_limits() | |
# sg_pixelformat_info sg_query_pixelformat(sg_pixel_format fmt) | |
# --- if you need to call into the underlying 3D-API directly, you must call: | |
# sg_reset_state_cache() | |
# ...before calling sokol_gfx functions again | |
# --- you can inspect the original sg_desc structure handed to sg_setup() | |
# by calling sg_query_desc(). This will return an sg_desc struct with | |
# the default values patched in instead of any zero-initialized values | |
# --- you can inspect various internal resource attributes via: | |
# sg_buffer_info sg_query_buffer_info(sg_buffer buf) | |
# sg_image_info sg_query_image_info(sg_image img) | |
# sg_shader_info sg_query_shader_info(sg_shader shd) | |
# sg_pipeline_info sg_query_pipeline_info(sg_pipeline pip) | |
# sg_pass_info sg_query_pass_info(sg_pass pass) | |
# ...please note that the returned info-structs are tied quite closely | |
# to sokol_gfx.h internals, and may change more often than other | |
# public API functions and structs. | |
# --- you can ask at runtime what backend sokol_gfx.h has been compiled | |
# for, or whether the GLES3 backend had to fall back to GLES2 with: | |
# sg_backend sg_query_backend(void) | |
# --- you can query the default resource creation parameters through the functions | |
# sg_buffer_desc sg_query_buffer_defaults(const sg_buffer_desc* desc) | |
# sg_image_desc sg_query_image_defaults(const sg_image_desc* desc) | |
# sg_shader_desc sg_query_shader_defaults(const sg_shader_desc* desc) | |
# sg_pipeline_desc sg_query_pipeline_defaults(const sg_pipeline_desc* desc) | |
# sg_pass_desc sg_query_pass_defaults(const sg_pass_desc* desc) | |
# These functions take a pointer to a desc structure which may contain | |
# zero-initialized items for default values. These zero-init values | |
# will be replaced with their concrete values in the returned desc | |
# struct. | |
# BACKEND-SPECIFIC TOPICS: | |
# ======================== | |
# --- the GL backends need to know about the internal structure of uniform | |
# blocks, and the texture sampler-name and -type: | |
# typedef struct { | |
# float mvp[16]; model-view-projection matrix | |
# float offset0[2]; some 2D vectors | |
# float offset1[2]; | |
# float offset2[2]; | |
# } params_t; | |
# uniform block structure and texture image definition in sg_shader_desc: | |
# sg_shader_desc desc = { | |
# uniform block description (size and internal structure) | |
# .vs.uniform_blocks[0] = { | |
# .size = sizeof(params_t), | |
# .uniforms = { | |
# [0] = { .name="mvp", .type=SG_UNIFORMTYPE_MAT4 }, | |
# [1] = { .name="offset0", .type=SG_UNIFORMTYPE_VEC2 }, | |
# ... | |
# } | |
# }, | |
# one texture on the fragment-shader-stage, GLES2/WebGL needs name and image type | |
# .fs.images[0] = { .name="tex", .type=SG_IMAGETYPE_ARRAY } | |
# ... | |
# }; | |
# --- the Metal and D3D11 backends only need to know the size of uniform blocks, | |
# not their internal member structure, and they only need to know | |
# the type of a texture sampler, not its name: | |
# sg_shader_desc desc = { | |
# .vs.uniform_blocks[0].size = sizeof(params_t), | |
# .fs.images[0].type = SG_IMAGETYPE_ARRAY, | |
# ... | |
# }; | |
# --- when creating a shader object, GLES2/WebGL need to know the vertex | |
# attribute names as used in the vertex shader: | |
# sg_shader_desc desc = { | |
# .attrs = { | |
# [0] = { .name="position" }, | |
# [1] = { .name="color1" } | |
# } | |
# }; | |
# The vertex attribute names provided when creating a shader will be | |
# used later in sg_create_pipeline() for matching the vertex layout | |
# to vertex shader inputs. | |
# --- on D3D11 you need to provide a semantic name and semantic index in the | |
# shader description struct instead (see the D3D11 documentation on | |
# D3D11_INPUT_ELEMENT_DESC for details): | |
# sg_shader_desc desc = { | |
# .attrs = { | |
# [0] = { .sem_name="POSITION", .sem_index=0 } | |
# [1] = { .sem_name="COLOR", .sem_index=1 } | |
# } | |
# }; | |
# The provided semantic information will be used later in sg_create_pipeline() | |
# to match the vertex layout to vertex shader inputs. | |
# --- on Metal, GL 3.3 or GLES3/WebGL2, you don't need to provide an attribute | |
# name or semantic name, since vertex attributes can be bound by their slot index | |
# (this is mandatory in Metal, and optional in GL): | |
# sg_pipeline_desc desc = { | |
# .layout = { | |
# .attrs = { | |
# [0] = { .format=SG_VERTEXFORMAT_FLOAT3 }, | |
# [1] = { .format=SG_VERTEXFORMAT_FLOAT4 } | |
# } | |
# } | |
# }; | |
# WORKING WITH CONTEXTS | |
# ===================== | |
# sokol-gfx allows to switch between different rendering contexts and | |
# associate resource objects with contexts. This is useful to | |
# create GL applications that render into multiple windows. | |
# A rendering context keeps track of all resources created while | |
# the context is active. When the context is destroyed, all resources | |
# "belonging to the context" are destroyed as well. | |
# A default context will be created and activated implicitly in | |
# sg_setup(), and destroyed in sg_shutdown(). So for a typical application | |
# which *doesn't* use multiple contexts, nothing changes, and calling | |
# the context functions isn't necessary. | |
# Three functions have been added to work with contexts: | |
# --- sg_context sg_setup_context(): | |
# This must be called once after a GL context has been created and | |
# made active. | |
# --- void sg_activate_context(sg_context ctx) | |
# This must be called after making a different GL context active. | |
# Apart from 3D-API-specific actions, the call to sg_activate_context() | |
# will internally call sg_reset_state_cache(). | |
# --- void sg_discard_context(sg_context ctx) | |
# This must be called right before a GL context is destroyed and | |
# will destroy all resources associated with the context (that | |
# have been created while the context was active) The GL context must be | |
# active at the time sg_discard_context(sg_context ctx) is called. | |
# Also note that resources (buffers, images, shaders and pipelines) must | |
# only be used or destroyed while the same GL context is active that | |
# was also active while the resource was created (an exception is | |
# resource sharing on GL, such resources can be used while | |
# another context is active, but must still be destroyed under | |
# the same context that was active during creation). | |
# For more information, check out the multiwindow-glfw sample: | |
# https:github.com/floooh/sokol-samples/blob/master/glfw/multiwindow-glfw.c | |
# TRACE HOOKS: | |
# ============ | |
# sokol_gfx.h optionally allows to install "trace hook" callbacks for | |
# each public API functions. When a public API function is called, and | |
# a trace hook callback has been installed for this function, the | |
# callback will be invoked with the parameters and result of the function. | |
# This is useful for things like debugging- and profiling-tools, or | |
# keeping track of resource creation and destruction. | |
# To use the trace hook feature: | |
# --- Define SOKOL_TRACE_HOOKS before including the implementation. | |
# --- Setup an sg_trace_hooks structure with your callback function | |
# pointers (keep all function pointers you're not interested | |
# in zero-initialized), optionally set the user_data member | |
# in the sg_trace_hooks struct. | |
# --- Install the trace hooks by calling sg_install_trace_hooks(), | |
# the return value of this function is another sg_trace_hooks | |
# struct which contains the previously set of trace hooks. | |
# You should keep this struct around, and call those previous | |
# functions pointers from your own trace callbacks for proper | |
# chaining. | |
# As an example of how trace hooks are used, have a look at the | |
# imgui/sokol_gfx_imgui.h header which implements a realtime | |
# debugging UI for sokol_gfx.h on top of Dear ImGui. | |
# A NOTE ON PORTABLE PACKED VERTEX FORMATS: | |
# ========================================= | |
# There are two things to consider when using packed | |
# vertex formats like UBYTE4, SHORT2, etc which need to work | |
# across all backends: | |
# - D3D11 can only convert *normalized* vertex formats to | |
# floating point during vertex fetch, normalized formats | |
# have a trailing 'N', and are "normalized" to a range | |
# -1.0..+1.0 (for the signed formats) or 0.0..1.0 (for the | |
# unsigned formats): | |
# - SG_VERTEXFORMAT_BYTE4N | |
# - SG_VERTEXFORMAT_UBYTE4N | |
# - SG_VERTEXFORMAT_SHORT2N | |
# - SG_VERTEXFORMAT_USHORT2N | |
# - SG_VERTEXFORMAT_SHORT4N | |
# - SG_VERTEXFORMAT_USHORT4N | |
# D3D11 will not convert *non-normalized* vertex formats to floating point | |
# vertex shader inputs, those can only be uses with the *ivecn* vertex shader | |
# input types when D3D11 is used as backend (GL and Metal can use both formats) | |
# - SG_VERTEXFORMAT_BYTE4, | |
# - SG_VERTEXFORMAT_UBYTE4 | |
# - SG_VERTEXFORMAT_SHORT2 | |
# - SG_VERTEXFORMAT_SHORT4 | |
# - WebGL/GLES2 cannot use integer vertex shader inputs (int or ivecn) | |
# - SG_VERTEXFORMAT_UINT10_N2 is not supported on WebGL/GLES2 | |
# So for a vertex input layout which works on all platforms, only use the following | |
# vertex formats, and if needed "expand" the normalized vertex shader | |
# inputs in the vertex shader by multiplying with 127.0, 255.0, 32767.0 or | |
# 65535.0: | |
# - SG_VERTEXFORMAT_FLOAT, | |
# - SG_VERTEXFORMAT_FLOAT2, | |
# - SG_VERTEXFORMAT_FLOAT3, | |
# - SG_VERTEXFORMAT_FLOAT4, | |
# - SG_VERTEXFORMAT_BYTE4N, | |
# - SG_VERTEXFORMAT_UBYTE4N, | |
# - SG_VERTEXFORMAT_SHORT2N, | |
# - SG_VERTEXFORMAT_USHORT2N | |
# - SG_VERTEXFORMAT_SHORT4N, | |
# - SG_VERTEXFORMAT_USHORT4N | |
# TODO: | |
# ==== | |
# - talk about asynchronous resource creation | |
# zlib/libpng license | |
# Copyright (c) 2018 Andre Weissflog | |
# This software is provided 'as-is', without any express or implied warranty. | |
# In no event will the authors be held liable for any damages arising from the | |
# use of this software. | |
# Permission is granted to anyone to use this software for any purpose, | |
# including commercial applications, and to alter it and redistribute it | |
# freely, subject to the following restrictions: | |
# 1. The origin of this software must not be misrepresented; you must not | |
# claim that you wrote the original software. If you use this software in a | |
# product, an acknowledgment in the product documentation would be | |
# appreciated but is not required. | |
# 2. Altered source versions must be plainly marked as such, and must not | |
# be misrepresented as being the original software. | |
# 3. This notice may not be removed or altered from any source | |
# distribution. | |
# | |
# | |
# Resource id typedefs: | |
# sg_buffer: vertex- and index-buffers | |
# sg_image: textures and render targets | |
# sg_shader: vertex- and fragment-shaders, uniform blocks | |
# sg_pipeline: associated shader and vertex-layouts, and render states | |
# sg_pass: a bundle of render targets and actions on them | |
# sg_context: a 'context handle' for switching between 3D-API contexts | |
# Instead of pointers, resource creation functions return a 32-bit | |
# number which uniquely identifies the resource object. | |
# The 32-bit resource id is split into a 16-bit pool index in the lower bits, | |
# and a 16-bit 'unique counter' in the upper bits. The index allows fast | |
# pool lookups, and combined with the unique-mask it allows to detect | |
# 'dangling accesses' (trying to use an object which no longer exists, and | |
# its pool slot has been reused for a new object) | |
# The resource ids are wrapped into a struct so that the compiler | |
# can complain when the wrong resource type is used. | |
# | |
sg_buffer* {.importc: "struct sg_buffer", header: headersokol_gfx, bycopy.} = object | |
id*: uint32 | |
sg_image* {.importc: "struct sg_image", header: headersokol_gfx, bycopy.} = object | |
id*: uint32 | |
sg_shader* {.importc: "struct sg_shader", header: headersokol_gfx, bycopy.} = object | |
id*: uint32 | |
sg_pipeline* {.importc: "struct sg_pipeline", header: headersokol_gfx, bycopy.} = object | |
id*: uint32 | |
sg_pass* {.importc: "struct sg_pass", header: headersokol_gfx, bycopy.} = object | |
id*: uint32 | |
sg_context* {.importc: "struct sg_context", header: headersokol_gfx, bycopy.} = object | |
id*: uint32 | |
# | |
# Runtime information about a pixel format, returned | |
# by sg_query_pixelformat(). | |
# | |
sg_pixelformat_info* {.importc: "struct sg_pixelformat_info", header: headersokol_gfx, bycopy.} = object | |
sample*: bool | |
filter*: bool | |
render*: bool | |
blend*: bool | |
msaa*: bool | |
depth*: bool | |
# | |
# Runtime information about available optional features, | |
# returned by sg_query_features() | |
# | |
sg_features* {.importc: "struct sg_features", header: headersokol_gfx, bycopy.} = object | |
instancing*: bool | |
origin_top_left*: bool | |
multiple_render_targets*: bool | |
msaa_render_targets*: bool | |
imagetype_3d*: bool | |
imagetype_array*: bool | |
image_clamp_to_border*: bool | |
# | |
# Runtime information about resource limits, returned by sg_query_limit() | |
# | |
sg_limits* {.importc: "struct sg_limits", header: headersokol_gfx, bycopy.} = object | |
max_image_size_2d*: uint32 | |
max_image_size_cube*: uint32 | |
max_image_size_3d*: uint32 | |
max_image_size_array*: uint32 | |
max_image_array_layers*: uint32 | |
max_vertex_attrs*: uint32 | |
# | |
# sg_pass_action | |
# The sg_pass_action struct defines the actions to be performed | |
# at the start of a rendering pass in the functions sg_begin_pass() | |
# and sg_begin_default_pass(). | |
# A separate action and clear values can be defined for each | |
# color attachment, and for the depth-stencil attachment. | |
# The default clear values are defined by the macros: | |
# - SG_DEFAULT_CLEAR_RED: 0.5f | |
# - SG_DEFAULT_CLEAR_GREEN: 0.5f | |
# - SG_DEFAULT_CLEAR_BLUE: 0.5f | |
# - SG_DEFAULT_CLEAR_ALPHA: 1.0f | |
# - SG_DEFAULT_CLEAR_DEPTH: 1.0f | |
# - SG_DEFAULT_CLEAR_STENCIL: 0 | |
# | |
sg_color_attachment_action* {.importc: "struct sg_color_attachment_action", header: headersokol_gfx, bycopy.} = object | |
action*: sg_action | |
val*: array[4, cfloat] | |
sg_depth_attachment_action* {.importc: "struct sg_depth_attachment_action", header: headersokol_gfx, bycopy.} = object | |
action*: sg_action | |
val*: cfloat | |
sg_stencil_attachment_action* {.importc: "struct sg_stencil_attachment_action", header: headersokol_gfx, bycopy.} = object | |
action*: sg_action | |
val*: uint8 | |
sg_pass_action* {.importc: "struct sg_pass_action", header: headersokol_gfx, bycopy.} = object | |
start_canary*: uint32 | |
colors*: array[SG_MAX_COLOR_ATTACHMENTS, sg_color_attachment_action] | |
depth*: sg_depth_attachment_action | |
stencil*: sg_stencil_attachment_action | |
end_canary*: uint32 | |
# | |
# sg_bindings | |
# The sg_bindings structure defines the resource binding slots | |
# of the sokol_gfx render pipeline, used as argument to the | |
# sg_apply_bindings() function. | |
# A resource binding struct contains: | |
# - 1..N vertex buffers | |
# - 0..N vertex buffer offsets | |
# - 0..1 index buffers | |
# - 0..1 index buffer offsets | |
# - 0..N vertex shader stage images | |
# - 0..N fragment shader stage images | |
# The max number of vertex buffer and shader stage images | |
# are defined by the SG_MAX_SHADERSTAGE_BUFFERS and | |
# SG_MAX_SHADERSTAGE_IMAGES configuration constants. | |
# The optional buffer offsets can be used to put different unrelated | |
# chunks of vertex- and/or index-data into the same buffer objects. | |
# | |
sg_bindings* {.importc: "struct sg_bindings", header: headersokol_gfx, bycopy.} = object | |
start_canary*: uint32 | |
vertex_buffers*: array[SG_MAX_SHADERSTAGE_BUFFERS, sg_buffer] | |
vertex_buffer_offsets*: array[SG_MAX_SHADERSTAGE_BUFFERS, cint] | |
index_buffer*: sg_buffer | |
index_buffer_offset*: cint | |
vs_images*: array[SG_MAX_SHADERSTAGE_IMAGES, sg_image] | |
fs_images*: array[SG_MAX_SHADERSTAGE_IMAGES, sg_image] | |
end_canary*: uint32 | |
# | |
# sg_buffer_desc | |
# Creation parameters for sg_buffer objects, used in the | |
# sg_make_buffer() call. | |
# The default configuration is: | |
# .size: 0 (this *must* be set to a valid size in bytes) | |
# .type: SG_BUFFERTYPE_VERTEXBUFFER | |
# .usage: SG_USAGE_IMMUTABLE | |
# .content 0 | |
# .label 0 (optional string label for trace hooks) | |
# The label will be ignored by sokol_gfx.h, it is only useful | |
# when hooking into sg_make_buffer() or sg_init_buffer() via | |
# the sg_install_trace_hooks() function. | |
# ADVANCED TOPIC: Injecting native 3D-API buffers: | |
# The following struct members allow to inject your own GL, Metal | |
# or D3D11 buffers into sokol_gfx: | |
# .gl_buffers[SG_NUM_INFLIGHT_FRAMES] | |
# .mtl_buffers[SG_NUM_INFLIGHT_FRAMES] | |
# .d3d11_buffer | |
# You must still provide all other members except the .content member, and | |
# these must match the creation parameters of the native buffers you | |
# provide. For SG_USAGE_IMMUTABLE, only provide a single native 3D-API | |
# buffer, otherwise you need to provide SG_NUM_INFLIGHT_FRAMES buffers | |
# (only for GL and Metal, not D3D11). Providing multiple buffers for GL and | |
# Metal is necessary because sokol_gfx will rotate through them when | |
# calling sg_update_buffer() to prevent lock-stalls. | |
# Note that it is expected that immutable injected buffer have already been | |
# initialized with content, and the .content member must be 0! | |
# Also you need to call sg_reset_state_cache() after calling native 3D-API | |
# functions, and before calling any sokol_gfx function. | |
# | |
sg_buffer_desc* {.importc: "struct sg_buffer_desc", header: headersokol_gfx, bycopy.} = object | |
start_canary*: uint32 | |
size*: cint | |
`type`*: sg_buffer_type | |
usage*: sg_usage | |
content*: pointer | |
label*: cstring | |
gl_buffers*: array[SG_NUM_INFLIGHT_FRAMES, uint32] | |
mtl_buffers*: array[SG_NUM_INFLIGHT_FRAMES, pointer] | |
d3d11_buffer*: pointer | |
end_canary*: uint32 | |
# | |
# sg_subimage_content | |
# Pointer to and size of a subimage-surface data, this is | |
# used to describe the initial content of immutable-usage images, | |
# or for updating a dynamic- or stream-usage images. | |
# For 3D- or array-textures, one sg_subimage_content item | |
# describes an entire mipmap level consisting of all array- or | |
# 3D-slices of the mipmap level. It is only possible to update | |
# an entire mipmap level, not parts of it. | |
# | |
sg_subimage_content* {.importc: "struct sg_subimage_content", header: headersokol_gfx, bycopy.} = object | |
`ptr`*: pointer | |
size*: cint | |
# | |
# sg_image_content | |
# Defines the content of an image through a 2D array | |
# of sg_subimage_content structs. The first array dimension | |
# is the cubemap face, and the second array dimension the | |
# mipmap level. | |
# | |
sg_image_content* {.bycopy.} = object | |
subimage: array[SG_CUBEFACE_NUM, array[SG_MAX_MIPMAPS, sg_subimage_content]] | |
# | |
# sg_image_desc | |
# Creation parameters for sg_image objects, used in the | |
# sg_make_image() call. | |
# The default configuration is: | |
# .type: SG_IMAGETYPE_2D | |
# .render_target: false | |
# .width 0 (must be set to >0) | |
# .height 0 (must be set to >0) | |
# .depth/.layers: 1 | |
# .num_mipmaps: 1 | |
# .usage: SG_USAGE_IMMUTABLE | |
# .pixel_format: SG_PIXELFORMAT_RGBA8 for textures, backend-dependent | |
# for render targets (RGBA8 or BGRA8) | |
# .sample_count: 1 (only used in render_targets) | |
# .min_filter: SG_FILTER_NEAREST | |
# .mag_filter: SG_FILTER_NEAREST | |
# .wrap_u: SG_WRAP_REPEAT | |
# .wrap_v: SG_WRAP_REPEAT | |
# .wrap_w: SG_WRAP_REPEAT (only SG_IMAGETYPE_3D) | |
# .border_color SG_BORDERCOLOR_OPAQUE_BLACK | |
# .max_anisotropy 1 (must be 1..16) | |
# .min_lod 0.0f | |
# .max_lod FLT_MAX | |
# .content an sg_image_content struct to define the initial content | |
# .label 0 (optional string label for trace hooks) | |
# SG_IMAGETYPE_ARRAY and SG_IMAGETYPE_3D are not supported on | |
# WebGL/GLES2, use sg_query_features().imagetype_array and | |
# sg_query_features().imagetype_3d at runtime to check | |
# if array- and 3D-textures are supported. | |
# Images with usage SG_USAGE_IMMUTABLE must be fully initialized by | |
# providing a valid .content member which points to | |
# initialization data. | |
# ADVANCED TOPIC: Injecting native 3D-API textures: | |
# The following struct members allow to inject your own GL, Metal | |
# or D3D11 textures into sokol_gfx: | |
# .gl_textures[SG_NUM_INFLIGHT_FRAMES] | |
# .mtl_textures[SG_NUM_INFLIGHT_FRAMES] | |
# .d3d11_texture | |
# The same rules apply as for injecting native buffers | |
# (see sg_buffer_desc documentation for more details). | |
# | |
sg_image_desc* {.bycopy.} = object | |
start_canary*: uint32 | |
`type`*: sg_image_type | |
render_target*: bool | |
width*: cint | |
height*: cint | |
ano_c2nim_10*: INNER_C_UNION_c2nim_8 | |
num_mipmaps*: cint | |
usage*: sg_usage | |
pixel_format*: sg_pixel_format | |
sample_count*: cint | |
min_filter*: sg_filter | |
mag_filter*: sg_filter | |
wrap_u*: sg_wrap | |
wrap_v*: sg_wrap | |
wrap_w*: sg_wrap | |
border_color*: sg_border_color | |
max_anisotropy*: uint32 | |
min_lod*: cfloat | |
max_lod*: cfloat | |
content*: sg_image_content | |
label*: cstring ## GL specific | |
gl_textures*: array[SG_NUM_INFLIGHT_FRAMES, uint32] ## Metal specific | |
mtl_textures*: array[SG_NUM_INFLIGHT_FRAMES, pointer] ## D3D11 specific | |
d3d11_texture*: pointer | |
end_canary*: uint32 | |
# | |
# sg_shader_desc | |
# The structure sg_shader_desc defines all creation parameters | |
# for shader programs, used as input to the sg_make_shader() function: | |
# - reflection information for vertex attributes (vertex shader inputs): | |
# - vertex attribute name (required for GLES2, optional for GLES3 and GL) | |
# - a semantic name and index (required for D3D11) | |
# - for each vertex- and fragment-shader-stage: | |
# - the shader source or bytecode | |
# - an optional entry function name | |
# - reflection info for each uniform block used by the shader stage: | |
# - the size of the uniform block in bytes | |
# - reflection info for each uniform block member (only required for GL backends): | |
# - member name | |
# - member type (SG_UNIFORMTYPE_xxx) | |
# - if the member is an array, the number of array items | |
# - reflection info for the texture images used by the shader stage: | |
# - the image type (SG_IMAGETYPE_xxx) | |
# - the name of the texture sampler (required for GLES2, optional everywhere else) | |
# For all GL backends, shader source-code must be provided. For D3D11 and Metal, | |
# either shader source-code or byte-code can be provided. | |
# For D3D11, if source code is provided, the d3dcompiler_47.dll will be loaded | |
# on demand. If this fails, shader creation will fail. | |
# | |
sg_shader_attr_desc* {.importc: "struct sg_shader_attr_desc", header: headersokol_gfx, bycopy.} = object | |
name*: cstring | |
sem_name*: cstring | |
sem_index*: cint | |
sg_shader_uniform_desc* {.importc: "struct sg_shader_uniform_desc", header: headersokol_gfx, bycopy.} = object | |
name*: cstring | |
`type`*: sg_uniform_type | |
array_count*: cint | |
sg_shader_uniform_block_desc* {.importc: "struct sg_shader_uniform_block_desc", header: headersokol_gfx, bycopy.} = object | |
size*: cint | |
uniforms*: array[SG_MAX_UB_MEMBERS, sg_shader_uniform_desc] | |
sg_shader_image_desc* {.importc: "struct sg_shader_image_desc", header: headersokol_gfx, bycopy.} = object | |
name*: cstring | |
`type`*: sg_image_type | |
sg_shader_stage_desc* {.importc: "struct sg_shader_stage_desc", header: headersokol_gfx, bycopy.} = object | |
source*: cstring | |
byte_code*: ptr uint8 | |
byte_code_size*: cint | |
entry*: cstring | |
uniform_blocks*: array[SG_MAX_SHADERSTAGE_UBS, sg_shader_uniform_block_desc] | |
images*: array[SG_MAX_SHADERSTAGE_IMAGES, sg_shader_image_desc] | |
sg_shader_desc* {.importc: "struct sg_shader_desc", header: headersokol_gfx, bycopy.} = object | |
start_canary*: uint32 | |
attrs*: array[SG_MAX_VERTEX_ATTRIBUTES, sg_shader_attr_desc] | |
vs*: sg_shader_stage_desc | |
fs*: sg_shader_stage_desc | |
label*: cstring | |
end_canary*: uint32 | |
# | |
# sg_pipeline_desc | |
# The sg_pipeline_desc struct defines all creation parameters | |
# for an sg_pipeline object, used as argument to the | |
# sg_make_pipeline() function: | |
# - the vertex layout for all input vertex buffers | |
# - a shader object | |
# - the 3D primitive type (points, lines, triangles, ...) | |
# - the index type (none, 16- or 32-bit) | |
# - depth-stencil state | |
# - alpha-blending state | |
# - rasterizer state | |
# If the vertex data has no gaps between vertex components, you can omit | |
# the .layout.buffers[].stride and layout.attrs[].offset items (leave them | |
# default-initialized to 0), sokol-gfx will then compute the offsets and strides | |
# from the vertex component formats (.layout.attrs[].format). Please note | |
# that ALL vertex attribute offsets must be 0 in order for the | |
# automatic offset computation to kick in. | |
# The default configuration is as follows: | |
# .layout: | |
# .buffers[]: vertex buffer layouts | |
# .stride: 0 (if no stride is given it will be computed) | |
# .step_func SG_VERTEXSTEP_PER_VERTEX | |
# .step_rate 1 | |
# .attrs[]: vertex attribute declarations | |
# .buffer_index 0 the vertex buffer bind slot | |
# .offset 0 (offsets can be omitted if the vertex layout has no gaps) | |
# .format SG_VERTEXFORMAT_INVALID (must be initialized!) | |
# .shader: 0 (must be initialized with a valid sg_shader id!) | |
# .primitive_type: SG_PRIMITIVETYPE_TRIANGLES | |
# .index_type: SG_INDEXTYPE_NONE | |
# .depth_stencil: | |
# .stencil_front, .stencil_back: | |
# .fail_op: SG_STENCILOP_KEEP | |
# .depth_fail_op: SG_STENCILOP_KEEP | |
# .pass_op: SG_STENCILOP_KEEP | |
# .compare_func SG_COMPAREFUNC_ALWAYS | |
# .depth_compare_func: SG_COMPAREFUNC_ALWAYS | |
# .depth_write_enabled: false | |
# .stencil_enabled: false | |
# .stencil_read_mask: 0 | |
# .stencil_write_mask: 0 | |
# .stencil_ref: 0 | |
# .blend: | |
# .enabled: false | |
# .src_factor_rgb: SG_BLENDFACTOR_ONE | |
# .dst_factor_rgb: SG_BLENDFACTOR_ZERO | |
# .op_rgb: SG_BLENDOP_ADD | |
# .src_factor_alpha: SG_BLENDFACTOR_ONE | |
# .dst_factor_alpha: SG_BLENDFACTOR_ZERO | |
# .op_alpha: SG_BLENDOP_ADD | |
# .color_write_mask: SG_COLORMASK_RGBA | |
# .color_attachment_count 1 | |
# .color_format SG_PIXELFORMAT_RGBA8 | |
# .depth_format SG_PIXELFORMAT_DEPTHSTENCIL | |
# .blend_color: { 0.0f, 0.0f, 0.0f, 0.0f } | |
# .rasterizer: | |
# .alpha_to_coverage_enabled: false | |
# .cull_mode: SG_CULLMODE_NONE | |
# .face_winding: SG_FACEWINDING_CW | |
# .sample_count: 1 | |
# .depth_bias: 0.0f | |
# .depth_bias_slope_scale: 0.0f | |
# .depth_bias_clamp: 0.0f | |
# .label 0 (optional string label for trace hooks) | |
# | |
sg_buffer_layout_desc* {.importc: "struct sg_buffer_layout_desc", header: headersokol_gfx, bycopy.} = object | |
stride*: cint | |
step_func*: sg_vertex_step | |
step_rate*: cint | |
sg_vertex_attr_desc* {.importc: "struct sg_vertex_attr_desc", header: headersokol_gfx, bycopy.} = object | |
buffer_index*: cint | |
offset*: cint | |
format*: sg_vertex_format | |
sg_layout_desc* {.importc: "struct sg_layout_desc", header: headersokol_gfx, bycopy.} = object | |
buffers*: array[SG_MAX_SHADERSTAGE_BUFFERS, sg_buffer_layout_desc] | |
attrs*: array[SG_MAX_VERTEX_ATTRIBUTES, sg_vertex_attr_desc] | |
sg_stencil_state* {.importc: "struct sg_stencil_state", header: headersokol_gfx, bycopy.} = object | |
fail_op*: sg_stencil_op | |
depth_fail_op*: sg_stencil_op | |
pass_op*: sg_stencil_op | |
compare_func*: sg_compare_func | |
sg_depth_stencil_state* {.importc: "struct sg_depth_stencil_state", header: headersokol_gfx, bycopy.} = object | |
stencil_front*: sg_stencil_state | |
stencil_back*: sg_stencil_state | |
depth_compare_func*: sg_compare_func | |
depth_write_enabled*: bool | |
stencil_enabled*: bool | |
stencil_read_mask*: uint8 | |
stencil_write_mask*: uint8 | |
stencil_ref*: uint8 | |
sg_blend_state* {.importc: "struct sg_blend_state", header: headersokol_gfx, bycopy.} = object | |
enabled*: bool | |
src_factor_rgb*: sg_blend_factor | |
dst_factor_rgb*: sg_blend_factor | |
op_rgb*: sg_blend_op | |
src_factor_alpha*: sg_blend_factor | |
dst_factor_alpha*: sg_blend_factor | |
op_alpha*: sg_blend_op | |
color_write_mask*: uint8 | |
color_attachment_count*: cint | |
color_format*: sg_pixel_format | |
depth_format*: sg_pixel_format | |
blend_color*: array[4, cfloat] | |
sg_rasterizer_state* {.importc: "struct sg_rasterizer_state", header: headersokol_gfx, bycopy.} = object | |
alpha_to_coverage_enabled*: bool | |
cull_mode*: sg_cull_mode | |
face_winding*: sg_face_winding | |
sample_count*: cint | |
depth_bias*: cfloat | |
depth_bias_slope_scale*: cfloat | |
depth_bias_clamp*: cfloat | |
sg_pipeline_desc* {.importc: "struct sg_pipeline_desc", header: headersokol_gfx, bycopy.} = object | |
start_canary*: uint32 | |
layout*: sg_layout_desc | |
shader*: sg_shader | |
primitive_type*: sg_primitive_type | |
index_type*: sg_index_type | |
depth_stencil*: sg_depth_stencil_state | |
blend*: sg_blend_state | |
rasterizer*: sg_rasterizer_state | |
label*: cstring | |
end_canary*: uint32 | |
# | |
# sg_pass_desc | |
# Creation parameters for an sg_pass object, used as argument | |
# to the sg_make_pass() function. | |
# A pass object contains 1..4 color-attachments and none, or one, | |
# depth-stencil-attachment. Each attachment consists of | |
# an image, and two additional indices describing | |
# which subimage the pass will render to: one mipmap index, and | |
# if the image is a cubemap, array-texture or 3D-texture, the | |
# face-index, array-layer or depth-slice. | |
# Pass images must fulfill the following requirements: | |
# All images must have: | |
# - been created as render target (sg_image_desc.render_target = true) | |
# - the same size | |
# - the same sample count | |
# In addition, all color-attachment images must have the same pixel format. | |
# | |
sg_attachment_desc* {.bycopy.} = object | |
image*: sg_image | |
mip_level*: cint | |
ano_c2nim_8*: INNER_C_UNION_c2nim_5 | |
sg_pass_desc* {.importc: "struct sg_pass_desc", header: headersokol_gfx, bycopy.} = object | |
start_canary*: uint32 | |
color_attachments*: array[SG_MAX_COLOR_ATTACHMENTS, sg_attachment_desc] | |
depth_stencil_attachment*: sg_attachment_desc | |
label*: cstring | |
end_canary*: uint32 | |
# | |
# sg_trace_hooks | |
# Installable callback functions to keep track of the sokol-gfx calls, | |
# this is useful for debugging, or keeping track of resource creation | |
# and destruction. | |
# Trace hooks are installed with sg_install_trace_hooks(), this returns | |
# another sg_trace_hooks struct with the previous set of | |
# trace hook function pointers. These should be invoked by the | |
# new trace hooks to form a proper call chain. | |
# | |
sg_trace_hooks* {.importc: "struct sg_trace_hooks", header: headersokol_gfx, bycopy.} = object | |
user_data*: pointer | |
reset_state_cache*: proc(user_data: pointer) {.cdecl.} | |
make_buffer*: proc(desc: ptr sg_buffer_desc, result: sg_buffer, user_data: pointer) {.cdecl.} | |
make_image*: proc(desc: ptr sg_image_desc, result: sg_image, user_data: pointer) {.cdecl.} | |
make_shader*: proc(desc: ptr sg_shader_desc, result: sg_shader, user_data: pointer) {.cdecl.} | |
make_pipeline*: proc(desc: ptr sg_pipeline_desc, result: sg_pipeline, user_data: pointer) {.cdecl.} | |
make_pass*: proc(desc: ptr sg_pass_desc, result: sg_pass, user_data: pointer) {.cdecl.} | |
destroy_buffer*: proc(buf: sg_buffer, user_data: pointer) {.cdecl.} | |
destroy_image*: proc(img: sg_image, user_data: pointer) {.cdecl.} | |
destroy_shader*: proc(shd: sg_shader, user_data: pointer) {.cdecl.} | |
destroy_pipeline*: proc(pip: sg_pipeline, user_data: pointer) {.cdecl.} | |
destroy_pass*: proc(pass: sg_pass, user_data: pointer) {.cdecl.} | |
update_buffer*: proc(buf: sg_buffer, data_ptr: pointer, data_size: cint, user_data: pointer) {.cdecl.} | |
update_image*: proc(img: sg_image, data: ptr sg_image_content, user_data: pointer) {.cdecl.} | |
append_buffer*: proc(buf: sg_buffer, data_ptr: pointer, data_size: cint, result: cint, user_data: pointer) {.cdecl.} | |
begin_default_pass*: proc(pass_action: ptr sg_pass_action, width: cint, height: cint, user_data: pointer) {.cdecl.} | |
begin_pass*: proc(pass: sg_pass, pass_action: ptr sg_pass_action, user_data: pointer) {.cdecl.} | |
apply_viewport*: proc(x: cint, y: cint, width: cint, height: cint, origin_top_left: bool, user_data: pointer) {.cdecl.} | |
apply_scissor_rect*: proc(x: cint, y: cint, width: cint, height: cint, origin_top_left: bool, user_data: pointer) {.cdecl.} | |
apply_pipeline*: proc(pip: sg_pipeline, user_data: pointer) {.cdecl.} | |
apply_bindings*: proc(bindings: ptr sg_bindings, user_data: pointer) {.cdecl.} | |
apply_uniforms*: proc(stage: sg_shader_stage, ub_index: cint, data: pointer, num_bytes: cint, user_data: pointer) {.cdecl.} | |
draw*: proc(base_element: cint, num_elements: cint, num_instances: cint, user_data: pointer) {.cdecl.} | |
end_pass*: proc(user_data: pointer) {.cdecl.} | |
commit*: proc(user_data: pointer) {.cdecl.} | |
alloc_buffer*: proc(result: sg_buffer, user_data: pointer) {.cdecl.} | |
alloc_image*: proc(result: sg_image, user_data: pointer) {.cdecl.} | |
alloc_shader*: proc(result: sg_shader, user_data: pointer) {.cdecl.} | |
alloc_pipeline*: proc(result: sg_pipeline, user_data: pointer) {.cdecl.} | |
alloc_pass*: proc(result: sg_pass, user_data: pointer) {.cdecl.} | |
init_buffer*: proc(buf_id: sg_buffer, desc: ptr sg_buffer_desc, user_data: pointer) {.cdecl.} | |
init_image*: proc(img_id: sg_image, desc: ptr sg_image_desc, user_data: pointer) {.cdecl.} | |
init_shader*: proc(shd_id: sg_shader, desc: ptr sg_shader_desc, user_data: pointer) {.cdecl.} | |
init_pipeline*: proc(pip_id: sg_pipeline, desc: ptr sg_pipeline_desc, user_data: pointer) {.cdecl.} | |
init_pass*: proc(pass_id: sg_pass, desc: ptr sg_pass_desc, user_data: pointer) {.cdecl.} | |
fail_buffer*: proc(buf_id: sg_buffer, user_data: pointer) {.cdecl.} | |
fail_image*: proc(img_id: sg_image, user_data: pointer) {.cdecl.} | |
fail_shader*: proc(shd_id: sg_shader, user_data: pointer) {.cdecl.} | |
fail_pipeline*: proc(pip_id: sg_pipeline, user_data: pointer) {.cdecl.} | |
fail_pass*: proc(pass_id: sg_pass, user_data: pointer) {.cdecl.} | |
push_debug_group*: proc(name: cstring, user_data: pointer) {.cdecl.} | |
pop_debug_group*: proc(user_data: pointer) {.cdecl.} | |
err_buffer_pool_exhausted*: proc(user_data: pointer) {.cdecl.} | |
err_image_pool_exhausted*: proc(user_data: pointer) {.cdecl.} | |
err_shader_pool_exhausted*: proc(user_data: pointer) {.cdecl.} | |
err_pipeline_pool_exhausted*: proc(user_data: pointer) {.cdecl.} | |
err_pass_pool_exhausted*: proc(user_data: pointer) {.cdecl.} | |
err_context_mismatch*: proc(user_data: pointer) {.cdecl.} | |
err_pass_invalid*: proc(user_data: pointer) {.cdecl.} | |
err_draw_invalid*: proc(user_data: pointer) {.cdecl.} | |
err_bindings_invalid*: proc(user_data: pointer) {.cdecl.} | |
# | |
# sg_buffer_info | |
# sg_image_info | |
# sg_shader_info | |
# sg_pipeline_info | |
# sg_pass_info | |
# These structs contain various internal resource attributes which | |
# might be useful for debug-inspection. Please don't rely on the | |
# actual content of those structs too much, as they are quite closely | |
# tied to sokol_gfx.h internals and may change more frequently than | |
# the other public API elements. | |
# The *_info structs are used as the return values of the following functions: | |
# sg_query_buffer_info() | |
# sg_query_image_info() | |
# sg_query_shader_info() | |
# sg_query_pipeline_info() | |
# sg_query_pass_info() | |
# | |
sg_slot_info* {.importc: "struct sg_slot_info", header: headersokol_gfx, bycopy.} = object | |
state*: sg_resource_state | |
res_id*: uint32 | |
ctx_id*: uint32 | |
sg_buffer_info* {.importc: "struct sg_buffer_info", header: headersokol_gfx, bycopy.} = object | |
slot*: sg_slot_info | |
update_frame_index*: uint32 | |
append_frame_index*: uint32 | |
append_pos*: cint | |
append_overflow*: bool | |
num_slots*: cint | |
active_slot*: cint | |
sg_image_info* {.importc: "struct sg_image_info", header: headersokol_gfx, bycopy.} = object | |
slot*: sg_slot_info | |
upd_frame_index*: uint32 | |
num_slots*: cint | |
active_slot*: cint | |
sg_shader_info* {.importc: "struct sg_shader_info", header: headersokol_gfx, bycopy.} = object | |
slot*: sg_slot_info | |
sg_pipeline_info* {.importc: "struct sg_pipeline_info", header: headersokol_gfx, bycopy.} = object | |
slot*: sg_slot_info | |
sg_pass_info* {.importc: "struct sg_pass_info", header: headersokol_gfx, bycopy.} = object | |
slot*: sg_slot_info | |
# | |
# sg_desc | |
# The sg_desc struct contains configuration values for sokol_gfx, | |
# it is used as parameter to the sg_setup() call. | |
# The default configuration is: | |
# .buffer_pool_size: 128 | |
# .image_pool_size: 128 | |
# .shader_pool_size: 32 | |
# .pipeline_pool_size: 64 | |
# .pass_pool_size: 16 | |
# .context_pool_size: 16 | |
# GL specific: | |
# .gl_force_gles2 | |
# if this is true the GL backend will act in "GLES2 fallback mode" even | |
# when compiled with SOKOL_GLES3, this is useful to fall back | |
# to traditional WebGL if a browser doesn't support a WebGL2 context | |
# Metal specific: | |
# (NOTE: All Objective-C object references are transferred through | |
# a bridged (const void*) to sokol_gfx, which will use a unretained | |
# bridged cast (__bridged id<xxx>) to retrieve the Objective-C | |
# references back. Since the bridge cast is unretained, the caller | |
# must hold a strong reference to the Objective-C object for the | |
# duration of the sokol_gfx call! | |
# .mtl_device | |
# a pointer to the MTLDevice object | |
# .mtl_renderpass_descriptor_cb | |
# a C callback function to obtain the MTLRenderPassDescriptor for the | |
# current frame when rendering to the default framebuffer, will be called | |
# in sg_begin_default_pass() | |
# .mtl_drawable_cb | |
# a C callback function to obtain a MTLDrawable for the current | |
# frame when rendering to the default framebuffer, will be called in | |
# sg_end_pass() of the default pass | |
# .mtl_global_uniform_buffer_size | |
# the size of the global uniform buffer in bytes, this must be big | |
# enough to hold all uniform block updates for a single frame, | |
# the default value is 4 MByte (4 * 1024 * 1024) | |
# .mtl_sampler_cache_size | |
# the number of slots in the sampler cache, the Metal backend | |
# will share texture samplers with the same state in this | |
# cache, the default value is 64 | |
# D3D11 specific: | |
# .d3d11_device | |
# a pointer to the ID3D11Device object, this must have been created | |
# before sg_setup() is called | |
# .d3d11_device_context | |
# a pointer to the ID3D11DeviceContext object | |
# .d3d11_render_target_view_cb | |
# a C callback function to obtain a pointer to the current | |
# ID3D11RenderTargetView object of the default framebuffer, | |
# this function will be called in sg_begin_pass() when rendering | |
# to the default framebuffer | |
# .d3d11_depth_stencil_view_cb | |
# a C callback function to obtain a pointer to the current | |
# ID3D11DepthStencilView object of the default framebuffer, | |
# this function will be called in sg_begin_pass() when rendering | |
# to the default framebuffer | |
# | |
sg_desc* {.importc: "struct sg_desc", header: headersokol_gfx, bycopy.} = object | |
start_canary*: uint32 | |
buffer_pool_size*: cint | |
image_pool_size*: cint | |
shader_pool_size*: cint | |
pipeline_pool_size*: cint | |
pass_pool_size*: cint | |
context_pool_size*: cint | |
gl_force_gles2*: bool | |
mtl_device*: pointer | |
mtl_renderpass_descriptor_cb*: proc(): pointer {.cdecl.} | |
mtl_drawable_cb*: proc(): pointer {.cdecl.} | |
mtl_global_uniform_buffer_size*: cint | |
mtl_sampler_cache_size*: cint | |
d3d11_device*: pointer | |
d3d11_device_context*: pointer | |
d3d11_render_target_view_cb*: proc(): pointer {.cdecl.} | |
d3d11_depth_stencil_view_cb*: proc(): pointer {.cdecl.} | |
end_canary*: uint32 | |
# setup and misc functions | |
proc sg_setup*(desc: ptr sg_desc) {.impsokol_gfxC.} | |
proc sg_shutdown*() {.impsokol_gfxC.} | |
proc sg_isvalid*(): bool {.impsokol_gfxC.} | |
proc sg_reset_state_cache*() {.impsokol_gfxC.} | |
proc sg_install_trace_hooks*(trace_hooks: ptr sg_trace_hooks): sg_trace_hooks {.impsokol_gfxC.} | |
proc sg_push_debug_group*(name: cstring) {.impsokol_gfxC.} | |
proc sg_pop_debug_group*() {.impsokol_gfxC.} | |
# resource creation, destruction and updating | |
proc sg_make_buffer*(desc: ptr sg_buffer_desc): sg_buffer {.impsokol_gfxC.} | |
proc sg_make_image*(desc: ptr sg_image_desc): sg_image {.impsokol_gfxC.} | |
proc sg_make_shader*(desc: ptr sg_shader_desc): sg_shader {.impsokol_gfxC.} | |
proc sg_make_pipeline*(desc: ptr sg_pipeline_desc): sg_pipeline {.impsokol_gfxC.} | |
proc sg_make_pass*(desc: ptr sg_pass_desc): sg_pass {.impsokol_gfxC.} | |
proc sg_destroy_buffer*(buf: sg_buffer) {.impsokol_gfxC.} | |
proc sg_destroy_image*(img: sg_image) {.impsokol_gfxC.} | |
proc sg_destroy_shader*(shd: sg_shader) {.impsokol_gfxC.} | |
proc sg_destroy_pipeline*(pip: sg_pipeline) {.impsokol_gfxC.} | |
proc sg_destroy_pass*(pass: sg_pass) {.impsokol_gfxC.} | |
proc sg_update_buffer*(buf: sg_buffer, data_ptr: pointer, data_size: cint) {.impsokol_gfxC.} | |
proc sg_update_image*(img: sg_image, data: ptr sg_image_content) {.impsokol_gfxC.} | |
proc sg_append_buffer*(buf: sg_buffer, data_ptr: pointer, data_size: cint): cint {.impsokol_gfxC.} | |
proc sg_query_buffer_overflow*(buf: sg_buffer): bool {.impsokol_gfxC.} | |
# rendering functions | |
proc sg_begin_default_pass*(pass_action: ptr sg_pass_action, width: cint, height: cint) {.impsokol_gfxC.} | |
proc sg_begin_pass*(pass: sg_pass, pass_action: ptr sg_pass_action) {.impsokol_gfxC.} | |
proc sg_apply_viewport*(x: cint, y: cint, width: cint, height: cint, origin_top_left: bool) {.impsokol_gfxC.} | |
proc sg_apply_scissor_rect*(x: cint, y: cint, width: cint, height: cint, origin_top_left: bool) {.impsokol_gfxC.} | |
proc sg_apply_pipeline*(pip: sg_pipeline) {.impsokol_gfxC.} | |
proc sg_apply_bindings*(bindings: ptr sg_bindings) {.impsokol_gfxC.} | |
proc sg_apply_uniforms*(stage: sg_shader_stage, ub_index: cint, data: pointer, num_bytes: cint) {.impsokol_gfxC.} | |
proc sg_draw*(base_element: cint, num_elements: cint, num_instances: cint) {.impsokol_gfxC.} | |
proc sg_end_pass*() {.impsokol_gfxC.} | |
proc sg_commit*() {.impsokol_gfxC.} | |
# getting information | |
proc sg_query_desc*(): sg_desc {.impsokol_gfxC.} | |
proc sg_query_backend*(): sg_backend {.impsokol_gfxC.} | |
proc sg_query_features*(): sg_features {.impsokol_gfxC.} | |
proc sg_query_limits*(): sg_limits {.impsokol_gfxC.} | |
proc sg_query_pixelformat*(fmt: sg_pixel_format): sg_pixelformat_info {.impsokol_gfxC.} | |
# get current state of a resource (INITIAL, ALLOC, VALID, FAILED, INVALID) | |
proc sg_query_buffer_state*(buf: sg_buffer): sg_resource_state {.impsokol_gfxC.} | |
proc sg_query_image_state*(img: sg_image): sg_resource_state {.impsokol_gfxC.} | |
proc sg_query_shader_state*(shd: sg_shader): sg_resource_state {.impsokol_gfxC.} | |
proc sg_query_pipeline_state*(pip: sg_pipeline): sg_resource_state {.impsokol_gfxC.} | |
proc sg_query_pass_state*(pass: sg_pass): sg_resource_state {.impsokol_gfxC.} | |
# get runtime information about a resource | |
proc sg_query_buffer_info*(buf: sg_buffer): sg_buffer_info {.impsokol_gfxC.} | |
proc sg_query_image_info*(img: sg_image): sg_image_info {.impsokol_gfxC.} | |
proc sg_query_shader_info*(shd: sg_shader): sg_shader_info {.impsokol_gfxC.} | |
proc sg_query_pipeline_info*(pip: sg_pipeline): sg_pipeline_info {.impsokol_gfxC.} | |
proc sg_query_pass_info*(pass: sg_pass): sg_pass_info {.impsokol_gfxC.} | |
# get resource creation desc struct with their default values replaced | |
proc sg_query_buffer_defaults*(desc: ptr sg_buffer_desc): sg_buffer_desc {.impsokol_gfxC.} | |
proc sg_query_image_defaults*(desc: ptr sg_image_desc): sg_image_desc {.impsokol_gfxC.} | |
proc sg_query_shader_defaults*(desc: ptr sg_shader_desc): sg_shader_desc {.impsokol_gfxC.} | |
proc sg_query_pipeline_defaults*(desc: ptr sg_pipeline_desc): sg_pipeline_desc {.impsokol_gfxC.} | |
proc sg_query_pass_defaults*(desc: ptr sg_pass_desc): sg_pass_desc {.impsokol_gfxC.} | |
# separate resource allocation and initialization (for async setup) | |
proc sg_alloc_buffer*(): sg_buffer {.impsokol_gfxC.} | |
proc sg_alloc_image*(): sg_image {.impsokol_gfxC.} | |
proc sg_alloc_shader*(): sg_shader {.impsokol_gfxC.} | |
proc sg_alloc_pipeline*(): sg_pipeline {.impsokol_gfxC.} | |
proc sg_alloc_pass*(): sg_pass {.impsokol_gfxC.} | |
proc sg_init_buffer*(buf_id: sg_buffer, desc: ptr sg_buffer_desc) {.impsokol_gfxC.} | |
proc sg_init_image*(img_id: sg_image, desc: ptr sg_image_desc) {.impsokol_gfxC.} | |
proc sg_init_shader*(shd_id: sg_shader, desc: ptr sg_shader_desc) {.impsokol_gfxC.} | |
proc sg_init_pipeline*(pip_id: sg_pipeline, desc: ptr sg_pipeline_desc) {.impsokol_gfxC.} | |
proc sg_init_pass*(pass_id: sg_pass, desc: ptr sg_pass_desc) {.impsokol_gfxC.} | |
proc sg_fail_buffer*(buf_id: sg_buffer) {.impsokol_gfxC.} | |
proc sg_fail_image*(img_id: sg_image) {.impsokol_gfxC.} | |
proc sg_fail_shader*(shd_id: sg_shader) {.impsokol_gfxC.} | |
proc sg_fail_pipeline*(pip_id: sg_pipeline) {.impsokol_gfxC.} | |
proc sg_fail_pass*(pass_id: sg_pass) {.impsokol_gfxC.} | |
# rendering contexts (optional) | |
proc sg_setup_context*(): sg_context {.impsokol_gfxC.} | |
proc sg_activate_context*(ctx_id: sg_context) {.impsokol_gfxC.} | |
proc sg_discard_context*(ctx_id: sg_context) {.impsokol_gfxC.} | |
# Importing /Users/zacharycarter/dev/junkers/lib/sokol/sokol_app.h | |
# Generated at 2020-04-07T22:54:24-05:00 | |
# Command line: | |
# /Users/zacharycarter/.nimble/pkgs/nimterop-0.4.4/nimterop/toast --preprocess --pnim --symOverride=INNER_C_UNION_c2nim_5,sg_attachment_desc,sg_image_content,INNER_C_UNION_c2nim_8,sg_image_desc --nim:/Users/zacharycarter/.choosenim/toolchains/nim-#devel/bin/nim --pluginSourcePath=/Users/zacharycarter/.cache/nim/nimterop/cPlugins/nimterop_2793949904.nim /Users/zacharycarter/dev/junkers/lib/sokol/sokol_app.h | |
{.hint[ConvFromXtoItselfNotNeeded]: off.} | |
import nimterop/types | |
# | |
# sokol_app.h -- cross-platform application wrapper | |
# Project URL: https:github.com/floooh/sokol | |
# Do this: | |
# #define SOKOL_IMPL | |
# before you include this file in *one* C or C++ file to create the | |
# implementation. | |
# Optionally provide the following defines with your own implementations: | |
# SOKOL_ASSERT(c) - your own assert macro (default: assert(c)) | |
# SOKOL_LOG(msg) - your own logging function (default: puts(msg)) | |
# SOKOL_UNREACHABLE() - a guard macro for unreachable code (default: assert(false)) | |
# SOKOL_ABORT() - called after an unrecoverable error (default: abort()) | |
# SOKOL_WIN32_FORCE_MAIN - define this on Win32 to use a main() entry point instead of WinMain | |
# SOKOL_NO_ENTRY - define this if sokol_app.h shouldn't "hijack" the main() function | |
# SOKOL_API_DECL - public function declaration prefix (default: extern) | |
# SOKOL_API_IMPL - public function implementation prefix (default: -) | |
# SOKOL_CALLOC - your own calloc function (default: calloc(n, s)) | |
# SOKOL_FREE - your own free function (default: free(p)) | |
# Optionally define the following to force debug checks and validations | |
# even in release mode: | |
# SOKOL_DEBUG - by default this is defined if _DEBUG is defined | |
# If sokol_app.h is compiled as a DLL, define the following before | |
# including the declaration or implementation: | |
# SOKOL_DLL | |
# On Windows, SOKOL_DLL will define SOKOL_API_DECL as __declspec(dllexport) | |
# or __declspec(dllimport) as needed. | |
# Portions of the Windows and Linux GL initialization and event code have been | |
# taken from GLFW (http:www.glfw.org/) | |
# iOS onscreen keyboard support 'inspired' by libgdx. | |
# If you use sokol_app.h together with sokol_gfx.h, include both headers | |
# in the implementation source file, and include sokol_app.h before | |
# sokol_gfx.h since sokol_app.h will also include the required 3D-API | |
# headers. | |
# On Windows, a minimal 'GL header' and function loader is integrated which | |
# contains just enough of GL for sokol_gfx.h. If you want to use your own | |
# GL header-generator/loader instead, define SOKOL_WIN32_NO_GL_LOADER | |
# before including the implementation part of sokol_app.h. | |
# For example code, see https:github.com/floooh/sokol-samples/tree/master/sapp | |
# FEATURE OVERVIEW | |
# ================ | |
# sokol_app.h provides a minimalistic cross-platform API which | |
# implements the 'application-wrapper' parts of a 3D application: | |
# - a common application entry function | |
# - creates a window and 3D-API context/device with a 'default framebuffer' | |
# - makes the rendered frame visible | |
# - provides keyboard-, mouse- and low-level touch-events | |
# - platforms: MacOS, iOS, HTML5, Win32, Linux, Android (TODO: RaspberryPi) | |
# - 3D-APIs: Metal, D3D11, GL3.2, GLES2, GLES3, WebGL, WebGL2 | |
# FEATURE/PLATFORM MATRIX | |
# ======================= | |
# | Windows | macOS | Linux | iOS | Android | Raspi | HTML5 | |
# --------------------+---------+-------+-------+-------+---------+-------+------- | |
# gl 3.x | YES | YES | YES | --- | --- | --- | --- | |
# gles2/webgl | --- | --- | --- | YES | YES | TODO | YES | |
# gles3/webgl2 | --- | --- | --- | YES | YES | --- | YES | |
# metal | --- | YES | --- | YES | --- | --- | --- | |
# d3d11 | YES | --- | --- | --- | --- | --- | --- | |
# KEY_DOWN | YES | YES | YES | SOME | TODO | TODO | YES | |
# KEY_UP | YES | YES | YES | SOME | TODO | TODO | YES | |
# CHAR | YES | YES | YES | YES | TODO | TODO | YES | |
# MOUSE_DOWN | YES | YES | YES | --- | --- | TODO | YES | |
# MOUSE_UP | YES | YES | YES | --- | --- | TODO | YES | |
# MOUSE_SCROLL | YES | YES | YES | --- | --- | TODO | YES | |
# MOUSE_MOVE | YES | YES | YES | --- | --- | TODO | YES | |
# MOUSE_ENTER | YES | YES | YES | --- | --- | TODO | YES | |
# MOUSE_LEAVE | YES | YES | YES | --- | --- | TODO | YES | |
# TOUCHES_BEGAN | --- | --- | --- | YES | YES | --- | YES | |
# TOUCHES_MOVED | --- | --- | --- | YES | YES | --- | YES | |
# TOUCHES_ENDED | --- | --- | --- | YES | YES | --- | YES | |
# TOUCHES_CANCELLED | --- | --- | --- | YES | YES | --- | YES | |
# RESIZED | YES | YES | YES | YES | YES | --- | YES | |
# ICONIFIED | YES | YES | YES | --- | --- | --- | --- | |
# RESTORED | YES | YES | YES | --- | --- | --- | --- | |
# SUSPENDED | --- | --- | --- | YES | YES | --- | TODO | |
# RESUMED | --- | --- | --- | YES | YES | --- | TODO | |
# QUIT_REQUESTED | YES | YES | YES | --- | --- | TODO | --- | |
# UPDATE_CURSOR | YES | YES | TODO | --- | --- | --- | TODO | |
# IME | TODO | TODO? | TODO | ??? | TODO | ??? | ??? | |
# key repeat flag | YES | YES | YES | --- | --- | TODO | YES | |
# windowed | YES | YES | YES | --- | --- | TODO | YES | |
# fullscreen | YES | YES | TODO | YES | YES | TODO | --- | |
# pointer lock | TODO | TODO | TODO | --- | --- | TODO | TODO | |
# screen keyboard | --- | --- | --- | YES | TODO | --- | YES | |
# swap interval | YES | YES | YES | YES | TODO | TODO | YES | |
# high-dpi | YES | YES | TODO | YES | YES | TODO | YES | |
# clipboard | YES | YES | TODO | --- | --- | --- | YES | |
# TODO | |
# ==== | |
# - Linux clipboard support | |
# - sapp_consume_event() on non-web platforms? | |
# STEP BY STEP | |
# ============ | |
# --- Add a sokol_main() function to your code which returns a sapp_desc structure | |
# with initialization parameters and callback function pointers. This | |
# function is called very early, usually at the start of the | |
# platform's entry function (e.g. main or WinMain). You should do as | |
# little as possible here, since the rest of your code might be called | |
# from another thread (this depends on the platform): | |
# sapp_desc sokol_main(int argc, char* argv[]) { | |
# return (sapp_desc) { | |
# .width = 640, | |
# .height = 480, | |
# .init_cb = my_init_func, | |
# .frame_cb = my_frame_func, | |
# .cleanup_cb = my_cleanup_func, | |
# .event_cb = my_event_func, | |
# ... | |
# }; | |
# } | |
# There are many more setup parameters, but these are the most important. | |
# For a complete list search for the sapp_desc structure declaration | |
# below. | |
# DO NOT call any sokol-app function from inside sokol_main(), since | |
# sokol-app will not be initialized at this point. | |
# The .width and .height parameters are the preferred size of the 3D | |
# rendering canvas. The actual size may differ from this depending on | |
# platform and other circumstances. Also the canvas size may change at | |
# any time (for instance when the user resizes the application window, | |
# or rotates the mobile device). | |
# All provided function callbacks will be called from the same thread, | |
# but this may be different from the thread where sokol_main() was called. | |
# .init_cb (void (*)(void)) | |
# This function is called once after the application window, | |
# 3D rendering context and swap chain have been created. The | |
# function takes no arguments and has no return value. | |
# .frame_cb (void (*)(void)) | |
# This is the per-frame callback, which is usually called 60 | |
# times per second. This is where your application would update | |
# most of its state and perform all rendering. | |
# .cleanup_cb (void (*)(void)) | |
# The cleanup callback is called once right before the application | |
# quits. | |
# .event_cb (void (*)(const sapp_event* event)) | |
# The event callback is mainly for input handling, but in the | |
# future may also be used to communicate other types of events | |
# to the application. Keep the event_cb struct member zero-initialized | |
# if your application doesn't require event handling. | |
# .fail_cb (void (*)(const char* msg)) | |
# The fail callback is called when a fatal error is encountered | |
# during start which doesn't allow the program to continue. | |
# Providing a callback here gives you a chance to show an error message | |
# to the user. The default behaviour is SOKOL_LOG(msg) | |
# As you can see, those 'standard callbacks' don't have a user_data | |
# argument, so any data that needs to be preserved between callbacks | |
# must live in global variables. If you're allergic to global variables | |
# or cannot use them for other reasons, an alternative set of callbacks | |
# can be defined in sapp_desc, together with a user_data pointer: | |
# .user_data (void*) | |
# The user-data argument for the callbacks below | |
# .init_userdata_cb (void (*)(void* user_data)) | |
# .frame_userdata_cb (void (*)(void* user_data)) | |
# .cleanup_userdata_cb (void (*)(void* user_data)) | |
# .event_cb (void(*)(const sapp_event* event, void* user_data)) | |
# .fail_cb (void(*)(const char* msg, void* user_data)) | |
# These are the user-data versions of the callback functions. You | |
# can mix those with the standard callbacks that don't have the | |
# user_data argument. | |
# The function sapp_userdata() can be used to query the user_data | |
# pointer provided in the sapp_desc struct. | |
# You can call sapp_query_desc() to get a copy of the | |
# original sapp_desc structure. | |
# NOTE that there's also an alternative compile mode where sokol_app.h | |
# doesn't "hijack" the main() function. Search below for SOKOL_NO_ENTRY. | |
# --- Implement the initialization callback function (init_cb), this is called | |
# once after the rendering surface, 3D API and swap chain have been | |
# initialized by sokol_app. All sokol-app functions can be called | |
# from inside the initialization callback, the most useful functions | |
# at this point are: | |
# int sapp_width(void) | |
# Returns the current width of the default framebuffer, this may change | |
# from one frame to the next. | |
# int sapp_height(void) | |
# Likewise, returns the current height of the default framebuffer. | |
# bool sapp_gles2(void) | |
# Returns true if a GLES2 or WebGL context has been created. This | |
# is useful when a GLES3/WebGL2 context was requested but is not | |
# available so that sokol_app.h had to fallback to GLES2/WebGL. | |
# const void* sapp_metal_get_device(void) | |
# const void* sapp_metal_get_renderpass_descriptor(void) | |
# const void* sapp_metal_get_drawable(void) | |
# If the Metal backend has been selected, these functions return pointers | |
# to various Metal API objects required for rendering, otherwise | |
# they return a null pointer. These void pointers are actually | |
# Objective-C ids converted with an ARC __bridge cast so that | |
# they ids can be tunnel through C code. Also note that the returned | |
# pointers to the renderpass-descriptor and drawable may change from one | |
# frame to the next, only the Metal device object is guaranteed to | |
# stay the same. | |
# const void* sapp_macos_get_window(void) | |
# On macOS, get the NSWindow object pointer, otherwise a null pointer. | |
# Before being used as Objective-C object, the void* must be converted | |
# back with an ARC __bridge cast. | |
# const void* sapp_ios_get_window(void) | |
# On iOS, get the UIWindow object pointer, otherwise a null pointer. | |
# Before being used as Objective-C object, the void* must be converted | |
# back with an ARC __bridge cast. | |
# const void* sapp_win32_get_hwnd(void) | |
# On Windows, get the window's HWND, otherwise a null pointer. The | |
# HWND has been cast to a void pointer in order to be tunneled | |
# through code which doesn't include Windows.h. | |
# const void* sapp_d3d11_get_device(void); | |
# const void* sapp_d3d11_get_device_context(void); | |
# const void* sapp_d3d11_get_render_target_view(void); | |
# const void* sapp_d3d11_get_depth_stencil_view(void); | |
# Similar to the sapp_metal_* functions, the sapp_d3d11_* functions | |
# return pointers to D3D11 API objects required for rendering, | |
# only if the D3D11 backend has been selected. Otherwise they | |
# return a null pointer. Note that the returned pointers to the | |
# render-target-view and depth-stencil-view may change from one | |
# frame to the next! | |
# const void* sapp_android_get_native_activity(void); | |
# On Android, get the native activity ANativeActivity pointer, otherwise | |
# a null pointer. | |
# --- Implement the frame-callback function, this function will be called | |
# on the same thread as the init callback, but might be on a different | |
# thread than the sokol_main() function. Note that the size of | |
# the rendering framebuffer might have changed since the frame callback | |
# was called last. Call the functions sapp_width() and sapp_height() | |
# each frame to get the current size. | |
# --- Optionally implement the event-callback to handle input events. | |
# sokol-app provides the following type of input events: | |
# - a 'virtual key' was pressed down or released | |
# - a single text character was entered (provided as UTF-32 code point) | |
# - a mouse button was pressed down or released (left, right, middle) | |
# - mouse-wheel or 2D scrolling events | |
# - the mouse was moved | |
# - the mouse has entered or left the application window boundaries | |
# - low-level, portable multi-touch events (began, moved, ended, cancelled) | |
# - the application window was resized, iconified or restored | |
# - the application was suspended or restored (on mobile platforms) | |
# - the user or application code has asked to quit the application | |
# - a string was pasted to the system clipboard | |
# To explicitly 'consume' an event and prevent that the event is | |
# forwarded for further handling to the operating system, call | |
# sapp_consume_event() from inside the event handler (NOTE that | |
# this behaviour is currently only implemented for some HTML5 | |
# events, support for other platforms and event types will | |
# be added as needed, please open a github ticket and/or provide | |
# a PR if needed). | |
# NOTE: Do *not* call any 3D API functions in the event callback | |
# function, since the 3D API context may not be active when the | |
# event callback is called (it may work on some platforms and | |
# 3D APIs, but not others, and the exact behaviour may change | |
# between sokol-app versions). | |
# --- Implement the cleanup-callback function, this is called once | |
# after the user quits the application (see the section | |
# "APPLICATION QUIT" for detailed information on quitting | |
# behaviour, and how to intercept a pending quit (for instance to show a | |
# "Really Quit?" dialog box). Note that the cleanup-callback isn't | |
# called on the web and mobile platforms. | |
# CLIPBOARD SUPPORT | |
# ================= | |
# Applications can send and receive UTF-8 encoded text data from and to the | |
# system clipboard. By default, clipboard support is disabled and | |
# must be enabled at startup via the following sapp_desc struct | |
# members: | |
# sapp_desc.enable_clipboard - set to true to enable clipboard support | |
# sapp_desc.clipboard_size - size of the internal clipboard buffer in bytes | |
# Enabling the clipboard will dynamically allocate a clipboard buffer | |
# for UTF-8 encoded text data of the requested size in bytes, the default | |
# size if 8 KBytes. Strings that don't fit into the clipboard buffer | |
# (including the terminating zero) will be silently clipped, so it's | |
# important that you provide a big enough clipboard size for your | |
# use case. | |
# To send data to the clipboard, call sapp_set_clipboard_string() with | |
# a pointer to an UTF-8 encoded, null-terminated C-string. | |
# NOTE that on the HTML5 platform, sapp_set_clipboard_string() must be | |
# called from inside a 'short-lived event handler', and there are a few | |
# other HTML5-specific caveats to workaround. You'll basically have to | |
# tinker until it works in all browsers :/ (maybe the situation will | |
# improve when all browsers agree on and implement the new | |
# HTML5 navigator.clipboard API). | |
# To get data from the clipboard, check for the SAPP_EVENTTYPE_CLIPBOARD_PASTED | |
# event in your event handler function, and then call sapp_get_clipboard_string() | |
# to obtain the updated UTF-8 encoded text. | |
# NOTE that behaviour of sapp_get_clipboard_string() is slightly different | |
# depending on platform: | |
# - on the HTML5 platform, the internal clipboard buffer will only be updated | |
# right before the SAPP_EVENTTYPE_CLIPBOARD_PASTED event is sent, | |
# and sapp_get_clipboard_string() will simply return the current content | |
# of the clipboard buffer | |
# - on 'native' platforms, the call to sapp_get_clipboard_string() will | |
# update the internal clipboard buffer with the most recent data | |
# from the system clipboard | |
# Portable code should check for the SAPP_EVENTTYPE_CLIPBOARD_PASTED event, | |
# and then call sapp_get_clipboard_string() right in the event handler. | |
# The SAPP_EVENTTYPE_CLIPBOARD_PASTED event will be generated by sokol-app | |
# as follows: | |
# - on macOS: when the Cmd+V key is pressed down | |
# - on HTML5: when the browser sends a 'paste' event to the global 'window' object | |
# - on all other platforms: when the Ctrl+V key is pressed down | |
# HIGH-DPI RENDERING | |
# ================== | |
# You can set the sapp_desc.high_dpi flag during initialization to request | |
# a full-resolution framebuffer on HighDPI displays. The default behaviour | |
# is sapp_desc.high_dpi=false, this means that the application will | |
# render to a lower-resolution framebuffer on HighDPI displays and the | |
# rendered content will be upscaled by the window system composer. | |
# In a HighDPI scenario, you still request the same window size during | |
# sokol_main(), but the framebuffer sizes returned by sapp_width() | |
# and sapp_height() will be scaled up according to the DPI scaling | |
# ratio. You can also get a DPI scaling factor with the function | |
# sapp_dpi_scale(). | |
# Here's an example on a Mac with Retina display: | |
# sapp_desc sokol_main() { | |
# return (sapp_desc) { | |
# .width = 640, | |
# .height = 480, | |
# .high_dpi = true, | |
# ... | |
# }; | |
# } | |
# The functions sapp_width(), sapp_height() and sapp_dpi_scale() will | |
# return the following values: | |
# sapp_width -> 1280 | |
# sapp_height -> 960 | |
# sapp_dpi_scale -> 2.0 | |
# If the high_dpi flag is false, or you're not running on a Retina display, | |
# the values would be: | |
# sapp_width -> 640 | |
# sapp_height -> 480 | |
# sapp_dpi_scale -> 1.0 | |
# APPLICATION QUIT | |
# ================ | |
# Without special quit handling, a sokol_app.h application will exist | |
# 'gracefully' when the user clicks the window close-button. 'Graceful | |
# exit' means that the application-provided cleanup callback will be | |
# called. | |
# This 'graceful exit' is only supported on native desktop platforms, on | |
# the web and mobile platforms an application may be terminated at any time | |
# by the user or browser/OS runtime environment without a chance to run | |
# custom shutdown code. | |
# On the web platform, you can call the following function to let the | |
# browser open a standard popup dialog before the user wants to leave a site: | |
# sapp_html5_ask_leave_site(bool ask); | |
# The initial state of the associated internal flag can be provided | |
# at startup via sapp_desc.html5_ask_leave_site. | |
# This feature should only be used sparingly in critical situations - for | |
# instance when the user would loose data - since popping up modal dialog | |
# boxes is considered quite rude in the web world. Note that there's no way | |
# to customize the content of this dialog box or run any code as a result | |
# of the user's decision. Also note that the user must have interacted with | |
# the site before the dialog box will appear. These are all security measures | |
# to prevent fishing. | |
# On native desktop platforms, sokol_app.h provides more control over the | |
# application-quit-process. It's possible to initiate a 'programmatic quit' | |
# from the application code, and a quit initiated by the application user | |
# can be intercepted (for instance to show a custom dialog box). | |
# This 'programmatic quit protocol' is implemented trough 3 functions | |
# and 1 event: | |
# - sapp_quit(): This function simply quits the application without | |
# giving the user a chance to intervene. Usually this might | |
# be called when the user clicks the 'Ok' button in a 'Really Quit?' | |
# dialog box | |
# - sapp_request_quit(): Calling sapp_request_quit() will send the | |
# event SAPP_EVENTTYPE_QUIT_REQUESTED to the applications event handler | |
# callback, giving the user code a chance to intervene and cancel the | |
# pending quit process (for instance to show a 'Really Quit?' dialog | |
# box). If the event handler callback does nothing, the application | |
# will be quit as usual. To prevent this, call the function | |
# sapp_cancel_quit() from inside the event handler. | |
# - sapp_cancel_quit(): Cancels a pending quit request, either initiated | |
# by the user clicking the window close button, or programmatically | |
# by calling sapp_request_quit(). The only place where calling this | |
# function makes sense is from inside the event handler callback when | |
# the SAPP_EVENTTYPE_QUIT_REQUESTED event has been received. | |
# - SAPP_EVENTTYPE_QUIT_REQUESTED: this event is sent when the user | |
# clicks the window's close button or application code calls the | |
# sapp_request_quit() function. The event handler callback code can handle | |
# this event by calling sapp_cancel_quit() to cancel the quit. | |
# If the event is ignored, the application will quit as usual. | |
# The Dear ImGui HighDPI sample contains example code of how to | |
# implement a 'Really Quit?' dialog box with Dear ImGui (native desktop | |
# platforms only), and for showing the hardwired "Leave Site?" dialog box | |
# when running on the web platform: | |
# https:floooh.github.io/sokol-html5/wasm/imgui-highdpi-sapp.html | |
# FULLSCREEN | |
# ========== | |
# If the sapp_desc.fullscreen flag is true, sokol-app will try to create | |
# a fullscreen window on platforms with a 'proper' window system | |
# (mobile devices will always use fullscreen). The implementation details | |
# depend on the target platform, in general sokol-app will use a | |
# 'soft approach' which doesn't interfere too much with the platform's | |
# window system (for instance borderless fullscreen window instead of | |
# a 'real' fullscreen mode). Such details might change over time | |
# as sokol-app is adapted for different needs. | |
# The most important effect of fullscreen mode to keep in mind is that | |
# the requested canvas width and height will be ignored for the initial | |
# window size, calling sapp_width() and sapp_height() will instead return | |
# the resolution of the fullscreen canvas (however the provided size | |
# might still be used for the non-fullscreen window, in case the user can | |
# switch back from fullscreen- to windowed-mode). | |
# ONSCREEN KEYBOARD | |
# ================= | |
# On some platforms which don't provide a physical keyboard, sokol-app | |
# can display the platform's integrated onscreen keyboard for text | |
# input. To request that the onscreen keyboard is shown, call | |
# sapp_show_keyboard(true); | |
# Likewise, to hide the keyboard call: | |
# sapp_show_keyboard(false); | |
# Note that on the web platform, the keyboard can only be shown from | |
# inside an input handler. On such platforms, sapp_show_keyboard() | |
# will only work as expected when it is called from inside the | |
# sokol-app event callback function. When called from other places, | |
# an internal flag will be set, and the onscreen keyboard will be | |
# called at the next 'legal' opportunity (when the next input event | |
# is handled). | |
# OPTIONAL: DON'T HIJACK main() (#define SOKOL_NO_ENTRY) | |
# ====================================================== | |
# In its default configuration, sokol_app.h "hijacks" the platform's | |
# standard main() function. This was done because different platforms | |
# have different main functions which are not compatible with | |
# C's main() (for instance WinMain on Windows has completely different | |
# arguments). However, this "main hijacking" posed a problem for | |
# usage scenarios like integrating sokol_app.h with other languages than | |
# C or C++, so an alternative SOKOL_NO_ENTRY mode has been added | |
# in which the user code provides the platform's main function: | |
# - define SOKOL_NO_ENTRY before including the sokol_app.h implementation | |
# - do *not* provide a sokol_main() function | |
# - instead provide the standard main() function of the platform | |
# - from the main function, call the function ```sapp_run()``` which | |
# takes a pointer to an ```sapp_desc``` structure. | |
# - ```sapp_run()``` takes over control and calls the provided init-, frame-, | |
# shutdown- and event-callbacks just like in the default model, it | |
# will only return when the application quits (or not at all on some | |
# platforms, like emscripten) | |
# NOTE: SOKOL_NO_ENTRY is currently not supported on Android. | |
# TEMP NOTE DUMP | |
# ============== | |
# - onscreen keyboard support on Android requires Java :(, should we even bother? | |
# - sapp_desc needs a bool whether to initialize depth-stencil surface | |
# - GL context initialization needs more control (at least what GL version to initialize) | |
# - application icon | |
# - mouse pointer visibility(?) | |
# - the UPDATE_CURSOR event currently behaves differently between Win32 and OSX | |
# (Win32 sends the event each frame when the mouse moves and is inside the window | |
# client area, OSX sends it only once when the mouse enters the client area) | |
# - the Android implementation calls cleanup_cb() and destroys the egl context in onDestroy | |
# at the latest but should do it earlier, in onStop, as an app is "killable" after onStop | |
# on Android Honeycomb and later (it can't be done at the moment as the app may be started | |
# again after onStop and the sokol lifecycle does not yet handle context teardown/bringup) | |
# FIXME: ERROR HANDLING (this will need an error callback function) | |
# zlib/libpng license | |
# Copyright (c) 2018 Andre Weissflog | |
# This software is provided 'as-is', without any express or implied warranty. | |
# In no event will the authors be held liable for any damages arising from the | |
# use of this software. | |
# Permission is granted to anyone to use this software for any purpose, | |
# including commercial applications, and to alter it and redistribute it | |
# freely, subject to the following restrictions: | |
# 1. The origin of this software must not be misrepresented; you must not | |
# claim that you wrote the original software. If you use this software in a | |
# product, an acknowledgment in the product documentation would be | |
# appreciated but is not required. | |
# 2. Altered source versions must be plainly marked as such, and must not | |
# be misrepresented as being the original software. | |
# 3. This notice may not be removed or altered from any source | |
# distribution. | |
# | |
defineEnum(Enum_sokol_apph1) | |
defineEnum(sapp_event_type) | |
# key codes are the same names and values as GLFW | |
defineEnum(sapp_keycode) | |
defineEnum(sapp_mousebutton) | |
defineEnum(Enum_sokol_apph2) | |
const | |
headersokol_app {.used.} = "/Users/zacharycarter/dev/junkers/lib/sokol/sokol_app.h" | |
SAPP_MAX_TOUCHPOINTS* = (8).Enum_sokol_apph1 | |
SAPP_MAX_MOUSEBUTTONS* = (3).Enum_sokol_apph1 | |
SAPP_MAX_KEYCODES* = (512).Enum_sokol_apph1 | |
SAPP_EVENTTYPE_INVALID* = 0.sapp_event_type | |
SAPP_EVENTTYPE_KEY_DOWN* = 1.sapp_event_type | |
SAPP_EVENTTYPE_KEY_UP* = 2.sapp_event_type | |
SAPP_EVENTTYPE_CHAR* = 3.sapp_event_type | |
SAPP_EVENTTYPE_MOUSE_DOWN* = 4.sapp_event_type | |
SAPP_EVENTTYPE_MOUSE_UP* = 5.sapp_event_type | |
SAPP_EVENTTYPE_MOUSE_SCROLL* = 6.sapp_event_type | |
SAPP_EVENTTYPE_MOUSE_MOVE* = 7.sapp_event_type | |
SAPP_EVENTTYPE_MOUSE_ENTER* = 8.sapp_event_type | |
SAPP_EVENTTYPE_MOUSE_LEAVE* = 9.sapp_event_type | |
SAPP_EVENTTYPE_TOUCHES_BEGAN* = 10.sapp_event_type | |
SAPP_EVENTTYPE_TOUCHES_MOVED* = 11.sapp_event_type | |
SAPP_EVENTTYPE_TOUCHES_ENDED* = 12.sapp_event_type | |
SAPP_EVENTTYPE_TOUCHES_CANCELLED* = 13.sapp_event_type | |
SAPP_EVENTTYPE_RESIZED* = 14.sapp_event_type | |
SAPP_EVENTTYPE_ICONIFIED* = 15.sapp_event_type | |
SAPP_EVENTTYPE_RESTORED* = 16.sapp_event_type | |
SAPP_EVENTTYPE_SUSPENDED* = 17.sapp_event_type | |
SAPP_EVENTTYPE_RESUMED* = 18.sapp_event_type | |
SAPP_EVENTTYPE_UPDATE_CURSOR* = 19.sapp_event_type | |
SAPP_EVENTTYPE_QUIT_REQUESTED* = 20.sapp_event_type | |
SAPP_EVENTTYPE_CLIPBOARD_PASTED* = 21.sapp_event_type | |
SAPP_EVENTTYPE_NUM* = 22.sapp_event_type | |
SAPP_EVENTTYPE_FORCE_U32* = (0x7FFFFFFF).sapp_event_type | |
SAPP_KEYCODE_INVALID* = (0).sapp_keycode | |
SAPP_KEYCODE_SPACE* = (32).sapp_keycode | |
SAPP_KEYCODE_APOSTROPHE* = (39).sapp_keycode | |
SAPP_KEYCODE_COMMA* = (44).sapp_keycode | |
SAPP_KEYCODE_MINUS* = (45).sapp_keycode | |
SAPP_KEYCODE_PERIOD* = (46).sapp_keycode | |
SAPP_KEYCODE_SLASH* = (47).sapp_keycode | |
SAPP_KEYCODE_0* = (48).sapp_keycode | |
SAPP_KEYCODE_1* = (49).sapp_keycode | |
SAPP_KEYCODE_2* = (50).sapp_keycode | |
SAPP_KEYCODE_3* = (51).sapp_keycode | |
SAPP_KEYCODE_4* = (52).sapp_keycode | |
SAPP_KEYCODE_5* = (53).sapp_keycode | |
SAPP_KEYCODE_6* = (54).sapp_keycode | |
SAPP_KEYCODE_7* = (55).sapp_keycode | |
SAPP_KEYCODE_8* = (56).sapp_keycode | |
SAPP_KEYCODE_9* = (57).sapp_keycode | |
SAPP_KEYCODE_SEMICOLON* = (59).sapp_keycode | |
SAPP_KEYCODE_EQUAL* = (61).sapp_keycode | |
SAPP_KEYCODE_A* = (65).sapp_keycode | |
SAPP_KEYCODE_B* = (66).sapp_keycode | |
SAPP_KEYCODE_C* = (67).sapp_keycode | |
SAPP_KEYCODE_D* = (68).sapp_keycode | |
SAPP_KEYCODE_E* = (69).sapp_keycode | |
SAPP_KEYCODE_F* = (70).sapp_keycode | |
SAPP_KEYCODE_G* = (71).sapp_keycode | |
SAPP_KEYCODE_H* = (72).sapp_keycode | |
SAPP_KEYCODE_I* = (73).sapp_keycode | |
SAPP_KEYCODE_J* = (74).sapp_keycode | |
SAPP_KEYCODE_K* = (75).sapp_keycode | |
SAPP_KEYCODE_L* = (76).sapp_keycode | |
SAPP_KEYCODE_M* = (77).sapp_keycode | |
SAPP_KEYCODE_N* = (78).sapp_keycode | |
SAPP_KEYCODE_O* = (79).sapp_keycode | |
SAPP_KEYCODE_P* = (80).sapp_keycode | |
SAPP_KEYCODE_Q* = (81).sapp_keycode | |
SAPP_KEYCODE_R* = (82).sapp_keycode | |
SAPP_KEYCODE_S* = (83).sapp_keycode | |
SAPP_KEYCODE_T* = (84).sapp_keycode | |
SAPP_KEYCODE_U* = (85).sapp_keycode | |
SAPP_KEYCODE_V* = (86).sapp_keycode | |
SAPP_KEYCODE_W* = (87).sapp_keycode | |
SAPP_KEYCODE_X* = (88).sapp_keycode | |
SAPP_KEYCODE_Y* = (89).sapp_keycode | |
SAPP_KEYCODE_Z* = (90).sapp_keycode | |
SAPP_KEYCODE_LEFT_BRACKET* = (91).sapp_keycode | |
SAPP_KEYCODE_BACKSLASH* = (92).sapp_keycode | |
SAPP_KEYCODE_RIGHT_BRACKET* = (93).sapp_keycode | |
SAPP_KEYCODE_GRAVE_ACCENT* = (96).sapp_keycode | |
SAPP_KEYCODE_WORLD_1* = (161).sapp_keycode | |
SAPP_KEYCODE_WORLD_2* = (162).sapp_keycode | |
SAPP_KEYCODE_ESCAPE* = (256).sapp_keycode | |
SAPP_KEYCODE_ENTER* = (257).sapp_keycode | |
SAPP_KEYCODE_TAB* = (258).sapp_keycode | |
SAPP_KEYCODE_BACKSPACE* = (259).sapp_keycode | |
SAPP_KEYCODE_INSERT* = (260).sapp_keycode | |
SAPP_KEYCODE_DELETE* = (261).sapp_keycode | |
SAPP_KEYCODE_RIGHT* = (262).sapp_keycode | |
SAPP_KEYCODE_LEFT* = (263).sapp_keycode | |
SAPP_KEYCODE_DOWN* = (264).sapp_keycode | |
SAPP_KEYCODE_UP* = (265).sapp_keycode | |
SAPP_KEYCODE_PAGE_UP* = (266).sapp_keycode | |
SAPP_KEYCODE_PAGE_DOWN* = (267).sapp_keycode | |
SAPP_KEYCODE_HOME* = (268).sapp_keycode | |
SAPP_KEYCODE_END* = (269).sapp_keycode | |
SAPP_KEYCODE_CAPS_LOCK* = (280).sapp_keycode | |
SAPP_KEYCODE_SCROLL_LOCK* = (281).sapp_keycode | |
SAPP_KEYCODE_NUM_LOCK* = (282).sapp_keycode | |
SAPP_KEYCODE_PRINT_SCREEN* = (283).sapp_keycode | |
SAPP_KEYCODE_PAUSE* = (284).sapp_keycode | |
SAPP_KEYCODE_F1* = (290).sapp_keycode | |
SAPP_KEYCODE_F2* = (291).sapp_keycode | |
SAPP_KEYCODE_F3* = (292).sapp_keycode | |
SAPP_KEYCODE_F4* = (293).sapp_keycode | |
SAPP_KEYCODE_F5* = (294).sapp_keycode | |
SAPP_KEYCODE_F6* = (295).sapp_keycode | |
SAPP_KEYCODE_F7* = (296).sapp_keycode | |
SAPP_KEYCODE_F8* = (297).sapp_keycode | |
SAPP_KEYCODE_F9* = (298).sapp_keycode | |
SAPP_KEYCODE_F10* = (299).sapp_keycode | |
SAPP_KEYCODE_F11* = (300).sapp_keycode | |
SAPP_KEYCODE_F12* = (301).sapp_keycode | |
SAPP_KEYCODE_F13* = (302).sapp_keycode | |
SAPP_KEYCODE_F14* = (303).sapp_keycode | |
SAPP_KEYCODE_F15* = (304).sapp_keycode | |
SAPP_KEYCODE_F16* = (305).sapp_keycode | |
SAPP_KEYCODE_F17* = (306).sapp_keycode | |
SAPP_KEYCODE_F18* = (307).sapp_keycode | |
SAPP_KEYCODE_F19* = (308).sapp_keycode | |
SAPP_KEYCODE_F20* = (309).sapp_keycode | |
SAPP_KEYCODE_F21* = (310).sapp_keycode | |
SAPP_KEYCODE_F22* = (311).sapp_keycode | |
SAPP_KEYCODE_F23* = (312).sapp_keycode | |
SAPP_KEYCODE_F24* = (313).sapp_keycode | |
SAPP_KEYCODE_F25* = (314).sapp_keycode | |
SAPP_KEYCODE_KP_0* = (320).sapp_keycode | |
SAPP_KEYCODE_KP_1* = (321).sapp_keycode | |
SAPP_KEYCODE_KP_2* = (322).sapp_keycode | |
SAPP_KEYCODE_KP_3* = (323).sapp_keycode | |
SAPP_KEYCODE_KP_4* = (324).sapp_keycode | |
SAPP_KEYCODE_KP_5* = (325).sapp_keycode | |
SAPP_KEYCODE_KP_6* = (326).sapp_keycode | |
SAPP_KEYCODE_KP_7* = (327).sapp_keycode | |
SAPP_KEYCODE_KP_8* = (328).sapp_keycode | |
SAPP_KEYCODE_KP_9* = (329).sapp_keycode | |
SAPP_KEYCODE_KP_DECIMAL* = (330).sapp_keycode | |
SAPP_KEYCODE_KP_DIVIDE* = (331).sapp_keycode | |
SAPP_KEYCODE_KP_MULTIPLY* = (332).sapp_keycode | |
SAPP_KEYCODE_KP_SUBTRACT* = (333).sapp_keycode | |
SAPP_KEYCODE_KP_ADD* = (334).sapp_keycode | |
SAPP_KEYCODE_KP_ENTER* = (335).sapp_keycode | |
SAPP_KEYCODE_KP_EQUAL* = (336).sapp_keycode | |
SAPP_KEYCODE_LEFT_SHIFT* = (340).sapp_keycode | |
SAPP_KEYCODE_LEFT_CONTROL* = (341).sapp_keycode | |
SAPP_KEYCODE_LEFT_ALT* = (342).sapp_keycode | |
SAPP_KEYCODE_LEFT_SUPER* = (343).sapp_keycode | |
SAPP_KEYCODE_RIGHT_SHIFT* = (344).sapp_keycode | |
SAPP_KEYCODE_RIGHT_CONTROL* = (345).sapp_keycode | |
SAPP_KEYCODE_RIGHT_ALT* = (346).sapp_keycode | |
SAPP_KEYCODE_RIGHT_SUPER* = (347).sapp_keycode | |
SAPP_KEYCODE_MENU* = (348).sapp_keycode | |
SAPP_MOUSEBUTTON_INVALID* = (-1).sapp_mousebutton | |
SAPP_MOUSEBUTTON_LEFT* = (0).sapp_mousebutton | |
SAPP_MOUSEBUTTON_RIGHT* = (1).sapp_mousebutton | |
SAPP_MOUSEBUTTON_MIDDLE* = (2).sapp_mousebutton | |
SAPP_MODIFIER_SHIFT* = ((1 shl 0)).Enum_sokol_apph2 | |
SAPP_MODIFIER_CTRL* = ((1 shl 1)).Enum_sokol_apph2 | |
SAPP_MODIFIER_ALT* = ((1 shl 2)).Enum_sokol_apph2 | |
SAPP_MODIFIER_SUPER* = ((1 shl 3)).Enum_sokol_apph2 | |
{.pragma: impsokol_app, importc, header: headersokol_app.} | |
{.pragma: impsokol_appC, impsokol_app, cdecl.} | |
type | |
sapp_touchpoint* {.importc: "struct sapp_touchpoint", header: headersokol_app, bycopy.} = object | |
identifier*: ptr uint | |
pos_x*: cfloat | |
pos_y*: cfloat | |
changed*: bool | |
sapp_event* {.importc: "struct sapp_event", header: headersokol_app, bycopy.} = object | |
frame_count*: uint64 | |
`type`*: sapp_event_type | |
key_code*: sapp_keycode | |
char_code*: uint32 | |
key_repeat*: bool | |
modifiers*: uint32 | |
mouse_button*: sapp_mousebutton | |
mouse_x*: cfloat | |
mouse_y*: cfloat | |
scroll_x*: cfloat | |
scroll_y*: cfloat | |
num_touches*: cint | |
touches*: array[SAPP_MAX_TOUCHPOINTS, sapp_touchpoint] | |
window_width*: cint | |
window_height*: cint | |
framebuffer_width*: cint | |
framebuffer_height*: cint | |
sapp_desc* {.importc: "struct sapp_desc", header: headersokol_app, bycopy.} = object | |
init_cb*: proc() {.cdecl.} | |
frame_cb*: proc() {.cdecl.} | |
cleanup_cb*: proc() {.cdecl.} | |
event_cb*: proc(a1: ptr sapp_event) {.cdecl.} | |
fail_cb*: proc(a1: cstring) {.cdecl.} | |
user_data*: pointer | |
init_userdata_cb*: proc(a1: pointer) {.cdecl.} | |
frame_userdata_cb*: proc(a1: pointer) {.cdecl.} | |
cleanup_userdata_cb*: proc(a1: pointer) {.cdecl.} | |
event_userdata_cb*: proc(a1: ptr sapp_event, a2: pointer) {.cdecl.} | |
fail_userdata_cb*: proc(a1: cstring, a2: pointer) {.cdecl.} | |
width*: cint | |
height*: cint | |
sample_count*: cint | |
swap_interval*: cint | |
high_dpi*: bool | |
fullscreen*: bool | |
alpha*: bool | |
window_title*: cstring | |
user_cursor*: bool | |
enable_clipboard*: bool | |
clipboard_size*: cint | |
html5_canvas_name*: cstring | |
html5_canvas_resize*: bool | |
html5_preserve_drawing_buffer*: bool | |
html5_premultiplied_alpha*: bool | |
html5_ask_leave_site*: bool | |
ios_keyboard_resizes_canvas*: bool | |
gl_force_gles2*: bool | |
# user-provided functions | |
# Declaration 'sokol_main' skipped | |
# Declaration 'argc' skipped | |
# Declaration 'sokol_main' skipped | |
# Declaration 'argc' skipped | |
# Declaration 'argv' skipped | |
# returns true after sokol-app has been initialized | |
proc sapp_isvalid*(): bool {.impsokol_appC.} | |
# returns the current framebuffer width in pixels | |
proc sapp_width*(): cint {.impsokol_appC.} | |
# returns the current framebuffer height in pixels | |
proc sapp_height*(): cint {.impsokol_appC.} | |
# returns true when high_dpi was requested and actually running in a high-dpi scenario | |
proc sapp_high_dpi*(): bool {.impsokol_appC.} | |
# returns the dpi scaling factor (window pixels to framebuffer pixels) | |
proc sapp_dpi_scale*(): cfloat {.impsokol_appC.} | |
# show or hide the mobile device onscreen keyboard | |
proc sapp_show_keyboard*(visible: bool) {.impsokol_appC.} | |
# return true if the mobile device onscreen keyboard is currently shown | |
proc sapp_keyboard_shown*(): bool {.impsokol_appC.} | |
# show or hide the mouse cursor | |
proc sapp_show_mouse*(visible: bool) {.impsokol_appC.} | |
# show or hide the mouse cursor | |
proc sapp_mouse_shown*(): bool {.impsokol_appC.} | |
# return the userdata pointer optionally provided in sapp_desc | |
proc sapp_userdata*(): pointer {.impsokol_appC.} | |
# return a copy of the sapp_desc structure | |
proc sapp_query_desc*(): sapp_desc {.impsokol_appC.} | |
# initiate a "soft quit" (sends SAPP_EVENTTYPE_QUIT_REQUESTED) | |
proc sapp_request_quit*() {.impsokol_appC.} | |
# cancel a pending quit (when SAPP_EVENTTYPE_QUIT_REQUESTED has been received) | |
proc sapp_cancel_quit*() {.impsokol_appC.} | |
# initiate a "hard quit" (quit application without sending SAPP_EVENTTYPE_QUIT_REQUSTED) | |
proc sapp_quit*() {.impsokol_appC.} | |
# call from inside event callback to consume the current event (don't forward to platform) | |
proc sapp_consume_event*() {.impsokol_appC.} | |
# get the current frame counter (for comparison with sapp_event.frame_count) | |
proc sapp_frame_count*(): uint64 {.impsokol_appC.} | |
# write string into clipboard | |
proc sapp_set_clipboard_string*(str: cstring) {.impsokol_appC.} | |
# read string from clipboard (usually during SAPP_EVENTTYPE_CLIPBOARD_PASTED) | |
proc sapp_get_clipboard_string*(): cstring {.impsokol_appC.} | |
# special run-function for SOKOL_NO_ENTRY (in standard mode this is an empty stub) | |
proc sapp_run*(desc: ptr sapp_desc): cint {.impsokol_appC.} | |
# GL: return true when GLES2 fallback is active (to detect fallback from GLES3) | |
proc sapp_gles2*(): bool {.impsokol_appC.} | |
# HTML5: enable or disable the hardwired "Leave Site?" dialog box | |
proc sapp_html5_ask_leave_site*(ask: bool) {.impsokol_appC.} | |
# Metal: get ARC-bridged pointer to Metal device object | |
proc sapp_metal_get_device*(): pointer {.impsokol_appC.} | |
# Metal: get ARC-bridged pointer to this frame's renderpass descriptor | |
proc sapp_metal_get_renderpass_descriptor*(): pointer {.impsokol_appC.} | |
# Metal: get ARC-bridged pointer to current drawable | |
proc sapp_metal_get_drawable*(): pointer {.impsokol_appC.} | |
# macOS: get ARC-bridged pointer to macOS NSWindow | |
proc sapp_macos_get_window*(): pointer {.impsokol_appC.} | |
# iOS: get ARC-bridged pointer to iOS UIWindow | |
proc sapp_ios_get_window*(): pointer {.impsokol_appC.} | |
# D3D11: get pointer to ID3D11Device object | |
proc sapp_d3d11_get_device*(): pointer {.impsokol_appC.} | |
# D3D11: get pointer to ID3D11DeviceContext object | |
proc sapp_d3d11_get_device_context*(): pointer {.impsokol_appC.} | |
# D3D11: get pointer to ID3D11RenderTargetView object | |
proc sapp_d3d11_get_render_target_view*(): pointer {.impsokol_appC.} | |
# D3D11: get pointer to ID3D11DepthStencilView | |
proc sapp_d3d11_get_depth_stencil_view*(): pointer {.impsokol_appC.} | |
# Win32: get the HWND window handle | |
proc sapp_win32_get_hwnd*(): pointer {.impsokol_appC.} | |
# Android: get native activity handle | |
proc sapp_android_get_native_activity*(): pointer {.impsokol_appC.} | |
{.compile: "/Users/zacharycarter/dev/junkers/lib/sokol.m".} | |
CC: sokol | |
CC: stdlib_assertions.nim | |
CC: stdlib_system.nim | |
CC: stdlib_hashes.nim | |
CC: stdlib_math.nim | |
CC: stdlib_posix.nim | |
CC: stdlib_times.nim | |
CC: stdlib_os.nim | |
CC: stdlib_sets.nim | |
CC: stdlib_tables.nim | |
CC: ../../../.nimble/pkgs/nimterop-0.4.4/nimterop/plugin.nim | |
CC: stdlib_cpuinfo.nim | |
CC: sokol.nim |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment