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=-=-=-=-=-=-=|
| |
| ┏━┓┏━┓━━━━━━━━━━━┓━━━━━━━━━━━━━━━┓━━━┓━━━┓━━━┓━━━┓━━━┓ |
| ┃┃┗┛┃┃━━━━━━━━┏━┓┃━━━━━━━━━━━┏┓┏┓┃┏━┓┃┏━┓┃┏━┓┃┏━━┛┏━┓┃ |
| ┃┏┓┏┓┃┓━┓━┓━━━┗━┛┃━━┓━┓━┏┓━━━┛┃┃┗┛┗━┛┃┃━┃┃┃━┗┛┗━━┓┗━┛┃ |
! ┃┃┃┃┃┃┫┏┓┓┫━━━┏┓┏┛━┓┃━┃━┃┃━━━━┃┃━━┏┓┏┛┗━┛┃┃━┏┓┏━━┛┏┓┏┛ !
! ┃┃┃┃┃┃┃┃┃┃┃━━━┃┃┗┓┗┛┗┓┗━┛┃━━━┏┛┗┓━┃┃┗┓┏━┓┃┗━┛┃┗━━┓┃┃┗┓ !
: ┗┛┗┛┗┛┛┛┗┛┛━━━┛┗━┛━━━┛━┓┏┛━━━┗━━┛━┛┗━┛┛━┗┛━━━┛━━━┛┛┗━┛ :
: ━━━━━━━━━━━━━━━━━━━━━━━┛┃━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ :
. ━━━━━━━━━━━━━━━━━━━━━━━━┛━━━━━━━━━━━━━━━━━━by lpaulo-m .
. .
: __ __ ___ __ __ __ :
: / / \|\ | | |__)/ \| (_ :
! \__\__/| \| | | \ \__/|____) !
! !
| - Esc or q: Exits program |
| - Left and Right Arrows: Switch camera |
| - s: Saves viewport to bitmap |
| |
\-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=/
A ray tracer written in C that handles scene files, spheres, planes, cylinders,
multiple cameras and hard shadows with multiple light.
Traces the scene described in a file and displays it in an interactive window.
It can also save the rendered scene to a .bmp file.
Based on my implementation of Ray Tracing in One Weekend:
For more details and examples you can read the Docs and the Checklist.
This project will only compile on Linux and FreeBSD.
You will need a C compiler (gcc or clang)
and minilibx,
an X-Window API made by 42 Paris:
# Clone the repo
git clone https://github.com/42Paris/minilibx-linux.git
cd minilibx-linux
# Install dependencies and build
sudo apt install libxext-dev libxrandr-dev libx11-dev libbsd-dev libssl-dev
make
# Copy archive and headers to system path
sudo cp libmlx.a /usr/local/lib/
sudo cp mlx.h /usr/local/include/
# Add pages to man (optional)
sudo mkdir /usr/local/man/man1
sudo cp man/man1/* /usr/local/man/man1/
man mlxClone the repo and run make:
$ git clone https://github.com/librity/ft_minirt.git
$ cd ft_minirt
$ make runA beautiful image should pop out of your terminal like magic.
See the Docs.
Norminette Github Action by @AdrianWR
Part of the larger 42 Network, 42 São Paulo is a software engineering school that offers a healthy alternative to traditional education:
- It doesn't have any teachers and classes.
- Students learn by cooperating and correcting each other's work (peer-to-peer learning).
- Its focus is as much on social skills as it is on technical skills.
- It's completely free to anyone that passes its selection process - The Piscine
It's an amazing school, and I'm grateful for the opportunity.
See the Docs.