References
Base header types
mlx_context
Opaque handle that represents the MLX context.
mlx_window
Opaque handle that represents a MLX window.
mlx_image
Opaque handle that represents a MLX image.
mlx_color
Union representing RGBA color with access to each part as bytes.
mlx_window_create_info
Descriptor structure for window creation
Note: if a valid mlx_image
is passed as render_target
, this window will not be a real system window
and will rather act as a gate to use any draw function to draw directly on an image.
Ex: you could use mlx_string_put
or mlx_pixel_put
to draw on a given image and then use this image
with mlx_put_image_to_window
to render it on a real window.
mlx_event_type
Type of event.
Base header prototypes
mlx_init()
Initializes the MLX internal application
Returns an opaque handler to the internal MLX application or NULL
(0x0) in case of error
mlx_set_fps_goal()
Set a maximum number of FPS that MacroLibX cannot exceed
- param
mlx
: Internal MLX application - param
fps
: The FPS cap
mlx_destroy_context()
Destroys internal MLX application
- param
mlx
: Internal MLX application
mlx_new_window()
Creates a new window
- param
mlx
: Internal MLX application - param
info
: Pointer to a descriptor structure
Returns an opaque handler to the internal MLX window or NULL
(0x0) in case of error
mlx_destroy_window()
Destroys internal window
- param
mlx
: Internal MLX application - param
win
: Internal window
mlx_set_window_position()
Sets window position
- param
mlx
: Internal MLX application - param
win
: Internal window to move - param
x
: New x position - param
y
: New y position
mlx_set_window_size()
Sets window size
- param
mlx
: Internal MLX application - param
win
: Internal window to move - param
width
: New width - param
height
: New height
mlx_set_window_title()
Sets window title
- param
mlx
: Internal MLX application - param
win
: Internal window to move - param
title
: New title
mlx_set_window_fullscreen()
Enables/Disables window fullscreen mode
- param
mlx
: Internal MLX application - param
win
: Internal window to move - param
enable
: Switch or not to fullscreen
mlx_get_window_position()
Gets window position
- param
mlx
: Internal MLX application - param
win
: Internal window to move - param
x
: Pointers to get position of the window - param
y
: Pointers to get position of the window
mlx_get_window_size()
Gets window size
- param
mlx
: Internal MLX application - param
win
: Internal window to move - param
x
: Pointers to get size of the window - param
y
: Pointers to get size of the window
mlx_clear_window()
Clears the given window (resets all rendered data)
- param
mlx
: Internal MLX application - param
win
: Internal window
mlx_get_screen_size()
Get the size of the screen the given window is on
- param
mlx
: Internal MLX application - param
win
: Internal window to choose screen the window is on - param
w
: Get width size - param
h
: Get height size
mlx_add_loop_hook()
Gives another function to be executed at each loop turn
- param
mlx
: Internal MLX application - param
f
: The function - param
param
: Param to give to the function passed
mlx_loop()
Starts the internal main loop
- param
mlx
: Internal MLX application
mlx_loop_end()
Ends the internal run loop
- param
mlx
: Internal MLX application
mlx_mouse_show()
Shows mouse cursor
- param
mlx
: Internal MLX application
mlx_mouse_hide()
Hides mouse cursor
- param
mlx
: Internal MLX application
mlx_mouse_move()
Moves cursor to givent position
- param
mlx
: Internal MLX application - param
win
: Internal window from which cursor moves - param
x
: X coordinate - param
y
: Y coordinate
mlx_mouse_get_pos()
Get cursor’s position
- param
mlx
: Internal MLX application - param
x
: Get x coordinate - param
y
: Get y coordinate
mlx_on_event()
Gives a function to be executed on event type, does not override previous functions
- param
mlx
: Internal MLX application - param
win
: Internal window - param
event
: Event type (see union on top of this file) - param
f
: Function to be executed - param
param
: Parameter given to the function
mlx_pixel_put()
Put a pixel in the window
- param
mlx
: Internal MLX application - param
win
: Internal window - param
x
: X coordinate - param
y
: Y coordinate - param
color
: Color of the pixel
mlx_new_image()
Create a new empty image
- param
mlx
: Internal MLX application - param
width
: Width of the image - param
height
: Height of the image
Returns an opaque handler to the internal image or NULL (0x0) in case of error
mlx_new_image_from_file()
Create a new image from a png/jpg/bmp file
- param
mlx
: Internal MLX application - param
filename
: Path to the png file - param
width
: Get the width of the image - param
heigth
: Get the height of the image
Returns an opaque handler to the internal image or NULL (0x0) in case of error
mlx_destroy_image()
Destroys internal image
- param
mlx
: Internal MLX application - param
img
: Internal image
mlx_get_image_pixel()
Get image pixel data
- param
mlx
: Internal MLX application - param
img
: Internal image - param
x
: X coordinate in the image - param
y
: Y coordinate in the image
Returns the pixel data
mlx_set_image_pixel()
Set image pixel data
- param
mlx
: Internal MLX application - param
img
: Internal image - param
x
: X coordinate in the image - param
y
: Y coordinate in the image - param
color
: Color of the pixel to set
mlx_put_image_to_window()
Put image to the given window
- param
mlx
: Internal MLX application - param
win
: Internal window - param
img
: Internal image - param
x
: X coordinate - param
y
: Y coordinate
mlx_string_put()
Put text in given window
- param
mlx
: Internal MLX application - param
win
: Internal window - param
x
: X coordinate - param
y
: Y coordinate - param
color
: Color of the pixel - param
str
: Text to put
mlx_set_font()
Loads a font to be used by mlx_string_put
- param
mlx
: Internal MLX application - param
win
: Internal window - param
filepath
: Filepath to the font or “default” to reset to the embedded font
mlx_set_font_scale()
Loads a font to be used by mlx_string_put
and scales it
- param
mlx
: Internal MLX application - param
win
: Internal window - param
filepath
: Filepath to the font or “default” to reset to the embedded font - param
scale
: Scale to apply to the font
Extended header prototypes
mlx_set_window_max_size()
Sets maximum window size
- param
mlx
: Internal MLX application - param
win
: Internal window to move - param
x
: New x maximum size - param
y
: New y maximum size
mlx_set_window_min_size()
Sets minimum window size
- param
mlx
: Internal MLX application - param
win
: Internal window to move - param
x
: New x minimum size - param
y
: New y minimum size
mlx_maximise_window()
Maximizes a window
- param
mlx
: Internal MLX application - param
win
: Internal window to move
mlx_minimize_window()
Minimizes a window
- param
mlx
: Internal MLX application - param
win
: Internal window to move
mlx_restore_window()
Restore window to formal size
- param
mlx
: Internal MLX application - param
win
: Internal window to move
mlx_pixel_put_array()
Put an array of pixels in the window
- param
mlx
: Internal MLX application - param
win
: Internal window - param
x
: X coordinate - param
y
: Y coordinate - param
pixels
: Array of pixels - param
pixels_number
: Number of pixels
mlx_pixel_put_region()
Put a region of pixels in the window
- param
mlx
: Internal MLX application - param
win
: Internal window - param
x
: X coordinate - param
y
: Y coordinate - param
w
: Width - param
h
: Height - param
pixels
: Array of pixels
Note: it is responsability of the user to make sure the size of pixels
is
big enough for the given region.
mlx_get_image_region()
Get image region
- param
mlx
: Internal MLX application - param
img
: Internal image - param
x
: X coordinate in the image - param
y
: Y coordinate in the image - param
w
: Width of the region - param
y
: Height of the region - param
dst
: Array of pixels to copy to
Note: it is responsability of the user to make sure the size of dst
is
big enough for the given region.
mlx_set_image_region()
Set image region
- param
mlx
: Internal MLX application - param
img
: Internal image - param
x
: X coordinate in the image - param
y
: Y coordinate in the image - param
w
: Width of the region - param
h
: Height of the region - param
pixels
: Array of pixels to copy from
Note: it is responsability of the user to make sure the size of pixels
is
big enough for the given region.
mlx_put_transformed_image_to_window()
Transform and put image to the given window
- param
mlx
: Internal MLX application - param
win
: Internal window - param
img
: Internal image - param
x
: X coordinate - param
y
: Y coordinate - param
scale_x
: Scale x of the image - param
scale_y
: Scale y of the image - param
angle
: Rotation angle of the image (clockwise)