Question
WebGL: Add code so that the Reset button clears all the points on the display. (reset button uses for both clears all the points display
WebGL: Add code so that the "Reset" button clears all the points on the display.
(reset button uses for both clears all the points display on the canvas, and also reset the position of color Sliders, but you do not need to change anything for color Sliders reset because it is done) So, just add code to clear canvas.
Code need to modify
// Set up the callback for the reset button resetButton.addEventListener("click", function () { for (var i in rgbSliders) { rgbSliders[i].value = rgbSliders[i].max / 2.0; rgbSliders[i].valueDisplay.textContent = rgbSliders[i].valueAsNumber / rgbSliders[i].max; } requestAnimationFrame(render); });
Something maybe help:
/** * Render - draw the frame * */ Lab2.prototype.Render = function () { var gl = this.gl; gl.clearColor(0.0, 0.0, 0.25, 1.0); gl.clear(gl.COLOR_BUFFER_BIT); gl.drawArrays(gl.POINTS, 0, this.pointCount); };
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