-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
40 lines (32 loc) · 864 Bytes
/
main.js
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
//the OpenGL context
var gl = null,
program = null;
/**
* initializes OpenGL context, compile shader, and load buffers
*/
function init(resources) {
//create a GL context
gl = createContext(400 /*width*/, 400 /*height*/);
//compile and link shader program
program = createProgram(gl, resources.vs, resources.fs);
}
/**
* render one frame
*/
function render() {
gl.clearColor(0.9, 0.9, 0.9, 1.0);
//clear the buffer
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
//TODO
//request another call as soon as possible
//requestAnimationFrame(render);
}
//load the shader resources using a utility function
loadResources({
vs: 'shader/empty.vs.glsl',
fs: 'shader/empty.fs.glsl'
}).then(function (resources /*an object containing our keys with the loaded resources*/) {
init(resources);
//render one frame
render();
});