@@ -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
@@ -283,176 +272,179 @@ c_void_p, c_uint, c_uint, c_char_p
283272 def mlx_destroy_window (mlx_ptr : int , win_ptr : int ) -> int :
284273```
285274
286- ### Description
275+ ## —– UNDER CONSTRUCTION —–
287276
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.
277+ ## Description
296278
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.
279+ The **mlx_new_window** () function creates a new window on the screen,
280+ using the *width* and *height* parameters to determine its size, and
281+ *title* as the text that should be displayed in the window\'s title bar.
282+ The *mlx_ptr* parameter is the connection identifier returned by
283+ **mlx_init** () (see the **mlx** man page). **mlx_new_window** ()
284+ returns a *void \** window identifier that can be used by other MiniLibX
285+ calls. Note that the MiniLibX can handle an arbitrary number of separate
286+ windows.
301287
302- ### Return values
288+ **mlx_clear_window** () and **mlx_destroy_window** () respectively clear
289+ (in black) and destroy the given window. They both have the same
290+ parameters: *mlx_ptr* is the screen connection identifier, and *win_ptr*
291+ is a window identifier.
303292
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.
293+ ## Return values
308294
309- ## Drawing inside windows: mlx_pixel_put(), mlx_string_put()
295+ If **mlx_new_window()** fails to create a new window (whatever the
296+ reason), it will return NULL, otherwise a non-null pointer is returned
297+ as a window identifier. **mlx_clear_window** and **mlx_destroy_window**
298+ return nothing.
310299
311- ### Synopsis
300+ # Drawing inside windows: mlx_pixel_put(), mlx_string_put()
312301
313- int
302+ ## Synopsis
314303
315- ** mlx_pixel_put** ( * void \* mlx_ptr, void \* win_ptr, unsigned int x,
316- unsigned int y, unsigned int color* );
304+ int
317305
318- int
306+ **mlx_pixel_put** ( *void \*mlx_ptr, void \*win_ptr, unsigned int x,
307+ unsigned int y, unsigned int color* );
319308
320- ** mlx_string_put** ( * void \* mlx_ptr, void \* win_ptr, unsigned int x,
321- unsigned int y, unsigned int color, char \* string* );
309+ int
322310
323- ### Description
311+ **mlx_string_put** ( *void \*mlx_ptr, void \*win_ptr, unsigned int x,
312+ unsigned int y, unsigned int color, char \*string* );
324313
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).
314+ ## Description
330315
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* ).
316+ The **mlx_pixel_put** () function draws a defined pixel in the window
317+ *win_ptr* using the ( *x* , *y* ) coordinates, and the specified *color*
318+ . The origin (0,0) is the upper left corner of the window, the x and y
319+ axis respectively pointing right and down. The connection identifier,
320+ *mlx_ptr* , is needed (see the **mlx** man page).
333321
334- Both functions will discard any display outside the window. This makes
335- ** mlx_pixel_put ** slow. Consider using images instead .
322+ Parameters for **mlx_string_put** () have the same meaning. Instead of a
323+ simple pixel, the specified *string* will be displayed at ( *x* , *y* ) .
336324
337- ### Color management
325+ Both functions will discard any display outside the window. This makes
326+ **mlx_pixel_put** slow. Consider using images instead.
338327
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:
328+ ## Color management
348329
349- | B | G | R | A | colour integer
350- +---+---+---+---+
330+ The *color* parameter has an unsigned integer type. The displayed colour
331+ needs to be encoded in this integer, following a defined scheme. All
332+ displayable colours can be split in 3 basic colours: red, green and
333+ blue. Three associated values, in the 0-255 range, represent how much of
334+ each colour is mixed up to create the original colour. The fourth byte
335+ represent transparency, where 0 is fully transparent and 255 opaque.
336+ Theses four values must be set inside the unsigned integer to display
337+ the right colour. The bytes of this integer are filled as shown in the
338+ picture below:
351339
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.
340+ | B | G | R | A | colour integer
341+ +---+---+---+---+
355342
356- ## Handle events:
343+ While filling the integer, make sure you avoid endian problems. Example:
344+ the \"blue\" byte will be the least significant byte inside the integer
345+ on a little endian machine.
357346
358- ### Synopsis
347+ # Handle events:
359348
360- int
349+ ## Synopsis
361350
362- ** mlx_loop ** ( * void \* mlx_ptr * );
351+ int
363352
364- int
353+ **mlx_loop** ( *void \*mlx_ptr* );
365354
366- ** mlx_key_hook** ( * void \* win_ptr, int (\* funct_ptr)(), void \* param*
367- );
355+ int
368356
369- int
357+ **mlx_key_hook** ( *void \*win_ptr, int (\*funct_ptr)(), void \*param*
358+ );
370359
371- ** mlx_mouse_hook** ( * void \* win_ptr, int (\* funct_ptr)(), void \* param*
372- );
360+ int
373361
374- int
362+ **mlx_mouse_hook** ( *void \*win_ptr, int (\*funct_ptr)(), void \*param*
363+ );
375364
376- ** mlx_expose_hook** ( * void \* win_ptr, int (\* funct_ptr)(), void
377- \* param* );
365+ int
378366
379- int
367+ **mlx_expose_hook** ( *void \*win_ptr, int (\*funct_ptr)(), void
368+ \*param* );
380369
381- ** mlx_loop_hook** ( * void \* mlx_ptr, int (\* funct_ptr)(), void \* param*
382- );
370+ int
383371
384- int
372+ **mlx_loop_hook** ( *void \*mlx_ptr, int (\*funct_ptr)(), void \*param*
373+ );
385374
386- ** mlx_loop_exit ** ( * void \* mlx_ptr * );
375+ int
387376
388- ### Events
377+ **mlx_loop_exit** ( *void \*mlx_ptr* );
389378
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.
379+ ## Events
395380
396- ### Description
381+ The graphical system is bi-directional. On one hand, the program sends
382+ orders to the screen to display pixels, images, and so on. On the other
383+ hand, it can get information from the keyboard and mouse associated to
384+ the screen. To do so, the program receives \"events\" from the keyboard
385+ or the mouse.
386+
387+ ## Description
388+
389+ To receive events, you must use **mlx_loop** (). This function never
390+ returns, unless **mlx_loop_exit** is called. It is an infinite loop that
391+ waits for an event, and then calls a user-defined function associated
392+ with this event. A single parameter is needed, the connection identifier
393+ *mlx_ptr* (see the **mlx manual).**
394+
395+ You can assign different functions to the three following events:\
396+ - A key is released\
397+ - The mouse button is pressed\
398+ - A part of the window should be re-drawn (this is called an \"expose\"
399+ event, and it is your program\'s job to handle it in the Unix/Linux X11
400+ environment, but at the opposite it never happens on Unix/Linux
401+ Wayland-Vulkan nor on MacOS).\
402+
403+ Each window can define a different function for the same event.
404+
405+ The three functions **mlx_key_hook** (), **mlx_mouse_hook** () and
406+ **mlx_expose_hook** () work exactly the same way. *funct_ptr* is a
407+ pointer to the function you want to be called when an event occurs. This
408+ assignment is specific to the window defined by the *win_ptr*
409+ identifier. The *param* address will be passed back to your function
410+ every time it is called, and should be used to store the parameters it
411+ might need.
412+
413+ The syntax for the **mlx_loop_hook** () function is similar to the
414+ previous ones, but the given function will be called when no event
415+ occurs, and is not bound to a specific window.
416+
417+ When it catches an event, the MiniLibX calls the corresponding function
418+ with fixed parameters:
419+
420+
421+ expose_hook(void *param);
422+ key_hook(unsigned int keycode, void *param);
423+ mouse_hook(unsigned int button, unsigned int x, unsigned int y, void *param);
424+ loop_hook(void *param);
425+
426+ These function names are arbitrary. They here are used to distinguish
427+ parameters according to the event. These functions are NOT part of the
428+ MiniLibX.
429+
430+ *param* is the address specified in the mlx\_\*\_hook calls. This
431+ address is never used nor modified by the MiniLibX. On key and mouse
432+ events, additional information is passed: *keycode* tells you which key
433+ is pressed (just try to find out :) ), ( *x* , *y* ) are the coordinates
434+ of the mouse click in the window, and *button* tells you which mouse
435+ button was pressed.
436+
437+ ## Going further with events
438+
439+ The MiniLibX provides a much generic access to other available events.
440+ The *mlx.h* include define **mlx_hook()** in the same manner
441+ mlx\_\*\_hook functions work. The event and mask values will be taken
442+ from the historical X11 include file \"X.h\". Some Wayland and MacOS
443+ events are mapped to these values when it makes sense, and the mask may
444+ not be used in some configurations.
397445
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.
446+ See source code of the MiniLibX to find out how it will call your own
447+ function for a specific event.
456448
457449## Got any suggestions?
458450
0 commit comments