Skip to content

Commit

Permalink
Attempting to fix the "black bars" problem seen on Macs. Noticed that…
Browse files Browse the repository at this point in the history
… the Mac assigns vertex attributes in a different order from other platforms, so assuming that "attribute vec3 position" is the same attribute ID in both vertex shaders is no longer a valid assumption. Added code to track the attribute IDs separately.
  • Loading branch information
emackey committed Mar 14, 2012
1 parent f0a9f17 commit 644fa79
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@

var quality = 2, quality_levels = [ 0.5, 1, 2, 4, 8 ];
var toolbar, compileButton, fullscreenButton, compileTimer, errorLines = [];
var code, canvas, gl, buffer, currentProgram, vertexPosition, panButton,
var code, canvas, gl, buffer, currentProgram, vertexPosition, screenVertexPosition, panButton,
parameters = { startTime: Date.now(), time: 0, mouseX: 0.5, mouseY: 0.5, screenWidth: 0, screenHeight: 0 },
surface = { centerX: 0, centerY: 0, width: 1, height: 1, isPanning: false, isZooming: false, lastX: 0, lastY: 0 },
frontTarget, backTarget, screenProgram, getWebGL, resizer = {}, compileOnChangeCode = true;
Expand Down Expand Up @@ -562,9 +562,7 @@
surface.positionAttribute = gl.getAttribLocation(currentProgram, "surfacePosAttrib");
gl.enableVertexAttribArray(surface.positionAttribute);

gl.bindBuffer( gl.ARRAY_BUFFER, buffer );
vertexPosition = gl.getAttribLocation(currentProgram, "position");
gl.vertexAttribPointer( vertexPosition, 2, gl.FLOAT, false, 0, 0 );
gl.enableVertexAttribArray( vertexPosition );

}
Expand Down Expand Up @@ -598,9 +596,14 @@

screenProgram = program;

gl.useProgram( screenProgram );

cacheUniformLocation( program, 'resolution' );
cacheUniformLocation( program, 'texture' );

screenVertexPosition = gl.getAttribLocation(currentProgram, "position");
gl.enableVertexAttribArray( screenVertexPosition );

}

function cacheUniformLocation( program, label ) {
Expand Down Expand Up @@ -834,6 +837,9 @@
gl.uniform2f( screenProgram.uniformsCache[ 'resolution' ], parameters.screenWidth, parameters.screenHeight );
gl.uniform1i( screenProgram.uniformsCache[ 'texture' ], 1 );

gl.bindBuffer( gl.ARRAY_BUFFER, buffer );
gl.vertexAttribPointer( screenVertexPosition, 2, gl.FLOAT, false, 0, 0 );

gl.activeTexture( gl.TEXTURE1 );
gl.bindTexture( gl.TEXTURE_2D, frontTarget.texture );

Expand Down

0 comments on commit 644fa79

Please sign in to comment.