Module sokol.gfx stdlib

sokol.gfx
Version:
0.3.3
License:
MIT
Dependencies from vmod:
0
Imports:
2
Imported by:
5
Repository:
OS-specific
Show selected OS-specific symbols.
Backend-specific
Show selected Backend-specific symbols.

Dependencies defined in v.mod

This section is empty.

Imports

Imported by

Aliases

#type Desc

type Desc = C.sg_desc

#type ContextDesc

type ContextDesc = C.sg_context_desc

#type GLContextDesc

type GLContextDesc = C.sg_gl_context_desc

#type MetalContextDesc

type MetalContextDesc = C.sg_metal_context_desc

#type D3D11ContextDesc

type D3D11ContextDesc = C.sg_d3d11_context_desc

#type ColorState

type ColorState = C.sg_color_state

#type PipelineDesc

type PipelineDesc = C.sg_pipeline_desc

#type PipelineInfo

type PipelineInfo = C.sg_pipeline_info

#type Pipeline

type Pipeline = C.sg_pipeline

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

type ShaderDesc = C.sg_shader_desc

#fn (&ShaderDesc) make_shader

fn (desc &ShaderDesc) make_shader() Shader

#type ShaderAttrDesc

type ShaderAttrDesc = C.sg_shader_attr_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 ShaderImageDesc

type ShaderImageDesc = C.sg_shader_image_desc

#type ShaderInfo

type ShaderInfo = C.sg_shader_info

#type Context

type Context = C.sg_context

#type Range

type Range = C.sg_range

#type Color

type Color = C.sg_color

#type Shader

type Shader = C.sg_shader

#fn (&Shader) free

fn (mut s &Shader) free()

#type PassDesc

type PassDesc = C.sg_pass_desc

#type PassInfo

type PassInfo = C.sg_pass_info

#type PassAction

type PassAction = C.sg_pass_action

#type Pass

type Pass = C.sg_pass

#fn (&Pass) free

fn (mut p &Pass) free()

#type BufferDesc

type BufferDesc = C.sg_buffer_desc

#type SlotInfo

type SlotInfo = C.sg_slot_info

#type BufferInfo

type BufferInfo = C.sg_buffer_info

#type Buffer

type Buffer = C.sg_buffer

#fn (&Buffer) free

fn (mut b &Buffer) free()

#type ImageDesc

type ImageDesc = C.sg_image_desc

#type ImageInfo

type ImageInfo = C.sg_image_info

#type Image

type Image = C.sg_image

#fn (&Image) free

fn (mut i &Image) free()

#type ImageData

type ImageData = C.sg_image_data

#type Features

type Features = C.sg_features

#type Limits

type Limits = C.sg_limits

#type LayoutDesc

type LayoutDesc = C.sg_layout_desc

#type BufferLayoutDesc

type BufferLayoutDesc = C.sg_buffer_layout_desc

#type VertexAttrDesc

type VertexAttrDesc = C.sg_vertex_attr_desc

#type StencilState

type StencilState = C.sg_stencil_state

#type DepthState

type DepthState = C.sg_depth_state

#type StencilFaceState

type StencilFaceState = C.sg_stencil_face_state

#type BlendState

type BlendState = C.sg_blend_state

#type ColorAttachmentAction

type ColorAttachmentAction = C.sg_color_attachment_action

#type DepthAttachmentAction

type DepthAttachmentAction = C.sg_depth_attachment_action

#type StencilAttachmentAction

type StencilAttachmentAction = C.sg_stencil_attachment_action

#type PixelFormatInfo

type PixelFormatInfo = C.sg_pixelformat_info

#type PassAttachmentDesc

type PassAttachmentDesc = C.sg_pass_attachment_desc

Constants

#constant version

pub const version = 1

#constant used_import

pub const used_import = c.used_import

#constant sg_cubeface_num

pub const sg_cubeface_num = 6

#constant sg_max_mipmaps

pub const sg_max_mipmaps = 16

Sum types

This section is empty.

Functions

#fn activate_context

inline
fn activate_context(ctx_id Context)

#fn append_buffer

inline
fn append_buffer(buf Buffer, data &Range) int

#fn apply_bindings

inline
fn apply_bindings(bindings &Bindings)

#fn apply_pipeline

inline
fn apply_pipeline(pip Pipeline)

#fn apply_scissor_rect

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

#fn apply_uniforms

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

#fn apply_viewport

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

#fn begin_default_pass

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

rendering functions

#fn begin_pass

inline
fn begin_pass(pass Pass, actions &PassAction)

#fn commit

inline
fn commit()

#fn create_clear_pass

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

#fn destroy_buffer

inline
fn destroy_buffer(buf Buffer)

#fn destroy_image

inline
fn destroy_image(img Image)

#fn destroy_pass

inline
fn destroy_pass(pass Pass)

#fn destroy_pipeline

inline
fn destroy_pipeline(pip Pipeline)

#fn destroy_shader

inline
fn destroy_shader(shd Shader)

#fn discard_context

inline
fn discard_context(ctx_id Context)

#fn draw

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

#fn end_pass

inline
fn end_pass()

#fn is_valid

inline
fn is_valid() bool

#fn make_buffer

inline
fn make_buffer(desc &BufferDesc) Buffer

resource creation, destruction and updating

#fn make_image

inline
fn make_image(desc &ImageDesc) Image

#fn make_pass

inline
fn make_pass(desc &PassDesc) Pass

#fn make_pipeline

inline
fn make_pipeline(desc &PipelineDesc) Pipeline

#fn make_shader

inline
fn make_shader(desc &ShaderDesc) Shader

#fn query_backend

inline
fn query_backend() Backend

#fn query_buffer_defaults

inline
fn query_buffer_defaults(desc &Buffer) BufferDesc

get resource creation desc struct with their default values replaced

#fn query_buffer_info

inline
fn query_buffer_info(buf Buffer) BufferInfo

get runtime information about a resource

#fn query_buffer_overflow

inline
fn query_buffer_overflow(buf Buffer) bool

#fn query_buffer_state

inline
fn query_buffer_state(buf Buffer) ResourceState

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

#fn query_desc

inline
fn query_desc() Desc

getting information

#fn query_features

inline
fn query_features() Features

#fn query_image_defaults

inline
fn query_image_defaults(desc &Image) ImageDesc

#fn query_image_info

inline
fn query_image_info(img Image) ImageInfo

#fn query_image_state

inline
fn query_image_state(img Image) ResourceState

#fn query_limits

inline
fn query_limits() Limits

#fn query_pass_defaults

inline
fn query_pass_defaults(desc &Pass) PassDesc

#fn query_pass_info

inline
fn query_pass_info(pass Pass) PassInfo

#fn query_pass_state

inline
fn query_pass_state(pass Pass) ResourceState

#fn query_pipeline_defaults

inline
fn query_pipeline_defaults(desc &Pipeline) PipelineDesc

#fn query_pipeline_info

inline
fn query_pipeline_info(pip Pipeline) PipelineInfo

#fn query_pipeline_state

inline
fn query_pipeline_state(pip Pipeline) ResourceState

#fn query_pixelformat

inline
fn query_pixelformat(fmt PixelFormat) PixelFormatInfo

#fn query_shader_defaults

inline
fn query_shader_defaults(desc &Shader) ShaderDesc

#fn query_shader_info

inline
fn query_shader_info(shd Shader) ShaderInfo

#fn query_shader_state

inline
fn query_shader_state(shd Shader) ResourceState

#fn reset_state_cache

inline
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

inline
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

inline
fn update_buffer(buf Buffer, data &Range)

#fn update_image

inline
fn update_image(img Image, data &ImageData)

Structs

#struct C.sg_allocator

typedef
pub struct C.sg_allocator {
pub mut:
	alloc     memory.FnAllocatorAlloc
	free      memory.FnAllocatorFree
	user_data voidptr
}

#struct C.sg_logger

typedef
pub struct C.sg_logger {
pub mut:
	log_cb    memory.FnLogCb
	user_data voidptr
}

#struct C.sg_desc

pub 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_range

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

#struct C.sg_image_desc

pub 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

pub 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_image

pub struct C.sg_image {
pub:
	id u32
}

#struct C.sg_image_data

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

#struct C.sg_limits

pub 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_layout_desc

pub struct C.sg_layout_desc {
pub mut:
	buffers [8]BufferLayoutDesc
	attrs   [16]VertexAttrDesc
}

#struct C.sg_buffer_layout_desc

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

#struct C.sg_vertex_attr_desc

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

#struct C.sg_depth_attachment_action

pub struct C.sg_depth_attachment_action {
pub mut:
	action Action
	value  f32
}

#struct C.sg_stencil_attachment_action

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

#struct C.sg_pixelformat_info

pub 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
}

Interfaces

This section is empty.

Enums

#enum Backend

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

#enum PixelFormat

pub 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 ResourceState

pub enum ResourceState {
	initial
	alloc
	valid
	failed
	invalid
}

#enum Usage

pub enum Usage {
	_default // value 0 reserved for default-init
	immutable
	dynamic
	stream
	_num
}

#enum BufferType

pub enum BufferType {
	_default // value 0 reserved for default-init
	vertexbuffer
	indexbuffer
	_num
}

#enum IndexType

pub enum IndexType {
	_default // value 0 reserved for default-init
	@none
	uint16
	uint32
	_num
}

#enum ImageType

pub enum ImageType {
	_default // value 0 reserved for default-init
	_2d
	cube
	_3d
	array
	_num
}

#enum CubeFace

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

#enum ShaderStage

pub enum ShaderStage {
	vs
	fs
}

#enum PrimitiveType

pub enum PrimitiveType {
	_default // value 0 reserved for default-init
	points
	lines
	line_strip
	triangles
	triangle_strip
	_num
}

#enum Filter

pub 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 Wrap

pub enum Wrap {
	_default // value 0 reserved for default-init
	repeat
	clamp_to_edge
	clamp_to_border
	mirrored_repeat
	_num
}

#enum BorderColor

pub enum BorderColor {
	_default // value 0 reserved for default-init
	transparent_black
	opaque_black
	opaque_white
	_num
}

#enum VertexFormat

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

#enum VertexStep

pub enum VertexStep {
	_default // value 0 reserved for default-init
	per_vertex
	per_instance
	_num
}

#enum UniformType

pub enum UniformType {
	invalid
	float
	float2
	float3
	float4
	mat4
	_num
}

#enum CullMode

pub enum CullMode {
	_default // value 0 reserved for default-init
	@none
	front
	back
	_num
}

#enum FaceWinding

pub enum FaceWinding {
	_facewinding_default // value 0 reserved for default-init
	facewinding_ccw
	facewinding_cw
	_facewinding_num
}

FaceWindin is C.sg_face_winding

#enum CompareFunc

pub enum CompareFunc {
	_default // value 0 reserved for default-init
	never
	less
	equal
	less_equal
	greater
	not_equal
	greater_equal
	always
	_num
}

#enum StencilOp

pub enum StencilOp {
	_default // value 0 reserved for default-init
	keep
	zero
	replace
	incr_clamp
	decr_clamp
	invert
	incr_wrap
	decr_wrap
	_num
}

#enum BlendFactor

pub 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

pub enum BlendOp {
	_default // value 0 reserved for default-init
	add
	subtract
	reverse_subtract
	_num
}

#enum ColorMask

pub 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 Action

pub enum Action {
	_default
	clear
	load
	dontcare
	_num
}

#enum UniformLayout

pub 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
}