Answered step by step
Verified Expert Solution
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
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 hereStep 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