一个简单的webGL的测试程序
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>webgl-lesson01</title>
<script>
function Init(){
var canvasElement=document.getElementById('webgl');
var context=canvasElement.getContext('webgl');
context.viewport(0,0,canvasElement.clientWidth,canvasElement.clientHeight);
context.clearColor(1.0,1.0,0.0,1.0);
context.clear(context.COLOR_BUFFER_BIT);
}
</script>
</head>
<body οnlοad='Init()'>
<canvas id="webgl" style="border: 1px solid red;" width="500" height="500"></canvas>
</body>
</html>
第一句<!DOCTYPE html>指明了用的是HTML5.保存成.html文件,作用火狐浏览器打开。显示结果