const (
version = 1
used_import = c.used_import
)
fn activate_context(ctx_id C.sg_context)
fn append_buffer(buf C.sg_buffer, ptr voidptr, num_bytes int) int
fn apply_bindings(bindings &C.sg_bindings)
fn apply_pipeline(pip C.sg_pipeline)
fn apply_scissor_rect(x int, y int, width int, height int, origin_top_left bool)
fn apply_uniforms(stage int, ub_index int, data voidptr, num_bytes int)
fn apply_viewport(x int, y int, width int, height int, origin_top_left bool)
fn begin_default_pass(actions &C.sg_pass_action, width int, height int)
rendering functions
fn begin_pass(pass C.sg_pass, actions &C.sg_pass_action)
fn commit()
fn create_clear_pass(r f32, g f32, b f32, a f32) C.sg_pass_action
fn destroy_buffer(buf C.sg_buffer)
fn destroy_image(img C.sg_image)
fn destroy_pass(pass C.sg_pass)
fn destroy_pipeline(pip C.sg_pipeline)
fn destroy_shader(shd C.sg_shader)
fn discard_context(ctx_id C.sg_context)
fn draw(base_element int, num_elements int, num_instances int)
fn end_pass()
fn make_buffer(desc &C.sg_buffer_desc) C.sg_buffer
resource creation, destruction and updating
fn make_image(desc &C.sg_image_desc) C.sg_image
fn make_pass(desc &C.sg_pass_desc) C.sg_pass
fn make_pipeline(desc &C.sg_pipeline_desc) C.sg_pipeline
fn make_shader(desc &C.sg_shader_desc) C.sg_shader
fn query_backend() Backend
fn query_buffer_defaults(desc &C.sg_buffer) C.sg_buffer_desc
get resource creation desc struct with their default values replaced
fn query_buffer_info(buf C.sg_buffer) C.sg_buffer_info
get runtime information about a resource
fn query_buffer_overflow(buf C.sg_buffer) bool
fn query_buffer_state(buf C.sg_buffer) C.sg_resource_state
get current state of a resource (INITIAL, ALLOC, VALID, FAILED, INVALID)
fn query_desc() C.sg_desc
getting information
fn query_features() C.sg_features
fn query_image_defaults(desc &C.sg_image) C.sg_image_desc
fn query_image_info(img C.sg_image) C.sg_image_info
fn query_image_state(img C.sg_image) C.sg_resource_state
fn query_limits() C.sg_limits
fn query_pass_defaults(desc &C.sg_pass) C.sg_pass_desc
fn query_pass_info(pass C.sg_pass) C.sg_pass_info
fn query_pass_state(pass C.sg_pass) C.sg_resource_state
fn query_pipeline_defaults(desc &C.sg_pipeline) C.sg_pipeline_desc
fn query_pipeline_info(pip C.sg_pipeline) C.sg_pipeline_info
fn query_pipeline_state(pip C.sg_pipeline) C.sg_resource_state
fn query_pixelformat(fmt PixelFormat) C.sg_pixelformat_info
fn query_shader_defaults(desc &C.sg_shader) C.sg_shader_desc
fn query_shader_info(shd C.sg_shader) C.sg_shader_info
fn query_shader_state(shd C.sg_shader) C.sg_resource_state
fn reset_state_cache()
fn setup(desc &C.sg_desc)
setup and misc functions
fn setup_context() C.sg_context
rendering contexts (optional)
fn shutdown()
fn update_buffer(buf C.sg_buffer, ptr voidptr, num_bytes int)
fn update_image(img C.sg_image, content &C.sg_image_content)
enum Action {
_default
clear
load
dontcare
_num
}
enum Backend {
glcore33
gles2
gles3
d3d11
metal_ios
metal_macos
metal_simulator
dummy
}
enum BlendFactor {
_default
zero
one
src_color
one_minus_src_color
src_alpha
one_minus_src_alpha
dst_color
one_minus_dst_color
dst_alpha
one_minus_dst_alpha
src_alpha_saturated
blend_color
one_minus_blend_color
blend_alpha
one_minus_blend_alpha
_num
}
enum BlendOp {
_default
add
subtract
reverse_subtract
_num
}
enum BorderColor {
_default
transparent_black
opaque_black
opaque_white
_num
}
enum BufferType {
_default
vertexbuffer
indexbuffer
_num
}
enum ColorMask {
_default = 0
none = 0x10
r = 1
g = 2
b = 4
a = 8
rgb = 0x7
rgba = 0xF
}
enum CompareFunc {
_default
never
less
equal
less_equal
greater
not_equal
greater_equal
always
_num
}
enum CubeFace {
pos_x
neg_x
pos_y
neg_y
pos_z
neg_z
num
}
enum CullMode {
_default
none
front
back
_num
}
enum FaceWinding {
_facewinding_default
facewinding_ccw
facewinding_cw
_facewinding_num
}
enum Filter {
_default
nearest
linear
nearest_mipmap_nearest
nearest_mipmap_linear
linear_mipmap_nearest
linear_mipmap_linear
_num
}
enum ImageType {
_default
_2d
cube
_3d
array
_num
}
enum IndexType {
_default
none
uint16
uint32
_num
}
enum PixelFormat {
_default
none
r8
r8sn
r8ui
r8si
r16
r16sn
r16ui
r16si
r16f
rg8
rg8sn
rg8ui
rg8si
r32ui
r32si
r32f
rg16
rg16sn
rg16ui
rg16si
rg16f
rgba8
rgba8sn
rgba8ui
rgba8si
bgra8
rgb10a2
rg11b10f
rg32ui
rg32si
rg32f
rgba16
rgba16sn
rgba16ui
rgba16si
rgba16f
rgba32ui
rgba32si
rgba32f
depth
depth_stencil
bc1_rgba
bc2_rgba
bc3_rgba
bc4_r
bc4_rsn
bc5_rg
bc5_rgsn
bc6h_rgbf
bc6h_rgbuf
bc7_rgba
pvrtc_rgb_2bpp
pvrtc_rgb_4bpp
pvrtc_rgba_2bpp
pvrtc_rgba_4bpp
etc2_rgb8
etc2_rgb8a1
etc2_rgba8
etc2_rg11
etc2_rg11sn
_num
}
enum PrimitiveType {
_default
points
lines
line_strip
triangles
triangle_strip
_num
}
enum ResourceState {
initial
alloc
valid
failed
invalid
}
enum ShaderStage {
vs
fs
}
enum StencilOp {
_default
keep
zero
replace
incr_clamp
decr_clamp
invert
incr_wrap
decr_wrap
_num
}
enum UniformType {
invalid
float
float2
float3
float4
mat4
_num
}
enum Usage {
_default
immutable
dynamic
stream
_num
}
enum VertexFormat {
invalid
float
float2
float3
float4
byte4
byte4n
ubyte4
ubyte4n
short2
short2n
ushort2n
short4
short4n
ushort4n
uint10_n2
_num
}
enum VertexStep {
_default
per_vertex
per_instance
_num
}
enum Wrap {
_default
repeat
clamp_to_edge
clamp_to_border
mirrored_repeat
_num
}
struct C.sg_attachment_desc {
pub mut:
image C.sg_image
mip_level int
face int
}
struct C.sg_bindings {
pub mut:
_start_canary u32
vertex_buffers [8]C.sg_buffer
vertex_buffer_offsets [8]int
index_buffer C.sg_buffer
index_buffer_offset int
vs_images [8]C.sg_image
fs_images [8]C.sg_image
_end_canary u32
}
fn (mut b C.sg_bindings) set_vert_image(index int, img C.sg_image)
fn (mut b C.sg_bindings) set_frag_image(index int, img C.sg_image)
fn (b &C.sg_bindings) update_vert_buffer(index int, data voidptr, element_size int, element_count int)
fn (b &C.sg_bindings) append_vert_buffer(index int, data voidptr, element_size int, element_count int) int
fn (b &C.sg_bindings) update_index_buffer(data voidptr, element_size int, element_count int)
fn (b &C.sg_bindings) append_index_buffer(data voidptr, element_size int, element_count int) int
struct C.sg_blend_state {
pub mut:
enabled bool
src_factor_rgb BlendFactor
dst_factor_rgb BlendFactor
op_rgb BlendOp
src_factor_alpha BlendFactor
dst_factor_alpha BlendFactor
op_alpha BlendOp
color_write_mask byte
color_attachment_count int
color_format PixelFormat
depth_format PixelFormat
blend_color [4]f32
}
struct C.sg_buffer {
id u32
}
fn (b C.sg_buffer) free()
struct C.sg_buffer_desc {
pub mut:
_start_canary u32
size int
type BufferType
usage Usage
content byteptr
label byteptr
gl_buffers [2]u32
mtl_buffers [2]voidptr
d3d11_buffer voidptr
_end_canary u32
}
struct C.sg_buffer_info {
}
struct C.sg_buffer_layout_desc {
pub mut:
stride int
step_func VertexStep
step_rate int
}
struct C.sg_color_attachment_action {
pub mut:
action Action
val [4]f32
}
struct C.sg_context {
id u32
}
struct C.sg_context_desc {
sample_count int
gl C.sg_gl_context_desc
metal C.sg_mtl_context_desc
d3d11 C.sg_d3d11_context_desc
color_format PixelFormat
depth_format PixelFormat
}
struct C.sg_d3d11_context_desc {
device voidptr
device_context voidptr
render_target_view_cb fn () voidptr
depth_stencil_view_cb fn () voidptr
}
struct C.sg_depth_attachment_action {
pub mut:
action Action
val f32
}
struct C.sg_depth_stencil_state {
stencil_front C.sg_stencil_state
stencil_back C.sg_stencil_state
depth_compare_func CompareFunc
depth_write_enabled bool
stencil_enabled bool
stencil_read_mask byte
stencil_write_mask byte
stencil_ref byte
}
struct C.sg_desc {
_start_canary u32
buffer_pool_size int
image_pool_size int
shader_pool_size int
pipeline_pool_size int
pass_pool_size int
context_pool_size int
context C.sg_context_desc
_end_canary u32
}
struct C.sg_features {
pub:
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
}
struct C.sg_gl_context_desc {
gl_force_gles2 bool
}
struct C.sg_image {
pub:
id u32
}
fn (i C.sg_image) free()
struct C.sg_image_content {
pub mut:
subimage [6][16]C.sg_subimage_content
}
struct C.sg_image_desc {
pub mut:
_start_canary u32
type ImageType
render_target bool
width int
height int
depth DepthLayers
num_mipmaps int
usage Usage
pixel_format PixelFormat
sample_count int
min_filter Filter
mag_filter Filter
wrap_u Wrap
wrap_v Wrap
wrap_w Wrap
border_color BorderColor
max_anisotropy u32
min_lod f32
max_lod f32
content C.sg_image_content
label byteptr
gl_textures [2]u32
mtl_textures [2]voidptr
d3d11_texture voidptr
_end_canary u32
}
struct C.sg_image_info {
pub mut:
slot C.sg_slot_info
upd_frame_index u32
num_slots int
active_slot int
}
struct C.sg_layout_desc {
pub mut:
buffers [8]C.sg_buffer_layout_desc
attrs [16]C.sg_vertex_attr_desc
}
struct C.sg_limits {
pub:
max_image_size_2d u32
max_image_size_cube u32
max_image_size_3d u32
max_image_size_array u32
max_image_array_layers u32
max_vertex_attrs u32
}
struct C.sg_mtl_context_desc {
device voidptr
renderpass_descriptor_cb fn () voidptr
drawable_cb fn () voidptr
}
struct C.sg_pass {
id u32
}
fn (p C.sg_pass) free()
struct C.sg_pass_action {
pub mut:
_start_canary u32
colors [4]C.sg_color_attachment_action
depth C.sg_depth_attachment_action
stencil C.sg_stencil_attachment_action
_end_canary u32
}
struct C.sg_pass_desc {
pub mut:
_start_canary u32
color_attachments [4]C.sg_attachment_desc
depth_stencil_attachment C.sg_attachment_desc
label byteptr
_end_canary u32
}
struct C.sg_pass_info {
info C.sg_slot_info
}
struct C.sg_pipeline {
pub:
id u32
}
fn (p C.sg_pipeline) free()
struct C.sg_pipeline_desc {
pub mut:
_start_canary u32
layout C.sg_layout_desc
shader C.sg_shader
primitive_type PrimitiveType
index_type IndexType
depth_stencil C.sg_depth_stencil_state
blend C.sg_blend_state
rasterizer C.sg_rasterizer_state
label byteptr
_end_canary u32
}
struct C.sg_pipeline_info {
}
struct C.sg_pixelformat_info {
pub:
sample bool
filter bool
render bool
blend bool
msaa bool
depth bool
}
struct C.sg_rasterizer_state {
pub mut:
alpha_to_coverage_enabled bool
cull_mode CullMode
face_winding FaceWinding
sample_count int
depth_bias f32
depth_bias_slope_scale f32
depth_bias_clamp f32
}
struct C.sg_shader {
pub:
id u32
}
fn (s C.sg_shader) free()
struct C.sg_shader_attr_desc {
pub mut:
name byteptr
sem_name byteptr
sem_index int
}
struct C.sg_shader_desc {
pub mut:
_start_canary u32
attrs [16]C.sg_shader_attr_desc
vs C.sg_shader_stage_desc
fs C.sg_shader_stage_desc
label byteptr
_end_canary u32
}
fn (mut desc C.sg_shader_desc) set_vert_src(src string) &C.sg_shader_desc
fn (mut desc C.sg_shader_desc) set_frag_src(src string) &C.sg_shader_desc
fn (mut desc C.sg_shader_desc) set_vert_image(index int, name string) &C.sg_shader_desc
fn (mut desc C.sg_shader_desc) set_frag_image(index int, name string) &C.sg_shader_desc
fn (mut desc C.sg_shader_desc) set_vert_uniform_block_size(block_index int, size int) &C.sg_shader_desc
fn (mut desc C.sg_shader_desc) set_frag_uniform_block_size(block_index int, size int) &C.sg_shader_desc
fn (mut desc C.sg_shader_desc) set_vert_uniform(block_index int, uniform_index int, name string, type UniformType, array_count int) &C.sg_shader_desc
fn (mut desc C.sg_shader_desc) set_frag_uniform(block_index int, uniform_index int, name string, type UniformType, array_count int) &C.sg_shader_desc
fn (desc &C.sg_shader_desc) make_shader() C.sg_shader
struct C.sg_shader_image_desc {
pub mut:
name byteptr
type ImageType
}
struct C.sg_shader_info {
}
struct C.sg_shader_stage_desc {
pub mut:
source byteptr
byte_code &byte
byte_code_size int
entry byteptr
uniform_blocks [4]C.sg_shader_uniform_block_desc
images [12]C.sg_shader_image_desc
}
fn (mut desc C.sg_shader_stage_desc) set_image(index int, name string) C.sg_shader_stage_desc
struct C.sg_shader_uniform_block_desc {
pub mut:
size int
uniforms [16]C.sg_shader_uniform_desc
}
struct C.sg_shader_uniform_desc {
pub mut:
name byteptr
type UniformType
array_count int
}
struct C.sg_stencil_attachment_action {
pub mut:
action Action
val byte
}
struct C.sg_stencil_state {
fail_op StencilOp
depth_fail_op StencilOp
pass_op StencilOp
compare_func CompareFunc
}
struct C.sg_subimage_content {
pub mut:
ptr voidptr
size int
}
struct C.sg_vertex_attr_desc {
pub mut:
buffer_index int
offset int
format VertexFormat
}
struct DepthLayers {
depth int
layers int
}