@@ -39,18 +39,7 @@ to the native MiniLibX library.
3939- [ Managing windows: mlx_new_window(), mlx_clear_window,
4040 mlx_destroy_window] ( #managing-windows-mlx_new_window-mlx_clear_window-mlx_destroy_window )
4141 - [ Synopsis] ( #synopsis-1 )
42- - [ Description] ( #description-1 )
43- - [ Return values] ( #return-values-1 )
44- - [ Drawing inside windows: mlx_pixel_put(),
45- mlx_string_put()] ( #drawing-inside-windows-mlx_pixel_put-mlx_string_put )
46- - [ Synopsis] ( #synopsis-2 )
47- - [ Description] ( #description-2 )
48- - [ Color management] ( #color-management )
49- - [ Handle events:] ( #handle-events )
50- - [ Synopsis] ( #synopsis-3 )
51- - [ Events] ( #events )
52- - [ Description] ( #description-3 )
53- - [ Going further with events] ( #going-further-with-events )
42+ - [ —– UNDER CONSTRUCTION —–] ( #under-construction )
5443- [ Got any suggestions?] ( #got-any-suggestions )
5544
5645## Introduction
@@ -261,9 +250,6 @@ to the library routines. The mlx_release function can be used at the end
261250of the program to disconnect from the graphic system and release
262251resources.
263252
264- If ** mlx_init()** fails to set up the connection to the display, it will
265- return None.
266-
267253### Return values
268254
269255If ** mlx_init()** set up the connection to the display correctly, it
@@ -283,176 +269,179 @@ c_void_p, c_uint, c_uint, c_char_p
283269 def mlx_destroy_window (mlx_ptr : int , win_ptr : int ) -> int :
284270```
285271
286- ### Description
272+ ## —– UNDER CONSTRUCTION —–
287273
288- The ** mlx_new_window** () function creates a new window on the screen,
289- using the * width* and * height* parameters to determine its size, and
290- * title* as the text that should be displayed in the window's title bar.
291- The * mlx_ptr* parameter is the connection identifier returned by
292- ** mlx_init** () (see the ** mlx** man page). ** mlx_new_window** ()
293- returns a * void \* * window identifier that can be used by other MiniLibX
294- calls. Note that the MiniLibX can handle an arbitrary number of separate
295- windows.
274+ ## Description
296275
297- ** mlx_clear_window** () and ** mlx_destroy_window** () respectively clear
298- (in black) and destroy the given window. They both have the same
299- parameters: * mlx_ptr* is the screen connection identifier, and * win_ptr*
300- is a window identifier.
276+ The **mlx_new_window** () function creates a new window on the screen,
277+ using the *width* and *height* parameters to determine its size, and
278+ *title* as the text that should be displayed in the window\'s title bar.
279+ The *mlx_ptr* parameter is the connection identifier returned by
280+ **mlx_init** () (see the **mlx** man page). **mlx_new_window** ()
281+ returns a *void \** window identifier that can be used by other MiniLibX
282+ calls. Note that the MiniLibX can handle an arbitrary number of separate
283+ windows.
301284
302- ### Return values
285+ **mlx_clear_window** () and **mlx_destroy_window** () respectively clear
286+ (in black) and destroy the given window. They both have the same
287+ parameters: *mlx_ptr* is the screen connection identifier, and *win_ptr*
288+ is a window identifier.
303289
304- If ** mlx_new_window()** fails to create a new window (whatever the
305- reason), it will return NULL, otherwise a non-null pointer is returned
306- as a window identifier. ** mlx_clear_window** and ** mlx_destroy_window**
307- return nothing.
290+ ## Return values
308291
309- ## Drawing inside windows: mlx_pixel_put(), mlx_string_put()
292+ If **mlx_new_window()** fails to create a new window (whatever the
293+ reason), it will return NULL, otherwise a non-null pointer is returned
294+ as a window identifier. **mlx_clear_window** and **mlx_destroy_window**
295+ return nothing.
310296
311- ### Synopsis
297+ # Drawing inside windows: mlx_pixel_put(), mlx_string_put()
312298
313- int
299+ ## Synopsis
314300
315- ** mlx_pixel_put** ( * void \* mlx_ptr, void \* win_ptr, unsigned int x,
316- unsigned int y, unsigned int color* );
301+ int
317302
318- int
303+ **mlx_pixel_put** ( *void \*mlx_ptr, void \*win_ptr, unsigned int x,
304+ unsigned int y, unsigned int color* );
319305
320- ** mlx_string_put** ( * void \* mlx_ptr, void \* win_ptr, unsigned int x,
321- unsigned int y, unsigned int color, char \* string* );
306+ int
322307
323- ### Description
308+ **mlx_string_put** ( *void \*mlx_ptr, void \*win_ptr, unsigned int x,
309+ unsigned int y, unsigned int color, char \*string* );
324310
325- The ** mlx_pixel_put** () function draws a defined pixel in the window
326- * win_ptr* using the ( * x* , * y* ) coordinates, and the specified * color*
327- . The origin (0,0) is the upper left corner of the window, the x and y
328- axis respectively pointing right and down. The connection identifier,
329- * mlx_ptr* , is needed (see the ** mlx** man page).
311+ ## Description
330312
331- Parameters for ** mlx_string_put** () have the same meaning. Instead of a
332- simple pixel, the specified * string* will be displayed at ( * x* , * y* ).
313+ The **mlx_pixel_put** () function draws a defined pixel in the window
314+ *win_ptr* using the ( *x* , *y* ) coordinates, and the specified *color*
315+ . The origin (0,0) is the upper left corner of the window, the x and y
316+ axis respectively pointing right and down. The connection identifier,
317+ *mlx_ptr* , is needed (see the **mlx** man page).
333318
334- Both functions will discard any display outside the window. This makes
335- ** mlx_pixel_put ** slow. Consider using images instead .
319+ Parameters for **mlx_string_put** () have the same meaning. Instead of a
320+ simple pixel, the specified *string* will be displayed at ( *x* , *y* ) .
336321
337- ### Color management
322+ Both functions will discard any display outside the window. This makes
323+ **mlx_pixel_put** slow. Consider using images instead.
338324
339- The * color* parameter has an unsigned integer type. The displayed colour
340- needs to be encoded in this integer, following a defined scheme. All
341- displayable colours can be split in 3 basic colours: red, green and
342- blue. Three associated values, in the 0-255 range, represent how much of
343- each colour is mixed up to create the original colour. The fourth byte
344- represent transparency, where 0 is fully transparent and 255 opaque.
345- Theses four values must be set inside the unsigned integer to display
346- the right colour. The bytes of this integer are filled as shown in the
347- picture below:
325+ ## Color management
348326
349- | B | G | R | A | colour integer
350- +---+---+---+---+
327+ The *color* parameter has an unsigned integer type. The displayed colour
328+ needs to be encoded in this integer, following a defined scheme. All
329+ displayable colours can be split in 3 basic colours: red, green and
330+ blue. Three associated values, in the 0-255 range, represent how much of
331+ each colour is mixed up to create the original colour. The fourth byte
332+ represent transparency, where 0 is fully transparent and 255 opaque.
333+ Theses four values must be set inside the unsigned integer to display
334+ the right colour. The bytes of this integer are filled as shown in the
335+ picture below:
351336
352- While filling the integer, make sure you avoid endian problems. Example:
353- the "blue" byte will be the least significant byte inside the integer on
354- a little endian machine.
337+ | B | G | R | A | colour integer
338+ +---+---+---+---+
355339
356- ## Handle events:
340+ While filling the integer, make sure you avoid endian problems. Example:
341+ the \"blue\" byte will be the least significant byte inside the integer
342+ on a little endian machine.
357343
358- ### Synopsis
344+ # Handle events:
359345
360- int
346+ ## Synopsis
361347
362- ** mlx_loop ** ( * void \* mlx_ptr * );
348+ int
363349
364- int
350+ **mlx_loop** ( *void \*mlx_ptr* );
365351
366- ** mlx_key_hook** ( * void \* win_ptr, int (\* funct_ptr)(), void \* param*
367- );
352+ int
368353
369- int
354+ **mlx_key_hook** ( *void \*win_ptr, int (\*funct_ptr)(), void \*param*
355+ );
370356
371- ** mlx_mouse_hook** ( * void \* win_ptr, int (\* funct_ptr)(), void \* param*
372- );
357+ int
373358
374- int
359+ **mlx_mouse_hook** ( *void \*win_ptr, int (\*funct_ptr)(), void \*param*
360+ );
375361
376- ** mlx_expose_hook** ( * void \* win_ptr, int (\* funct_ptr)(), void
377- \* param* );
362+ int
378363
379- int
364+ **mlx_expose_hook** ( *void \*win_ptr, int (\*funct_ptr)(), void
365+ \*param* );
380366
381- ** mlx_loop_hook** ( * void \* mlx_ptr, int (\* funct_ptr)(), void \* param*
382- );
367+ int
383368
384- int
369+ **mlx_loop_hook** ( *void \*mlx_ptr, int (\*funct_ptr)(), void \*param*
370+ );
385371
386- ** mlx_loop_exit ** ( * void \* mlx_ptr * );
372+ int
387373
388- ### Events
374+ **mlx_loop_exit** ( *void \*mlx_ptr* );
389375
390- The graphical system is bi-directional. On one hand, the program sends
391- orders to the screen to display pixels, images, and so on. On the other
392- hand, it can get information from the keyboard and mouse associated to
393- the screen. To do so, the program receives "events" from the keyboard or
394- the mouse.
376+ ## Events
395377
396- ### Description
378+ The graphical system is bi-directional. On one hand, the program sends
379+ orders to the screen to display pixels, images, and so on. On the other
380+ hand, it can get information from the keyboard and mouse associated to
381+ the screen. To do so, the program receives \"events\" from the keyboard
382+ or the mouse.
383+
384+ ## Description
385+
386+ To receive events, you must use **mlx_loop** (). This function never
387+ returns, unless **mlx_loop_exit** is called. It is an infinite loop that
388+ waits for an event, and then calls a user-defined function associated
389+ with this event. A single parameter is needed, the connection identifier
390+ *mlx_ptr* (see the **mlx manual).**
391+
392+ You can assign different functions to the three following events:\
393+ - A key is released\
394+ - The mouse button is pressed\
395+ - A part of the window should be re-drawn (this is called an \"expose\"
396+ event, and it is your program\'s job to handle it in the Unix/Linux X11
397+ environment, but at the opposite it never happens on Unix/Linux
398+ Wayland-Vulkan nor on MacOS).\
399+
400+ Each window can define a different function for the same event.
401+
402+ The three functions **mlx_key_hook** (), **mlx_mouse_hook** () and
403+ **mlx_expose_hook** () work exactly the same way. *funct_ptr* is a
404+ pointer to the function you want to be called when an event occurs. This
405+ assignment is specific to the window defined by the *win_ptr*
406+ identifier. The *param* address will be passed back to your function
407+ every time it is called, and should be used to store the parameters it
408+ might need.
409+
410+ The syntax for the **mlx_loop_hook** () function is similar to the
411+ previous ones, but the given function will be called when no event
412+ occurs, and is not bound to a specific window.
413+
414+ When it catches an event, the MiniLibX calls the corresponding function
415+ with fixed parameters:
416+
417+
418+ expose_hook(void *param);
419+ key_hook(unsigned int keycode, void *param);
420+ mouse_hook(unsigned int button, unsigned int x, unsigned int y, void *param);
421+ loop_hook(void *param);
422+
423+ These function names are arbitrary. They here are used to distinguish
424+ parameters according to the event. These functions are NOT part of the
425+ MiniLibX.
426+
427+ *param* is the address specified in the mlx\_\*\_hook calls. This
428+ address is never used nor modified by the MiniLibX. On key and mouse
429+ events, additional information is passed: *keycode* tells you which key
430+ is pressed (just try to find out :) ), ( *x* , *y* ) are the coordinates
431+ of the mouse click in the window, and *button* tells you which mouse
432+ button was pressed.
433+
434+ ## Going further with events
435+
436+ The MiniLibX provides a much generic access to other available events.
437+ The *mlx.h* include define **mlx_hook()** in the same manner
438+ mlx\_\*\_hook functions work. The event and mask values will be taken
439+ from the historical X11 include file \"X.h\". Some Wayland and MacOS
440+ events are mapped to these values when it makes sense, and the mask may
441+ not be used in some configurations.
397442
398- To receive events, you must use ** mlx_loop** (). This function never
399- returns, unless ** mlx_loop_exit** is called. It is an infinite loop that
400- waits for an event, and then calls a user-defined function associated
401- with this event. A single parameter is needed, the connection identifier
402- * mlx_ptr* (see the ** mlx manual).**
403-
404- You can assign different functions to the three following events:
405- - A key is released
406- - The mouse button is pressed
407- - A part of the window should be re-drawn (this is called an "expose"
408- event, and it is your program's job to handle it in the Unix/Linux X11
409- environment, but at the opposite it never happens on Unix/Linux
410- Wayland-Vulkan nor on MacOS).
411-
412- Each window can define a different function for the same event.
413-
414- The three functions ** mlx_key_hook** (), ** mlx_mouse_hook** () and
415- ** mlx_expose_hook** () work exactly the same way. * funct_ptr* is a
416- pointer to the function you want to be called when an event occurs. This
417- assignment is specific to the window defined by the * win_ptr*
418- identifier. The * param* address will be passed back to your function
419- every time it is called, and should be used to store the parameters it
420- might need.
421-
422- The syntax for the ** mlx_loop_hook** () function is similar to the
423- previous ones, but the given function will be called when no event
424- occurs, and is not bound to a specific window.
425-
426- When it catches an event, the MiniLibX calls the corresponding function
427- with fixed parameters:
428-
429- expose_hook(void *param);
430- key_hook(unsigned int keycode, void *param);
431- mouse_hook(unsigned int button, unsigned int x, unsigned int y, void *param);
432- loop_hook(void *param);
433-
434- These function names are arbitrary. They here are used to distinguish
435- parameters according to the event. These functions are NOT part of the
436- MiniLibX.
437-
438- * param* is the address specified in the mlx\_\*\_ hook calls. This
439- address is never used nor modified by the MiniLibX. On key and mouse
440- events, additional information is passed: * keycode* tells you which key
441- is pressed (just try to find out :) ), ( * x* , * y* ) are the coordinates
442- of the mouse click in the window, and * button* tells you which mouse
443- button was pressed.
444-
445- ### Going further with events
446-
447- The MiniLibX provides a much generic access to other available events.
448- The * mlx.h* include define ** mlx_hook()** in the same manner
449- mlx\_\*\_ hook functions work. The event and mask values will be taken
450- from the historical X11 include file "X.h". Some Wayland and MacOS
451- events are mapped to these values when it makes sense, and the mask may
452- not be used in some configurations.
453-
454- See source code of the MiniLibX to find out how it will call your own
455- function for a specific event.
443+ See source code of the MiniLibX to find out how it will call your own
444+ function for a specific event.
456445
457446## Got any suggestions?
458447
0 commit comments