Skip to content

sokol.gfx #

Constants #

const version = 1
const used_import = c.used_import
const sg_cubeface_num = 6
const sg_max_mipmaps = 16

fn activate_context #

fn activate_context(ctx_id Context)

fn append_buffer #

fn append_buffer(buf Buffer, data &Range) int

fn apply_bindings #

fn apply_bindings(bindings &Bindings)

fn apply_pipeline #

fn apply_pipeline(pip Pipeline)

fn apply_scissor_rect #

fn apply_scissor_rect(x int, y int, width int, height int, origin_top_left bool)

fn apply_uniforms #

fn apply_uniforms(stage ShaderStage, ub_index int, data &Range)

fn apply_viewport #

fn apply_viewport(x int, y int, width int, height int, origin_top_left bool)

fn begin_default_pass #

fn begin_default_pass(actions &PassAction, width int, height int)

rendering functions

fn begin_pass #

fn begin_pass(pass Pass, actions &PassAction)

fn commit #

fn commit()

fn create_clear_pass #

fn create_clear_pass(r f32, g f32, b f32, a f32) PassAction

fn destroy_buffer #

fn destroy_buffer(buf Buffer)

fn destroy_image #

fn destroy_image(img Image)

fn destroy_pass #

fn destroy_pass(pass Pass)

fn destroy_pipeline #

fn destroy_pipeline(pip Pipeline)

fn destroy_sampler #

fn destroy_sampler(smp Sampler)

fn destroy_shader #

fn destroy_shader(shd Shader)

fn disable_frame_stats #

fn disable_frame_stats()

disable_frame_stats disables the sokol frame statistics.

fn discard_context #

fn discard_context(ctx_id Context)

fn draw #

fn draw(base_element int, num_elements int, num_instances int)

fn enable_frame_stats #

fn enable_frame_stats()

enable_frame_stats enables the sokol frame statistics.

fn end_pass #

fn end_pass()

fn frame_stats_enabled #

fn frame_stats_enabled() bool

frame_stats_enabled returns true if the sokol frame statistics is enabled.

fn is_valid #

fn is_valid() bool

fn make_buffer #

fn make_buffer(desc &BufferDesc) Buffer

resource creation, destruction and updating

fn make_image #

fn make_image(desc &ImageDesc) Image

fn make_pass #

fn make_pass(desc &PassDesc) Pass

fn make_pipeline #

fn make_pipeline(desc &PipelineDesc) Pipeline

fn make_sampler #

fn make_sampler(desc &SamplerDesc) Sampler

fn make_shader #

fn make_shader(desc &ShaderDesc) Shader

fn query_backend #

fn query_backend() Backend

fn query_buffer_defaults #

fn query_buffer_defaults(desc &Buffer) BufferDesc

get resource creation desc struct with their default values replaced

fn query_buffer_info #

fn query_buffer_info(buf Buffer) BufferInfo

get runtime information about a resource

fn query_buffer_overflow #

fn query_buffer_overflow(buf Buffer) bool

fn query_buffer_state #

fn query_buffer_state(buf Buffer) ResourceState

get current state of a resource (INITIAL, ALLOC, VALID, FAILED, INVALID)

fn query_desc #

fn query_desc() Desc

getting information

fn query_features #

fn query_features() Features

fn query_frame_stats #

fn query_frame_stats() FrameStats

query_frame_stats returns the sokol frame statistics for the current frame.

fn query_image_defaults #

fn query_image_defaults(desc &Image) ImageDesc

fn query_image_info #

fn query_image_info(img Image) ImageInfo

fn query_image_state #

fn query_image_state(img Image) ResourceState

fn query_limits #

fn query_limits() Limits

fn query_pass_defaults #

fn query_pass_defaults(desc &Pass) PassDesc

fn query_pass_info #

fn query_pass_info(pass Pass) PassInfo

fn query_pass_state #

fn query_pass_state(pass Pass) ResourceState

fn query_pipeline_defaults #

fn query_pipeline_defaults(desc &Pipeline) PipelineDesc

fn query_pipeline_info #

fn query_pipeline_info(pip Pipeline) PipelineInfo

fn query_pipeline_state #

fn query_pipeline_state(pip Pipeline) ResourceState

fn query_pixelformat #

fn query_pixelformat(fmt PixelFormat) PixelFormatInfo

fn query_shader_defaults #

fn query_shader_defaults(desc &Shader) ShaderDesc

fn query_shader_info #

fn query_shader_info(shd Shader) ShaderInfo

fn query_shader_state #

fn query_shader_state(shd Shader) ResourceState

fn reset_state_cache #

fn reset_state_cache()

fn setup #

fn setup(desc &Desc)

setup initialises the SOKOL's gfx library, based on the information passed in desc

fn setup_context #

fn setup_context() Context

rendering contexts (optional)

fn shutdown #

fn shutdown()

shutdown tells the SOKOL's gfx library to shutdown, and release the resources it is using

fn update_buffer #

fn update_buffer(buf Buffer, data &Range)

fn update_image #

fn update_image(img Image, data &ImageData)

type Bindings #

type Bindings = C.sg_bindings

fn (Bindings) set_vert_image #

fn (mut b Bindings) set_vert_image(index int, img Image)

fn (Bindings) set_frag_image #

fn (mut b Bindings) set_frag_image(index int, img Image)

fn (Bindings) update_vert_buffer #

fn (b &Bindings) update_vert_buffer(index int, data voidptr, element_size int, element_count int)

fn (Bindings) append_vert_buffer #

fn (b &Bindings) append_vert_buffer(index int, data voidptr, element_size int, element_count int) int

fn (Bindings) update_index_buffer #

fn (b &Bindings) update_index_buffer(data voidptr, element_size int, element_count int)

fn (Bindings) append_index_buffer #

fn (b &Bindings) append_index_buffer(data voidptr, element_size int, element_count int) int

type BlendState #

type BlendState = C.sg_blend_state

type Buffer #

type Buffer = C.sg_buffer

fn (Buffer) free #

fn (mut b Buffer) free()

type BufferDesc #

type BufferDesc = C.sg_buffer_desc

type BufferInfo #

type BufferInfo = C.sg_buffer_info

type Color #

type Color = C.sg_color

type ColorAttachmentAction #

type ColorAttachmentAction = C.sg_color_attachment_action

type ColorTargetState #

type ColorTargetState = C.sg_color_target_state

type CommitListener #

type CommitListener = C.sg_commit_listener

type Context #

type Context = C.sg_context

type ContextDesc #

type ContextDesc = C.sg_context_desc

type D3D11ContextDesc #

type D3D11ContextDesc = C.sg_d3d11_context_desc

type DepthAttachmentAction #

type DepthAttachmentAction = C.sg_depth_attachment_action

type DepthState #

type DepthState = C.sg_depth_state

type Desc #

type Desc = C.sg_desc

type Features #

type Features = C.sg_features

type FrameStats #

type FrameStats = C.sg_frame_stats

type FrameStatsD3D11 #

type FrameStatsD3D11 = C.sg_frame_stats_d3d11

type FrameStatsD3D11Bindings #

type FrameStatsD3D11Bindings = C.sg_frame_stats_d3d11_bindings

type FrameStatsD3D11Draw #

type FrameStatsD3D11Draw = C.sg_frame_stats_d3d11_draw

type FrameStatsD3D11Pass #

type FrameStatsD3D11Pass = C.sg_frame_stats_d3d11_pass

type FrameStatsD3D11Pipeline #

type FrameStatsD3D11Pipeline = C.sg_frame_stats_d3d11_pipeline

type FrameStatsD3D11Uniforms #

type FrameStatsD3D11Uniforms = C.sg_frame_stats_d3d11_uniforms

type FrameStatsGL #

type FrameStatsGL = C.sg_frame_stats_gl

type FrameStatsMetal #

type FrameStatsMetal = C.sg_frame_stats_metal

type FrameStatsMetalBindings #

type FrameStatsMetalBindings = C.sg_frame_stats_metal_bindings

type FrameStatsMetalIdpool #

type FrameStatsMetalIdpool = C.sg_frame_stats_metal_idpool

type FrameStatsMetalPipeline #

type FrameStatsMetalPipeline = C.sg_frame_stats_metal_pipeline

type FrameStatsMetalUniforms #

type FrameStatsMetalUniforms = C.sg_frame_stats_metal_uniforms

type FrameStatsWGPU #

type FrameStatsWGPU = C.sg_frame_stats_wgpu

type FrameStatsWGPUBindings #

type FrameStatsWGPUBindings = C.sg_frame_stats_wgpu_bindings

type FrameStatsWGPUUniforms #

type FrameStatsWGPUUniforms = C.sg_frame_stats_wgpu_uniforms

type GLContextDesc #

type GLContextDesc = C.sg_gl_context_desc

type Image #

type Image = C.sg_image

fn (Image) free #

fn (mut i Image) free()

type ImageData #

type ImageData = C.sg_image_data

type ImageDesc #

type ImageDesc = C.sg_image_desc

type ImageInfo #

type ImageInfo = C.sg_image_info

type Limits #

type Limits = C.sg_limits

type MetalContextDesc #

type MetalContextDesc = C.sg_metal_context_desc

type Pass #

type Pass = C.sg_pass

fn (Pass) free #

fn (mut p Pass) free()

type PassAction #

type PassAction = C.sg_pass_action

type PassAttachmentDesc #

type PassAttachmentDesc = C.sg_pass_attachment_desc

type PassDesc #

type PassDesc = C.sg_pass_desc

type PassInfo #

type PassInfo = C.sg_pass_info

type Pipeline #

type Pipeline = C.sg_pipeline

type PipelineDesc #

type PipelineDesc = C.sg_pipeline_desc

type PipelineInfo #

type PipelineInfo = C.sg_pipeline_info

type PixelFormatInfo #

type PixelFormatInfo = C.sg_pixelformat_info

type Range #

type Range = C.sg_range

type Sampler #

type Sampler = C.sg_sampler

type SamplerDesc #

type SamplerDesc = C.sg_sampler_desc

type Shader #

type Shader = C.sg_shader

fn (Shader) free #

fn (mut s Shader) free()

type ShaderAttrDesc #

type ShaderAttrDesc = C.sg_shader_attr_desc

type ShaderDesc #

type ShaderDesc = C.sg_shader_desc

fn (ShaderDesc) make_shader #

fn (desc &ShaderDesc) make_shader() Shader

type ShaderImageDesc #

type ShaderImageDesc = C.sg_shader_image_desc

type ShaderImageSamplerPairDesc #

type ShaderImageSamplerPairDesc = C.sg_shader_image_sampler_pair_desc

type ShaderInfo #

type ShaderInfo = C.sg_shader_info

type ShaderSamplerDesc #

type ShaderSamplerDesc = C.sg_shader_sampler_desc

type ShaderStageDesc #

type ShaderStageDesc = C.sg_shader_stage_desc

fn (ShaderStageDesc) set_image #

fn (mut desc ShaderStageDesc) set_image(index int, name string) ShaderStageDesc

type ShaderUniformBlockDesc #

type ShaderUniformBlockDesc = C.sg_shader_uniform_block_desc

type ShaderUniformDesc #

type ShaderUniformDesc = C.sg_shader_uniform_desc

type SlotInfo #

type SlotInfo = C.sg_slot_info

type StageBindings #

type StageBindings = C.sg_stage_bindings

type StencilAttachmentAction #

type StencilAttachmentAction = C.sg_stencil_attachment_action

type StencilFaceState #

type StencilFaceState = C.sg_stencil_face_state

type StencilState #

type StencilState = C.sg_stencil_state

type VertexAttrDesc #

type VertexAttrDesc = C.sg_vertex_attr_state

type VertexBufferLayoutState #

type VertexBufferLayoutState = C.sg_vertex_buffer_layout_state

type VertexLayoutState #

type VertexLayoutState = C.sg_vertex_layout_state

enum Backend #

enum Backend {
	glcore33
	gles3
	d3d11
	metal_ios
	metal_macos
	metal_simulator
	wgpu
	dummy
}

enum BlendFactor #

enum BlendFactor as u32 {
	_default // value 0 reserved for default-init
	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
	_force_u32            = 0x7FFFFFFF
}

enum BlendOp #

enum BlendOp as u32 {
	_default // value 0 reserved for default-init
	add
	subtract
	reverse_subtract
	_num
	_force_u32       = 0x7FFFFFFF
}

enum BorderColor #

enum BorderColor as u32 {
	_default // value 0 reserved for default-init
	transparent_black
	opaque_black
	opaque_white
	_num
	_force_u32        = 0x7FFFFFFF
}

enum BufferType #

enum BufferType as u32 {
	_default // value 0 reserved for default-init
	vertexbuffer
	indexbuffer
	_num
	_force_u32   = 0x7FFFFFFF
}

enum ColorMask #

enum ColorMask as u32 {
	_default   = 0 // value 0 reserved for default-init
	@none      = 0x10 // special value for 'all channels disabled
	r          = 1
	g          = 2
	rg         = 3
	b          = 4
	rb         = 5
	gb         = 6
	rgb        = 7
	a          = 8
	ra         = 9
	ga         = 0xa
	rga        = 0xb
	ba         = 0xc
	rba        = 0xd
	gba        = 0xe
	rgba       = 0xf
	_force_u32 = 0x7FFFFFFF
}

enum CompareFunc #

enum CompareFunc as u32 {
	_default // value 0 reserved for default-init
	never
	less
	equal
	less_equal
	greater
	not_equal
	greater_equal
	always
	_num
	_force_u32    = 0x7FFFFFFF
}

enum CubeFace #

enum CubeFace as u32 {
	pos_x
	neg_x
	pos_y
	neg_y
	pos_z
	neg_z
	num
	_force_u32 = 0x7fffffff
}

enum CullMode #

enum CullMode as u32 {
	_default // value 0 reserved for default-init
	@none
	front
	back
	_num
	_force_u32 = 0x7FFFFFFF
}

enum FaceWinding #

enum FaceWinding as u32 {
	default // value 0 reserved for default-init
	ccw
	cw
	num
	force_u32 = 0x7FFFFFFF
}

FaceWindin is C.sg_face_winding

enum Filter #

enum Filter as u32 {
	_default // value 0 reserved for default-init
	@none
	nearest
	linear
	_num
	_force_u32 = 0x7fffffff
}

enum ImageSampleType #

enum ImageSampleType as u32 {
	_default // value 0 reserved for default-init
	float
	depth
	sint
	uint
	unfilterable_float
	_num
	_force_u32         = 0x7FFFFFFF
}

enum ImageType #

enum ImageType as u32 {
	_default // value 0 reserved for default-init
	_2d
	cube
	_3d
	array
	_num
	_force_u32 = 0x7FFFFFFF
}

enum IndexType #

enum IndexType as u32 {
	_default // value 0 reserved for default-init
	@none
	uint16
	uint32
	_num
	_force_u32 = 0x7FFFFFFF
}

enum LoadAction #

enum LoadAction as u32 {
	_default
	clear
	load
	dontcare
	_force_u32 = 0x7FFFFFFF
}

enum PixelFormat #

enum PixelFormat as u32 {
	_default // value 0 reserved for default-init
	@none
	//
	r8
	r8sn
	r8ui
	r8si
	//
	r16
	r16sn
	r16ui
	r16si
	r16f
	rg8
	rg8sn
	rg8ui
	rg8si
	//
	r32ui
	r32si
	r32f
	rg16
	rg16sn
	rg16ui
	rg16si
	rg16f
	rgba8
	srgb8a8
	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
	//
	rgb9e5
	//
	_num
	_force_u32      = 0x7FFFFFFF
}

PixelFormat is C.sg_pixel_format

enum PrimitiveType #

enum PrimitiveType as u32 {
	_default // value 0 reserved for default-init
	points
	lines
	line_strip
	triangles
	triangle_strip
	_num
	_force_u32     = 0x7FFFFFFF
}

enum ResourceState #

enum ResourceState as u32 {
	initial
	alloc
	valid
	failed
	invalid
	_force_u32 = 0x7FFFFFFF
}

enum SamplerType #

enum SamplerType as u32 {
	_default
	filtering
	nonfiltering
	comparison
	_num
	_force_u32   = 0x7FFFFFFF
}

enum ShaderStage #

enum ShaderStage as u32 {
	vs
	fs
	_force_u32 = 0x7FFFFFFF
}

enum StencilOp #

enum StencilOp as u32 {
	_default // value 0 reserved for default-init
	keep
	zero
	replace
	incr_clamp
	decr_clamp
	invert
	incr_wrap
	decr_wrap
	_num
	_force_u32 = 0x7FFFFFFF
}

enum StoreAction #

enum StoreAction as u32 {
	_default
	store
	dontcare
	_force_u32 = 0x7FFFFFFF
}

enum UniformLayout #

enum UniformLayout as u32 {
	uniformlayout_default = 0 // value 0 reserved for default-init
	uniformlayout_native // default: layout depends on currently active backend
	uniformlayout_std140 // std140: memory layout according to std140
	_num
	_force_u32            = 0x7FFFFFFF
}

enum UniformType #

enum UniformType as u32 {
	invalid
	float
	float2
	float3
	float4
	int
	int2
	int3
	int4
	mat4
	_num
	_force_u32 = 0x7FFFFFFF
}

enum Usage #

enum Usage as u32 {
	_default // value 0 reserved for default-init
	immutable
	dynamic
	stream
	_num
	_force_u32 = 0x7FFFFFFF
}

enum VertexFormat #

enum VertexFormat as u32 {
	invalid
	float
	float2
	float3
	float4
	byte4
	byte4n // normalized
	ubyte4
	ubyte4n
	short2
	short2n
	ushort2n
	short4
	short4n
	ushort4n
	uint10_n2
	half2
	half4
	_num
	_force_u32 = 0x7FFFFFFF
}

enum VertexStep #

enum VertexStep as u32 {
	_default // value 0 reserved for default-init
	per_vertex
	per_instance
	_num
	_force_u32   = 0x7FFFFFFF
}

enum Wrap #

enum Wrap as u32 {
	_default // value 0 reserved for default-init
	repeat // The default wrap mode.
	clamp_to_edge
	clamp_to_border // 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 clamp_to_edge without a validation error.
	mirrored_repeat
	_num
	_force_u32      = 0x7FFFFFFF
}

struct C.sg_allocator #

struct C.sg_allocator {
pub mut:
	alloc_fn  memory.FnAllocatorAlloc = unsafe { nil }
	free_fn   memory.FnAllocatorFree  = unsafe { nil }
	user_data voidptr
}

struct C.sg_bindings #

struct C.sg_bindings {
pub mut:
	_start_canary         u32
	vertex_buffers        [8]Buffer
	vertex_buffer_offsets [8]int
	index_buffer          Buffer
	index_buffer_offset   int
	vs                    StageBindings
	fs                    StageBindings
	_end_canary           u32
	// vs_images             [8]Image // old
	// fs_images             [8]Image // old
}

struct C.sg_blend_state #

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
}

struct C.sg_buffer #

struct C.sg_buffer {
	id u32
}

struct C.sg_buffer_desc #

struct C.sg_buffer_desc {
pub mut:
	size  usize
	@type BufferType
	usage Usage
	data  Range
	label &char
	// backend-specific resources
	gl_buffers   [2]u32
	mtl_buffers  [2]voidptr
	d3d11_buffer voidptr
	wgpu_buffer  voidptr
}

struct C.sg_buffer_info #

struct C.sg_buffer_info {
pub:
	slot               SlotInfo
	update_frame_index u32
	append_frame_index u32
	append_pos         int
	append_overflow    bool
	num_slots          int
	active_slot        int
}

struct C.sg_color #

struct C.sg_color {
pub mut:
	r f32
	g f32
	b f32
	a f32
}

struct C.sg_color_attachment_action #

struct C.sg_color_attachment_action {
pub mut:
	load_action  LoadAction
	store_action StoreAction
	clear_value  Color
}

struct C.sg_color_target_state #

struct C.sg_color_target_state {
pub mut:
	pixel_format PixelFormat
	write_mask   ColorMask
	blend        BlendState
}

struct C.sg_commit_listener #

struct C.sg_commit_listener {
pub:
	func      fn (user_data voidptr)
	user_data voidptr
}

C.sg_commit_listener is used with sg_add_commit_listener, to add a callback, which will be called in sg_commit(). This is useful for libraries building on top of sokol-gfx to be notified about when a frame ends (instead of having to guess, or add a manual 'new-frame' function).

struct C.sg_context #

struct C.sg_context {
pub:
	id u32
}

struct C.sg_context_desc #

struct C.sg_context_desc {
pub mut:
	color_format PixelFormat
	depth_format PixelFormat
	sample_count int
	gl           GLContextDesc
	metal        MetalContextDesc
	d3d11        D3D11ContextDesc
	// TODO C.sg_wgpu_context_desc wgpu;
}

struct C.sg_d3d11_context_desc #

struct C.sg_d3d11_context_desc {
	device                voidptr
	device_context        voidptr
	render_target_view_cb fn () voidptr = unsafe { nil }
	depth_stencil_view_cb fn () voidptr = unsafe { nil }
}

struct C.sg_depth_attachment_action #

struct C.sg_depth_attachment_action {
pub mut:
	load_action  LoadAction
	store_action StoreAction
	clear_value  f32
}

struct C.sg_depth_state #

struct C.sg_depth_state {
	pixel_format     PixelFormat
	compare          CompareFunc
	write_enabled    bool
	bias             f32
	bias_slope_scale f32
	bias_clamp       f32
}

struct C.sg_desc #

struct C.sg_desc {
pub mut:
	buffer_pool_size               int
	image_pool_size                int
	sampler_pool_size              int
	shader_pool_size               int
	pipeline_pool_size             int
	pass_pool_size                 int
	context_pool_size              int
	uniform_buffer_size            int
	max_commit_listeners           int
	disable_validation             bool // disable validation layer even in debug mode, useful for tests
	mtl_force_managed_storage_mode bool // for debugging: use Metal managed storage mode for resources even with UMA
	wgpu_disable_bindgroups_cache  bool // set to true to disable the WebGPU backend BindGroup cache
	wgpu_bindgroups_cache_size     int  // number of slots in the WebGPU bindgroup cache (must be 2^N)
	//
	allocator C.sg_allocator
	logger    C.sg_logger
	//
	context C.sg_context_desc
}

C.sg_desc describes

struct C.sg_features #

struct C.sg_features {
pub:
	origin_top_left             bool // framebuffer and texture origin is in top left corner
	image_clamp_to_border       bool // border color and clamp-to-border UV-wrap mode is supported
	mrt_independent_blend_state bool // multiple-render-target rendering can use per-render-target blend state
	mrt_independent_write_mask  bool // multiple-render-target rendering can use per-render-target color write masks
	//	instancing                  bool // hardware instancing supported
	//	multiple_render_targets     bool // offscreen render passes can have multiple render targets attached
	//	msaa_render_targets         bool // offscreen render passes support MSAA antialiasing
	//	imagetype_3d                bool // creation of SG_IMAGETYPE_3D images is supported
	//	imagetype_array             bool // creation of SG_IMAGETYPE_ARRAY images is supported
}

struct C.sg_frame_stats #

struct C.sg_frame_stats {
	frame_index u32 // current frame counter, starts at 0
	//
	num_passes             u32
	num_apply_viewport     u32
	num_apply_scissor_rect u32
	num_apply_pipeline     u32
	num_apply_bindings     u32
	num_apply_uniforms     u32
	num_draw               u32
	num_update_buffer      u32
	num_append_buffer      u32
	num_update_image       u32
	//
	size_apply_uniforms u32
	size_update_buffer  u32
	size_append_buffer  u32
	size_update_image   u32
	//
	gl    FrameStatsGL
	d3d11 FrameStatsD3D11
	metal FrameStatsMetal
	wgpu  FrameStatsWGPU
}

struct C.sg_frame_stats_d3d11 #

struct C.sg_frame_stats_d3d11 {
	pass      FrameStatsD3D11Pass
	pipeline  FrameStatsD3D11Pipeline
	bindings  FrameStatsD3D11Bindings
	uniforms  FrameStatsD3D11Uniforms
	draw      FrameStatsD3D11Draw
	num_map   u32
	num_unmap u32
}

struct C.sg_frame_stats_d3d11_bindings #

struct C.sg_frame_stats_d3d11_bindings {
	num_ia_set_vertex_buffers   u32
	num_ia_set_index_buffer     u32
	num_vs_set_shader_resources u32
	num_ps_set_shader_resources u32
	num_vs_set_samplers         u32
	num_ps_set_samplers         u32
}

struct C.sg_frame_stats_d3d11_draw #

struct C.sg_frame_stats_d3d11_draw {
	num_draw_indexed_instanced u32
	num_draw_indexed           u32
	num_draw_instanced         u32
	num_draw                   u32
}

struct C.sg_frame_stats_d3d11_pass #

struct C.sg_frame_stats_d3d11_pass {
	num_om_set_render_targets    u32
	num_clear_render_target_view u32
	num_clear_depth_stencil_view u32
	num_resolve_subresource      u32
}

struct C.sg_frame_stats_d3d11_pipeline #

struct C.sg_frame_stats_d3d11_pipeline {
	num_rs_set_state               u32
	num_om_set_depth_stencil_state u32
	num_om_set_blend_state         u32
	num_ia_set_primitive_topology  u32
	num_ia_set_input_layout        u32
	num_vs_set_shader              u32
	num_vs_set_constant_buffers    u32
	num_ps_set_shader              u32
	num_ps_set_constant_buffers    u32
}

struct C.sg_frame_stats_d3d11_uniforms #

struct C.sg_frame_stats_d3d11_uniforms {
	num_update_subresource u32
}

struct C.sg_frame_stats_gl #

struct C.sg_frame_stats_gl {
	num_bind_buffer                 u32
	num_active_texture              u32
	num_bind_texture                u32
	num_bind_sampler                u32
	num_use_program                 u32
	num_render_state                u32
	num_vertex_attrib_pointer       u32
	num_vertex_attrib_divisor       u32
	num_enable_vertex_attrib_array  u32
	num_disable_vertex_attrib_array u32
	num_uniform                     u32
}

struct C.sg_frame_stats_metal #

struct C.sg_frame_stats_metal {
	idpool   FrameStatsMetalIdpool
	pipeline FrameStatsMetalPipeline
	bindings FrameStatsMetalBindings
	uniforms FrameStatsMetalUniforms
}

struct C.sg_frame_stats_metal_bindings #

struct C.sg_frame_stats_metal_bindings {
	num_set_vertex_buffer          u32
	num_set_vertex_texture         u32
	num_set_vertex_sampler_state   u32
	num_set_fragment_texture       u32
	num_set_fragment_sampler_state u32
}

struct C.sg_frame_stats_metal_idpool #

struct C.sg_frame_stats_metal_idpool {
	num_added             u32
	num_released          u32
	num_garbage_collected u32
}

struct C.sg_frame_stats_metal_pipeline #

struct C.sg_frame_stats_metal_pipeline {
	num_set_blend_color             u32
	num_set_cull_mode               u32
	num_set_front_facing_winding    u32
	num_set_stencil_reference_value u32
	num_set_depth_bias              u32
	num_set_render_pipeline_state   u32
	num_set_depth_stencil_state     u32
}

struct C.sg_frame_stats_metal_uniforms #

struct C.sg_frame_stats_metal_uniforms {
	num_set_vertex_buffer_offset   u32
	num_set_fragment_buffer_offset u32
}

struct C.sg_frame_stats_wgpu #

struct C.sg_frame_stats_wgpu {
	uniforms FrameStatsWGPUUniforms
	bindings FrameStatsWGPUBindings
}

struct C.sg_frame_stats_wgpu_bindings #

struct C.sg_frame_stats_wgpu_bindings {
	num_set_vertex_buffer                    u32
	num_skip_redundant_vertex_buffer         u32
	num_set_index_buffer                     u32
	num_skip_redundant_index_buffer          u32
	num_create_bindgroup                     u32
	num_discard_bindgroup                    u32
	num_set_bindgroup                        u32
	num_skip_redundant_bindgroup             u32
	num_bindgroup_cache_hits                 u32
	num_bindgroup_cache_misses               u32
	num_bindgroup_cache_collisions           u32
	num_bindgroup_cache_hash_vs_key_mismatch u32
}

struct C.sg_frame_stats_wgpu_uniforms #

struct C.sg_frame_stats_wgpu_uniforms {
	num_set_bindgroup u32
	size_write_buffer u32
}

struct C.sg_gl_context_desc #

struct C.sg_gl_context_desc {
	force_gles2 bool
}

struct C.sg_image #

struct C.sg_image {
pub mut:
	id u32
}

struct C.sg_image_data #

struct C.sg_image_data {
pub mut:
	subimage [sg_cubeface_num][sg_max_mipmaps]Range
}

struct C.sg_image_desc #

struct C.sg_image_desc {
pub mut:
	@type         ImageType
	render_target bool
	width         int
	height        int
	num_slices    int
	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
	data  ImageData
	label &char
	// backend-specific resources
	gl_textures                [2]u32
	gl_texture_target          u32
	mtl_textures               [2]voidptr
	d3d11_texture              voidptr
	d3d11_shader_resource_view voidptr
	wgpu_texture               voidptr
}

struct C.sg_image_info #

struct C.sg_image_info {
pub mut:
	slot            SlotInfo // resource pool slot info
	upd_frame_index u32      // frame index of last sg_update_image()
	num_slots       int      // number of renaming-slots for dynamically updated images
	active_slot     int      // currently active write-slot for dynamically updated images
}

struct C.sg_limits #

struct C.sg_limits {
pub:
	max_image_size_2d                   int // max width/height of SG_IMAGETYPE_2D images
	max_image_size_cube                 int // max width/height of SG_IMAGETYPE_CUBE images
	max_image_size_3d                   int // max width/height/depth of SG_IMAGETYPE_3D images
	max_image_size_array                int // max width/height pf SG_IMAGETYPE_ARRAY images
	max_image_array_layers              int // max number of layers in SG_IMAGETYPE_ARRAY images
	max_vertex_attrs                    int // <= SG_MAX_VERTEX_ATTRIBUTES (only on some GLES2 impls)
	gl_max_vertex_uniform_vectors       int // <= GL_MAX_VERTEX_UNIFORM_VECTORS (only on GL backends)
	gl_max_combined_texture_image_units int // <= GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS (only on GL backends)
}

struct C.sg_logger #

struct C.sg_logger {
pub mut:
	func      memory.FnLogCb = unsafe { nil }
	user_data voidptr
}

struct C.sg_metal_context_desc #

struct C.sg_metal_context_desc {
	device                   voidptr
	renderpass_descriptor_cb fn () voidptr = unsafe { nil }
	drawable_cb              fn () voidptr = unsafe { nil }
}

struct C.sg_pass #

struct C.sg_pass {
	id u32
}

struct C.sg_pass_action #

struct C.sg_pass_action {
pub mut:
	colors  [4]ColorAttachmentAction
	depth   DepthAttachmentAction
	stencil StencilAttachmentAction
}

struct C.sg_pass_attachment_desc #

struct C.sg_pass_attachment_desc {
pub mut:
	image     Image
	mip_level int
	slice     int
	// image sg_image
	// mip_level int
	// union {
	// face int
	// layer int
	// slice int
	// }
}

struct C.sg_pass_desc #

struct C.sg_pass_desc {
pub mut:
	color_attachments        [4]PassAttachmentDesc
	depth_stencil_attachment PassAttachmentDesc
	label                    &char
}

struct C.sg_pass_info #

struct C.sg_pass_info {
	info SlotInfo
}

struct C.sg_pipeline #

struct C.sg_pipeline {
pub:
	id u32
}

fn (C.sg_pipeline) free #

fn (mut p C.sg_pipeline) free()

struct C.sg_pipeline_desc #

struct C.sg_pipeline_desc {
pub mut:
	shader                    Shader
	layout                    VertexLayoutState
	depth                     DepthState
	stencil                   StencilState
	color_count               int
	colors                    [4]ColorTargetState // C.SG_MAX_COLOR_ATTACHMENTS
	primitive_type            PrimitiveType
	index_type                IndexType
	cull_mode                 CullMode
	face_winding              FaceWinding
	sample_count              int
	blend_color               Color
	alpha_to_coverage_enabled bool
	label                     &char = &char(0)
}

struct C.sg_pipeline_info #

struct C.sg_pipeline_info {
pub:
	slot SlotInfo
}

struct C.sg_pixelformat_info #

struct C.sg_pixelformat_info {
pub:
	sample bool // pixel format can be sampled in shaders
	filter bool // pixel format can be sampled with filtering
	render bool // pixel format can be used as render target
	blend  bool // alpha-blending is supported
	msaa   bool // pixel format can be used as MSAA render target
	depth  bool // pixel format is a depth format
}

struct C.sg_range #

struct C.sg_range {
pub mut:
	ptr  voidptr
	size usize
}

struct C.sg_sampler #

struct C.sg_sampler {
pub mut:
	id u32
}

struct C.sg_sampler_desc #

struct C.sg_sampler_desc {
	min_filter     Filter
	mag_filter     Filter
	mipmap_filter  Filter
	wrap_u         Wrap
	wrap_v         Wrap
	wrap_w         Wrap
	min_lod        f32
	max_lod        f32
	border_color   BorderColor
	compare        CompareFunc
	max_anisotropy u32
	label          &char
	// backend-specific resources
	gl_sampler    u32
	mtl_sampler   voidptr
	d3d11_sampler voidptr
	wgpu_sampler  voidptr
}

struct C.sg_sampler_info #

struct C.sg_sampler_info {}

pub struct C.sg_resource_state {} enum

struct C.sg_shader #

struct C.sg_shader {
pub:
	id u32
}

struct C.sg_shader_attr_desc #

struct C.sg_shader_attr_desc {
pub mut:
	name      &char // GLSL vertex attribute name (only required for GLES2)
	sem_name  &char // HLSL semantic name
	sem_index int   // HLSL semantic index
}

struct C.sg_shader_desc #

struct C.sg_shader_desc {
pub mut:
	attrs [16]ShaderAttrDesc
	vs    ShaderStageDesc
	fs    ShaderStageDesc
	label &char
}

fn (C.sg_shader_desc) set_vert_src #

fn (mut desc C.sg_shader_desc) set_vert_src(src string) &ShaderDesc

fn (C.sg_shader_desc) set_frag_src #

fn (mut desc C.sg_shader_desc) set_frag_src(src string) &ShaderDesc

fn (C.sg_shader_desc) set_vert_image #

fn (mut desc C.sg_shader_desc) set_vert_image(index int, name string) &ShaderDesc

fn (C.sg_shader_desc) set_frag_image #

fn (mut desc C.sg_shader_desc) set_frag_image(index int, name string) &ShaderDesc

fn (C.sg_shader_desc) set_vert_uniform_block_size #

fn (mut desc C.sg_shader_desc) set_vert_uniform_block_size(block_index int, size usize) &ShaderDesc

fn (C.sg_shader_desc) set_frag_uniform_block_size #

fn (mut desc C.sg_shader_desc) set_frag_uniform_block_size(block_index int, size usize) &ShaderDesc

fn (C.sg_shader_desc) set_vert_uniform #

fn (mut desc C.sg_shader_desc) set_vert_uniform(block_index int, uniform_index int, name string, @type UniformType, array_count int) &ShaderDesc

fn (C.sg_shader_desc) set_frag_uniform #

fn (mut desc C.sg_shader_desc) set_frag_uniform(block_index int, uniform_index int, name string, @type UniformType, array_count int) &ShaderDesc

struct C.sg_shader_image_desc #

struct C.sg_shader_image_desc {
pub mut:
	used         bool
	multisampled bool
	// name         &char
	image_type  ImageType
	sample_type ImageSampleType
}

struct C.sg_shader_image_sampler_pair_desc #

struct C.sg_shader_image_sampler_pair_desc {
pub mut:
	used         bool
	image_slot   int
	sampler_slot int
	glsl_name    &char
}

struct C.sg_shader_info #

struct C.sg_shader_info {
pub:
	slot SlotInfo
}

struct C.sg_shader_sampler_desc #

struct C.sg_shader_sampler_desc {
pub mut:
	used         bool
	sampler_type SamplerType
}

struct C.sg_shader_stage_desc #

struct C.sg_shader_stage_desc {
pub mut:
	source              &char
	bytecode            Range
	entry               &char
	d3d11_target        &char
	uniform_blocks      [4]ShaderUniformBlockDesc
	images              [12]ShaderImageDesc
	samplers            [8]ShaderSamplerDesc
	image_sampler_pairs [12]ShaderImageSamplerPairDesc
}

struct C.sg_shader_uniform_block_desc #

struct C.sg_shader_uniform_block_desc {
pub mut:
	size     usize
	layout   UniformLayout
	uniforms [16]ShaderUniformDesc
}

struct C.sg_shader_uniform_desc #

struct C.sg_shader_uniform_desc {
pub mut:
	name        &char
	@type       UniformType
	array_count int
}

struct C.sg_slot_info #

struct C.sg_slot_info {
	state  ResourceState
	res_id u32
	ctx_id u32
}

struct C.sg_stage_bindings #

struct C.sg_stage_bindings {
pub mut:
	images   [12]Image
	samplers [8]Sampler
}

struct C.sg_stencil_attachment_action #

struct C.sg_stencil_attachment_action {
pub mut:
	load_action  LoadAction
	store_action StoreAction
	clear_value  u8
}

struct C.sg_stencil_face_state #

struct C.sg_stencil_face_state {
	compare       CompareFunc
	fail_op       StencilOp
	depth_fail_op StencilOp
	pass_op       StencilOp
}

struct C.sg_stencil_state #

struct C.sg_stencil_state {
	enabled    bool
	front      StencilFaceState
	back       StencilFaceState
	read_mask  u8
	write_mask u8
	ref        u8
}

struct C.sg_trace_hooks #

struct C.sg_trace_hooks {}

struct C.sg_vertex_attr_state #

struct C.sg_vertex_attr_state {
pub mut:
	buffer_index int
	offset       int
	format       VertexFormat
}

struct C.sg_vertex_buffer_layout_state #

struct C.sg_vertex_buffer_layout_state {
pub mut:
	stride    int
	step_func VertexStep
	step_rate int
}

struct C.sg_vertex_layout_state #

struct C.sg_vertex_layout_state {
pub mut:
	buffers [8]VertexBufferLayoutState
	attrs   [16]VertexAttrDesc
}