From 8e1809688cf51713b696d512c4998326bca55213 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 1 Aug 2023 13:44:58 +0100 Subject: [PATCH] The WebGLRenderer will now validate that the `mipmapFilter` property in the Game Config is a valid mipmap before assigning it. --- src/core/Config.js | 2 +- src/core/typedefs/RenderConfig.js | 2 +- src/renderer/webgl/WebGLRenderer.js | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/Config.js b/src/core/Config.js index 5da598342..5d5f95516 100644 --- a/src/core/Config.js +++ b/src/core/Config.js @@ -361,7 +361,7 @@ var Config = new Class({ this.antialiasGL = GetValue(renderConfig, 'antialiasGL', true, config); /** - * @const {string} Phaser.Core.Config#mipmapFilter - Sets the `mipmapFilter` property when the WebGL renderer is created. + * @const {string} Phaser.Core.Config#mipmapFilter - Sets the mipmap magFilter to be used when creating WebGL textures. Don't set unless you wish to create mipmaps. Set to one of the following: 'NEAREST', 'LINEAR', 'NEAREST_MIPMAP_NEAREST', 'LINEAR_MIPMAP_NEAREST', 'NEAREST_MIPMAP_LINEAR' or 'LINEAR_MIPMAP_LINEAR'. */ this.mipmapFilter = GetValue(renderConfig, 'mipmapFilter', '', config); diff --git a/src/core/typedefs/RenderConfig.js b/src/core/typedefs/RenderConfig.js index d1bf336d0..3adc7cff6 100644 --- a/src/core/typedefs/RenderConfig.js +++ b/src/core/typedefs/RenderConfig.js @@ -16,7 +16,7 @@ * @property {number} [batchSize=4096] - The default WebGL batch size. Represents the number of _quads_ that can be added to a single batch. * @property {number} [maxLights=10] - The maximum number of lights allowed to be visible within range of a single Camera in the LightManager. * @property {number} [maxTextures=-1] - When in WebGL mode, this sets the maximum number of GPU Textures to use. The default, -1, will use all available units. The WebGL1 spec says all browsers should provide a minimum of 8. - * @property {string} [mipmapFilter=''] - The mipmap magFilter to be used when creating WebGL textures. + * @property {string} [mipmapFilter=''] - The mipmap magFilter to be used when creating WebGL textures. Don't set unless you wish to create mipmaps. Set to one of the following: 'NEAREST', 'LINEAR', 'NEAREST_MIPMAP_NEAREST', 'LINEAR_MIPMAP_NEAREST', 'NEAREST_MIPMAP_LINEAR' or 'LINEAR_MIPMAP_LINEAR'. * @property {Phaser.Types.Core.PipelineConfig} [pipeline] - The WebGL Pipeline configuration object. * @property {boolean} [autoMobilePipeline=true] - Automatically enable the Mobile Pipeline if iOS or Android detected? * @property {string} [defaultPipeline='MultiPipeline'] - The WebGL Pipeline that Game Objects will use by default. Set to 'MultiPipeline' as standard. diff --git a/src/renderer/webgl/WebGLRenderer.js b/src/renderer/webgl/WebGLRenderer.js index 707a65eae..f42d43db4 100644 --- a/src/renderer/webgl/WebGLRenderer.js +++ b/src/renderer/webgl/WebGLRenderer.js @@ -783,7 +783,9 @@ var WebGLRenderer = new Class({ gl.clearColor(clearColor.redGL, clearColor.greenGL, clearColor.blueGL, clearColor.alphaGL); // Mipmaps - if (config.mipmapFilter !== '') + var validMipMaps = [ 'NEAREST', 'LINEAR', 'NEAREST_MIPMAP_NEAREST', 'LINEAR_MIPMAP_NEAREST', 'NEAREST_MIPMAP_LINEAR', 'LINEAR_MIPMAP_LINEAR' ]; + + if (validMipMaps.indexOf(config.mipmapFilter) !== -1) { this.mipmapFilter = gl[config.mipmapFilter]; }