Module rokol::gfx [−][src]
Expand description
Graphics (FFI
)
Resource types
BakedResource
implementations:
Buffer
: index or vertex bufferImage
: 2D or 3D imagePass
: offscreen rendering passPipeline
: vertex-layouts, shader and render statesShader
: vertex and fragment shaders with shader-parameter declarations
Be sure to specify uniform names when making Shader
.
Render loop
For example, for one frame with one screen rendering pass:
begin_default_pass
(screen rendering pass)- Optionally
viewport
andscissor
apply_pipeline
(vertex-layouts, shader and render states)apply_uniforms
(set shader uniform block with index)apply_bindings
(Bindings
: vertex and index buffer and images, basically a mesh)draw
- Optionally
end_pass
commit
References
- Sokol articles (The Brain Dump)
- Learn OpenGL
- Learn OpenGL Examples (with Sokol in C)
- zig-renderkit
Structs
Pass action
Enums
Defines what action should be performed at the start of a render pass:
The source and destination factors in blending operations.
Index | Vertex
"
, !=
, >
, >=
, <
, <=
, true
, false
Front | Back | None
CCW | CW
The filtering mode when sampling a texture image
2D | 3D | Array | Cube
UInt16 | UInt32
Actions to be performed at the start of a rendering pass in begin_pass
or begin_default_pass
Pixel format
Common subset of 3D primitive types supported across all 3D APIs. Field of PipelineDesc
.
Update strategy of buffers and images
Float | SInt | UInt
Fs | Vs
Mat4 | Float | Float2 | Float3 | Float4
Data type of a vertex component
The texture coordinates wrapping mode when sampling a texture image
Traits
Functions
Appends vertices/indices to vertex/index buffer
Applies buffer Bindings
: vertex/index buffer and images
Applies Pipeline
: vertex-layouts, shader and render states)
Applies uniform data to shader
Screen rendering pass. Pass framebuffer size as arguments
Screen rendering pass. Pass framebuffer size as arguments
Offscreeen rendering pass
draw(base_elems, n_elems, n_instances)
[Non-Sokol] Helper for creating index buffer
[Non-Sokol] Helper for creating index buffer
Discard output fragments outside of this rectangle
Sets up sokol_gfx.h
. You’d want to use glue code in this crate.
[Non-Sokol] Helper for making shaders
Cleans up sokol_gfx.h
Uploads vertices/indices to vertex/index buffer
Only one update per frame is allowed for buffer and image resources
[Non-Sokol] Helper for creating dynamic vertex buffer
[Non-Sokol] Helper for creating immutable vertex buffer
Output rectangle space
Type Definitions
Vertex/index buffer and image slots
(Resource) Handle (ID) of vertex | index buffer
An RGBA color value (f32)
(Resource) Handle (ID) of image
The width and height are scaled size (e.g. if on 2x DPI monitor display with 2560x1440 pixels, give scaled size of 1280x720.
(Resource) Handle(ID) of rendering pass
(Resource) Handle (ID) of pipeline object: vertex layouts, shader and render states
Can be created from &[u8]
Field of SetupDesc
(Resource) Handle (ID) of shader
Derive Macros
Implements [LayoutDesc
] constructor (i.e., layout_desc
method)