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.

GitHub
0
0
0

Last updated

April 07, 2026

FDF

FDF (fil de fer, “wire frame”) is a collaborative team project developed as part of the curriculum at 42 School. The program reads a 2D grid of heights from a .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).
  • make and a C compiler (cc).

Clone the repository to your local machine using the following command in the terminal.

sh
git clone https://github.com/milandekruijf/fdf.git && cd fdf

Compiling

In order to compile the program, run the following command in the project root directory.

sh
make

Compiles 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.

sh
./out/fdf assets/maps/42.fdf

Expected usage: fdf <*.fdf> (see main.c).

Optional: address sanitizer build

To build with AddressSanitizer (useful for catching memory issues), run:

sh
make fclean && TEST=1 make

This 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:

sh
./scripts/test.sh

The 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

  • .fdf parsing: Reads a rectangular grid of integer heights; supports optional hex color per cell in the form height,0xRRGGBB (see read.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 in init_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.

Acknowledgements

  • MiniLibX (42): Simple X11 windowing and drawing library used for the render window and pixels.
  • 42: The educational institution that inspired and supported the development of this project.
  • Codam: The partner school of 42 in the Netherlands, where the project was developed.