Skip to content

Commit

Permalink
Fix getParameter call inside texture update (#5198)
Browse files Browse the repository at this point in the history
  • Loading branch information
pandamicro authored and 2youyou2 committed Aug 26, 2019
1 parent 4362bda commit b41dd6b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions cocos2d/renderer/gfx/device.js
Expand Up @@ -564,6 +564,13 @@ function _attach(gl, location, attachment, face = 0) {
}

export default class Device {
/**
* @property caps
*/
get caps() {
return this._caps;
}

/**
* @param {HTMLElement} canvasEL
* @param {object} opts
Expand Down Expand Up @@ -689,6 +696,7 @@ export default class Device {
this._caps.maxFragUniforms = gl.getParameter(gl.MAX_FRAGMENT_UNIFORM_VECTORS);
this._caps.maxTextureUnits = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS);
this._caps.maxVertexAttribs = gl.getParameter(gl.MAX_VERTEX_ATTRIBS);
this._caps.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);

this._caps.maxDrawBuffers = extDrawBuffers ? gl.getParameter(extDrawBuffers.MAX_DRAW_BUFFERS_WEBGL) : 1;
this._caps.maxColorAttachments = extDrawBuffers ? gl.getParameter(extDrawBuffers.MAX_COLOR_ATTACHMENTS_WEBGL) : 1;
Expand Down
4 changes: 2 additions & 2 deletions cocos2d/renderer/gfx/texture-2d.js
Expand Up @@ -77,8 +77,8 @@ export default class Texture2D extends Texture {
genMipmap = options.mipmap;
}

let maxSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
let textureMaxSize = (options.width && options.height) ? Math.max(options.width, options.height) : 0;
let maxSize = this._device.caps.maxTextureSize || Number.MAX_VALUE;
let textureMaxSize = Math.max(options.width || 0, options.height || 0);
if (maxSize < textureMaxSize)
console.warn(`The current texture size ${textureMaxSize} exceeds the maximum size [${maxSize}] supported on the device.`);

Expand Down

0 comments on commit b41dd6b

Please sign in to comment.