Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b3obqqePfZ9m2Jk5Ub
1.1 KiB
1.1 KiB
cg/dda - DDA line drawing algorithm
Companion code for https://ankurm.com/c-program-to-implement-dda-line-drawing-algorithm/
| File | What it is | Build |
|---|---|---|
src/dda_console.c |
Plain C, no graphics library. Prints the step table and an ASCII plot. | gcc -std=c11 -Wall -Wextra -o dda_console src/dda_console.c -lm |
src/dda_sdl.c |
SDL2 version. Draws pixels into an off-screen surface and saves a BMP (or --window). |
gcc -std=c11 -Wall -Wextra -o dda_sdl src/dda_sdl.c $(sdl2-config --cflags --libs) -lm |
src/dda_graphics_h.cpp |
Corrected Turbo C++ / WinBGIm graphics.h version. |
Turbo C++ or MinGW + WinBGIm only |
legacy/dda_original_2015.cpp |
The original 2015 program, kept for comparison (has an integer-division bug). | same as above |
Usage: ./dda_console x1 y1 x2 y2 (default 2 3 10 8), SDL_VIDEODRIVER=dummy ./dda_sdl 2 3 10 8 out.bmp.
Tested with gcc 13 and SDL 2.30 on Linux. The graphics.h programs were only compile-checked against a stub header that prints each putpixel call; they were not run against a real BGI driver.