Skip to content

sokol.sgl #

Constants #

const version = gfx.version + 1
const default_context = Context{0x00010001}

fn begin_line_strip #

fn begin_line_strip()

begin_line_strip begins drawing a line strip (connected lines).

fn begin_lines #

fn begin_lines()

begin_lines begins drawing lines.

fn begin_points #

fn begin_points()

begin_points begins drawing points.

fn begin_quads #

fn begin_quads()

begin_quads begins drawing quads.

fn begin_triangle_strip #

fn begin_triangle_strip()

begin_triangle_strip begins drawing a triangle strip.

fn begin_triangles #

fn begin_triangles()

begin_triangles begins drawing triangles.

fn c1i #

fn c1i(rgba u32)

c1i sets the current color using a packed RGBA u32 value.

fn c3b #

fn c3b(r u8, g u8, b u8)

c3b sets the current color using RGB byte values (0-255).

fn c3f #

fn c3f(r f32, g f32, b f32)

c3f sets the current color using RGB float values (0.0-1.0).

fn c4b #

fn c4b(r u8, g u8, b u8, a u8)

c4b sets the current color using RGBA byte values (0-255).

fn c4f #

fn c4f(r f32, g f32, b f32, a f32)

c4f sets the current color using RGBA float values (0.0-1.0).

fn context_draw #

fn context_draw(ctx_handle Context)

fn context_draw_layer #

fn context_draw_layer(ctx_handle Context, layer_id int)

fn context_error #

fn context_error(ctx_handle Context) SglError

fn context_make_pipeline #

fn context_make_pipeline(ctx_handle Context, desc &gfx.PipelineDesc) Pipeline

fn default_context #

fn default_context() Context

fn default_pipeline #

fn default_pipeline()

fn defaults #

fn defaults()

render state

fn deg #

fn deg(r f32) f32

fn destroy_context #

fn destroy_context(ctx Context)

fn destroy_pipeline #

fn destroy_pipeline(pip Pipeline)

fn disable_texture #

fn disable_texture()

fn draw #

fn draw()

render recorded commands

fn draw_layer #

fn draw_layer(layer_id int)

fn enable_texture #

fn enable_texture()

fn end #

fn end()

end primitive and record draw command

fn error #

fn error() SglError

fn frustum #

fn frustum(l f32, r f32, b f32, t f32, n f32, f f32)

fn get_context #

fn get_context() Context

fn layer #

fn layer(layer_id int)

fn load_default_pipeline #

fn load_default_pipeline()

pipeline stack

fn load_identity #

fn load_identity()

fn load_matrix #

fn load_matrix(m []f32)

fn load_pipeline #

fn load_pipeline(pip Pipeline)

fn load_transpose_matrix #

fn load_transpose_matrix(m []f32)

fn lookat #

fn lookat(eye_x f32, eye_y f32, eye_z f32, center_x f32, center_y f32, center_z f32, up_x f32, up_y f32, up_z f32)

fn make_context #

fn make_context(desc &ContextDesc) Context

context functions

fn make_pipeline #

fn make_pipeline(desc &gfx.PipelineDesc) Pipeline

pipeline functions

fn matrix_mode_modelview #

fn matrix_mode_modelview()

matrix functions

fn matrix_mode_projection #

fn matrix_mode_projection()

fn matrix_mode_texture #

fn matrix_mode_texture()

fn mult_matrix #

fn mult_matrix(m []f32)

fn mult_transpose_matrix #

fn mult_transpose_matrix(m []f32)

fn ortho #

fn ortho(l f32, r f32, b f32, t f32, n f32, f f32)

fn perspective #

fn perspective(fov_y f32, aspect f32, z_near f32, z_far f32)

fn point_size #

fn point_size(s f32)

point_size sets the size of points when drawing point primitives.

fn pop_matrix #

fn pop_matrix()

fn pop_pipeline #

fn pop_pipeline()

fn push_matrix #

fn push_matrix()

fn push_pipeline #

fn push_pipeline()

fn rad #

fn rad(deg f32) f32

fn rotate #

fn rotate(angle_rad f32, x f32, y f32, z f32)

fn scale #

fn scale(x f32, y f32, z f32)

fn scissor_rect #

fn scissor_rect(x int, y int, w int, h int, origin_top_left bool)

fn scissor_rectf #

fn scissor_rectf(x f32, y f32, w f32, h f32, origin_top_left bool)

fn set_context #

fn set_context(ctx Context)

fn setup #

fn setup(desc &Desc)

setup/shutdown

fn shutdown #

fn shutdown()

fn t2f #

fn t2f(u f32, v f32)

texcoord / color / point size

fn texture #

fn texture(img gfx.Image, smp gfx.Sampler)

fn translate #

fn translate(x f32, y f32, z f32)

fn v2f #

fn v2f(x f32, y f32)

v2f submits a 2D vertex position.

fn v2f_c1i #

fn v2f_c1i(x f32, y f32, rgba u32)

v2f_c1i submits a 2D vertex with packed RGBA color.

fn v2f_c3b #

fn v2f_c3b(x f32, y f32, r u8, g u8, b u8)

v2f_c3b submits a 2D vertex with RGB color (bytes).

fn v2f_c3f #

fn v2f_c3f(x f32, y f32, r f32, g f32, b f32)

v2f_c3f submits a 2D vertex with RGB color (float).

fn v2f_c4b #

fn v2f_c4b(x f32, y f32, r u8, g u8, b u8, a u8)

v2f_c4b submits a 2D vertex with RGBA color (bytes).

fn v2f_c4f #

fn v2f_c4f(x f32, y f32, r f32, g f32, b f32, a f32)

v2f_c4f submits a 2D vertex with RGBA color (float).

fn v2f_t2f #

fn v2f_t2f(x f32, y f32, u f32, v f32)

v2f_t2f submits a 2D vertex with texture coordinates.

fn v2f_t2f_c1i #

fn v2f_t2f_c1i(x f32, y f32, u f32, v f32, rgba u32)

fn v2f_t2f_c3b #

fn v2f_t2f_c3b(x f32, y f32, u f32, v f32, r u8, g u8, b u8)

fn v2f_t2f_c3f #

fn v2f_t2f_c3f(x f32, y f32, u f32, v f32, r f32, g f32, b f32)

fn v2f_t2f_c4b #

fn v2f_t2f_c4b(x f32, y f32, u f32, v f32, r u8, g u8, b u8, a u8)

fn v2f_t2f_c4f #

fn v2f_t2f_c4f(x f32, y f32, u f32, v f32, r f32, g f32, b f32, a f32)

fn v3f #

fn v3f(x f32, y f32, z f32)

v3f submits a 3D vertex position.

fn v3f_c1i #

fn v3f_c1i(x f32, y f32, z f32, rgba u32)

fn v3f_c3b #

fn v3f_c3b(x f32, y f32, z f32, r u8, g u8, b u8)

v3f_c3b submits a 3D vertex with RGB color (bytes).

fn v3f_c3f #

fn v3f_c3f(x f32, y f32, z f32, r f32, g f32, b f32)

v3f_c3f submits a 3D vertex with RGB color (float).

fn v3f_c4b #

fn v3f_c4b(x f32, y f32, z f32, r u8, g u8, b u8, a u8)

fn v3f_c4f #

fn v3f_c4f(x f32, y f32, z f32, r f32, g f32, b f32, a f32)

fn v3f_t2f #

fn v3f_t2f(x f32, y f32, z f32, u f32, v f32)

v3f_t2f submits a 3D vertex with texture coordinates.

fn v3f_t2f_c1i #

fn v3f_t2f_c1i(x f32, y f32, z f32, u f32, v f32, rgba u32)

fn v3f_t2f_c3b #

fn v3f_t2f_c3b(x f32, y f32, z f32, u f32, v f32, r u8, g u8, b u8)

fn v3f_t2f_c3f #

fn v3f_t2f_c3f(x f32, y f32, z f32, u f32, v f32, r f32, g f32, b f32)

fn v3f_t2f_c4b #

fn v3f_t2f_c4b(x f32, y f32, z f32, u f32, v f32, r u8, g u8, b u8, a u8)

fn v3f_t2f_c4f #

fn v3f_t2f_c4f(x f32, y f32, z f32, u f32, v f32, r f32, g f32, b f32, a f32)

fn viewport #

fn viewport(x int, y int, w int, h int, origin_top_left bool)

fn viewportf #

fn viewportf(x f32, y f32, w f32, h f32, origin_top_left bool)

enum SglError #

enum SglError {
	no_error
	vertices_full
	uniforms_full
	commands_full
	stack_overflow
	stack_underflow
	no_context
}

struct Allocator #

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

struct Context #

struct Context {
pub:
	id u32
}

struct ContextDesc #

struct ContextDesc {
pub mut:
	max_vertices int
	max_commands int
	color_format gfx.PixelFormat
	depth_format gfx.PixelFormat
	sample_count int
}

struct Desc #

struct Desc {
pub mut:
	max_vertices       int
	max_commands       int
	context_pool_size  int
	pipeline_pool_size int
	color_format       gfx.PixelFormat
	depth_format       gfx.PixelFormat
	sample_count       int
	face_winding       gfx.FaceWinding
	allocator          Allocator
	logger             Logger
}

struct Logger #

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

struct Pipeline #

struct Pipeline {
pub:
	id u32
}

Public types