Topics:
Define polygon shapes
Pass attribute data to vertex shader
Pass color data to fragment shader
Draw color-interpolated triangles.
Create the following picture:
Use the variables "aPosition" and "aColor" to pass the vertex and color information to the vertex shader.
The shapes should be drawn as GL_TRIANGLE{S,_FAN,_STRIP}s.
The Circle: use the parametric equation of a circle to create multiple vertexes in a polygon. The parametric equations is:
x=R*cos( angle )
y=R*sin( angle )
You will need to increment the angle between 0 and 2*pi to draw the circle.
You can scale (change the value of R, the circle radius) and move the circle by multiplying the coordinates and
adding offsets to them.
Vary the red color as a function of angle to get the shading effect.
You should use a GL_TRIANGLE_FAN consisting of vertices on the outer
boundary of the circle and with the first vertex (at 3 o'clock) having a
black color.
Do not place the first vertex at the center of the circle.
You do not need to create the exact same interior shading pattern,
but the shades along the circle's perimeter should be the same as in the
example.
The Ellipse: For the ellipse, use the same equation but scale the y down to 60% .
Adding a constant vector to the vertices will allow you to define the objects around the origin and then have them translated to a different part of the window.
Last modified January 24, 2023.