EAGL.WindowBehaviour behaviour (eagl v0.3.0)

View Source

Behaviour for OpenGL window management. Handles window creation, OpenGL context setup, and event loop management.

Summary

Callbacks

Called when the window is being closed. Should clean up resources in state.

Called when an event occurs (keyboard, mouse, etc.). This callback is optional. If not implemented, events are ignored. Should return {:ok, new_state} to continue with updated state.

Called when the window needs to be rendered. The OpenGL context is already current and the viewport is set.

Called when the OpenGL context is ready and shaders should be created. Should return {:ok, state} or {:error, reason}

Callbacks

cleanup(any)

@callback cleanup(any()) :: :ok

Called when the window is being closed. Should clean up resources in state.

handle_event(event, state)

(optional)
@callback handle_event(event :: any(), state :: any()) :: {:ok, any()}

Called when an event occurs (keyboard, mouse, etc.). This callback is optional. If not implemented, events are ignored. Should return {:ok, new_state} to continue with updated state.

render(width, height, state)

@callback render(width :: float(), height :: float(), state :: any()) :: :ok

Called when the window needs to be rendered. The OpenGL context is already current and the viewport is set.

setup()

@callback setup() :: {:ok, any()} | {:error, term()}

Called when the OpenGL context is ready and shaders should be created. Should return {:ok, state} or {:error, reason}