Documentation

Hesper.GLFW.Internal

GLFW Internal FFI Bindings #

Low-level FFI bindings to GLFW and WebGPU rendering functions.

Resources are automatically managed via Lean.External with C++ finalizers. No manual cleanup is required.

@[extern lean_glfw_init]

Initialize GLFW. Must be called before creating windows. Throws error on failure.

@[extern lean_glfw_terminate]

Terminate GLFW. Should be called when done with all windows.

@[extern lean_glfw_create_window]
opaque Hesper.GLFW.Internal.createWindow (width height : UInt32) (title : String) :

Create a window with the given dimensions and title. Automatically cleaned up by GC.

@[extern lean_glfw_window_should_close]

Check if a window should close

@[extern lean_glfw_poll_events]

Poll for window events (must be called regularly in the render loop)

@[extern lean_glfw_window_get_key]

Get key state for a specific key

@[extern lean_glfw_create_surface]

Create a WebGPU surface for the given window. Automatically cleaned up by GC.

@[extern lean_glfw_configure_surface]
opaque Hesper.GLFW.Internal.configureSurface (surface : Surface) (width height format : UInt32) :

Configure the surface with the given dimensions and format

@[extern lean_glfw_surface_get_preferred_format]

Get the preferred texture format for the surface

@[extern lean_glfw_surface_get_current_texture]

Get the current texture from the surface for rendering. Automatically cleaned up by GC.

@[extern lean_glfw_surface_present]

Present the surface (swap buffers)

@[extern lean_glfw_texture_create_view]

Create a view of the texture for rendering. Automatically cleaned up by GC.

@[extern lean_glfw_create_command_encoder]

Create a command encoder for recording commands. Automatically cleaned up by GC.

@[extern lean_glfw_begin_render_pass]

Begin a render pass with the given texture view. Automatically cleaned up by GC.

@[extern lean_glfw_render_pass_set_pipeline]

Set the render pipeline for the render pass

@[extern lean_glfw_render_pass_draw]
opaque Hesper.GLFW.Internal.draw (pass : RenderPassEncoder) (vertexCount : UInt32) :

Draw vertices

@[extern lean_glfw_render_pass_end]

End the render pass

@[extern lean_glfw_encoder_finish]

Finish recording commands and create a command buffer. Automatically cleaned up by GC.

@[extern lean_glfw_queue_submit]

Submit a command buffer to the GPU queue

@[extern lean_glfw_create_shader_module]

Create a shader module from WGSL code. Automatically cleaned up by GC.

@[extern lean_glfw_create_render_pipeline]

Create a render pipeline from a shader module. Automatically cleaned up by GC.