Skip to content

Latest commit

 

History

History
174 lines (115 loc) · 6.82 KB

README.md

File metadata and controls

174 lines (115 loc) · 6.82 KB

42cursus' miniRT

Development repo for 42cursus' miniRT project
For further information about 42cursus and its projects, please refer to 42cursus repo.

GitHub code size in bytes Number of lines of code Code language count GitHub top language GitHub last commit


🗣️ About

This project is an introduction to the beautiful world of Raytracing. Once completed you will be able to render simple Computer-Generated-Images and you will never be afraid of implementing mathematical formulas again.

For detailed information, refer to the subject of this project.

🚀 TLDR: this project consists of coding a simple RayTracer that runs with the miniLibX,
a simple X-Window (X11R6) programming API in C.

Example of image generated by the program

📑 Index

@root

  • 📁 images: contains BMP image files generated by the program.
  • 📁 includes: contains the program's headers.
  • 📁 libft: contains the source code of the libft library, which is used in the program.
  • 📁 scenes: contains .rt files, a file type that describes the scene to be rendered by the program.
  • 📁 srcs: contains the source code of the program.
  • Makefile - contains instructions for compiling the program and testing it.

Note: program covers only mandatory requirements of the project's subject.

🛠️ Usage

Requirements

The program is written in C language for Linux distributions and thus needs the clang compiler and some standard C libraries to run.

Instructions

1. Installing miniLibX

First, to install all miniLibX requirements, run:

$ sudo apt-get install -y libxext-dev && sudo apt-get install -y libxrandr-dev && sudo apt-get install -y libx11-dev && sudo apt-get install -y libbsd-dev && sudo apt-get install -y libssl-dev

Then, we'll clone the miniLibX repository, checkout to the commit that is compatible with the program and compile the library:

$ cd ~ && git clone https://github.com/42Paris/minilibx-linux.git && cd minilibx-linux && git checkout acc9a87 && make

Finally, we'll create a directory for storing miniLibX manuals:

$ cd /usr/local/man/ && sudo mkdir man1

and copy the manuals to the directory we have just created:

$ sudo cp man/man1/* /usr/local/man/man1/ && sudo cp libmlx.a /usr/local/lib/ && sudo cp mlx.h /usr/local/include/

To show miniLibX 's manual page, run:

$ man mlx

Note: To use the miniLibX in your project, you must add the following flags:

-lbsd -lmlx -lXext -lX11

2. Compiling the program

To compile the program, run:

$ make

3. Executing the program

To execute the program on a window, run:

$ ./miniRT <scene-file.rt>

or, to generate a BMP image file, run:

$ ./miniRT <scene-file.rt> --save

📋 Testing

Files on the scenes folder that begins with a numeral are scene files prepared for the evaluation of the project. You can run the program with such files as argument to check all rendering possibilities implemented in the program.

Below are all images generated from scenes of this folder, including some bonus scenes.

The 5 Basic Shapes

Example of image generated by the program Example of image generated by the program Example of image generated by the program Example of image generated by the program Example of image generated by the program

Translations and rotations / Multi-objects

Example of image generated by the program Example of image generated by the program Example of image generated by the program Example of image generated by the program

Camera's position and direction

Example of image generated by the program Example of image generated by the program Example of image generated by the program

Brightness & Shadows

Example of image generated by the program Example of image generated by the program Example of image generated by the program

Multi-spots

Example of image generated by the program Example of image generated by the program Example of image generated by the program

Bonus

Example of image generated by the program

Example of image generated by the program Example of image generated by the program
Example of image generated by the program Example of image generated by the program

Many thanks to @aroque for making these scene files (42 logo, pokeball and Giza pyramids) available :)

📌 Useful Links