Browse CVS Repository
Annotation of /webgl/webgl/sample.html
Parent Directory
| Revision Log
| Revision Graph
Revision 1.1 -
(view)
(download)
(as text)
| 1 : |
yam |
1.1 |
<html> |
| 2 : |
|
|
<head> |
| 3 : |
|
|
<script type="text/javascript" src="./GL/gl.js"></script> |
| 4 : |
|
|
<script type="text/javascript">//<![CDATA[ |
| 5 : |
|
|
var POINTS = [ |
| 6 : |
|
|
1.2, 0.0, 0.0, |
| 7 : |
|
|
0.0, 1.2, 0.0, |
| 8 : |
|
|
0.0, 0.0, 1.2, |
| 9 : |
|
|
]; |
| 10 : |
|
|
|
| 11 : |
|
|
var AXIS = [ |
| 12 : |
|
|
1.0, 0.0, 0.0, |
| 13 : |
|
|
0.0, 0.0, 0.0, |
| 14 : |
|
|
0.0, 1.0, 0.0, |
| 15 : |
|
|
0.0, 0.0, 0.0, |
| 16 : |
|
|
0.0, 0.0, 1.0, |
| 17 : |
|
|
0.0, 0.0, 0.0, |
| 18 : |
|
|
]; |
| 19 : |
|
|
|
| 20 : |
|
|
var canvas = undefined; |
| 21 : |
|
|
var gl = undefined; |
| 22 : |
|
|
|
| 23 : |
|
|
function initOnLoad(){ |
| 24 : |
|
|
canvas = document.getElementById("draw3d"); |
| 25 : |
|
|
gl = new GL(canvas); |
| 26 : |
|
|
} |
| 27 : |
|
|
|
| 28 : |
|
|
function draw3(r){ |
| 29 : |
|
|
with(gl){ |
| 30 : |
|
|
glClear(GL_COLOR_BUFFER_BIT); |
| 31 : |
|
|
glViewport(0, 0, 320, 240); |
| 32 : |
|
|
glMatrixMode(GL_PROJECTION); |
| 33 : |
|
|
glLoadIdentity(); |
| 34 : |
|
|
glMatrixMode(GL_MODELVIEW); |
| 35 : |
|
|
glLoadIdentity(); |
| 36 : |
|
|
glScale(80,80,80); |
| 37 : |
|
|
glRotateZ(r); |
| 38 : |
|
|
glRotateX(r-0.01); |
| 39 : |
|
|
glRotateY(-r/15.0); |
| 40 : |
|
|
|
| 41 : |
|
|
glVertexPointer(3, 0, 0, POINTS); |
| 42 : |
|
|
glDrawArrays(GL_POINTS, 0, 1); |
| 43 : |
|
|
glVertexPointer(3, 0, 0, AXIS); |
| 44 : |
|
|
glDrawArrays(GL_LINES, 0, 1); |
| 45 : |
|
|
} |
| 46 : |
|
|
|
| 47 : |
|
|
} |
| 48 : |
|
|
|
| 49 : |
|
|
var r=0.0; |
| 50 : |
|
|
var timerID=null; |
| 51 : |
|
|
function anim(){ |
| 52 : |
|
|
draw3(r); |
| 53 : |
|
|
r+=0.2; |
| 54 : |
|
|
timerID = setTimeout('anim()', 50); |
| 55 : |
|
|
} |
| 56 : |
|
|
//]]></script> |
| 57 : |
|
|
</head> |
| 58 : |
|
|
<body onLoad="initOnLoad();"> |
| 59 : |
|
|
<canvas id="draw3d" width="320" height="240" style="border:1px black solid"></canvas> |
| 60 : |
|
|
<form> |
| 61 : |
|
|
<input onclick="clearTimeout(timerID); anim();" type="button" value="Start"></input> |
| 62 : |
|
|
<input onclick="clearTimeout(timerID);" type="button" value="Stop"></input> |
| 63 : |
|
|
<input onclick="draw3(0);" type="button" value=" Draw "></input> |
| 64 : |
|
|
</form> |
| 65 : |
|
|
</body> |
| 66 : |
|
|
</html> |
|
|