learning the basic of webgl
gl.clearColor(${red}, ${gree}, ${blue}, ${alpha})
set the rgba color, input arguemtns are floating point 0 - 1gl.clear(gl.COLOR_BUFFER_BIT)
clear the color channel of the drawing buffer
gl.drawingBufferWidth
the width of the contextgl.drawingBufferHeight
the height of the contextgl.viewport(${x}, ${y}, ${width}, ${height})
use viewport to specify the portion of the context before drawing function
most time drawing with entire screen of contextgl.viewport(0,0 gl.drawingBufferWidth, gl.drawingBufferHeight)
The Scissor is similar to cropping an image, while set viewport is similar to resize the imagegl.enable(${capability})
turn on a specified capabilitygl.enable(gl.SCISSOR_TEST)
turn on the scissor capabilitygl.scissor(${x}, ${y}, ${width}, ${height})
set the scissor region, x, y coordinate from the lower left cornergl.disable(gl.SCISSOR_TEST)
turn off the scissor capability
after enbale the scissor, should disable the scissor after drawing to let drawing buff restore from previous state
const w = gl.drawingBufferWidth
const h = gl.drawingBufferHeight
gl.clearColor(1,1,0,1)
gl.clear(gl.COLOR_BUFFER_BIT)
gl.enable(gl.SCISSOR_TEST)
gl.scissor(0,0,w/2,h/2)
gl.clearColor(1,0,0,1)
gl.clear(gl.COLOR_BUFFER_BIT)
gl.disable(gl.SCISSOR_TEST)