Skip to content

Asimawad/Computer-Graphics-code-CPP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎨 Computer Graphics in C++

Learning computer graphics from the ground up with C++ and OpenGL/GLUT. From basic 2D shapes to 3D transformations.

3D Cube

3D Cube

Mathematical Curves

Mathematical Curves

Regular Polygons

Polygons

Data Visualization (Pie Chart)

Pie Chart


📁 Project Structure

├── Simple shapes and lines/    # Basic 2D primitives
├── Advanced Geometrics/        # Complex polygons, filled shapes
├── Curves/                     # Mathematical curves (polar coordinates)
└── Three Dimentional Drawing/  # 3D rendering with depth buffer

🧊 3D Graphics

Colored Cube

Demonstrates:

  • Perspective projection with gluPerspective
  • Depth buffering (GL_DEPTH_TEST)
  • Per-face vertex coloring
  • 3D transformations (translate, rotate)
glTranslatef(0.0, 0.0, -5.0);
glRotatef(30, 1.f, 1.f, 0.f);

glBegin(GL_QUADS);
  glColor3f(0.0f, 1.0f, 0.0f); // Green
  glVertex3f(-0.5f, -0.5f, 0.5f);
  glVertex3f( 0.5f, -0.5f, 0.5f);
  // ...
glEnd();

📐 Mathematical Curves

Curves rendered using polar coordinate equations:

Curve Equation
Limacon r = a·cos(θ) + b
Cardioid r = a·(1 + cos(θ))
Three-Leaf r = a·cos(3θ)
Four-Leaf r = a·cos(2θ)
Spiral r = a·θ

🛠️ Building

# Install dependencies (Ubuntu/Debian)
sudo apt install freeglut3-dev libgl1-mesa-dev

# Compile a program
g++ -o cube "Three Dimentional Drawing/shape2-Cube.cpp" -lGL -lGLU -lglut

# Run
./cube

📚 Topics Covered

  • 2D Graphics: Lines, polygons, transformations
  • 3D Graphics: Cubes, perspective, depth buffering
  • Curves: Bezier, polar coordinate equations
  • Animation: Timer callbacks, double buffering
  • Math: Matrix transformations, trigonometry

Author

Asim OsmanPortfolio | GitHub

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages