You are on page 1of 20

CSE202 –

Computer Graphics Using


OpenGL
Unit I

09-04-2022
Graphics Attributes
• Point attributes
• Line attributes
• Curve attributes
• Fill area attributes
• OpenGL Fill-Area Attribute Functions

09-04-2022 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 2


Point attributes
• We can set two attributes for points:
• color
• Size

09-04-2022 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 3
Line attributes
• A straight-line segment can be displayed with three basic attributes:
• Color
• Width
• Style
• Line Color
• glColor3f(1.0, 0.0, 0.0); // object color
• Line Width
• Draw a thick line

09-04-2022 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 4
Line attributes (Contd.)
• Line Style
• solid lines, dashed lines, and dotted lines

• If factor is 3, for example, each bit in the pattern is used three times before
the next bit in the pattern is used.
• Specifies a 16-bit integer whose bit pattern determines which fragments of a
line will be drawn when the line is rasterized

09-04-2022 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 5
Line attributes (Contd.)

09-04-2022 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 6
Curve attributes
• Parameters for curve attributes are the same as those for straight-line
segments.

09-04-2022 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 7
Fill area attributes
• We can fill any specified regions, including circles, ellipses, and other
objects with curved boundaries
• Fill Styles

09-04-2022 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 8
General Scan-Line Polygon-Fill
Algorithm
• First determining the intersection positions
• Then the fill colors are applied to each section of a scan line

ODD- Interior
Even- Exterior

09-04-2022 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 9
Scan-line algorithm(Contd.)

09-04-2022 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 10
Scan-line algorithm(Contd.)

09-04-2022 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 11
Scan-line algorithm(Contd.)

09-04-2022 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 12
Boundary-Fill Algorithm
• Irregular Boundaries
• If the boundary of some region is specified in a single color

09-04-2022 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 13
Boundary-Fill Algorithm (Contd.)
• 4-connected
• 8-connected

09-04-2022 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 14
Boundary-Fill Algorithm (Contd.)

09-04-2022 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 15
Boundary-Fill Algorithm (Contd.)

09-04-2022 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 16
Flood-Fill Algorithm
• Sometimes we want to fill in (or recolor) an area that is not defined
within a single color boundary

09-04-2022 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 17
Flood-Fill Algorithm (Contd.)

09-04-2022 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 18
OpenGL Fill-Area Attribute Functions

09-04-2022 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 19
References
• Donald D. Hearn, M. Pauline Baker and Warren Carithers, “Computer
Graphics with OpenGL”, Pearson Education, Fourth Edition, 2011.

09-04-2022 20

You might also like