This project demonstrates the use of orthogonal and perspective projections in an OpenGL environment. The program renders a cube and allows the user to switch between projection modes and interact with the visualization using the keyboard.
- Rendering a cube using OpenGL.
- Switching between orthogonal and perspective projection.
- Control of rotation and translation of the cube via the keyboard.
- OpenGL
- GLUT (OpenGL Utility Toolkit)
-
Install the necessary libraries (on Unix-based systems):
sudo apt-get install freeglut3-dev
-
Compile the source code:
gcc -o projection projection.c -lGL -lGLU -lglut -lm
-
Run the program:
./projection
ESC
: Exit the program.q
: Switch to orthogonal projection.e
: Switch to perspective projection.w
: Move the view to the right.s
: Move the view to the left.d
: Rotate the view to the right.a
: Rotate the view to the left.
The image below illustrates an example of orthogonal and perspective projection, showing how different geometric figures are represented in each mode:
Configures the perspective projection in the X direction.
void Ortogonal(GLdouble xmin, GLdouble xmax, GLdouble ymin, GLdouble ymax, GLdouble znear, GLdouble zfar)
Configures the orthogonal projection.
Main drawing function that renders the cube.
Configures the viewport and projections according to the window size.
Keyboard input callback function, allows changing projection modes and manipulating the cube's visualization.
- Thiago Monteles
This project is licensed under the MIT License. See the LICENSE file for more details.