Configuring WebGL Properties

We need to initialize and configure our canvas and gl instances:

function configure() {
canvas = utils.getCanvas('webgl-canvas');
utils.autoResizeCanvas(canvas);
gl = utils.getGLContext(canvas);

// ...
}

Then, we need to initialize scene, clock, and program:

clock = new Clock();
program = new Program(gl, 'vertex-shader', 'fragment-shader');
scene = new Scene(gl, program);

These core components are defined globally so that we can reference them throughout our application.

Finally, we need to set the background color and the depth test properties, as follows:

gl.clearColor(...clearColor);
gl.clearDepth(1);
gl.enable(gl.DEPTH_TEST);
gl.depthFunc(gl.LESS);
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.69.255