sokol/framebuffer
sokol_framebuffer
Types
14Allocator
Allocator :: struct {
alloc_fn: proc(a0: c.size_t, a1: rawptr) -> (rawptr),
a0: c.size_t,
size_t: rawptr,
a1: rawptr,
free_fn: proc(a0: rawptr, a1: rawptr),
a0: rawptr,
a1: rawptr,
user_data: rawptr,
}Sourcesfb_allocator
Used in sfb_desc to provide custom memory-alloc and -free functions to sokol_framebuffer.h. If memory management should be overridden, both the alloc and free function must be provided (e.g. it's not valid to override one function but not the other).
Desc
Desc :: struct {
framebuffer_pool_size: c.int,
allocator: Allocator,
logger: Logger,
}SourceInitialization parameters passed into sfb_setup(). You should at least provide a logging function, otherwise you won't see any error logging.
Format
Format :: enum i32 {
DEFAULT = 0,
RGBA8 = 1,
PALETTE8 = 2,
}Sourcesfb_format
The framebuffer pixel format. Either RGBA8 direct color where each pixel is an uint32_t, or paletted format with uint8_t pixels as index into a 256 entry color palette.
Framebuffer
Framebuffer :: struct {
id: u32,
}Sourcesfb_framebuffer
A framebuffer handle, created with sfb_make_framebuffer(), destroyed with sfb_destroy_framebuffer()
Framebuffer_Desc
Framebuffer_Desc :: struct {
width: c.int,
height: c.int,
prescale: c.int,
format: Format,
cliprect: Rect,
rotate90: bool,
render_pass: Render_Pass_Desc,
}Sourcesfb_framebuffer_desc
Creation parameters for a framebuffer object. Passed into sfb_make_framebuffer().
Framebuffer_Info
Framebuffer_Info :: struct {
update: Texture_Info,
offscreen: Texture_Info,
palette: Texture_Info,
nearest_sampler: sg.Sampler,
linear_sampler: sg.Sampler,
}Sourcesfb_framebuffer_info
Result of sfb_query_framebuffer_info(), returns handles to the internally managed images, texture views and samplers, image sizes and pixel formats. This is mostly useful when completely replacing the sfb_render_ex functions with a complete custom implementation (like a CRT shader which requires multiple render passes).
Logger
Logger :: struct {
func: proc(
a0: cstring,
a1: u32,
a2: u32,
a3: cstring,
a4: u32,
a5: cstring,
a6: rawptr,
),
a0: cstring,
a1: u32,
a2: u32,
a3: cstring,
a4: u32,
a5: cstring,
a6: rawptr,
user_data: rawptr,
}Sourcesfb_logger
Used in sfb_desc to provide a custom logging and error reporting callback to sokol_framebuffer.h.
Rect
Rect :: struct {
x: c.int,
y: c.int,
width: c.int,
height: c.int,
}Sourcesfb_rect
Used as clipping rectangle in struct sfb_framebuffer_desc and sfb_resize_desc.
Render_Desc
Render_Desc :: struct {
use_nearest_filter: bool,
pip: sg.Pipeline,
views: [32]sg.View,
samplers: [12]sg.Sampler,
uniforms: [8]sg.Range,
}Sourcesfb_render_overrides
Passed into sfb_render_ex() to override the default shader. Mainly useful to inject custom shaders (like CRT shaders).
TODO: add more details once sokol_crt.h is ready.
Render_Pass_Desc
Render_Pass_Desc :: struct {
color_format: sg.Pixel_Format,
depth_format: sg.Pixel_Format,
sample_count: c.int,
}Sourcesfb_render_pass_desc
Describes render pass properties in an sfb_framebuffer_desc (color- and depth-pixel-format, sample count). This is used to create the sg_pipeline objects applied in the render functions. When rendering to a default swapchain all the values can remain at default (zero).
Resize_Desc
Resize_Desc :: struct {
width: c.int,
height: c.int,
prescale: c.int,
cliprect: Rect,
}Sourcesfb_resize_desc
Parameters for sfb_resize(). Needs to be called before sfb_update() in a frame if with potentially new framebuffer size parameters or clipping rectangle. Note that the sfb_resize() function can be called even when no resizing needs to happen, in that case the function will be a silent no-op and return false. When the function returns true this means that internal image objects had been recreated and need to be repopulated again via sfb_update()
Resizing is slightly cheaper than destroying and creating the frambuffer because only image objects needs to be re-created, but no pipeline objects.
Resource_State
Resource_State :: enum i32 {
INITIAL = 0,
ALLOC = 1,
VALID = 2,
FAILED = 3,
INVALID = 4,
}Sourcesfb_resource_state
The state of a framebuffer object, obtainable via sfb_query_framebuffer_state(). Publicly visible values are only SFB_RESOURCESTATE_VALID and SFB_RESOURCESTATE_FAILED.
Texture_Info
Texture_Info :: struct {
width: c.int,
height: c.int,
pixel_format: sg.Pixel_Format,
image: sg.Image,
tex_view: sg.View,
}Sourcesfb_texture_info
Nested struct in sfb_framebuffer_info to describe the properties of an internal image/view pair.
Update_Desc
Update_Desc :: struct {
pixels: sg.Range,
palette: sg.Range,
}Sourcesfb_update_desc
Passed into sfb_update() to update the pixel-date and/or color-palette-data The sfb_update() function should only be called when any of the above actually changes, at most once per frame, and outside any sokol-gfx pass.
Constants
5DEBUG
DEBUG :: _ = #config(SOKOL_FRAMEBUFFER_DEBUG, SOKOL_DEBUG)SourceINVALID_ID
INVALID_ID :: 0SourcePublic constants.
SOKOL_DEBUG
SOKOL_DEBUG :: _ = #config(SOKOL_DEBUG, ODIN_DEBUG)SourceUSE_DLL
USE_DLL :: _ = #config(SOKOL_DLL, false)SourceUSE_GL
USE_GL :: _ = #config(SOKOL_USE_GL, false)Source