Skip to content
W2.Wizard edited this page Feb 12, 2022 · 25 revisions

Hoosk in MLX42

Hooks allow you to add your own functions to the main loop execution of the program, aka these functions get executed every frame.

These are the existing hooks:

/**
 * This function sets the scroll callback, which is called when a scrolling 
 * device is used, such as a mouse wheel.
 * 
 * @param[in] mlx The MLX instance handle.
 * @param[in] func The scroll wheel callback function.
 * @param[in] param An additional optional parameter.
 */
void		mlx_scroll_hook(t_mlx *mlx, t_mlx_scrollfunc func, void *param);
/**
 * This function sets the key callback, which is called when a key is pressed
 * on the keyboard. Useful for single key press detection.
 * 
 * @param[in] mlx The MLX instance handle.
 * @param[in] func The key press callback function.
 * @param[in] param An additional optional parameter.
 */
void		mlx_key_hook(t_mlx *mlx, t_mlx_keyfunc func, void *param);
/**
 * Adds a function hook to the main loop. Aka, executes a function per frame.
 * 
 * @param[in] mlx The MLX instance handle.
 * @param[in] f The function.
 * @param[in] param The parameter to pass onto the function.
 * @returns Wether the hook was added successfuly. 
 */
bool		mlx_loop_hook(t_mlx *mlx, void (*f)(void *), void *param);
Clone this wiki locally