Skip to content

AugustoAmaral/computer-graphics-assignment-opengl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Computer Graphics - OpenGL Projects

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.

Project Structure

.
├── 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

Features

Main Program (main.c)

  • Basic OpenGL setup and initialization
  • Simple polygon rendering (black square on white background)
  • Demonstrates fundamental OpenGL concepts

Assignment 1 (trabalho_1/)

Interactive Polygon Manipulation (basicGlutGlMouseManipula.c)

  • 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

Point and Polygon Drawing (basicGlutGlPontosPoligonos.c)

  • 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

Prerequisites

  • GCC compiler
  • OpenGL development libraries
  • GLUT (OpenGL Utility Toolkit)
  • X11 libraries (for Linux/Unix systems)

Installation on Ubuntu/Debian:

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

Installation on macOS:

# Using Homebrew
brew install freeglut

How to Compile and Run

Quick Start

To compile and run a program, use the provided script:

# For main.c
./c.sh

# For other programs (without .c extension)
./c.sh program_name

Manual Compilation

You can also use the Makefile directly:

# Compile a specific program
make program_name

# Run the compiled program
./program_name

Examples

# 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

Usage Instructions

Mouse Manipulation Program

  1. Left-click on a polygon vertex to select it (highlighted in green)
  2. Right-click to open the transformation menu
  3. 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
  4. Use the menu to toggle between wireframe and filled rendering

Point/Polygon Drawing Program

  1. Left-click to place points on the canvas
  2. Right-click to access the menu:
    • Switch between "Points" and "Polygon" display modes
    • Clear the canvas to start over
  3. Points are automatically connected to form a polygon when switching modes

Technical Details

  • 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

Educational Objectives

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

Author

Developed for Computer Graphics coursework, demonstrating practical implementation of fundamental graphics concepts using OpenGL and C programming.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors