Module rokol::gfx [−][src]
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)viewport
andscissor
apply_pipeline
(vertex-layouts, shader and render states)apply_bindings
(Bindings
: vertex and index buffer and images)apply_uniforms
(set shader uniform with an index)draw
end_pass
commit
References
- Sokol articles (The Brain Dump)
- A Tour of sokol_gfx.h (2017)
- A small sokol_gfx.h API update (2019)
- Sokol headers: spring 2020 update (2020)
- Learn OpenGL
- Learn OpenGL Examples (with Sokol in C)
- zig-renderkit
Structs
ColorMask | |
PassAction | Pass action |
Enums
Action | Defines what action should be performed at the start of a render pass: |
BlendFactor | The source and destination factors in blending operations. |
BufferType | Index | Vertex |
CompareFunc |
|
CullMode | Front | Back | None |
FaceWinding | CCW | CW |
Filter | The filtering mode when sampling a texture image |
ImageType | 2D | 3D | Array | Cube |
IndexType | UInt16 | UInt32 |
PassActionKind | Actions to be performed at the start of a rendering pass in |
PixelFormat | Pixel format |
PrimitiveType | Common subset of 3D primitive types supported across all 3D APIs. Field of |
ResourceUsage | Update strategy of buffers and images |
SamplerType | Float | SInt | UInt |
ShaderStage | Fs | Vs |
UniformType | Mat4 | Float | Float2 | Float3 | Float4 |
VertexFormat | Data type of a vertex component |
Wrap | The texture coordinates wrapping mode when sampling a texture image |
Traits
BakedResource |
Functions
append_buffer | Appends vertices/indices to vertex/index buffer |
apply_bindings | Applies buffer |
apply_pipeline | Applies |
apply_uniforms | Applies uniform data to shader |
apply_uniforms_as_bytes⚠ | [Non-Sokol] Helper for setting shader uniform |
begin_default_pass | Screen rendering pass |
begin_default_pass_f | |
begin_pass | Offscreeen rendering pass |
buf_desc⚠ | [Non-Sokol] Helper for creating dynamic vertex buffer |
commit | |
draw |
|
end_pass | |
ibuf_desc_dyn | [Non-Sokol] Helper for creating index buffer |
ibuf_desc_immutable | [Non-Sokol] Helper for creating index buffer |
scissor | Discard output fragments outside of this rectangle |
scissor_f | |
setup | Should be called from |
shader_desc⚠ | [Non-Sokol] Helper for making shaders |
update_buffer⚠ | Uploads vertices/indices to vertex/index buffer |
update_image⚠ | Only one update per frame is allowed for buffer and image resources |
vbuf_desc_dyn | [Non-Sokol] Helper for creating dynamic vertex buffer |
vbuf_desc_immutable | [Non-Sokol] Helper for creating immutable vertex buffer |
viewport | Output rectangle space |
viewport_f |