WebGLRenderer.setExtensions is a new method that queries the GL context to get the list of supported extensions. Which it then sets into the class properties. This method is called internally as part of the init and restore process.

When the WebGL context was restored it would incorrectly try to call `init.setupExtensions()` which didn't exist. It now calls the correct method, `WebGLRenderer.setExtensions`. Fix #6905
This commit is contained in:
Richard Davey 2024-09-17 15:08:20 +01:00
parent e41b3be8ff
commit ad5b38b1cb
2 changed files with 35 additions and 23 deletions

View file

@ -8,4 +8,4 @@
## Bug Fixes
* When the WebGL context was restored it would incorrectly try to call `init.setupExtensions()` which didn't exist.
* When the WebGL context was restored it would incorrectly try to call `init.setupExtensions()` which didn't exist. It now calls the correct method, `WebGLRenderer.setExtensions`. Fix #6905 (thanks @RedRoosterMobile)

View file

@ -407,7 +407,7 @@ var WebGLRenderer = new Class({
/**
* Array of strings that indicate which WebGL extensions are supported by the browser.
* This is populated in the `boot` method.
* This is populated in the `setExtensions` method.
*
* @name Phaser.Renderer.WebGL.WebGLRenderer#supportedExtensions
* @type {string[]}
@ -420,6 +420,8 @@ var WebGLRenderer = new Class({
* If the browser supports the `ANGLE_instanced_arrays` extension, this property will hold
* a reference to the glExtension for it.
*
* This is populated in the `setExtensions` method.
*
* @name Phaser.Renderer.WebGL.WebGLRenderer#instancedArraysExtension
* @type {ANGLE_instanced_arrays}
* @default null
@ -431,6 +433,8 @@ var WebGLRenderer = new Class({
* If the browser supports the `OES_vertex_array_object` extension, this property will hold
* a reference to the glExtension for it.
*
* This is populated in the `setExtensions` method.
*
* @name Phaser.Renderer.WebGL.WebGLRenderer#vaoExtension
* @type {OES_vertex_array_object}
* @default null
@ -775,26 +779,7 @@ var WebGLRenderer = new Class({
this.gl = gl;
var _this = this;
// Load supported extensions
var setupExtensions = function ()
{
var exts = gl.getSupportedExtensions();
_this.supportedExtensions = exts;
var angleString = 'ANGLE_instanced_arrays';
_this.instancedArraysExtension = (exts.indexOf(angleString) > -1) ? gl.getExtension(angleString) : null;
var vaoString = 'OES_vertex_array_object';
_this.vaoExtension = (exts.indexOf(vaoString) > -1) ? gl.getExtension(vaoString) : null;
};
setupExtensions();
this.setExtensions();
this.setContextHandlers();
@ -944,6 +929,33 @@ var WebGLRenderer = new Class({
this.resize(width, height);
},
/**
* Queries the GL context to get the supported extensions.
*
* Then sets them into the `supportedExtensions`, `instancedArraysExtension` and `vaoExtension` properties.
*
* Called automatically during the `init` method.
*
* @method Phaser.Renderer.WebGL.WebGLRenderer#setExtensions
* @since 3.85.2
*/
setExtensions: function ()
{
var gl = this.gl;
var exts = gl.getSupportedExtensions();
this.supportedExtensions = exts;
var angleString = 'ANGLE_instanced_arrays';
this.instancedArraysExtension = (exts.indexOf(angleString) > -1) ? gl.getExtension(angleString) : null;
var vaoString = 'OES_vertex_array_object';
this.vaoExtension = (exts.indexOf(vaoString) > -1) ? gl.getExtension(vaoString) : null;
},
/**
* Sets the handlers that are called when WebGL context is lost or restored by the browser.
*
@ -1084,7 +1096,7 @@ var WebGLRenderer = new Class({
this.resize(this.game.scale.baseSize.width, this.game.scale.baseSize.height);
// Restore GL extensions.
this.init.setupExtensions();
this.setExtensions();
// Context has been restored.