Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Fill in the task2a and 2b, using javascript webgl function createcircleGeometry(radius, segments) { var pi2 = 2 * Math.PI; var step = pi2 / segments;

Fill in the task2a and 2b, using javascript webgl

image text in transcribed

image text in transcribed

function createcircleGeometry(radius, segments) { var pi2 = 2 * Math.PI; var step = pi2 / segments; var points = []; var colors = []; // *** TODO_A1 : Task 2a // Create a circle geometry which can be rendered using a TRIANGLE_FAN. // Use the arguments of the function to specify the radius of the circle // and the number of linear segments to approximate it. // Interpolate the color values on the circle linearly using the HUE of // the HSV color-space (function hsvToRgb(.,.,.)). // code here return flattenArrays(points, colors); // ============================================================================ // Nested render loop function. It performs the acutual drawing of the scence and // to be called each time anything has changes and needs to be updated. function render() { // clears the colorbuffer with the color specified above. gl.clear(gl.COLOR_BUFFER_BIT); //*** TODO_A1 : Task 2b //Adapt the rendering function to render the cirle geometry using a TRIANGLE // Use the same geometry to render a black outline of the circle //using a LINE_STRIP. //Take care of proper management of the attributes using //gl.enableVertexAttribArray(colorAttribLocation) and //gl.disableVertexAttribArray(colorAttribLocation); // You can override the attribute with one constant value using // gl.vertexAttrib4f(colorAttribLocation, r, g, b, a); // code here function createcircleGeometry(radius, segments) { var pi2 = 2 * Math.PI; var step = pi2 / segments; var points = []; var colors = []; // *** TODO_A1 : Task 2a // Create a circle geometry which can be rendered using a TRIANGLE_FAN. // Use the arguments of the function to specify the radius of the circle // and the number of linear segments to approximate it. // Interpolate the color values on the circle linearly using the HUE of // the HSV color-space (function hsvToRgb(.,.,.)). // code here return flattenArrays(points, colors); // ============================================================================ // Nested render loop function. It performs the acutual drawing of the scence and // to be called each time anything has changes and needs to be updated. function render() { // clears the colorbuffer with the color specified above. gl.clear(gl.COLOR_BUFFER_BIT); //*** TODO_A1 : Task 2b //Adapt the rendering function to render the cirle geometry using a TRIANGLE // Use the same geometry to render a black outline of the circle //using a LINE_STRIP. //Take care of proper management of the attributes using //gl.enableVertexAttribArray(colorAttribLocation) and //gl.disableVertexAttribArray(colorAttribLocation); // You can override the attribute with one constant value using // gl.vertexAttrib4f(colorAttribLocation, r, g, b, a); // code here

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

Graph Databases

Authors: Ian Robinson, Jim Webber, Emil Eifrem

1st Edition

1449356265, 978-1449356262

More Books

Students also viewed these Databases questions

Question

What are the key elements of control?

Answered: 1 week ago