CPSC362A
Video Game Development

Activity 2

Draw a Star

Create an OpenGL program that draws a five-pointed star.

Details

  1. Use a triangle fan where the fist point is the center of the star.

  2. The points of the star are on a circle. So the points can be computed using the equations:

    \[x = cos(\theta) \cdot radius\] \[y = sin(\theta) \cdot radius\]

    Where thea is the angle of rotation from the point (radius, 0) that the point is located.

  3. The inner points of the star are also on a circle. This circle’s radius is:

    \[inner\_radius = outer\_radius \cdot sin(18\circ) / sin(136\circ)\]

Example