CS代写 12 WebGL 2.0

12 WebGL 2.0
R. Mukundan Department of Computer Science and Software Engineering University of Canterbury, .

Introduction

Copyright By PowCoder代写 加微信 powcoder

 3D graphics in a browser (rendering in an HTML context).
 Supported browsers: Firefox, Chrome, Edge.
 Uses WebGL 2. To test if a browser supports WebGL 2, load the following webpage and you should see a spinning cube.
https://get.webgl.org/webgl2/
 Requires hardware with OpenGL ES 3.0 support. WebGL 2 uses OpenGL ES 3.0 Shading Language.
 No software installation or plugins requried.
 Allows integration with HTML elements.
 WebGL 2.0 Specs:
https://www.khronos.org/registry/webgl/specs/latest/2.0/

Introduction
 WebGL programs are written in Javascript (see API Ref)
 Allows easy integration with HTML Document Object Model
(DOM) elements
 Scene rendered on a canvas (an HTML5 element) which acts as the viewport.
 JavaScript can register different types of event handlers to process mouse and timer events.
 We will be using the matrix library gl-matrix-min.js for vector and matrix operations ( https://glmatrix.net/ )
 The webpage provides a debugging console. This Javascript console is a useful tool for testing code segments and expressions: https://jsconsole.com/

Limitations
 Not supported by all browsers
 Very slow compared to native OpenGL-4 applications
 Keyboard and special key events cannot be handled. Commonly processed events are mouse events and button events.
 OpenGL ES 3.0 does not support tessellation or geometry shaders. Hence these shader stages are not currently available in WebGL.
 We cannot create models of teapots or other Bezier surfaces using control patches!
 We cannot generate terrain models with dynamic levels of tessellation.

File Organisation
 HTML file (.html )
 Contains the and sections
 Includes the code for vertex and fragment shaders specified as plain text sections using the