Bit20203 - Graphics Programming SEMESTER 1 SESSION 2020/2021
Bit20203 - Graphics Programming SEMESTER 1 SESSION 2020/2021
Bit20203 - Graphics Programming SEMESTER 1 SESSION 2020/2021
Labsheet #3
Title : Drawing Bresenham’s line
Objectives : At the end of the lab session, students should be able to:
(i) Draw/plot a straight line using Bresenham’s line
algorithm.
Date : 26 October 2020 (Monday) – S1 & S2
INSTRUCTIONS
1. Open CodeBlocks.
2. Create a new GLUT project.
3. Write the following codes:
1
LABSHEET #3 Drawing a Bresenham’s Line BIT20203
2
LABSHEET #3 Drawing a Bresenham’s Line BIT20203
4. Sample output:
5. After compiling and running the above codes successfully, do the following steps:
a. Change the endpoints coordinates (x0,y0) and (xn, yn) to (12,10) and (17,14)
respectively.
b. Add some codes to display to the detailed calculations of Bresenham’s line algorithm
in the console application.
c. Sample output:
3
LABSHEET #3 Drawing a Bresenham’s Line BIT20203
Write an OpenGL program that would be able draw a number of lines with different
slopes/gradients. You are required to modify the Bresenham’s line algorithm that has been learned
in Exercise 1. You should be able to:
1. Draw SIX (6) types of lines with the following slopes (m):
a. m is a positive value and m < 1
b. m is a positive value and m > 1
c. m is a negative value and m < 1
d. m is a negative value and m > 1
e. m = 0
f. m = ∞
2. Define a series of endpoints coordinates to represent the straight lines.
3. Assign different colors for each type of line.
4. Sample output:
4
LABSHEET #3 Drawing a Bresenham’s Line BIT20203
5. After completing this exercise (Exercise 2 only), you must submit your work and it will be
evaluated by your lecturer. Please consider the following requirements:
a. Prepare a report in Microsoft Word / PDF format.
b. The report must include the
i. Cover page. Write down your particular details such as name, matric no, etc.
ii. Source codes. Copy your code from CodeBlock and paste it in the report.
iii. Sample output. Capture the screenshot image of the output and put it in the
report.
c. Submission deadline: 1 November 2020 (11.59pm).
d. Submit softcopy of your report via Author account using the following naming
convention; LabAssignment1_matrik-no.docx/pdf.