Development repo for 42cursus' fdf project
For further information about 42cursus and its projects, please refer to 42cursus repo.
About · Index · Usage · Testing . Screenshots
The aim of this project is to make you code a function that returns a line ending with a newline, read from a file.
For detailed information, refer to the subject of this project.
🚀 TLDR: This project consists of graphically creating a schematic representation of a relief terrain.
@root
- 📁 includes: contains all prototypes and libraries includes.
- 📁 gnl: contains the get_next_line project sources.
- 📁 mlx: contains the minilibx sources.
- 📁 libft: contains the libft project sources.
- 📁 glib: contains the glib project sources.
- 📁 srcs: contains all project sources files.
- 📁 controls: contains all controls related files.
- 📁 parsing: contains all parsing related files.
- 📁 graphics: contains all graphics related files.
- 📁 utils: contains all utilities files.
@/srcs/main.c
main
- Starts the program.init_camera
- Initializes virtual camera.init
- Initializes camera & set default projection.init_window
- Initializes window & image via the glib.
@/srcs/graphics/
render
- Renders backgrounds and lines to window.clear_image
- Draws the background.draw_lines
- Draws lines from vector list.project
- Projects image using isometric or parallel function, rotate & fit camera.
@/srcs/controls/
close_fdf
- Closes program on escape key press.change_projection
- Changes projection between parrallel & isometric.dispatch_keys
- Calls accurate functions when a key is pressed.register_controls
- Registers keys events.movement_control
- Manage camera movements controls.rotation_control
- Manage camera rotation controls.zoom
- Manage camera zoom controls.
@/srcs/parsing/
parse_map
- Loads points from provided file.parse_file
- Parses points from provided file.parse_line
- Parses points from a single line.create_map
- Creates map in heap memory stack.v3f_validate
- Validates vectors 3f.free_map
- Free the map and all its components in memory to avoid leaks.
@/srcs/utils/
create_point
- Creates a point.convert_vectors
- Converts vectors 3f to points list.get_point_color
- Gets point color.isdigit_base
- Checks if a base is digit.has_prefix
- Checks if base prefix is present.atoi_base
- Parses hexadecimals from string.get_index
- Gets point index.new_3d_point
- Creates new vector 3f from 2D point.get_default_color
- Gets default color of a point from its altitude (z).v3f_length
- Gets length of a vector3f array.double_length
- Gets length of a pointer on pointer on char.free_parts
- Frees pointer on pointer on char.allocate_v3f
- Creates a new vector3f from parsing.join_v3f
- Concatenates two arrays of vector 3f.is_empty
- Checks if a string is empty.is_fdf_map
- Checks if filename has extension ".fdf".create_vector3f
- Create new vector 3f from its coordinates.
@/srcs/gnl/
ft_read
- read & wrap a buffer from a file descriptor.ft_read_next
- concatenate last red buffer and latest one.ft_find_nl
- cut line at the right length.get_next_line
- main function.ft_strlen
- find length of string.ft_strchr
- find first instance of character.ft_strlcpy
- copy a string in a new address space.ft_substr
- cut a string from an index to another.ft_strjoin
- concatenate two strings.
@/srcs/libft/
ft_strlcpy
- copy string to another locationft_strlcat
- concatenate stringsft_strdup
- save a copy of a string (with malloc)ft_strjoin
- join two strings (with malloc)ft_substr
- extract a substring (with malloc)ft_atoi
- convert a string to an integerft_isascii
- check if a character is in the ascii tableft_isprint
- check if a character is printableft_isdigit
- check if a character is a digitft_isupper
- check if a character is uppercaseft_islower
- check if a character is lowercaseft_memset
- fill memory with a constant byteft_memmove
- copy memory areaft_strlcpy
- size-bounded string copyingft_strlcat
- size-bounded string concatenationft_strchr
- locate first character instance in stringft_strrchr
- locate last character instance in stringft_strncmp
- compare two strings within given sizeft_memchr
- scan memory for a characterft_memcmp
- compare memory areasft_strnstr
- locate a substring in a stringft_calloc
- allocates memory for an array of a given lengthft_strdup
- duplicate a stringft_substr
- get a sub string from the original stringft_strjoin
- concatenate two stringsft_strtrim
- remove targeted charactersft_split
- split string into a 2d arrayft_itoa
- convert numbers to stringft_strmapi
- apply a function on each character of a stringft_striteri
- execute a function on each character of a stringft_putchar_fd
- write a characterft_putstr_fd
- write a stringft_putnbr_fd
- write numbersft_putendl_fd
- add a new line at the end of a fileft_lstnew
- create a new linked list elementft_lstadd_front
- add an element to the front of a linked listft_lstsize
- get the size of a linked listft_lstlast
- get the last element of a linked listft_lstadd_back
- add an element to the end of a linked listft_lstdelone
- delete an element from a linked listft_lstclear
- clear a linked listft_lstiter
- apply a function to each element of a linked listft_lstmap
- apply a function to each element of a linked list & create a new list
The function is written in C language and thus needs the gcc
compiler and some standard C libraries to run.
In order to install the fdf, you need to clone it:
git clone https://github.com/RochBlondiaux/Fdf.git && cd Fdf
Then, compile it with make:
make
It's really simple, you just have to execute this command:
./fdf my_map.fdf
The program only accept .fdf
files, you can use maps from the maps/
folder,
create your owns or even generate them with 42MapGenerator.