Question
Computer Graphics Suppose you want to create an animation of the blue rectangle rotating about the origin (about the Z-axis). Here is the code for
Computer Graphics
Suppose you want to create an animation of the blue rectangle rotating about the origin (about the Z-axis).
Here is the code for a vertex shader for this program:
attribute vec4 vPosition;
attribute vec4 vColor;
varying vec4 fColor;
uniform float theta;
void main()
{
float anglez = radians( theta );
float c = cos( anglez );
float s = sin( anglez );
mat4 rz =
mat4(c.z,-s.z,0.0,0.0,s.z,c.z,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0);
fColor = vColor;
gl_Position = rz * vPosition;
}
Assume that the rotation increment amount for each frame is +2 degrees and stored in a global called Anginc, and the total rotation amount is in a global called thetaz . Show the complete render() function you would write to do this. You may assume you have already gotten the uniform attribute location for theta by calling thetaLoc = gl.getUniformLocation(program, "theta");
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started