-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.js
More file actions
59 lines (45 loc) · 1.48 KB
/
bootstrap.js
File metadata and controls
59 lines (45 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
$(document).ready(function() {
$("#fullscreen-button").click(function() {
var container = document.getElementById("game-canvas-container");
container.requestFullScreen();
container.requestPointerLock();
})
webGLStart();
handleCanvasSizeChange();
});
function handleCanvasSizeChange() {
var canvas = document.getElementById("game-canvas");
if(document.webkitIsFullScreen) {
canvas.width = screen.width;
canvas.height = screen.height;
$("#fullscreen-button").hide();
} else {
canvas.width = innerWidth; // These are your original windowed size
canvas.height = innerHeight;
$("#fullscreen-button").show();
}
// Need to update the WebGL viewport.
gl.viewport(0, 0, canvas.width, canvas.height);
mat4.perspective(45.0, canvas.width/canvas.height, 0.1, 100.0, pMatrix);
};
function webGLStart() {
var canvas = document.getElementById("game-canvas");
var body = document.body;
body.onwebkitfullscreenchange = handleCanvasSizeChange;
body.onkeydown = handleKeyDown;
body.onkeyup = handleKeyUp;
body.oncontextmenu=function(){return false};
body.onmousemove = handleMouseMove;
body.onmousedown = handleMouseDown;
body.onmouseup = handleMouseUp;
canvas.width = innerWidth;
canvas.height = innerHeight;
initGL(canvas);
initMaterials();
initMeshes();
initGame();
gl.clearColor(0.4, 0.6, 1.0, 1.0);
gl.enable(gl.DEPTH_TEST);
game.running = true;
tick();
}