Computer Graphics Short Summary
Computer Graphics Short Summary
2D:
Figures
● Triangles : GL_TRIANGLES
● Rectangle and Square:
○ GL_QUADS
○ GL_POLYGON
● Polygon: 3 sides or more
○ GL_POLYGON
● Lines
○ GL_LINES
● Circle
○ Filled: GL_TRIANGLE_FAN
○ Line: GL_LINE_LOOP
Transformation
● Scaling
○ glScalef( x-axis , y-axis, z-axis)
● Rotation
○ glRotatef(angle, x-axis, y-axis, z-axis)
■ For example: rotating around x-axis with an angle 20
● glRotatef(20,1,0,0)
● Translation:
○ glTranslatef(x-axis, y-axis, z-axis)
● Shearing: Out of scope
Code Structure
1. #include
2. InitGL() = clear background, determine the orthogonals
3. AspectRatio()
4. display () = draw figures
5. Special keys () = allow user to interact with the drawing through button clicks
6. main()
3D
Transformations
● Rotation
● Scaling
● Translation
● Shearing
● Reflection: glScalef(x-axis, y-axis, z-axis) but
○ If i want to reflect around x-axis : y-axis value = -1
○ If i want to reflect around y-axis : x-axis value = -1
Figures
● Cube:
○ 6 squares with different z-axis values
● Cylinder
○ Top circle
○ Bottom Circle
○ Tube: unique code
● Cone
○ glutSolidCone(radius of base , height, slices, stacks)