一、实例代码
<html>
<canvas id='c' width='640' height='480'></canvas>
<script type="x-shader/x-vertex" id="vertex-shader">
attribute vec4 a_position;
attribute vec2 aTextureCoord;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
varying highp vec2 vTextureCoord;
void main(){
gl_Position = projection * view * model * a_position;
vTextureCoord = aTextureCoord;
}
</script>
<script type="x-shader/x-fragment" id="fragment-shader">
varying highp vec2 vTextureCoord;
uniform sampler2D uSampler;
void main(){
gl_FragColor = texture2D(uSampler, vTextureCoord);
}
</script>
<script src="WebGLUtils.js"> </script>
<script src="gl-matrix.js"></script>
<script>
var rotation = 0.0
var gl = createGLContext('c')
// alert(gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS))
//创建shader program
var program = createPr