Skip to content

Commit

Permalink
Renamed 'buffer2' to 'buffer'
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Wojciechowski committed Sep 28, 2015
1 parent 0b4c0fb commit 5287956
Show file tree
Hide file tree
Showing 13 changed files with 179 additions and 268 deletions.
23 changes: 20 additions & 3 deletions js/data/buffer2.js → js/data/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ function Buffer(options) {
}

// Start Buffer1 compatability code
var Buffer1 = require('./buffer/buffer');

Buffer.prototype = {

Expand All @@ -91,8 +90,26 @@ Buffer.prototype = {
this.arrayBuffer = null;
},

bind: Buffer1.prototype.bind,
destroy: Buffer1.prototype.destroy,
// binds the buffer to a webgl context
bind: function(gl) {
var type = gl[this.arrayType];
if (!this.buffer) {
this.buffer = gl.createBuffer();
gl.bindBuffer(type, this.buffer);
gl.bufferData(type, this.array.slice(0, this.pos), gl.STATIC_DRAW);

// dump array buffer once it's bound to gl
this.array = null;
} else {
gl.bindBuffer(type, this.buffer);
}
},

destroy: function(gl) {
if (this.buffer) {
gl.deleteBuffer(this.buffer);
}
},

setupViews: function() { /* intentional no-op */ }

Expand Down
78 changes: 0 additions & 78 deletions js/data/buffer/buffer.js

This file was deleted.

12 changes: 6 additions & 6 deletions js/data/buffer/circle_vertex_buffer.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
'use strict';

var util = require('../../util/util');
var Buffer2 = require('../buffer2');
var Buffer = require('../buffer');

function CircleVertexBuffer(options) {
Buffer2.call(this, options || {
type: Buffer2.BufferType.VERTEX,
Buffer.call(this, options || {
type: Buffer.BufferType.VERTEX,
attributes: {
pos: {
components: 2,
type: Buffer2.AttributeType.UNSIGNED_SHORT
type: Buffer.AttributeType.UNSIGNED_SHORT
}
}
});
}

CircleVertexBuffer.prototype = util.inherit(Buffer2, {
CircleVertexBuffer.prototype = util.inherit(Buffer, {
add: function(x, y, extrudeX, extrudeY) {
this.push([
(x * 2) + ((extrudeX + 1) / 2),
(y * 2) + ((extrudeY + 1) / 2)
]);
},
bind: function(gl, shader, offset) {
Buffer2.prototype.bind.call(this, gl);
Buffer.prototype.bind.call(this, gl);

gl.vertexAttribPointer(shader.a_pos, 2,
gl.SHORT, false,
Expand Down
14 changes: 7 additions & 7 deletions js/data/buffer/collision_box_vertex_buffer.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
'use strict';

var util = require('../../util/util');
var Buffer2 = require('../buffer2');
var Buffer = require('../buffer');

function CollisionBoxVertexBuffer(options) {
Buffer2.call(this, options || {
type: Buffer2.BufferType.VERTEX,
Buffer.call(this, options || {
type: Buffer.BufferType.VERTEX,
attributes: {
pos: {
type: Buffer2.AttributeType.SHORT,
type: Buffer.AttributeType.SHORT,
components: 2
},
extrusions: {
type: Buffer2.AttributeType.SHORT,
type: Buffer.AttributeType.SHORT,
components: 2
},
data: {
type: Buffer2.AttributeType.UNSIGNED_BYTE,
type: Buffer.AttributeType.UNSIGNED_BYTE,
components: 2
}
}
});
}

CollisionBoxVertexBuffer.prototype = util.inherit(Buffer2, {
CollisionBoxVertexBuffer.prototype = util.inherit(Buffer, {
// add a vertex to this buffer;
// x, y - vertex position
// ex, ey - extrude normal
Expand Down
10 changes: 5 additions & 5 deletions js/data/buffer/fill_vertex_buffer.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
'use strict';

var util = require('../../util/util');
var Buffer2 = require('../buffer2');
var Buffer = require('../buffer');

function FillVertexBuffer(options) {
Buffer2.call(this, options || {
type: Buffer2.BufferType.VERTEX,
Buffer.call(this, options || {
type: Buffer.BufferType.VERTEX,
attributes: {
pos: {
components: 2,
type: Buffer2.AttributeType.UNSIGNED_SHORT
type: Buffer.AttributeType.UNSIGNED_SHORT
}
}
});
}

FillVertexBuffer.prototype = util.inherit(Buffer2, {
FillVertexBuffer.prototype = util.inherit(Buffer, {
add: function(x, y) {
this.push([x, y]);
}
Expand Down
16 changes: 8 additions & 8 deletions js/data/buffer/glyph_vertex_buffer.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
'use strict';

var util = require('../../util/util');
var Buffer2 = require('../buffer2');
var Buffer = require('../buffer');

function GlyphVertexBuffer(options) {
Buffer2.call(this, options || {
type: Buffer2.BufferType.VERTEX,
Buffer.call(this, options || {
type: Buffer.BufferType.VERTEX,
attributes: {
pos: {
components: 2,
type: Buffer2.AttributeType.SHORT
type: Buffer.AttributeType.SHORT
},
extrude: {
components: 2,
type: Buffer2.AttributeType.SHORT
type: Buffer.AttributeType.SHORT
},
data: {
components: 8,
type: Buffer2.AttributeType.UNSIGNED_BYTE
type: Buffer.AttributeType.UNSIGNED_BYTE
}
}
});
}

GlyphVertexBuffer.prototype = util.inherit(Buffer2, {
GlyphVertexBuffer.prototype = util.inherit(Buffer, {
add: function(x, y, ox, oy, tx, ty, minzoom, maxzoom, labelminzoom) {
this.push({
pos: [
Expand All @@ -47,7 +47,7 @@ GlyphVertexBuffer.prototype = util.inherit(Buffer2, {
});
},
bind: function(gl, shader, offset) {
Buffer2.prototype.bind.call(this, gl);
Buffer.prototype.bind.call(this, gl);

var stride = this.itemSize;

Expand Down
16 changes: 8 additions & 8 deletions js/data/buffer/icon_vertex_buffer.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
'use strict';

var util = require('../../util/util');
var Buffer2 = require('../buffer2');
var Buffer = require('../buffer');

function IconVertexBuffer(options) {
Buffer2.call(this, options || {
type: Buffer2.BufferType.VERTEX,
Buffer.call(this, options || {
type: Buffer.BufferType.VERTEX,
attributes: {
pos: {
components: 2,
type: Buffer2.AttributeType.SHORT
type: Buffer.AttributeType.SHORT
},
extrude: {
components: 2,
type: Buffer2.AttributeType.SHORT
type: Buffer.AttributeType.SHORT
},
data: {
components: 8,
type: Buffer2.AttributeType.UNSIGNED_BYTE
type: Buffer.AttributeType.UNSIGNED_BYTE
}
}
});
}

IconVertexBuffer.prototype = util.inherit(Buffer2, {
IconVertexBuffer.prototype = util.inherit(Buffer, {
add: function(x, y, ox, oy, tx, ty, minzoom, maxzoom, labelminzoom) {
this.push({
pos:[
Expand All @@ -47,7 +47,7 @@ IconVertexBuffer.prototype = util.inherit(Buffer2, {
});
},
bind: function(gl, shader, offset) {
Buffer2.prototype.bind.call(this, gl);
Buffer.prototype.bind.call(this, gl);

var stride = this.itemSize;

Expand Down
10 changes: 5 additions & 5 deletions js/data/buffer/line_element_buffer.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
'use strict';

var util = require('../../util/util');
var Buffer2 = require('../buffer2');
var Buffer = require('../buffer');

function LineElementBuffer(options) {
Buffer2.call(this, options || {
type: Buffer2.BufferType.ELEMENT,
Buffer.call(this, options || {
type: Buffer.BufferType.ELEMENT,
attributes: {
vertices: {
components: 3,
type: Buffer2.AttributeType.UNSIGNED_SHORT
type: Buffer.AttributeType.UNSIGNED_SHORT
}
}
});
}

LineElementBuffer.prototype = util.inherit(Buffer2, {
LineElementBuffer.prototype = util.inherit(Buffer, {
add: function(a, b, c) {
this.push([a, b, c]);
}
Expand Down
12 changes: 6 additions & 6 deletions js/data/buffer/line_vertex_buffer.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
'use strict';

var util = require('../../util/util');
var Buffer2 = require('../buffer2');
var Buffer = require('../buffer');

function LineVertexBuffer(options) {
Buffer2.call(this, options || {
type: Buffer2.BufferType.VERTEX,
Buffer.call(this, options || {
type: Buffer.BufferType.VERTEX,
attributes: {
pos: {
components: 2,
type: Buffer2.AttributeType.SHORT
type: Buffer.AttributeType.SHORT
},
data: {
components: 4,
type: Buffer2.AttributeType.BYTE
type: Buffer.AttributeType.BYTE
}
}
});
Expand All @@ -26,7 +26,7 @@ function LineVertexBuffer(options) {
// normal array, while the extrude normal actually moves the vertex to create
// the acute/bevelled line join.

LineVertexBuffer.prototype = util.inherit(Buffer2, {
LineVertexBuffer.prototype = util.inherit(Buffer, {
extrudeScale: 63,
add: function(point, extrude, tx, ty, linesofar) {
var extrudeScale = this.extrudeScale;
Expand Down
10 changes: 5 additions & 5 deletions js/data/buffer/outline_element_buffer.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
'use strict';

var util = require('../../util/util');
var Buffer2 = require('../buffer2');
var Buffer = require('../buffer');

function OutlineElementBuffer(options) {
Buffer2.call(this, options || {
type: Buffer2.BufferType.ELEMENT,
Buffer.call(this, options || {
type: Buffer.BufferType.ELEMENT,
attributes: {
verticies: {
components: 2,
type: Buffer2.AttributeType.UNSIGNED_SHORT
type: Buffer.AttributeType.UNSIGNED_SHORT
}
}
});
}

OutlineElementBuffer.prototype = util.inherit(Buffer2, {
OutlineElementBuffer.prototype = util.inherit(Buffer, {
add: function(a, b) {
this.push([a, b]);
}
Expand Down
Loading

0 comments on commit 5287956

Please sign in to comment.