forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphicsWebGLData.js
More file actions
52 lines (40 loc) · 1.23 KB
/
Copy pathGraphicsWebGLData.js
File metadata and controls
52 lines (40 loc) · 1.23 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
Phaser.Renderer.WebGL.GameObjects.GraphicsData = function (gl)
{
this.gl = gl;
this.color = [0, 0, 0];
this.points = [];
this.indices = [];
this.buffer = gl.createBuffer();
this.indexBuffer = gl.createBuffer();
this.mode = 1;
this.alpha = 1;
this.dirty = true;
};
Phaser.Renderer.WebGL.GameObjects.GraphicsData.prototype.constructor = Phaser.Renderer.WebGL.GameObjects.GraphicsData;
Phaser.Renderer.WebGL.GameObjects.GraphicsData.prototype = {
reset: function ()
{
this.points = [];
this.indices = [];
},
upload: function ()
{
var gl = this.gl;
this.glPoints = new Float32Array(this.points);
gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer);
gl.bufferData(gl.ARRAY_BUFFER, this.glPoints, gl.STATIC_DRAW);
this.glIndicies = new Uint16Array(this.indices);
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.glIndicies, gl.STATIC_DRAW);
this.dirty = false;
},
destroy: function ()
{
this.gl = null;
this.color = null;
this.points = null;
this.indices = null;
this.buffer = null;
this.indexBuffer = null;
}
};