Skip to content

Commit abfe753

Browse files
committed
Removed the read of constant values from the WebGLRenderingContext object. Now they are read from an instance of webgl context.
1 parent 50c79c1 commit abfe753

3 files changed

Lines changed: 13 additions & 12 deletions

File tree

src/renderer/webgl/Utils.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,19 @@ module.exports = {
9797
* @since 3.0.0
9898
*
9999
* @param {number} attributes - [description]
100+
* @param {WebGLRenderingContext} glContext - [description]
100101
*
101102
* @return {number} [description]
102103
*/
103-
getComponentCount: function (attributes)
104+
getComponentCount: function (attributes, glContext)
104105
{
105106
var count = 0;
106107

107108
for (var index = 0; index < attributes.length; ++index)
108109
{
109110
var element = attributes[index];
110111

111-
if (element.type === WebGLRenderingContext.FLOAT)
112+
if (element.type === glContext.FLOAT)
112113
{
113114
count += element.size;
114115
}

src/renderer/webgl/WebGLPipeline.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ var WebGLPipeline = new Class({
185185
* @type {integer}
186186
* @since 3.0.0
187187
*/
188-
this.vertexComponentCount = Utils.getComponentCount(config.attributes);
188+
this.vertexComponentCount = Utils.getComponentCount(config.attributes, this.gl);
189189

190190
/**
191191
* Indicates if the current pipeline is flushing the contents to the GPU.

src/renderer/webgl/WebGLRenderer.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,6 @@ var WebGLRenderer = new Class({
179179
encoder: null
180180
};
181181

182-
for (var i = 0; i <= 16; i++)
183-
{
184-
this.blendModes.push({ func: [ WebGLRenderingContext.ONE, WebGLRenderingContext.ONE_MINUS_SRC_ALPHA ], equation: WebGLRenderingContext.FUNC_ADD });
185-
}
186-
187-
this.blendModes[1].func = [ WebGLRenderingContext.ONE, WebGLRenderingContext.DST_ALPHA ];
188-
this.blendModes[2].func = [ WebGLRenderingContext.DST_COLOR, WebGLRenderingContext.ONE_MINUS_SRC_ALPHA ];
189-
this.blendModes[3].func = [ WebGLRenderingContext.ONE, WebGLRenderingContext.ONE_MINUS_SRC_COLOR ];
190-
191182
// Internal Renderer State (Textures, Framebuffers, Pipelines, Buffers, etc)
192183

193184
/**
@@ -389,6 +380,15 @@ var WebGLRenderer = new Class({
389380

390381
this.gl = gl;
391382

383+
for (var i = 0; i <= 16; i++)
384+
{
385+
this.blendModes.push({ func: [ gl.ONE, gl.ONE_MINUS_SRC_ALPHA ], equation: gl.FUNC_ADD });
386+
}
387+
388+
this.blendModes[1].func = [ gl.ONE, gl.DST_ALPHA ];
389+
this.blendModes[2].func = [ gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA ];
390+
this.blendModes[3].func = [ gl.ONE, gl.ONE_MINUS_SRC_COLOR ];
391+
392392
// Load supported extensions
393393
this.supportedExtensions = gl.getSupportedExtensions();
394394

0 commit comments

Comments
 (0)