diff options
author | Jukka Jylänki <jujjyl@gmail.com> | 2014-01-22 12:26:21 +0200 |
---|---|---|
committer | Jukka Jylänki <jujjyl@gmail.com> | 2014-01-22 12:29:29 +0200 |
commit | e797f2af396f79acb824aaac8ac7befa7528dfa3 (patch) | |
tree | 26c0febee99e8b3ec607eb03edc8081f3485e511 | |
parent | cc77e142465c3df7ac02dfe21560e23ab7d1df70 (diff) |
Fix default vertex color to (1,1,1,1) and properly enable correct attribute streams when doing immediate mode rendering when GL_FFP_ONLY is set.
-rw-r--r-- | src/library_gl.js | 11 | ||||
-rw-r--r-- | tests/s3tc.c | 2 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/library_gl.js b/src/library_gl.js index bf4cccce..edd5890e 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -3501,6 +3501,11 @@ var LibraryGL = { GLImmediate.enabledClientAttributes[name] = true; GLImmediate.setClientAttribute(name, size, type, 0, GLImmediate.rendererComponentPointer); GLImmediate.rendererComponentPointer += size * GL.byteSizeByType[type - GL.byteSizeByTypeRoot]; +#if GL_FFP_ONLY + // We can enable the correct attribute stream index immediately here, since the same attribute in each shader + // will be bound to this same index. + GL.enableVertexAttribArray(name); +#endif } else { GLImmediate.rendererComponents[name]++; } @@ -3760,7 +3765,7 @@ var LibraryGL = { this.texCoordLocations[i] = GLctx.getAttribLocation(this.program, aTexCoordPrefix + i); } } - + this.colorLocation = GLctx.getAttribLocation(this.program, 'a_color'); if (!useCurrProgram) { // Temporarily switch to the program so we can set our sampler uniforms early. var prevBoundProg = GLctx.getParameter(GLctx.CURRENT_PROGRAM); @@ -3772,6 +3777,9 @@ var LibraryGL = { GLctx.uniform1i(texSamplerLoc, texUnitID); } } + // The default color attribute value is not the same as the default for all other attribute streams (0,0,0,1) but (1,1,1,1), + // so explicitly set it right at start. + GLctx.vertexAttrib4fv(this.colorLocation, [1,1,1,1]); GLctx.useProgram(prevBoundProg); } @@ -3779,7 +3787,6 @@ var LibraryGL = { for (var i = 0; i < GLImmediate.MAX_TEXTURES; i++) { this.textureMatrixLocations[i] = GLctx.getUniformLocation(this.program, 'u_textureMatrix' + i); } - this.colorLocation = GLctx.getAttribLocation(this.program, 'a_color'); this.normalLocation = GLctx.getAttribLocation(this.program, 'a_normal'); this.modelViewLocation = GLctx.getUniformLocation(this.program, 'u_modelView'); diff --git a/tests/s3tc.c b/tests/s3tc.c index 5f7bee83..eb2ed3fc 100644 --- a/tests/s3tc.c +++ b/tests/s3tc.c @@ -133,7 +133,7 @@ int main(int argc, char *argv[]) glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); - // Render the last item using oldschool glBegin etc + // Render the last item using oldschool glBegin etc glBegin( GL_TRIANGLE_STRIP ); glTexCoord2i( 0, 0 ); glVertex3f( 100, 300, 0 ); glTexCoord2i( 1, 0 ); glVertex3f( 300, 300, 0 ); |