sokol.gfx #

Constants #

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

fn activate_context #

fn activate_context(ctx_id C.sg_context)

fn append_buffer #

fn append_buffer(buf C.sg_buffer, data &C.sg_range) int

fn apply_bindings #

fn apply_bindings(bindings &C.sg_bindings)

fn apply_pipeline #

fn apply_pipeline(pip C.sg_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 int, ub_index int, data &C.sg_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 &C.sg_pass_action, width int, height int)

rendering functions

fn begin_pass #

fn begin_pass(pass C.sg_pass, actions &C.sg_pass_action)

fn commit #

fn commit()

fn create_clear_pass #

fn create_clear_pass(r f32, g f32, b f32, a f32) C.sg_pass_action

fn destroy_buffer #

fn destroy_buffer(buf C.sg_buffer)

fn destroy_image #

fn destroy_image(img C.sg_image)

fn destroy_pass #

fn destroy_pass(pass C.sg_pass)

fn destroy_pipeline #

fn destroy_pipeline(pip C.sg_pipeline)

fn destroy_shader #

fn destroy_shader(shd C.sg_shader)

fn discard_context #

fn discard_context(ctx_id C.sg_context)

fn draw #

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

fn end_pass #

fn end_pass()

fn is_valid #

fn is_valid() bool

fn make_buffer #

fn make_buffer(desc &C.sg_buffer_desc) C.sg_buffer

resource creation, destruction and updating

fn make_image #

fn make_image(desc &C.sg_image_desc) C.sg_image

fn make_pass #

fn make_pass(desc &C.sg_pass_desc) C.sg_pass

fn make_pipeline #

fn make_pipeline(desc &C.sg_pipeline_desc) C.sg_pipeline

fn make_shader #

fn make_shader(desc &C.sg_shader_desc) C.sg_shader

fn query_backend #

fn query_backend() Backend

fn query_buffer_defaults #

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 #

fn query_buffer_info(buf C.sg_buffer) C.sg_buffer_info

get runtime information about a resource

fn query_buffer_overflow #

fn query_buffer_overflow(buf C.sg_buffer) bool

fn query_buffer_state #

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 #

fn query_desc() C.sg_desc

getting information

fn query_features #

fn query_features() C.sg_features

fn query_image_defaults #

fn query_image_defaults(desc &C.sg_image) C.sg_image_desc

fn query_image_info #

fn query_image_info(img C.sg_image) C.sg_image_info

fn query_image_state #

fn query_image_state(img C.sg_image) C.sg_resource_state

fn query_limits #

fn query_limits() C.sg_limits

fn query_pass_defaults #

fn query_pass_defaults(desc &C.sg_pass) C.sg_pass_desc

fn query_pass_info #

fn query_pass_info(pass C.sg_pass) C.sg_pass_info

fn query_pass_state #

fn query_pass_state(pass C.sg_pass) C.sg_resource_state

fn query_pipeline_defaults #

fn query_pipeline_defaults(desc &C.sg_pipeline) C.sg_pipeline_desc

fn query_pipeline_info #

fn query_pipeline_info(pip C.sg_pipeline) C.sg_pipeline_info

fn query_pipeline_state #

fn query_pipeline_state(pip C.sg_pipeline) C.sg_resource_state

fn query_pixelformat #

fn query_pixelformat(fmt PixelFormat) C.sg_pixelformat_info

fn query_shader_defaults #

fn query_shader_defaults(desc &C.sg_shader) C.sg_shader_desc

fn query_shader_info #

fn query_shader_info(shd C.sg_shader) C.sg_shader_info

fn query_shader_state #

fn query_shader_state(shd C.sg_shader) C.sg_resource_state

fn reset_state_cache #

fn reset_state_cache()

fn setup #

fn setup(desc &C.sg_desc)

setup and misc functions

fn setup_context #

fn setup_context() C.sg_context

rendering contexts (optional)

fn shutdown #

fn shutdown()

fn update_buffer #

fn update_buffer(buf C.sg_buffer, data &C.sg_range)

fn update_image #

fn update_image(img C.sg_image, data &C.sg_image_data)

enum Action #

enum Action {
	_default
	clear
	load
	dontcare
	_num
}

enum Backend #

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

enum BlendFactor #

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 #

enum BlendOp {
	_default
	add
	subtract
	reverse_subtract
	_num
}

enum BorderColor #

enum BorderColor {
	_default
	transparent_black
	opaque_black
	opaque_white
	_num
}

enum BufferType #

enum BufferType {
	_default
	vertexbuffer
	indexbuffer
	_num
}

enum ColorMask #

enum ColorMask {
	_default = 0
	@none = 0x10
	r = 1
	g = 2
	b = 4
	a = 8
	rgb = 0x7
	rgba = 0xF
}

enum CompareFunc #

enum CompareFunc {
	_default
	never
	less
	equal
	less_equal
	greater
	not_equal
	greater_equal
	always
	_num
}

enum CubeFace #

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

enum CullMode #

enum CullMode {
	_default
	@none
	front
	back
	_num
}

enum FaceWinding #

enum FaceWinding {
	_facewinding_default
	facewinding_ccw
	facewinding_cw
	_facewinding_num
}

enum Filter #

enum Filter {
	_default
	nearest
	linear
	nearest_mipmap_nearest
	nearest_mipmap_linear
	linear_mipmap_nearest
	linear_mipmap_linear
	_num
}

enum ImageType #

enum ImageType {
	_default
	_2d
	cube
	_3d
	array
	_num
}

enum IndexType #

enum IndexType {
	_default
	@none
	uint16
	uint32
	_num
}

enum PixelFormat #

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 #

enum PrimitiveType {
	_default
	points
	lines
	line_strip
	triangles
	triangle_strip
	_num
}

enum ResourceState #

enum ResourceState {
	initial
	alloc
	valid
	failed
	invalid
}

enum ShaderStage #

enum ShaderStage {
	vs
	fs
}

enum StencilOp #

enum StencilOp {
	_default
	keep
	zero
	replace
	incr_clamp
	decr_clamp
	invert
	incr_wrap
	decr_wrap
	_num
}

enum UniformType #

enum UniformType {
	invalid
	float
	float2
	float3
	float4
	mat4
	_num
}

enum Usage #

enum Usage {
	_default
	immutable
	dynamic
	stream
	_num
}

enum VertexFormat #

enum VertexFormat {
	invalid
	float
	float2
	float3
	float4
	byte4
	byte4n
	ubyte4
	ubyte4n
	short2
	short2n
	ushort2n
	short4
	short4n
	ushort4n
	uint10_n2
	_num
}

enum VertexStep #

enum VertexStep {
	_default
	per_vertex
	per_instance
	_num
}

enum Wrap #

enum Wrap {
	_default
	repeat
	clamp_to_edge
	clamp_to_border
	mirrored_repeat
	_num
}

struct C.sg_bindings #

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 (C.sg_bindings) set_vert_image #

fn (mut b C.sg_bindings) set_vert_image(index int, img C.sg_image)

fn (C.sg_bindings) set_frag_image #

fn (mut b C.sg_bindings) set_frag_image(index int, img C.sg_image)

fn (C.sg_bindings) update_vert_buffer #

fn (b &C.sg_bindings) update_vert_buffer(index int, data voidptr, element_size int, element_count int)

fn (C.sg_bindings) append_vert_buffer #

fn (b &C.sg_bindings) append_vert_buffer(index int, data voidptr, element_size int, element_count int) int

fn (C.sg_bindings) update_index_buffer #

fn (b &C.sg_bindings) update_index_buffer(data voidptr, element_size int, element_count int)

fn (C.sg_bindings) append_index_buffer #

fn (b &C.sg_bindings) append_index_buffer(data voidptr, element_size int, element_count int) int

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
}

fn (C.sg_buffer) free #

fn (mut b C.sg_buffer) free()

struct C.sg_buffer_desc #

struct C.sg_buffer_desc {
pub mut:
	_start_canary u32
	size          usize
	@type         BufferType
	usage         Usage
	data          C.sg_range
	label         &char

	gl_buffers [2]u32

	mtl_buffers [2]voidptr

	d3d11_buffer voidptr
	_end_canary  u32
}

struct C.sg_buffer_info #

struct C.sg_buffer_info {
}

struct C.sg_buffer_layout_desc #

struct C.sg_buffer_layout_desc {
pub mut:
	stride    int
	step_func VertexStep
	step_rate 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:
	action Action
	value  C.sg_color
}

struct C.sg_color_state #

struct C.sg_color_state {
pub mut:
	pixel_format PixelFormat
	write_mask   ColorMask
	blend        C.sg_blend_state
}

struct C.sg_context #

struct C.sg_context {
	id u32
}

struct C.sg_context_desc #

struct C.sg_context_desc {
	sample_count int
	gl           C.sg_gl_context_desc
	metal        C.sg_metal_context_desc
	d3d11        C.sg_d3d11_context_desc
	color_format PixelFormat
	depth_format PixelFormat
}

struct C.sg_d3d11_context_desc #

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 #

struct C.sg_depth_attachment_action {
pub mut:
	action Action
	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 {
	_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 #

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
	mrt_independent_blend_state bool
	mrt_independent_write_mask  bool
}

struct C.sg_gl_context_desc #

struct C.sg_gl_context_desc {
	force_gles2 bool
}

struct C.sg_image #

struct C.sg_image {
pub:
	id u32
}

fn (C.sg_image) free #

fn (mut i C.sg_image) free()

struct C.sg_image_data #

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

struct C.sg_image_desc #

struct C.sg_image_desc {
pub mut:
	_start_canary  u32
	@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           C.sg_image_data
	label          &char

	gl_textures       [2]u32
	gl_texture_target u32

	mtl_textures [2]voidptr

	d3d11_texture              voidptr
	d3d11_shader_resource_view voidptr

	wgpu_texture voidptr
	_end_canary  u32
}

struct C.sg_image_info #

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 #

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 #

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_metal_context_desc #

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

struct C.sg_pass #

struct C.sg_pass {
	id u32
}

fn (C.sg_pass) free #

fn (mut p C.sg_pass) free()

struct C.sg_pass_action #

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_attachment_desc #

struct C.sg_pass_attachment_desc {
pub mut:
	image     C.sg_image
	mip_level int
	face      int
}

struct C.sg_pass_desc #

struct C.sg_pass_desc {
pub mut:
	_start_canary            u32
	color_attachments        [4]C.sg_pass_attachment_desc
	depth_stencil_attachment C.sg_pass_attachment_desc
	label                    &char
	_end_canary              u32
}

struct C.sg_pass_info #

struct C.sg_pass_info {
	info C.sg_slot_info
}

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:
	_start_canary             u32
	shader                    C.sg_shader
	layout                    C.sg_layout_desc
	depth                     C.sg_depth_state
	stencil                   C.sg_stencil_state
	color_count               int
	colors                    [4]C.sg_color_state
	primitive_type            PrimitiveType
	index_type                IndexType
	cull_mode                 CullMode
	face_winding              FaceWinding
	sample_count              int
	blend_color               C.sg_color
	alpha_to_coverage_enabled bool
	label                     &char = &char(0)
	_end_canary               u32
}

struct C.sg_pipeline_info #

struct C.sg_pipeline_info {
}

struct C.sg_pixelformat_info #

struct C.sg_pixelformat_info {
pub:
	sample bool
	filter bool
	render bool
	blend  bool
	msaa   bool
	depth  bool
}

struct C.sg_range #

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

struct C.sg_shader #

struct C.sg_shader {
pub:
	id u32
}

fn (C.sg_shader) free #

fn (mut s C.sg_shader) free()

struct C.sg_shader_attr_desc #

struct C.sg_shader_attr_desc {
pub mut:
	name      &char
	sem_name  &char
	sem_index int
}

struct C.sg_shader_desc #

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         &char
	_end_canary   u32
}

fn (C.sg_shader_desc) set_vert_src #

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

fn (C.sg_shader_desc) set_frag_src #

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

fn (C.sg_shader_desc) set_vert_image #

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

fn (C.sg_shader_desc) set_frag_image #

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

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) &C.sg_shader_desc

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) &C.sg_shader_desc

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) &C.sg_shader_desc

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) &C.sg_shader_desc

fn (C.sg_shader_desc) make_shader #

fn (desc &C.sg_shader_desc) make_shader() C.sg_shader

struct C.sg_shader_image_desc #

struct C.sg_shader_image_desc {
pub mut:
	name       &char
	image_type ImageType
}

struct C.sg_shader_info #

struct C.sg_shader_info {
}

struct C.sg_shader_stage_desc #

struct C.sg_shader_stage_desc {
pub mut:
	source         &char
	bytecode       C.sg_range
	entry          &char
	uniform_blocks [4]C.sg_shader_uniform_block_desc
	images         [12]C.sg_shader_image_desc
}

fn (C.sg_shader_stage_desc) set_image #

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 #

struct C.sg_shader_uniform_block_desc {
pub mut:
	size     usize
	uniforms [16]C.sg_shader_uniform_desc
}

struct C.sg_shader_uniform_desc #

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

struct C.sg_stencil_attachment_action #

struct C.sg_stencil_attachment_action {
pub mut:
	action Action
	value  byte
}

struct C.sg_stencil_face_state #

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

struct C.sg_stencil_state #

struct C.sg_stencil_state {
	enabled    bool
	front      C.sg_stencil_face_state
	back       C.sg_stencil_face_state
	read_mask  byte
	write_mask byte
	ref        byte
}

struct C.sg_vertex_attr_desc #

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

struct DepthLayers #

struct DepthLayers {
	depth  int
	layers int
}