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_shader #
fn destroy_shader(shd Shader)
fn discard_context #
fn discard_context(ctx_id 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 &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_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_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 BufferLayoutDesc #
type BufferLayoutDesc = C.sg_buffer_layout_desc
fn (C.sg_pipeline) free #
fn (mut p C.sg_pipeline) free()
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
type Color #
type Color = C.sg_color
type ColorAttachmentAction #
type ColorAttachmentAction = C.sg_color_attachment_action
type ColorState #
type ColorState = C.sg_color_state
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 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 LayoutDesc #
type LayoutDesc = C.sg_layout_desc
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 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 ShaderInfo #
type ShaderInfo = C.sg_shader_info
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 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_desc
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 // 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
}
enum BlendOp #
enum BlendOp {
_default // value 0 reserved for default-init
add
subtract
reverse_subtract
_num
}
enum BorderColor #
enum BorderColor {
_default // value 0 reserved for default-init
transparent_black
opaque_black
opaque_white
_num
}
enum BufferType #
enum BufferType {
_default // value 0 reserved for default-init
vertexbuffer
indexbuffer
_num
}
enum ColorMask #
enum ColorMask {
_default = 0 // value 0 reserved for default-init
@none = 0x10 // special value for 'all channels disabled
r = 1
g = 2
b = 4
a = 8
rgb = 0x7
rgba = 0xF
}
enum CompareFunc #
enum CompareFunc {
_default // value 0 reserved for default-init
never
less
equal
less_equal
greater
not_equal
greater_equal
always
_num
}
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 {
_default // value 0 reserved for default-init
@none
front
back
_num
}
enum FaceWinding #
enum FaceWinding {
_facewinding_default // value 0 reserved for default-init
facewinding_ccw
facewinding_cw
_facewinding_num
}
FaceWindin is C.sg_face_winding
enum Filter #
enum Filter {
_default // value 0 reserved for default-init
nearest
linear
nearest_mipmap_nearest
nearest_mipmap_linear
linear_mipmap_nearest
linear_mipmap_linear
_num
}
enum ImageType #
enum ImageType {
_default // value 0 reserved for default-init
_2d
cube
_3d
array
_num
}
enum IndexType #
enum IndexType {
_default // value 0 reserved for default-init
@none
uint16
uint32
_num
}
enum PixelFormat #
enum PixelFormat {
_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
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
}
PixelFormat is C.sg_pixel_format
enum PrimitiveType #
enum PrimitiveType {
_default // value 0 reserved for default-init
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 // value 0 reserved for default-init
keep
zero
replace
incr_clamp
decr_clamp
invert
incr_wrap
decr_wrap
_num
}
enum UniformLayout #
enum UniformLayout {
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
}
enum UniformType #
enum UniformType {
invalid
float
float2
float3
float4
mat4
_num
}
enum Usage #
enum Usage {
_default // value 0 reserved for default-init
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 // value 0 reserved for default-init
per_vertex
per_instance
_num
}
enum Wrap #
enum Wrap {
_default // value 0 reserved for default-init
repeat
clamp_to_edge
clamp_to_border
mirrored_repeat
_num
}
struct C.sg_allocator #
struct C.sg_allocator {
pub mut:
alloc memory.FnAllocatorAlloc
free memory.FnAllocatorFree
user_data voidptr
}
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_depth_attachment_action #
struct C.sg_depth_attachment_action {
pub mut:
action Action
value f32
}
struct C.sg_desc #
struct C.sg_desc {
pub mut:
_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
uniform_buffer_size int
staging_buffer_size int
sampler_cache_size int
max_commit_listeners int
disable_validation bool // disable validation layer even in debug mode, useful for tests
//
allocator C.sg_allocator
logger C.sg_logger
//
context ContextDesc
_end_canary u32
}
C.sg_desc describes
struct C.sg_image #
struct C.sg_image {
pub:
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:
_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 ImageData
label &char
// GL specific
gl_textures [2]u32
gl_texture_target u32
// Metal specific
mtl_textures [2]voidptr
// D3D11 specific
d3d11_texture voidptr
d3d11_shader_resource_view voidptr
// WebGPU specific
wgpu_texture voidptr
_end_canary u32
}
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_layout_desc #
struct C.sg_layout_desc {
pub mut:
buffers [8]BufferLayoutDesc
attrs [16]VertexAttrDesc
}
struct C.sg_limits #
struct C.sg_limits {
pub:
max_image_size_2d u32 // max width/height of SG_IMAGETYPE_2D images
max_image_size_cube u32 // max width/height of SG_IMAGETYPE_CUBE images
max_image_size_3d u32 // max width/height/depth of SG_IMAGETYPE_3D images
max_image_size_array u32 // max width/height pf SG_IMAGETYPE_ARRAY images
max_image_array_layers u32 // max number of layers in SG_IMAGETYPE_ARRAY images
max_vertex_attrs u32 // <= SG_MAX_VERTEX_ATTRIBUTES (only on some GLES2 impls)
}
struct C.sg_logger #
struct C.sg_logger {
pub mut:
log_cb memory.FnLogCb
user_data voidptr
}
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_stencil_attachment_action #
struct C.sg_stencil_attachment_action {
pub mut:
action Action
value u8
}
struct C.sg_vertex_attr_desc #
struct C.sg_vertex_attr_desc {
pub mut:
buffer_index int
offset int
format VertexFormat
}
- Constants
- fn activate_context
- fn append_buffer
- fn apply_bindings
- fn apply_pipeline
- fn apply_scissor_rect
- fn apply_uniforms
- fn apply_viewport
- fn begin_default_pass
- fn begin_pass
- fn commit
- fn create_clear_pass
- fn destroy_buffer
- fn destroy_image
- fn destroy_pass
- fn destroy_pipeline
- fn destroy_shader
- fn discard_context
- fn draw
- fn end_pass
- fn is_valid
- fn make_buffer
- fn make_image
- fn make_pass
- fn make_pipeline
- fn make_shader
- fn query_backend
- fn query_buffer_defaults
- fn query_buffer_info
- fn query_buffer_overflow
- fn query_buffer_state
- fn query_desc
- fn query_features
- fn query_image_defaults
- fn query_image_info
- fn query_image_state
- fn query_limits
- fn query_pass_defaults
- fn query_pass_info
- fn query_pass_state
- fn query_pipeline_defaults
- fn query_pipeline_info
- fn query_pipeline_state
- fn query_pixelformat
- fn query_shader_defaults
- fn query_shader_info
- fn query_shader_state
- fn reset_state_cache
- fn setup
- fn setup_context
- fn shutdown
- fn update_buffer
- fn update_image
- type Bindings
- type BlendState
- type Buffer
- type BufferDesc
- type BufferInfo
- type BufferLayoutDesc
- type C.sg_pipeline
- type C.sg_shader_desc
- type Color
- type ColorAttachmentAction
- type ColorState
- type Context
- type ContextDesc
- type D3D11ContextDesc
- type DepthAttachmentAction
- type DepthState
- type Desc
- type Features
- type GLContextDesc
- type Image
- type ImageData
- type ImageDesc
- type ImageInfo
- type LayoutDesc
- type Limits
- type MetalContextDesc
- type Pass
- type PassAction
- type PassAttachmentDesc
- type PassDesc
- type PassInfo
- type Pipeline
- type PipelineDesc
- type PipelineInfo
- type PixelFormatInfo
- type Range
- type Shader
- type ShaderAttrDesc
- type ShaderDesc
- type ShaderImageDesc
- type ShaderInfo
- type ShaderStageDesc
- type ShaderUniformBlockDesc
- type ShaderUniformDesc
- type SlotInfo
- type StencilAttachmentAction
- type StencilFaceState
- type StencilState
- type VertexAttrDesc
- enum Action
- enum Backend
- enum BlendFactor
- enum BlendOp
- enum BorderColor
- enum BufferType
- enum ColorMask
- enum CompareFunc
- enum CubeFace
- enum CullMode
- enum FaceWinding
- enum Filter
- enum ImageType
- enum IndexType
- enum PixelFormat
- enum PrimitiveType
- enum ResourceState
- enum ShaderStage
- enum StencilOp
- enum UniformLayout
- enum UniformType
- enum Usage
- enum VertexFormat
- enum VertexStep
- enum Wrap
- struct C.sg_allocator
- struct C.sg_buffer_layout_desc
- struct C.sg_depth_attachment_action
- struct C.sg_desc
- struct C.sg_image
- struct C.sg_image_data
- struct C.sg_image_desc
- struct C.sg_image_info
- struct C.sg_layout_desc
- struct C.sg_limits
- struct C.sg_logger
- struct C.sg_pixelformat_info
- struct C.sg_range
- struct C.sg_stencil_attachment_action
- struct C.sg_vertex_attr_desc