A collection of fundamental Computer Graphics algorithms and transformations implemented in C++ using the graphics.h / WinBGIm library.
This repository is useful for Computer Graphics laboratory practicals, academic learning, and understanding basic graphics algorithms.
Computer-Graphics-Algorithms-Cpp/
│
├── .vscode/
│ └── tasks.json
│
├── graphics-library/
│ └── graphics.zip
│
├── 01_Implementation_of_DDA_Algorithm.cpp
├── 02_Implementation_of_Bresenham_Line_Algorithm.cpp
├── 03_Implementation_of_Midpoint_Circle_Algorithm.cpp
├── 04_Implementation_of_Midpoint_Ellipse_Algorithm.cpp
├── 05_2D_Transformations.cpp
├── 06_Composite_2D_Transformations.cpp
│
├── README.md
└── .gitignore
- Digital Differential Analyzer (DDA) Algorithm
- Bresenham's Line Drawing Algorithm
- Midpoint Circle Generating Algorithm
- Midpoint Ellipse Generating Algorithm
- Translation
- Rotation
- Scaling
- Reflection
- Shearing
Multiple transformations are applied sequentially to a 2D object.
Examples:
Translation → Scaling → Rotation
or:
Scaling → Rotation → Shearing
To run these programs, you need:
- Windows
- Visual Studio Code
- MinGW C++ Compiler
- C/C++ Extension for VS Code
- WinBGIm Graphics Library
Open the VS Code terminal and run:
g++ --versionYou should see your GCC compiler information.
You can also check the MinGW installation path:
where.exe g++Example:
C:\MinGW\bin\g++.exe
The repository includes the required graphics library ZIP file.
Download or extract:
graphics-library/graphics.zip
You need these files:
graphics.h
winbgim.h
libbgi.a
Copy the header files:
graphics.h
winbgim.h
to:
C:\MinGW\include
Copy:
libbgi.a
to:
C:\MinGW\lib
After installation, your MinGW folders should contain:
C:\MinGW
│
├── include
│ ├── graphics.h
│ └── winbgim.h
│
└── lib
└── libbgi.a
For programs using graphics.h, use:
g++ "filename.cpp" -o program.exe -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32Example:
g++ "04_Implementation_of_mid-point_circle_generating_Algorithm.cpp" -o circle.exe -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32Then run:
.\circle.exeThe .vscode/tasks.json file can be configured to compile graphics programs automatically.
Open your C++ file and use:
Ctrl + Shift + P
Then select:
Tasks: Run Task
Choose:
Run Graphics C++
The task will automatically compile the program with the required WinBGIm libraries.
Example input:
Enter center coordinates (xc yc): 300 250
Enter radius: 100
The program uses the 8-way symmetry property of a circle to generate the complete circle efficiently.
Example input:
Enter center coordinates (xc yc): 400 300
Enter X-axis radius (rx): 200
Enter Y-axis radius (ry): 100
The algorithm divides the ellipse into two regions and uses 4-way symmetry.
Example polygon input:
Enter number of vertices: 4
Enter x1 y1: 300 300
Enter x2 y2: 400 300
Enter x3 y3: 400 400
Enter x4 y4: 300 400
Choice: 1
tx ty: 150 100
Choice: 2
Angle: 45
Choice: 3
sx sy: 1.5 1.5
Choice: 5
shx shy: 0.5 0
git clone https://github.com/Ronit049/Computer-Graphics-Algorithms-Cpp.gitOpen the project:
cd Computer-Graphics-Algorithms-Cpp- Install the WinBGIm library before running graphics programs.
- The programs use
graphics.h, which is not included in the standard C++ library. - Do not upload compiled
.exefiles to the repository. - Add new Computer Graphics algorithms to this repository as you learn them.
Contributions, improvements, and suggestions are welcome.
If you find this repository useful, consider giving it a ⭐.
Ronit Raj
- GitHub: https://github.com/Ronit049
- LinkedIn: www.linkedin.com/in/ronit-raj7497
⭐ If this repository helps you, don't forget to star it!