Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Bioinformatics Databases And Systems

Authors: Stanley I. Letovsky

1st Edition

1475784058, 978-1475784053

More Books

Students also viewed these Databases questions

Question

Question Who can establish a Keogh retirement plan?

Answered: 1 week ago