Go to the source code of this file.
Data Structures | |
struct | s_canvas |
The struct of type t_canvas contains the necessary fields for graphic initialization and window rendering. More... | |
struct | s_scene |
The structure t_scene is how the user sees the ray tracing rendering. There is a camera from which the world of shapes and point lights are seen. More... | |
Macros | |
#define | SCREEN_WIDTH 800 |
#define | SCREEN_HEIGHT 400 |
#define | K_ESCAPE 0xff1b |
#define | K_Q 0x0071 |
#define | DESTROYNOTIFY 17 |
#define | NOEVENTMASK 0L |
Typedefs | |
typedef struct s_canvas | t_canvas |
The struct of type t_canvas contains the necessary fields for graphic initialization and window rendering. More... | |
typedef struct s_scene | t_scene |
The structure t_scene is how the user sees the ray tracing rendering. There is a camera from which the world of shapes and point lights are seen. More... | |
Functions | |
void | init_mlx_connection (t_canvas *canvas) |
This function attempts to start a connection with Xserver using MLX library. More... | |
t_bool | new_canvas (t_canvas *canvas, int width, int height) |
This function attempts to start a connection with Xserver using MLX library. After that, an attempt to create a new image on screen with the new mlx_ptr, width and height is done. Lastly, the function tries to write information on the new image with a given bits per pixel, line length and endianess. More... | |
t_bool | put_on_window (t_canvas *canvas, char *title) |
The function tries to create a new window on screen with the established Xserver connection, width, height and window's title passed as parameter. More... | |
int | show_window (t_canvas *canvas) |
This function inserts an image to window. To do that, it needs from the parameter canvas a pointer to an existing Xserver connection, a pointer an existing window, a pointer to an existing image and the x and y screen position. The default for x and y is 0. More... | |
int | handle_keypress (int keysym, t_canvas *canvas) |
This function is to be used as the second parameter of the MLX library function mlx_key_hook(), which waits for an user event. If the user presses ESC or Q's key, the program is cleanly terminated with quit(). More... | |
int | quit (t_canvas *canvas) |
quit() frees every data regarding graphic initialization and window rendering. It destroys the created image and window as well as the pointer to an established Xserver's connection, whose variable must be freed thereafter. More... | |
t_bool | render (t_scene *scene, t_canvas *canvas) |
This functions renders a scene of ray casting objects. It attempts to initialize a connection to the graphic library MLX, if successfilly, it proceeds to write pixel by pixel to a image that will be rendered and seen by the user though a MLX's windows. More... | |
void | write_pixel (const t_canvas *canvas, int x, int y, int color) |
The function write_pixel() writes a pixel at (x, y) coordinates of the image, if a given coordinate is within canvas width and height. More... | |
The struct of type t_canvas contains the necessary fields for graphic initialization and window rendering.
ABOUT THE HEADER CANVAS.H
This header contains all functions that works directly or indirectly with graphic information and MLX's library manipulation.
mlx_ptr | Contains the pointer to a connection with the Xserver. |
win_ptr | Contains the pointer to a window created with MLX. |
img_ptr | Contains the pointer to a image created with MLX. |
addr | Stores information about how to write data on pixels from an instance of a MLX's windows and image. |
bpp | Contains the bits per pixel value from MLX. |
line_len | Contains the line length value from MLX. |
endian | Stores the most significant endianess order from MLX. |
width | Stores the width of the window and the image created with MLX. |
height | Stores the height of the window and the image created with MLX. |
The structure t_scene is how the user sees the ray tracing rendering. There is a camera from which the world of shapes and point lights are seen.
world | Stores the world objects to be displayed. |
camera | Stores the information about the point of view from which the world is observed. |
int handle_keypress | ( | int | keysym, |
t_canvas * | canvas | ||
) |
This function is to be used as the second parameter of the MLX library function mlx_key_hook(), which waits for an user event. If the user presses ESC or Q's key, the program is cleanly terminated with quit().
keysym | Stores the ID of the key pressed by the user. To see all possible values of keysym, refer to the header X11/keysymdef.h. |
canvas | A struct of type t_canvas containing the necessary fields for graphic initialization and window rendering. |
void init_mlx_connection | ( | t_canvas * | canvas | ) |
This function attempts to start a connection with Xserver using MLX library.
canvas | A struct of type t_canvas containing the necessary fields for graphic initialization and window rendering. |
t_bool new_canvas | ( | t_canvas * | canvas, |
int | width, | ||
int | height | ||
) |
This function attempts to start a connection with Xserver using MLX library. After that, an attempt to create a new image on screen with the new mlx_ptr, width and height is done. Lastly, the function tries to write information on the new image with a given bits per pixel, line length and endianess.
canvas | A struct of type t_canvas containing the necessary fields for graphic initialization and window rendering. |
width | The desired width of the window to be created. |
height | The desired height of the window to be created. |
t_bool put_on_window | ( | t_canvas * | canvas, |
char * | title | ||
) |
The function tries to create a new window on screen with the established Xserver connection, width, height and window's title passed as parameter.
canvas | A struct of type t_canvas containing the necessary fields for graphic initialization and window rendering. |
title | The desired title to describe the window to be created. |
int quit | ( | t_canvas * | canvas | ) |
quit() frees every data regarding graphic initialization and window rendering. It destroys the created image and window as well as the pointer to an established Xserver's connection, whose variable must be freed thereafter.
canvas | A struct of type t_canvas containing the necessary fields for graphic initialization and window rendering. |
This functions renders a scene of ray casting objects. It attempts to initialize a connection to the graphic library MLX, if successfilly, it proceeds to write pixel by pixel to a image that will be rendered and seen by the user though a MLX's windows.
scene | A struct of type t_scene that stores information about the how the world will be seen and which objects of a given world will be observed. |
canvas | A struct of type t_canvas containing the necessary fields for graphic initialization and window rendering. |
int show_window | ( | t_canvas * | canvas | ) |
This function inserts an image to window. To do that, it needs from the parameter canvas a pointer to an existing Xserver connection, a pointer an existing window, a pointer to an existing image and the x and y screen position. The default for x and y is 0.
canvas | A struct of type t_canvas containing the necessary fields for graphic initialization and window rendering. |
void write_pixel | ( | const t_canvas * | canvas, |
int | x, | ||
int | y, | ||
int | color | ||
) |
The function write_pixel() writes a pixel at (x, y) coordinates of the image, if a given coordinate is within canvas width and height.
canvas | A struct of type t_canvas containing the necessary fields for graphic initialization and window rendering. |
x | The x value of the pixel to be inserted. |
y | The y value of the pixel to be inserted. |
color | Stores the color of the pixel. |