fdf
Fdf is a project developed as part of the 42 School curriculum, aimed at creating a 3D wireframe model renderer in C using isometric projection. It focuses on graphics programming, coordinate transformations, and working with the MiniLibX library, helping students deepen their understanding of computer graphics and low-level C programming.
Last updated
FDF
.fdf map file and draws a simple 3D wireframe representation in a window using the MiniLibX library. It is a practical exercise in graphics basics, parsing, and C programming on Linux with X11.Usage
Prerequisites
- A Linux environment with X11 and development headers for libX11 and libXext (required to build and run MiniLibX).
makeand a C compiler (cc).
Clone the repository to your local machine using the following command in the terminal.
git clone https://github.com/milandekruijf/fdf.git && cd fdfCompiling
In order to compile the program, run the following command in the project root directory.
makeCompiles using the cc compiler with the flags -Wall, -Wextra, -Werror, and -O3.
Running
After compiling, the executable fdf is created in the /out directory. Pass exactly one map file (.fdf) as an argument.
./out/fdf assets/maps/42.fdfExpected usage: fdf <*.fdf> (see main.c).
Optional: address sanitizer build
To build with AddressSanitizer (useful for catching memory issues), run:
make fclean && TEST=1 makeThis adds -fsanitize=address to the compile flags (see the project Makefile).
Quick random map
After a successful build, you can launch the program with a random map from assets/maps using:
./scripts/test.shThe script expects ./out/fdf to exist and uses shuf to pick a map.
Features
FDF turns a height map into a wireframe view with projection and per-segment coloring. Below is an overview of what this implementation supports.
Map input
.fdfparsing: Reads a rectangular grid of integer heights; supports optional hex color per cell in the formheight,0xRRGGBB(seeread.c).- Validation: Reports errors for missing files, invalid arguments, or empty maps.
Rendering
- Wireframe mesh: Connects each point to its right and bottom neighbors using Bresenham-style line stepping (
draw.c). - Isometric projection: Projects the grid with configurable rotation angles and exaggerates depth via a depth multiplier (
cfg.c,draw.c). - Default view: Window size defaults to 1920×1080 (
fdf.h); zoom, origin, and rotation are initialized ininit_cfg.
Color
- Embedded colors: Uses map-supplied colors when present.
- Default palette (when no color is given): height 0 is drawn in yellow; positive heights in orange; negative in teal (
utils.c).
Window and input
- Escape: Press Esc to quit (
hooks.c). - Close window: Closing the window exits the program.
Limitations
- Single map file only; no multi-file or interactive file browser.
- No runtime controls in the current hooks beyond quit (zoom, rotation, and projection toggles are fixed at initialization unless you change the code).
- Linux / X11: Relies on the bundled MiniLibX and system X libraries; behavior on non-Linux setups depends on your toolchain and X server configuration.