This repository contains computer graphics projects developed using OpenGL and GLUT (OpenGL Utility Toolkit). The projects demonstrate fundamental concepts in computer graphics including polygon manipulation, transformations, and interactive graphics programming.
.
├── main.c # Basic OpenGL test program (draws a black square)
├── c.sh # Compilation and execution script
├── Makefile # Build configuration for OpenGL programs
├── trabalho_1/ # Assignment 1 - Polygon manipulation programs
│ ├── basicGlutGlMouseManipula.c # Interactive polygon transformations
│ └── basicGlutGlPontosPoligonos.c # Point and polygon drawing
└── README.md # This file
- Basic OpenGL setup and initialization
- Simple polygon rendering (black square on white background)
- Demonstrates fundamental OpenGL concepts
- Mouse-based polygon vertex selection and manipulation
- Transformation operations:
- Translation: Move polygons by dragging vertices
- Rotation: Rotate polygons around their center
- Scaling: Scale polygons uniformly or non-uniformly
- Shearing: Apply shear transformations
- Interactive menu system (right-click)
- Real-time visual feedback for selected vertices
- Support for both wireframe and filled polygon rendering
- Interactive point placement with mouse clicks
- Dynamic polygon creation from placed points
- Toggle between point and polygon display modes
- Menu-driven interface for mode switching
- Clear functionality to reset the drawing canvas
- GCC compiler
- OpenGL development libraries
- GLUT (OpenGL Utility Toolkit)
- X11 libraries (for Linux/Unix systems)
sudo apt-get install build-essential
sudo apt-get install freeglut3-dev
sudo apt-get install libgl1-mesa-dev
sudo apt-get install libglu1-mesa-dev# Using Homebrew
brew install freeglutTo compile and run a program, use the provided script:
# For main.c
./c.sh
# For other programs (without .c extension)
./c.sh program_nameYou can also use the Makefile directly:
# Compile a specific program
make program_name
# Run the compiled program
./program_name# Compile and run the basic test program
./c.sh
# Compile and run the mouse manipulation program
cd trabalho_1
../c.sh basicGlutGlMouseManipula
# Compile and run the point/polygon drawing program
cd trabalho_1
../c.sh basicGlutGlPontosPoligonos- Left-click on a polygon vertex to select it (highlighted in green)
- Right-click to open the transformation menu
- Select a transformation type:
- Move: Drag the selected vertex to translate the entire polygon
- Rotate: Move the mouse to rotate the polygon around its center
- Scale: Move the mouse to scale the polygon
- Shear: Apply shearing transformations
- Use the menu to toggle between wireframe and filled rendering
- Left-click to place points on the canvas
- Right-click to access the menu:
- Switch between "Points" and "Polygon" display modes
- Clear the canvas to start over
- Points are automatically connected to form a polygon when switching modes
- Graphics Library: OpenGL with GLUT
- Coordinate System: 2D orthographic projection
- Polygon Types: Configurable vertex count (default: 4 vertices for square)
- Transformations: Matrix-based transformations with proper center calculations
- Interaction: Mouse-driven interface with real-time feedback
This repository serves as a learning resource for:
- OpenGL programming fundamentals
- 2D geometric transformations
- Interactive graphics programming
- Event-driven programming with mouse and menu interactions
- Computer graphics algorithms and mathematical concepts
Developed for Computer Graphics coursework, demonstrating practical implementation of fundamental graphics concepts using OpenGL and C programming.