Sylhet Engineering College
Department of Computer Science & Engineering
LAB REPORT
Course Code : CSE-802
Course Title : Computer Graphics (Sessional)
Report No. : 01
Topic(s) : Drawing different shapes.
Submission Date : 25-01-2024
Submitted by Submitted to
- Md Lysuzzaman
Reg. No: 20183315 Lecturer (CSE)
Session: 2018-19 Sylhet Engineering College.
Experiment No: 01
Experiment Name: Draw a shape (Star) in OpenGL.
Objective: To draw a star shape.
Code:
Output:
Result and Discussion: The OpenGL program successfully draws a star within a 400x400 window. The
use of GL_TRIANGLES and GL_QUADS primitives, along with appropriate vertex coordinates, creates
the desired star pattern.
Experiment No: 02
Experiment Name: Translation of a shape (Star) with user input (Tx, Ty) in OpenGL.
Objective: To translate a star shape.
Code:
Output:
Result and Discussion:
The OpenGL program successfully translates the star shape based on user input values for Tx and Ty.
The translation operation is applied to the star, allowing dynamic positioning within the window,
demonstrating the interactive capabilities of the program.
Experiment No: 03
Experiment Name: Rotate a shape (Star) in OpenGL.
Objective: To rotate a star shape.
Code:
Output:
Result and Discussion:
The OpenGL program successfully rotates the star shape based on user input for the rotation angle.
Pressing 'r' in the display window triggers rotation mode, allowing users to dynamically specify the
angle and observe the rotation effect on the star, demonstrating the interactive rotational
capabilities of the program.
Experiment No: 04
Experiment Name: Reflection of a shape (Star) in all quadrants in OpenGL.
Objective: To draw reflections of a star shape in all quadrants.
Code:
Output:
Result and Discussion:
The OpenGL program successfully draws reflections of the star shape in all quadrants by applying
horizontal, vertical, and combined horizontal-vertical reflections. Different colors (red, green, and
blue) are used for each reflection, illustrating the versatility of transformations in creating mirrored
images of the original star shape.
Experiment No: 05
Experiment Name: Draw a line between two points using DDA line drawing algorithm in OpenGL.
Objective: To draw a line between two points using DDA line drawing algorithm.
Code:
Output:
Result and Discussion:
The OpenGL program successfully implements the DDA line drawing algorithm to draw a line
between two user-specified points. The algorithm calculates incremental steps in both x and y
directions, ensuring a smooth and accurate representation of the line, demonstrating the
effectiveness of the DDA algorithm for basic line drawing.
Experiment No: 06
Experiment Name: Draw a line between two points using Bresenham line drawing algorithm in
OpenGL.
Objective: To draw a line between two points using Bresenham line drawing algorithm.
Code:
Output:
Result and Discussion:
The OpenGL program successfully utilizes the Bresenham line drawing algorithm to draw a line
between two user-specified points. The Bresenham algorithm, with its arithmetic, efficiently handles
various line slopes and produces accurate results, demonstrating its effectiveness for line rendering.
Experiment No: 07
Experiment Name: Clip a line inside a window using Cohen Sutherland line clipping algorithm in
OpenGL.
Objective: To clip a line inside a window using Cohen Sutherland line clipping algorithm.
Code:
Output:
Result and Discussion:
The OpenGL program successfully implements the Cohen-Sutherland line clipping algorithm to clip a line
segment within a specified window. The red line represents the clipped portion, ensuring that only the
segment inside the defined clipping window is displayed, demonstrating the effectiveness of the Cohen-
Sutherland algorithm for line clipping.
Experiment No: 08
Experiment Name: Clip a polygon inside a window using Sutherland-Hodgman polygon clipping
algorithm in OpenGL.
Objective: To clip a polygon inside a window using Sutherland-Hodgman polygon clipping algorithm.
Code:
Output:
Result and Discussion:
The OpenGL program successfully implements the Sutherland-Hodgman polygon clipping algorithm
to clip a user-defined polygon within a specified window. The grey portion represents the original
polygon, and the green portion shows the clipped result inside the defined clipping window,
demonstrating the effectiveness of the Sutherland-Hodgman algorithm for polygon clipping.
Experiment No: 09
Experiment Name: Clip a polygon inside a window using Weiler Atherton polygon clipping algorithm
in OpenGL.
Objective: To clip a polygon inside a window using Weiler Atherton polygon clipping algorithm.
Code:
Output:
Result and Discussion:
The implemented Weiler Atherton polygon clipping algorithm successfully clips the example polygon
inside the specified window. The original green polygon is displayed along with the red clipped
portion, demonstrating the effective application of the algorithm in isolating the visible region.
Experiment No: 10
Experiment Name: Draw a circle using Bresenham circle drawing algorithm in OpenGL.
Objective: To draw a circle using Bresenham circle drawing algorithm.
Code:
Output:
Result and Discussion:
The OpenGL program successfully implements the Bresenham circle drawing algorithm to draw a
circle with a specified center and radius. The algorithm efficiently calculates and plots points in the
eight octants of the circle, producing an accurate and symmetrical representation, demonstrating
the effectiveness of Bresenham's algorithm for circle drawing.
Experiment No: 11
Experiment Name: Draw a circle using Mid-Point circle drawing algorithm in OpenGL.
Objective: To draw a circle using Mid-Point circle drawing algorithm.
Code:
Output:
Result and Discussion:
The OpenGL program successfully implements the Mid-Point circle drawing algorithm to draw a
circle with a specified center and radius. This algorithm efficiently calculates and plots points in the
circle's octants, producing an accurate and symmetrical representation. The Mid-Point circle drawing
algorithm is known for its efficiency in minimizing calculations and is widely used for drawing circles.