Skip to content

Commit e83db44

Browse files
committed
Fixed issue with attribute order on osx and ios
1 parent 511781b commit e83db44

6 files changed

Lines changed: 21 additions & 16 deletions

File tree

v3/src/renderer/webgl/renderers/blitterbatch/BlitterBatch.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ BlitterBatch.prototype = {
6262
var indexBuffer = indexDataBuffer.uintView;
6363
var max = CONST.MAX_PARTICLES * CONST.PARTICLE_INDEX_COUNT;
6464

65-
vertexBufferObject.addAttribute(0, 2, gl.FLOAT, false, CONST.VERTEX_SIZE, 0);
66-
vertexBufferObject.addAttribute(1, 2, gl.FLOAT, false, CONST.VERTEX_SIZE, 8);
67-
vertexBufferObject.addAttribute(2, 1, gl.FLOAT, false, CONST.VERTEX_SIZE, 16);
65+
vertexBufferObject.addAttribute(shader.getAttribLocation('a_position'), 2, gl.FLOAT, false, CONST.VERTEX_SIZE, 0);
66+
vertexBufferObject.addAttribute(shader.getAttribLocation('a_tex_coord'), 2, gl.FLOAT, false, CONST.VERTEX_SIZE, 8);
67+
vertexBufferObject.addAttribute(shader.getAttribLocation('a_alpha'), 1, gl.FLOAT, false, CONST.VERTEX_SIZE, 16);
6868

6969
this.vertexDataBuffer = vertexDataBuffer;
7070
this.indexDataBuffer = indexDataBuffer;

v3/src/renderer/webgl/renderers/effectrenderer/EffectRenderer.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ EffectRenderer.prototype = {
7070
this.vertexBufferObject = vertexBufferObject;
7171
this.viewMatrixLocation = viewMatrixLocation;
7272

73-
vertexBufferObject.addAttribute(0, 2, gl.FLOAT, false, CONST.VERTEX_SIZE, 0);
74-
vertexBufferObject.addAttribute(1, 2, gl.FLOAT, false, CONST.VERTEX_SIZE, 8);
75-
vertexBufferObject.addAttribute(2, 3, gl.UNSIGNED_BYTE, true, CONST.VERTEX_SIZE, 16);
76-
vertexBufferObject.addAttribute(3, 1, gl.FLOAT, false, CONST.VERTEX_SIZE, 20);
73+
vertexBufferObject.addAttribute(shader.getAttribLocation('a_position'), 2, gl.FLOAT, false, CONST.VERTEX_SIZE, 0);
74+
vertexBufferObject.addAttribute(shader.getAttribLocation('a_tex_coord'), 2, gl.FLOAT, false, CONST.VERTEX_SIZE, 8);
75+
vertexBufferObject.addAttribute(shader.getAttribLocation('a_color'), 3, gl.UNSIGNED_BYTE, true, CONST.VERTEX_SIZE, 16);
76+
vertexBufferObject.addAttribute(shader.getAttribLocation('a_alpha'), 1, gl.FLOAT, false, CONST.VERTEX_SIZE, 20);
7777

7878
// Populate the index buffer only once
7979
for (var indexA = 0, indexB = 0; indexA < max; indexA += CONST.QUAD_INDEX_COUNT, indexB += CONST.QUAD_VERTEX_COUNT)

v3/src/renderer/webgl/renderers/quadbatch/QuadBatch.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ QuadBatch.prototype = {
6161
var indexBuffer = indexDataBuffer.uintView;
6262
var max = CONST.MAX_AAQUAD * CONST.AAQUAD_INDEX_COUNT;
6363

64-
vertexBufferObject.addAttribute(0, 2, gl.FLOAT, false, CONST.VERTEX_SIZE, 0);
65-
vertexBufferObject.addAttribute(1, 4, gl.FLOAT, false, CONST.VERTEX_SIZE, 8);
64+
vertexBufferObject.addAttribute(shader.getAttribLocation('a_position'), 2, gl.FLOAT, false, CONST.VERTEX_SIZE, 0);
65+
vertexBufferObject.addAttribute(shader.getAttribLocation('a_color'), 4, gl.FLOAT, false, CONST.VERTEX_SIZE, 8);
6666

6767
this.vertexDataBuffer = vertexDataBuffer;
6868
this.indexDataBuffer = indexDataBuffer;

v3/src/renderer/webgl/renderers/shapebatch/ShapeBatch.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ ShapeBatch.prototype = {
6262
var viewMatrixLocation = shader.getUniformLocation('u_view_matrix');
6363
var max = CONST.MAX_VERTICES;
6464

65-
vertexBufferObject.addAttribute(0, 2, gl.FLOAT, false, CONST.VERTEX_SIZE, 0);
66-
vertexBufferObject.addAttribute(1, 4, gl.UNSIGNED_BYTE, true, CONST.VERTEX_SIZE, 8);
67-
vertexBufferObject.addAttribute(2, 1, gl.FLOAT, false, CONST.VERTEX_SIZE, 12);
65+
vertexBufferObject.addAttribute(shader.getAttribLocation('a_position'), 2, gl.FLOAT, false, CONST.VERTEX_SIZE, 0);
66+
vertexBufferObject.addAttribute(shader.getAttribLocation('a_color'), 4, gl.UNSIGNED_BYTE, true, CONST.VERTEX_SIZE, 8);
67+
vertexBufferObject.addAttribute(shader.getAttribLocation('a_alpha'), 1, gl.FLOAT, false, CONST.VERTEX_SIZE, 12);
6868

6969
this.vertexDataBuffer = vertexDataBuffer;
7070
this.shader = shader;

v3/src/renderer/webgl/renderers/spritebatch/SpriteBatch.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ SpriteBatch.prototype = {
7070
this.vertexBufferObject = vertexBufferObject;
7171
this.viewMatrixLocation = viewMatrixLocation;
7272

73-
vertexBufferObject.addAttribute(0, 2, gl.FLOAT, false, CONST.VERTEX_SIZE, 0);
74-
vertexBufferObject.addAttribute(1, 2, gl.FLOAT, false, CONST.VERTEX_SIZE, 8);
75-
vertexBufferObject.addAttribute(2, 3, gl.UNSIGNED_BYTE, true, CONST.VERTEX_SIZE, 16);
76-
vertexBufferObject.addAttribute(3, 1, gl.FLOAT, false, CONST.VERTEX_SIZE, 20);
73+
vertexBufferObject.addAttribute(shader.getAttribLocation('a_position'), 2, gl.FLOAT, false, CONST.VERTEX_SIZE, 0);
74+
vertexBufferObject.addAttribute(shader.getAttribLocation('a_tex_coord'), 2, gl.FLOAT, false, CONST.VERTEX_SIZE, 8);
75+
vertexBufferObject.addAttribute(shader.getAttribLocation('a_color'), 3, gl.UNSIGNED_BYTE, true, CONST.VERTEX_SIZE, 16);
76+
vertexBufferObject.addAttribute(shader.getAttribLocation('a_alpha'), 1, gl.FLOAT, false, CONST.VERTEX_SIZE, 20);
7777

7878
// Populate the index buffer only once
7979
for (var indexA = 0, indexB = 0; indexA < max; indexA += CONST.SPRITE_INDEX_COUNT, indexB += CONST.SPRITE_VERTEX_COUNT)

v3/src/renderer/webgl/resources/Shader.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ Shader.prototype = {
1717
return this.gl.getUniformLocation(this.program, name);
1818
},
1919

20+
getAttribLocation: function (name)
21+
{
22+
return this.gl.getAttribLocation(this.program, name);
23+
},
24+
2025
setConstantFloat1: function(location, x)
2126
{
2227
this.gl.useProgram(this.program);

0 commit comments

Comments
 (0)