mirror of
https://github.com/maoakeEnterprise/amazing.git
synced 2026-04-29 00:14:34 +02:00
fix(parsing): make output work for AMazeIng class __init__
Basic main to display ascii print
This commit is contained in:
+136
@@ -0,0 +1,136 @@
|
||||
.TH MiniLibX 3 "September 19, 2002"
|
||||
.SH NAME
|
||||
MiniLibX - Simple Window Interface Library for students
|
||||
.SH SYNOPSYS
|
||||
#include <mlx.h>
|
||||
|
||||
.nf
|
||||
.I void *
|
||||
.fi
|
||||
.B mlx_init
|
||||
();
|
||||
|
||||
.nf
|
||||
.I int
|
||||
.fi
|
||||
.B mlx_release
|
||||
(void *mlx_ptr);
|
||||
|
||||
.SH DESCRIPTION
|
||||
MiniLibX is an easy way to create graphical software,
|
||||
without any X-Window/Wayland/Vulkan programming knowledge under Unix/Linux,
|
||||
nor any AppKit programming knowledge under MacOS. It provides
|
||||
simple window creation, a drawing tool, image and basic events
|
||||
management.
|
||||
|
||||
.SH Unix/Linux: HISTORICAL X-WINDOW CONCEPT
|
||||
|
||||
X-Window is a network-oriented graphical system for Unix.
|
||||
It is based on two main parts:
|
||||
.br
|
||||
On one side, your software wants to draw something on the screen and/or
|
||||
get keyboard & mouse entries.
|
||||
.br
|
||||
On the other side, the X-Server manages the screen, keyboard and mouse
|
||||
(It is often referred to as a "display").
|
||||
.br
|
||||
A network connection must be established between these two entities to send
|
||||
drawing orders (from the software to the X-Server), and keyboard/mouse
|
||||
events (from the X-Server to the software).
|
||||
.br
|
||||
Nowadays, most of the time, both run on the same computer.
|
||||
|
||||
.SH Unix/Linux: MODERN GRAPHICAL APPROACH
|
||||
|
||||
Modern computers come with a powerful GPU that is directly accessed by applications.
|
||||
Along GPU libraries like Vulkan or OpenGL, the Wayland protocol ensure communication
|
||||
with the compositor program that manages the various windows on screen and the user
|
||||
input events.
|
||||
For your own application:
|
||||
.br
|
||||
The Vulkan or OpenGL library allow you to directly draw any content into your window.
|
||||
.br
|
||||
The Wayland compositor handles the place of your window on screen and send you back
|
||||
the keyboard and mouse inputs from the user.
|
||||
.br
|
||||
Unfortunately, this gain of graphical power through GPU access removes the networking aspects
|
||||
that exist with X-Window. It is not possible for a program to access a remote GPU and show its
|
||||
window on a remote display. But current software architectures are more likely based on a local
|
||||
display application that gets data in JSON through a web API.
|
||||
|
||||
.SH MacOS: WINDOW SERVER AND GPU
|
||||
|
||||
Your software interacts directly with the Window server who handles the
|
||||
cohabitation on the screen with other software and the event system,
|
||||
and interacts with the GPU to handle all drawing commands.
|
||||
|
||||
.SH INCLUDE FILE
|
||||
.B mlx.h
|
||||
should be included for a correct use of the MiniLibX API.
|
||||
It only contains function prototypes, no structure is needed.
|
||||
|
||||
.SH LIBRARY FUNCTIONS
|
||||
.P
|
||||
First of all, you need to initialize the connection
|
||||
between your software and the graphic and user sub-systems.
|
||||
Once this completed, you'll be able to use other MiniLibX
|
||||
functions to send and receive the messages from
|
||||
the display, like "I want to draw a yellow pixel in this window" or
|
||||
"did the user hit a key?".
|
||||
.P
|
||||
The
|
||||
.B mlx_init
|
||||
function will create this connection. No parameters are needed, ant it will
|
||||
return a
|
||||
.I "void *"
|
||||
identifier, used for further calls to the library routines. The
|
||||
.B mlx_release
|
||||
function can be used at the end of the program to disconnect from the graphic
|
||||
system and release resources.
|
||||
.P
|
||||
All other MiniLibX functions are described in the following man pages:
|
||||
|
||||
.TP 20
|
||||
.B mlx_new_window
|
||||
: manage windows
|
||||
.TP 20
|
||||
.B mlx_pixel_put
|
||||
: draw inside a window
|
||||
.TP 20
|
||||
.B mlx_new_image
|
||||
: manipulate images
|
||||
.TP 20
|
||||
.B mlx_loop
|
||||
: handle keyboard or mouse events
|
||||
.TP 20
|
||||
.B mlx_extra
|
||||
: extra functions available in the MinilibX
|
||||
|
||||
.SH LINKING MiniLibX
|
||||
To use MiniLibX functions, you may -or not- need to link
|
||||
your software with several libraries, including the MiniLibX library itself.
|
||||
On Unix/Linux, depending on the specific operating system, either just using
|
||||
.B -lmlx
|
||||
works, or you need to add
|
||||
.B -lxcb -lxcb-keysyms -lvulkan -lz -lbsd
|
||||
\&.
|
||||
On MacOS, the dynamic Metal library will find on its own the missing components:
|
||||
.B -lmlx
|
||||
\&.
|
||||
|
||||
You may also need to specify the path to these libraries, using the
|
||||
.B -L
|
||||
flag.
|
||||
|
||||
|
||||
.SH RETURN VALUES
|
||||
If
|
||||
.B mlx_init()
|
||||
fails to set up the connection to the display, it will return NULL, otherwise
|
||||
a non-null pointer is returned as a connection identifier.
|
||||
|
||||
.SH SEE ALSO
|
||||
mlx_new_window(3), mlx_pixel_put(3), mlx_new_image(3), mlx_loop(3), mlx_extra(3)
|
||||
|
||||
.SH AUTHOR
|
||||
Copyright ol@ - 2002-2025 - Olivier Crouzet
|
||||
+209
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
** mlx.h for MinilibX in
|
||||
**
|
||||
** Made by Charlie Root
|
||||
** Login <ol@42.fr>
|
||||
**
|
||||
** Started on Mon Jul 31 16:37:50 2000 Olivier Crouzet
|
||||
** Last update Tue Jun 25 16:23:28 2025 Olivier Crouzet
|
||||
*/
|
||||
|
||||
/*
|
||||
** MinilibX - Please report bugs
|
||||
*/
|
||||
|
||||
|
||||
/* mlx_CLXV version 2.2 */
|
||||
|
||||
/*
|
||||
**
|
||||
** This library is a simple framework to help 42 students
|
||||
** create simple graphical apps.
|
||||
** It only provides the minimum functions, it's students' job
|
||||
** to create the missing pieces for their own project :)
|
||||
**
|
||||
** Current XCB-Vulkan requirements for Linux:
|
||||
** libxcb, libxcb-keysyms, libvulkan,
|
||||
** libz, libbsd
|
||||
** You also need glslc to re-compile shaders if needed.
|
||||
** At 42, on current Ubuntu 22.04 dump in cluster, you need to get
|
||||
** libxcb-keysyms source for the include file and compile the .a library.
|
||||
**
|
||||
** The MinilibX can load XPM and PNG images.
|
||||
** Please note that both image loaders are incomplete, some
|
||||
** image may not load. Also, image loaders only work for little endian hosts.
|
||||
**
|
||||
** Historically, the alpha byte did represent transparency
|
||||
** instead of opacity. It's not the case anymore. MLX matches GPUs standards.
|
||||
**
|
||||
** MLX_CLXV API changes:
|
||||
** - mlx_get_data_addr now provides the image format instead of the
|
||||
endian, and returns an 'unsigned char' pointer.
|
||||
** - 'unsigned int' replace 'int' in many calls.
|
||||
** - mlx_get_color_value() is now deprecated.
|
||||
** - adding mlx_loop_exit().
|
||||
**
|
||||
** With recent X11 implementation and default configuration, the Expose event is only
|
||||
** received once at the program launch. This is often due to X server saving the
|
||||
** content of the window.
|
||||
** With Wayland, there is no such thing like Expose event, and the compositor saves
|
||||
** the window's content.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#ifndef MLX_H
|
||||
|
||||
#define MLX_H
|
||||
|
||||
|
||||
/*
|
||||
** mlx_init() is needed before everything else.
|
||||
** mlx_init() returns 'void *0' in case of failure.
|
||||
** mlx_release() returns 0 on success.
|
||||
*/
|
||||
void *mlx_init();
|
||||
int mlx_release(void *mlx_ptr);
|
||||
|
||||
|
||||
/*
|
||||
** Window actions
|
||||
*/
|
||||
void *mlx_new_window(void *mlx_ptr, unsigned int width,
|
||||
unsigned int height, const char *title);
|
||||
int mlx_clear_window(void *mlx_ptr, void *win_ptr);
|
||||
int mlx_pixel_put(void *mlx_ptr, void *win_ptr,
|
||||
unsigned int x, unsigned int y, unsigned int color);
|
||||
int mlx_destroy_window(void *mlx_ptr, void *win_ptr);
|
||||
/*
|
||||
** mlx_new_window() returns 'void *0' if failed.
|
||||
** Other functions return 0 on success.
|
||||
** Origin for x & y is top left corner of the window, y down is positive.
|
||||
** x and y must fit into the size of the window, values are not controled
|
||||
** Color byte order is B8G8R8A8, which could be 0xAARRGGBB or 0xBBGGRRAA
|
||||
** depending on local endianess.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
** Images
|
||||
*/
|
||||
void *mlx_new_image(void *mlx_ptr, unsigned int width, unsigned int height);
|
||||
unsigned char *mlx_get_data_addr(void *img_ptr, unsigned int *bits_per_pixel,
|
||||
unsigned int *size_line,
|
||||
unsigned int *format);
|
||||
int mlx_put_image_to_window(void *mlx_ptr, void *win_ptr, void *img_ptr,
|
||||
int x, int y);
|
||||
int mlx_destroy_image(void *mlx_ptr, void *img_ptr);
|
||||
/*
|
||||
** mlx_new_image() returns 'void *0' in case of failure.
|
||||
** mlx_get_data_addr() returns a pointer to a height * size_line bytes buffer
|
||||
** that holds the pixel values.
|
||||
** Other functions return 0 on success.
|
||||
** 'format' can be: 0 = B8G8R8A8; 1 = A8R8G8B8; (byte order).
|
||||
** Carefully consider the format, it can be reversed in some cases, like a remote graphic server
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
** deprecated function - format of image allows conversion on student's side
|
||||
** unsigned int mlx_get_color_value(void *mlx_ptr, int color);
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
** main loop & dealing with events
|
||||
*/
|
||||
typedef int (*mlx_mouse_callback)(unsigned int, unsigned int, unsigned int, void*);
|
||||
typedef int (*mlx_key_callback)(unsigned int, void *);
|
||||
typedef int (*mlx_expose_callback)(void *);
|
||||
typedef int (*mlx_loop_callback)(void *);
|
||||
typedef int (*mlx_hook_callback)(void *);
|
||||
|
||||
int mlx_loop(void *mlx_ptr);
|
||||
int mlx_loop_exit(void *mlx_ptr);
|
||||
int mlx_mouse_hook(void *win_ptr, mlx_mouse_callback funct_ptr, void *param);
|
||||
int mlx_key_hook(void *win_ptr, mlx_key_callback funct_ptr, void *param);
|
||||
int mlx_expose_hook(void *win_ptr, mlx_expose_callback funct_ptr, void *param);
|
||||
int mlx_loop_hook(void *mlx_ptr, mlx_loop_callback funct_ptr, void *param);
|
||||
/*
|
||||
** Functions return 0 on success.
|
||||
** Key event is triggered on KeyRelease, not KeyPressed.
|
||||
** Mouse event is triggered on clic.
|
||||
**
|
||||
** hook functions are called as follow:
|
||||
** expose_hook(void *param);
|
||||
** key_hook(unsigned int keycode, void *param);
|
||||
** mouse_hook(unsigned int button, unsigned int x, unsigned int y,
|
||||
** void *param);
|
||||
** loop_hook(void *param);
|
||||
*/
|
||||
|
||||
/*
|
||||
** Generic hook system for all events, and minilibX functions that
|
||||
** can be hooked. Some macro and defines from X11/X.h are needed here.
|
||||
** Warning: you may need to cast your function pointer for key and mouse events
|
||||
** as there will be extra parameters.
|
||||
*/
|
||||
int mlx_hook(void *win_ptr, unsigned int x_event, unsigned int x_mask,
|
||||
mlx_hook_callback funct_ptr, void *param);
|
||||
|
||||
|
||||
/*
|
||||
** Convenience functions
|
||||
** mlx_string_put() display may vary in size between OS and between
|
||||
** mlx implementations
|
||||
** mlx_string_put() returns 0 on success.
|
||||
** Other functions return an image (like mlx_new_image()) or 'void *0'.
|
||||
**
|
||||
*/
|
||||
int mlx_string_put(void *mlx_ptr, void *win_ptr,
|
||||
unsigned int x, unsigned int y,
|
||||
unsigned int color, char *string);
|
||||
void *mlx_xpm_to_image(void *mlx_ptr, const char **xpm_data,
|
||||
unsigned int *width, unsigned int *height);
|
||||
void *mlx_xpm_file_to_image(void *mlx_ptr, const char *filename,
|
||||
unsigned int *width, unsigned int *height);
|
||||
void *mlx_png_file_to_image(void *mlx_ptr, const char *filename,
|
||||
unsigned int *width, unsigned int *height);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** Convenience functions
|
||||
** All functions return 0 on success.
|
||||
*/
|
||||
int mlx_mouse_hide(void *mlx_ptr);
|
||||
int mlx_mouse_show(void *mlx_ptr);
|
||||
int mlx_mouse_move(void *win_ptr, int x, int y);
|
||||
int mlx_mouse_get_pos(void *win_ptr, int *x, int *y);
|
||||
int mlx_do_key_autorepeatoff(void *mlx_ptr);
|
||||
int mlx_do_key_autorepeaton(void *mlx_ptr);
|
||||
int mlx_get_screen_size(void *mlx_ptr,
|
||||
unsigned int *width, unsigned int *height);
|
||||
|
||||
|
||||
/*
|
||||
** Flush & Sync
|
||||
*/
|
||||
int mlx_do_sync(void *mlx_ptr);
|
||||
#define MLX_SYNC_IMAGE_WRITABLE 1
|
||||
#define MLX_SYNC_WIN_FLUSH 2
|
||||
#define MLX_SYNC_WIN_COMPLETED 3
|
||||
int mlx_sync(void *mlx_ptr, int cmd, void *param);
|
||||
/*
|
||||
** Functions return 0 on success.
|
||||
** mlx_do_sync() will *flush* (not sync) all requests and wait for completion.
|
||||
** Note: mlx_loop() always flush requests.
|
||||
** mlx_sync() 'cmd' commands are:
|
||||
** - 'image_writable' returns when image data can be written again.
|
||||
** - 'win_flush' returns when all pending requests are sent to server.
|
||||
** - 'win_completed' returns after flush and completion.
|
||||
** 'param' is image pointer or window pointer, according to the command.
|
||||
** mlx_do_sync() equals 'win_flush' for all windows.
|
||||
**
|
||||
*/
|
||||
|
||||
|
||||
#endif /* MLX_H */
|
||||
@@ -0,0 +1,121 @@
|
||||
.TH MiniLibX 3 "September 19, 2002"
|
||||
.SH NAME
|
||||
MiniLibX - Extra functions
|
||||
.SH SYNOPSYS
|
||||
|
||||
.nf
|
||||
.I int
|
||||
.fi
|
||||
.B mlx_mouse_hide
|
||||
(
|
||||
.I void *mlx_ptr
|
||||
);
|
||||
|
||||
.nf
|
||||
.I int
|
||||
.fi
|
||||
.B mlx_mouse_show
|
||||
(
|
||||
.I void *mlx_ptr
|
||||
);
|
||||
|
||||
.nf
|
||||
.I int
|
||||
.fi
|
||||
.B mlx_mouse_move
|
||||
(
|
||||
.I void *mlx_ptr, int x, int y
|
||||
);
|
||||
|
||||
.nf
|
||||
.I int
|
||||
.fi
|
||||
.B mlx_mouse_get_pos
|
||||
(
|
||||
.I void *win_ptr, int *x, int *y
|
||||
);
|
||||
|
||||
.nf
|
||||
.I int
|
||||
.fi
|
||||
.B mlx_do_key_autorepeatoff
|
||||
(
|
||||
.I void *mlx_ptr
|
||||
);
|
||||
|
||||
.nf
|
||||
.I int
|
||||
.fi
|
||||
.B mlx_do_key_autorepeaton
|
||||
(
|
||||
.I void *mlx_ptr
|
||||
);
|
||||
|
||||
.nf
|
||||
.I int
|
||||
.fi
|
||||
.B mlx_get_screen_size
|
||||
(
|
||||
.I void *mlx_ptr, unsigned int *width, unsigned int *height
|
||||
);
|
||||
|
||||
.nf
|
||||
.I int
|
||||
.fi
|
||||
.B mlx_do_sync
|
||||
(
|
||||
.I void *mlx_ptr
|
||||
);
|
||||
|
||||
.nf
|
||||
.I int
|
||||
.fi
|
||||
.B mlx_sync
|
||||
(
|
||||
.I void *mlx_ptr, int cmd, void *param
|
||||
);
|
||||
|
||||
.SH MOUSE EXTRA FUNCTIONS
|
||||
|
||||
It is possible to show / hide the mouse, and get its current position without user click or
|
||||
force its position inside a window.
|
||||
|
||||
.SH KEYBOARD EXTRA FUNCTIONS
|
||||
|
||||
The auto-repeat mode of the keyboard can be controlled. By default, auto-repeat is on:
|
||||
multiple "key pressed" events are generated every second until the key is released.
|
||||
|
||||
.SH SCREEN EXTRA FUNCTION
|
||||
|
||||
It is possible to retrieve the size of the current screen, even before the first
|
||||
window is created.
|
||||
|
||||
.SH FLUSH AND SYNC FUNCTIONS
|
||||
|
||||
The
|
||||
.B mlx_do_sync
|
||||
function will flush the pending commands to the graphic subsystems, ensuring nothing
|
||||
is cached on your software's side. On return, there is no guarantee that your
|
||||
commands have been processed.
|
||||
.br
|
||||
With
|
||||
.B mlx_sync
|
||||
you have more detailed control over the synchronisation mechanisms. Three different commands
|
||||
are available:
|
||||
.br
|
||||
#define MLX_SYNC_IMAGE_WRITABLE 1
|
||||
.br
|
||||
#define MLX_SYNC_WIN_FLUSH 2
|
||||
.br
|
||||
#define MLX_SYNC_WIN_COMPLETED 3
|
||||
.br
|
||||
The third parameter
|
||||
.I param
|
||||
can be either the image identifier (command #1) or the window identifier (commands #2 and #3).
|
||||
|
||||
|
||||
.SH SEE ALSO
|
||||
mlx(3), mlx_new_window(3), mlx_pixel_put(3), mlx_new_image(3), mlx_loop(3)
|
||||
|
||||
.SH AUTHOR
|
||||
Copyright ol@ - 2002-2025 - Olivier Crouzet
|
||||
@@ -0,0 +1,154 @@
|
||||
.TH MiniLibX 3 "September 19, 2002"
|
||||
.SH NAME
|
||||
MiniLibX - Handle events
|
||||
.SH SYNOPSYS
|
||||
|
||||
.nf
|
||||
.I int
|
||||
.fi
|
||||
.B mlx_loop
|
||||
(
|
||||
.I void *mlx_ptr
|
||||
);
|
||||
|
||||
.nf
|
||||
.I int
|
||||
.fi
|
||||
.B mlx_key_hook
|
||||
(
|
||||
.I void *win_ptr, int (*funct_ptr)(), void *param
|
||||
);
|
||||
|
||||
.nf
|
||||
.I int
|
||||
.fi
|
||||
.B mlx_mouse_hook
|
||||
(
|
||||
.I void *win_ptr, int (*funct_ptr)(), void *param
|
||||
);
|
||||
|
||||
.nf
|
||||
.I int
|
||||
.fi
|
||||
.B mlx_expose_hook
|
||||
(
|
||||
.I void *win_ptr, int (*funct_ptr)(), void *param
|
||||
);
|
||||
|
||||
.nf
|
||||
.I int
|
||||
.fi
|
||||
.B mlx_loop_hook
|
||||
(
|
||||
.I void *mlx_ptr, int (*funct_ptr)(), void *param
|
||||
);
|
||||
|
||||
.nf
|
||||
.I int
|
||||
.fi
|
||||
.B mlx_loop_exit
|
||||
(
|
||||
.I void *mlx_ptr
|
||||
);
|
||||
|
||||
.SH EVENTS
|
||||
|
||||
The graphical system is bi-directional. On one hand, the program sends orders to
|
||||
the screen to display pixels, images, and so on. On the other hand,
|
||||
it can get information from the keyboard and mouse associated to
|
||||
the screen. To do so, the program receives "events" from the keyboard or the
|
||||
mouse.
|
||||
|
||||
.SH DESCRIPTION
|
||||
|
||||
To receive events, you must use
|
||||
.B mlx_loop
|
||||
(). This function never returns, unless
|
||||
.B mlx_loop_exit
|
||||
is called. It is an
|
||||
infinite loop that waits for an event, and then calls a user-defined
|
||||
function associated with this event. A single parameter is needed,
|
||||
the connection identifier
|
||||
.I mlx_ptr
|
||||
(see the
|
||||
.B mlx manual).
|
||||
|
||||
You can assign different functions to the three following events:
|
||||
.br
|
||||
- A key is released
|
||||
.br
|
||||
- The mouse button is pressed
|
||||
.br
|
||||
- A part of the window should be re-drawn
|
||||
(this is called an "expose" event, and it is your program's job to handle it in the
|
||||
Unix/Linux X11 environment, but at the opposite it never happens on Unix/Linux Wayland-Vulkan nor on MacOS).
|
||||
.br
|
||||
|
||||
Each window can define a different function for the same event.
|
||||
|
||||
The three functions
|
||||
.B mlx_key_hook
|
||||
(),
|
||||
.B mlx_mouse_hook
|
||||
() and
|
||||
.B mlx_expose_hook
|
||||
() work exactly the same way.
|
||||
.I funct_ptr
|
||||
is a pointer to the function you want to be called
|
||||
when an event occurs. This assignment is specific to the window defined by the
|
||||
.I win_ptr
|
||||
identifier. The
|
||||
.I param
|
||||
address will be passed back to your function every time it is called, and should be
|
||||
used to store the parameters it might need.
|
||||
|
||||
The syntax for the
|
||||
.B mlx_loop_hook
|
||||
() function is similar to the previous ones, but the given function will be
|
||||
called when no event occurs, and is not bound to a specific window.
|
||||
|
||||
When it catches an event, the MiniLibX calls the corresponding function
|
||||
with fixed parameters:
|
||||
.nf
|
||||
|
||||
expose_hook(void *param);
|
||||
key_hook(unsigned int keycode, void *param);
|
||||
mouse_hook(unsigned int button, unsigned int x, unsigned int y, void *param);
|
||||
loop_hook(void *param);
|
||||
|
||||
.fi
|
||||
These function names are arbitrary. They here are used to distinguish
|
||||
parameters according to the event. These functions are NOT part of the
|
||||
MiniLibX.
|
||||
|
||||
.I param
|
||||
is the address specified in the mlx_*_hook calls. This address is never
|
||||
used nor modified by the MiniLibX. On key and mouse events, additional
|
||||
information is passed:
|
||||
.I keycode
|
||||
tells you which key is pressed (just try to find out :) ),
|
||||
(
|
||||
.I x
|
||||
,
|
||||
.I y
|
||||
) are the coordinates of the mouse click in the window, and
|
||||
.I button
|
||||
tells you which mouse button was pressed.
|
||||
|
||||
.SH GOING FURTHER WITH EVENTS
|
||||
The MiniLibX provides a much generic access to other available events. The
|
||||
.I mlx.h
|
||||
include define
|
||||
.B mlx_hook()
|
||||
in the same manner mlx_*_hook functions work. The event and mask values
|
||||
will be taken from the historical X11 include file "X.h". Some Wayland and MacOS events are mapped
|
||||
to these values when it makes sense, and the mask may not be used in some configurations.
|
||||
|
||||
See source code of the MiniLibX to find out how it will
|
||||
call your own function for a specific event.
|
||||
|
||||
.SH SEE ALSO
|
||||
mlx(3), mlx_new_window(3), mlx_pixel_put(3), mlx_new_image(3), mlx_extra(3)
|
||||
|
||||
.SH AUTHOR
|
||||
Copyright ol@ - 2002-2025 - Olivier Crouzet
|
||||
@@ -0,0 +1,180 @@
|
||||
.TH MiniLibX 3 "September 19, 2002"
|
||||
.SH NAME
|
||||
MiniLibX - Manipulating images
|
||||
.SH SYNOPSYS
|
||||
|
||||
.nf
|
||||
.I void *
|
||||
.fi
|
||||
.B mlx_new_image
|
||||
(
|
||||
.I void *mlx_ptr, unsigned int width, unsigned int height
|
||||
);
|
||||
|
||||
.nf
|
||||
.I unsigned char *
|
||||
.fi
|
||||
.B mlx_get_data_addr
|
||||
(
|
||||
.I void *img_ptr, unsigned int *bits_per_pixel, unsigned int *size_line, unsigned int *format
|
||||
);
|
||||
|
||||
.nf
|
||||
.I int
|
||||
.fi
|
||||
.B mlx_put_image_to_window
|
||||
(
|
||||
.I void *mlx_ptr, void *win_ptr, void *img_ptr, int x, int y
|
||||
);
|
||||
|
||||
.nf
|
||||
.I void *
|
||||
.fi
|
||||
.B mlx_xpm_to_image
|
||||
(
|
||||
.I void *mlx_ptr, const char **xpm_data, unsigned int *width, unsigned int *height
|
||||
);
|
||||
|
||||
.nf
|
||||
.I void *
|
||||
.fi
|
||||
.B mlx_xpm_file_to_image
|
||||
(
|
||||
.I void *mlx_ptr, const char *filename, unsigned int *width, unsigned int *height
|
||||
);
|
||||
|
||||
.nf
|
||||
.I void *
|
||||
.fi
|
||||
.B mlx_png_file_to_image
|
||||
(
|
||||
.I void *mlx_ptr, const char *filename, unsigned int *width, unsigned int *height
|
||||
);
|
||||
|
||||
.nf
|
||||
.I int
|
||||
.fi
|
||||
.B mlx_destroy_image
|
||||
(
|
||||
.I void *mlx_ptr, void *img_ptr
|
||||
);
|
||||
|
||||
|
||||
.SH DESCRIPTION
|
||||
|
||||
.B mlx_new_image
|
||||
() creates a new image in memory. It returns a
|
||||
.I void *
|
||||
identifier needed to manipulate this image later. It only needs
|
||||
the size of the image to be created, using the
|
||||
.I width
|
||||
and
|
||||
.I height
|
||||
parameters, and the
|
||||
.I mlx_ptr
|
||||
connection identifier (see the
|
||||
.B mlx
|
||||
manual).
|
||||
|
||||
The user can draw inside the image (see below), and
|
||||
can dump the image inside a specified window at any time to
|
||||
display it on the screen. This is done using
|
||||
.B mlx_put_image_to_window
|
||||
(). Three identifiers are needed here, for the connection to the
|
||||
display, the window to use, and the image (respectively
|
||||
.I mlx_ptr
|
||||
,
|
||||
.I win_ptr
|
||||
and
|
||||
.I img_ptr
|
||||
). The (
|
||||
.I x
|
||||
,
|
||||
.I y
|
||||
) coordinates define where the image should be placed in the window.
|
||||
|
||||
.B mlx_get_data_addr
|
||||
() returns information about the created image, allowing a user
|
||||
to modify it later. The
|
||||
.I img_ptr
|
||||
parameter specifies the image to use. The three next parameters should
|
||||
be the addresses of three different valid unsigned integers.
|
||||
.I bits_per_pixel
|
||||
will be filled with the number of bits needed to represent a pixel colour
|
||||
(also called the depth of the image).
|
||||
.I size_line
|
||||
is the number of bytes used to store one line of the image in memory.
|
||||
This information is needed to move from one line to another in the image.
|
||||
.I format
|
||||
tells you how each pixel colour in the image is structured. Currently only 2 values are defined:
|
||||
.P
|
||||
0 means format B8G8R8A8
|
||||
.P
|
||||
1 means format A8R8G8B8
|
||||
|
||||
.B mlx_get_data_addr
|
||||
returns an
|
||||
.I unsigned char *
|
||||
address that represents the beginning of the memory area where the image
|
||||
is stored. From this address, the first
|
||||
.I bits_per_pixel
|
||||
bits represent the colour of the first pixel in the first line of
|
||||
the image. The second group of
|
||||
.I bits_per_pixel
|
||||
bits represent the second pixel of the first line, and so on.
|
||||
Add
|
||||
.I size_line
|
||||
to the address to get the beginning of the second line. You can reach any
|
||||
pixels of the image that way.
|
||||
|
||||
.B mlx_destroy_image
|
||||
destroys the given image (
|
||||
.I img_ptr
|
||||
).
|
||||
|
||||
.SH STORING COLOURS INSIDE IMAGES
|
||||
|
||||
Depending on the graphic system, the number of bits used to store a pixel colour
|
||||
used to be different from one hardware to another. Today, the way the user usually
|
||||
represents a colour, in the ARGB mode, almost always matches the hardware capabilities
|
||||
on modern computers.
|
||||
|
||||
Keep in mind that packing the 4-byte ARGB into an unsigned int depends on the local
|
||||
computer's endian. Adjust your code accordingly.
|
||||
|
||||
.SH XPM AND PNG IMAGES
|
||||
|
||||
The
|
||||
.B mlx_xpm_to_image
|
||||
() ,
|
||||
.B mlx_xpm_file_to_image
|
||||
() and
|
||||
.B mlx_png_file_to_image
|
||||
() functions will create a new image the same way.
|
||||
They will fill it using the specified
|
||||
.I xpm_data
|
||||
or
|
||||
.I filename
|
||||
, depending on which function is used.
|
||||
Note that MiniLibX does not use the standard
|
||||
Xpm and png libraries to deal with xpm and png images. You may not be able to
|
||||
read all types of xpm and png images. It however handles transparency.
|
||||
|
||||
.SH RETURN VALUES
|
||||
The four functions that create images,
|
||||
.B mlx_new_image()
|
||||
,
|
||||
.B mlx_xpm_to_image()
|
||||
,
|
||||
.B mlx_xpm_file_to_image()
|
||||
and
|
||||
.B mlx_png_file_to_image()
|
||||
, will return NULL if an error occurs. Otherwise they return a non-null pointer
|
||||
as an image identifier.
|
||||
|
||||
|
||||
.SH SEE ALSO
|
||||
mlx(3), mlx_new_window(3), mlx_pixel_put(3), mlx_loop(3), mlx_extra(3)
|
||||
|
||||
.SH AUTHOR
|
||||
Copyright ol@ - 2002-2025 - Olivier Crouzet
|
||||
@@ -0,0 +1,79 @@
|
||||
.TH MiniLibX 3 "September 19, 2002"
|
||||
.SH NAME
|
||||
MiniLibX - Managing windows
|
||||
.SH SYNOPSYS
|
||||
|
||||
.nf
|
||||
.I void *
|
||||
.fi
|
||||
.B mlx_new_window
|
||||
(
|
||||
.I void *mlx_ptr, unsigned int width, unsigned int height, const char *title
|
||||
);
|
||||
|
||||
.nf
|
||||
.I int
|
||||
.fi
|
||||
.B mlx_clear_window
|
||||
(
|
||||
.I void *mlx_ptr, void *win_ptr
|
||||
);
|
||||
|
||||
.nf
|
||||
.I int
|
||||
.fi
|
||||
.B mlx_destroy_window
|
||||
(
|
||||
.I void *mlx_ptr, void *win_ptr
|
||||
);
|
||||
|
||||
|
||||
.SH DESCRIPTION
|
||||
The
|
||||
.B mlx_new_window
|
||||
() function creates a new window on the screen, using the
|
||||
.I width
|
||||
and
|
||||
.I height
|
||||
parameters to determine its size, and
|
||||
.I title
|
||||
as the text that should be displayed in the window's title bar.
|
||||
The
|
||||
.I mlx_ptr
|
||||
parameter is the connection identifier returned by
|
||||
.B mlx_init
|
||||
() (see the
|
||||
.B mlx
|
||||
man page).
|
||||
.B mlx_new_window
|
||||
() returns a
|
||||
.I void *
|
||||
window identifier that can be used by other MiniLibX calls.
|
||||
Note that the MiniLibX
|
||||
can handle an arbitrary number of separate windows.
|
||||
|
||||
.B mlx_clear_window
|
||||
() and
|
||||
.B mlx_destroy_window
|
||||
() respectively clear (in black) and destroy the given window. They both have
|
||||
the same parameters:
|
||||
.I mlx_ptr
|
||||
is the screen connection identifier, and
|
||||
.I win_ptr
|
||||
is a window identifier.
|
||||
|
||||
.SH RETURN VALUES
|
||||
If
|
||||
.B mlx_new_window()
|
||||
fails to create a new window (whatever the reason), it will return NULL,
|
||||
otherwise a non-null pointer is returned as a window identifier.
|
||||
.B mlx_clear_window
|
||||
and
|
||||
.B mlx_destroy_window
|
||||
return nothing.
|
||||
|
||||
.SH SEE ALSO
|
||||
mlx(3), mlx_pixel_put(3), mlx_new_image(3), mlx_loop(3), mlx_extra(3)
|
||||
|
||||
.SH AUTHOR
|
||||
Copyright ol@ - 2002-2025 - Olivier Crouzet
|
||||
@@ -0,0 +1,83 @@
|
||||
.TH MiniLibX 3 "September 19, 2002"
|
||||
.SH NAME
|
||||
MiniLibX - Drawing inside windows
|
||||
.SH SYNOPSYS
|
||||
|
||||
.nf
|
||||
.I int
|
||||
.fi
|
||||
.B mlx_pixel_put
|
||||
(
|
||||
.I void *mlx_ptr, void *win_ptr, unsigned int x, unsigned int y, unsigned int color
|
||||
);
|
||||
|
||||
.nf
|
||||
.I int
|
||||
.fi
|
||||
.B mlx_string_put
|
||||
(
|
||||
.I void *mlx_ptr, void *win_ptr, unsigned int x, unsigned int y, unsigned int color, char *string
|
||||
);
|
||||
|
||||
|
||||
.SH DESCRIPTION
|
||||
The
|
||||
.B mlx_pixel_put
|
||||
() function draws a defined pixel in the window
|
||||
.I win_ptr
|
||||
using the (
|
||||
.I x
|
||||
,
|
||||
.I y
|
||||
) coordinates, and the specified
|
||||
.I color
|
||||
\&. The origin (0,0) is the upper left corner of the window, the x and y axis
|
||||
respectively pointing right and down. The connection
|
||||
identifier,
|
||||
.I mlx_ptr
|
||||
, is needed (see the
|
||||
.B mlx
|
||||
man page).
|
||||
|
||||
Parameters for
|
||||
.B mlx_string_put
|
||||
() have the same meaning. Instead of a simple pixel, the specified
|
||||
.I string
|
||||
will be displayed at (
|
||||
.I x
|
||||
,
|
||||
.I y
|
||||
).
|
||||
|
||||
Both functions will discard any display outside the window. This makes
|
||||
.B mlx_pixel_put
|
||||
slow. Consider using images instead.
|
||||
|
||||
.SH COLOUR MANAGEMENT
|
||||
The
|
||||
.I color
|
||||
parameter has an unsigned integer type. The displayed colour needs to be encoded
|
||||
in this integer, following a defined scheme. All displayable colours
|
||||
can be split in 3 basic colours: red, green and blue. Three associated
|
||||
values, in the 0-255 range, represent how much of each colour is mixed up
|
||||
to create the original colour. The fourth byte represent transparency,
|
||||
where 0 is fully transparent and 255 opaque. Theses four values must be set inside the
|
||||
unsigned integer to display the right colour. The bytes of
|
||||
this integer are filled as shown in the picture below:
|
||||
|
||||
.nf
|
||||
| B | G | R | A | colour integer
|
||||
+---+---+---+---+
|
||||
.fi
|
||||
|
||||
While filling the integer, make sure you avoid endian problems. Example:
|
||||
the "blue" byte will be the least significant byte inside the integer on a
|
||||
little endian machine.
|
||||
|
||||
|
||||
.SH SEE ALSO
|
||||
mlx(3), mlx_new_window(3), mlx_new_image(3), mlx_loop(3), mlx_extra(3)
|
||||
|
||||
|
||||
.SH AUTHOR
|
||||
Copyright ol@ - 2002-2025 - Olivier Crouzet
|
||||
Reference in New Issue
Block a user