ã©ã¤ããããã®ãã¢ã¯こちらã§è©¦ãã¾ãã
ãã¥ã¼ãã表示ããã ããªãHTMLãå«ãã¦ãããã ãã®è¨è¿°ã§ããã°ã©ã å¯è½ã¿ããã§ãã
<html><body>
<script src="lightgl.js"></script>
<script>
var angle = 0;
var gl = GL.create();
var mesh = GL.Mesh.cube();
var shader = new GL.Shader('\
void main() {\
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\
}\
', '\
void main() {\
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\
}\
');
gl.onupdate = function(seconds) {
angle += 45 * seconds;
};
gl.ondraw = function() {
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
gl.loadIdentity();
gl.translate(0, 0, -5);
gl.rotate(30, 1, 0, 0);
gl.rotate(angle, 0, 1, 0);
shader.draw(mesh);
};
gl.fullscreen();
gl.animate();
</script>
</body></html>
evanw/lightgl.js - GitHub
https://github.com/evanw/lightgl.js/