WebGL 3D (入门篇)
2018-12-12 本文已影响17人
WebGiser
![](https://img.haomeiwen.com/i11354300/eaecc1af7492b108.png)
![](https://img.haomeiwen.com/i11354300/6b67531e7ccd69d4.png)
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body onload="init()">
<canvas id="canvas" width="600px" height="600px" style="border: 1px solid #ff0000;">
</canvas>
<script type="text/javascript">
function init(){
//获取<canvas>元素
var canvas = document.getElementById('canvas');
//获取三维图形的绘图上下文
var gl = canvas.getContext('webgl');
//指定清空<canvas>颜色
gl.clearColor(0.0,0.0,1.0,1.0);
//清空<canvas>
gl.clear(gl.COLOR_BUFFER_BIT);
}
</script>
</body>
</html>
![](https://img.haomeiwen.com/i11354300/c1fbb83a04ecda71.png)