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 /src | |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/library_gl.js | 11 |
1 files changed, 9 insertions, 2 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'); |