This project is a basic 3D rendering engine written in C++ using OpenGL, GLFW, and GLAD. It loads and displays a 3D model from an .obj file and allows user interaction through keyboard inputs.
The program is designed to showcase a rotating 3D object (such as the 42 school logo), with smooth switching between flat-colored faces and a textured surface—no external libraries are used for object loading, matrix math, or shaders.
- C++
- OpenGL
- GLFW – for window and input management
- GLAD – for loading OpenGL function pointers
- Load and parse
.obj3D model files - Render models with:
- Per-face color shading
- Texturing with toggling via keypress (with smooth transition)
- Basic camera controls
- Model rotates around its center axis
- Custom shader compilation and management
| Key | Action |
|---|---|
| Mouse wheel | Zoom Camera |
T |
Toggle between color and texture |
ESC |
Exit the program |
Shaders are small programs that run on the GPU to handle graphics rendering. In OpenGL, you typically use two types of shaders:
- Executes once per vertex
- Transforms 3D coordinates (model space) to 2D screen space
- Handles perspective projection and object rotation/translation
- Executes once per pixel
- Calculates the final color of a pixel
- Here, it decides whether to display a flat color per face or sample from a texture
In this project:
- Shaders are written in GLSL
- Loaded at runtime from custom files
- Compiled and linked manually using OpenGL functions
- Uniforms are used to pass transformation matrices and toggle states
make
./scop <path/to/model.obj>