- Name: Tran Ngoc Do
- ID: 20120057
- Class: 20TN
Project structure
├─── app
│ ├─── object/
│ ├─── utils/
| └─── main.cpp
└─── Sample-Input/
-
Source code is stored in
./sources/app
, the entry point isint main(int, char**)
from./sources/app/main.cpp
. -
object
folder store all the class objects that make the source code structure more clearly and easy to follow. -
utils
this folder contains all the code that handler main processing like object-rendering, Algorithms, or some helper functions such as Timer, Path, ...
Requirements:
-
C++ version: C++17
-
GNU make
The Makefile includes some helpful flags:
-
all
: compile all the dependencies if needed and link everything to binary executable file named20120057
. The release file will be put on the./Release
foler. -
test
: Run program with default input file (multiple objects will be printed on the glut window). Program will be recompiled if needed. -
clean
: Clean all oject files that required by linker. -
setup
: Automatic setup all of the necessary.
Requirements:
-
C++ version:
C++17 -
C version:
C14
First of all, glut and opengl must be installed on your machine. Follow this link to install glut and opengl on your machine. Then, open the project in Visual Studio 2019 and enjoy the source code.
Note
: All the configurations of project and solution is set.
To execute the program, use the following command:
[path_to_executable] [algorithm] [extra parameters]
-
Draw a single line in the glut windows:
- algorithm code:
- -1: Use built-in method
- 0 : Use DDA algorithm
- 1 : Use Bresenham algorithm
- parameters:
x1, y1, x2, y2
; where(x1, y1)
,(x2, y2)
are the coordinates of the first and last vertices respectively.
- algorithm code:
-
Draw a single circle in the glut windows:
- algorithm code:
- 2 : Use Midpoint algorithm
- parameters:
xc, yc, r
; where(xc, yc)
is the coordinate of the center, andr
is the radius of the circle.
- algorithm code:
-
Draw a single elipse in the glut windows:
- algorithm code:
- 3 : Use Midpoint algorithm
- parameters:
xc, yc, rx, ry
; where(xc, yc)
is the coordinate of the center, andrx
,ry
are the length of semi-major and semi-minor axis of the elipse in that order.
- algorithm code:
-
Draw a single parapole in the glut windows:
- algorithm code:
- 4 : Use Midpoint algorithm
- parameters:
xc, yc, p
; where(xc, yc)
is the coordinate of the center, andp
is the distance from center to focal point.
- algorithm code:
-
Draw a single hyperpole in the glut windows:
- algorithm code:
- 5 : Use Midpoint algorithm
- parameters:
xc, yc, rx, ry
; where(xc, yc)
is the coordinates of the center thenrx
andry
are the semi-length of transverse axis.
- algorithm code:
To draw multiple objects, use the following command:
[path_to_executable] -f [path_to_file]
- Input file is a multiple-line where each line contains the information of an object. The format of each line as followed:
[algorithm] [extra parameters]