Ok so to be more precise, the previous graphics API that our school mandates us too used is based mainly on X11, but the API itself is really really bad, the documentation is poor and being written in C it’s often a nightmare to build, so because I’ve suffer so much with it I decided to try to port it to something more modern while keeping 100% within the actual pedagogical intent of this library.
It’s meant to be a very dumb down graphics API, for very lightweight graphics project, It has to be able to be used with C, it needs to be cross-platform to Linux/Windows/Macos and is expected to be used on somewhat recent hardware nothing exotic.
The previous API had those functions
void *mlx_new_window(void *mlx_ptr, int size_x, int size_y, char *title);
int mlx_clear_window(void *mlx_ptr, void *win_ptr);
int mlx_pixel_put(void *mlx_ptr, void *win_ptr, int x, int y, int color);
void *mlx_new_image(void *mlx_ptr,int width,int height);
char *mlx_get_data_addr(void *img_ptr, int *bits_per_pixel,
int *size_line, int *endian);
int mlx_put_image_to_window(void *mlx_ptr, void *win_ptr, void *img_ptr,
int x, int y);
int mlx_get_color_value(void *mlx_ptr, int color);
int mlx_mouse_hook (void *win_ptr, int (*funct_ptr)(), void *param);
int mlx_key_hook (void *win_ptr, int (*funct_ptr)(), void *param);
int mlx_expose_hook (void *win_ptr, int (*funct_ptr)(), void *param);
int mlx_loop_hook (void *mlx_ptr, int (*funct_ptr)(), void *param);
int mlx_loop (void *mlx_ptr);
int mlx_loop_end (void *mlx_ptr);
int mlx_string_put(void *mlx_ptr, void *win_ptr, int x, int y, int color,
char *string);
void mlx_set_font(void *mlx_ptr, void *win_ptr, char *name);
void *mlx_xpm_to_image(void *mlx_ptr, char **xpm_data, int *width, int *height);
void *mlx_xpm_file_to_image(void *mlx_ptr, char *filename, int *width, int *height);
int mlx_destroy_window(void *mlx_ptr, void *win_ptr);
int mlx_destroy_image(void *mlx_ptr, void *img_ptr);
int mlx_destroy_display(void *mlx_ptr);
int mlx_hook(void *win_ptr, int x_event, int x_mask, int (*funct)(), void *param);
int mlx_do_key_autorepeatoff(void *mlx_ptr);
int mlx_do_key_autorepeaton(void *mlx_ptr);
int mlx_do_sync(void *mlx_ptr);
int mlx_mouse_get_pos(void *mlx_ptr, void *win_ptr, int *x, int *y);
int mlx_mouse_move(void *mlx_ptr, void *win_ptr, int x, int y);
int mlx_mouse_hide(void *mlx_ptr, void *win_ptr);
int mlx_mouse_show(void *mlx_ptr, void *win_ptr);
int mlx_get_screen_size(void *mlx_ptr, int *sizex, int *sizey);
As you can see it’s very basic, you can create windows, an image, get the buffer of the image, put the image to the window, get some hooks etc etc. While I fully agree with you that using the GPU would be much more efficient and pleasant I intend to make a library that follows those guidelines, of only rendering within the CPU, using an “image-based” / “pixel-buffer” approach. This is meant to be stupid simple just to teach everyone how to do basic computer graphics.
ps : i think I’ve missed a few prototypes but you get the idea