Skip to content

Commit 89329a2

Browse files
committed
Added getMaxTextures and getMaxTextureSize methods
1 parent b1d41e5 commit 89329a2

2 files changed

Lines changed: 46 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
### Updates
88

9+
* WebGLRenderer.config has a new property `maxTextures` which is derived from `gl.MAX_TEXTURE_IMAGE_UNITS`, you can get it via the new method `getMaxTextures()`.
10+
* WebGLRenderer.config has a new property `maxTextureSize` which is derived from `gl.MAX_TEXTURE_SIZE`, you can get it via the new method `getMaxTextureSize()`
11+
912
### Bug Fixes
1013

1114
### Examples, Documentation and TypeScript

src/renderer/webgl/WebGLRenderer.js

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ var WebGLRenderer = new Class({
8585
contextCreation: contextCreationConfig,
8686
resolution: gameConfig.resolution,
8787
autoResize: gameConfig.autoResize,
88-
roundPixels: gameConfig.roundPixels
88+
roundPixels: gameConfig.roundPixels,
89+
maxTextures: gameConfig.maxTextures,
90+
maxTextureSize: gameConfig.maxTextureSize
8991
};
9092

9193
/**
@@ -434,6 +436,18 @@ var WebGLRenderer = new Class({
434436
// Load supported extensions
435437
this.supportedExtensions = gl.getSupportedExtensions();
436438

439+
var config = this.config;
440+
441+
if (!config.maxTextures)
442+
{
443+
config.maxTextures = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS);
444+
}
445+
446+
if (!config.maxTextureSize)
447+
{
448+
config.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
449+
}
450+
437451
// Setup initial WebGL state
438452
gl.disable(gl.DEPTH_TEST);
439453
gl.disable(gl.CULL_FACE);
@@ -1885,6 +1899,34 @@ var WebGLRenderer = new Class({
18851899
return this;
18861900
},
18871901

1902+
/**
1903+
* Returns the maximum number of texture units that can be used in a fragment shader.
1904+
*
1905+
* @method Phaser.Renderer.WebGL.WebGLRenderer#getMaxTextures
1906+
* @since 3.8.0
1907+
*
1908+
* @return {integer} The maximum number of textures WebGL supports.
1909+
*/
1910+
getMaxTextures: function ()
1911+
{
1912+
return this.config.maxTextures;
1913+
},
1914+
1915+
/**
1916+
* Returns the largest texture size (either width or height) that can be created.
1917+
* Note that VRAM may not allow a texture of any given size, it just expresses
1918+
* hardware / driver support for a given size.
1919+
*
1920+
* @method Phaser.Renderer.WebGL.WebGLRenderer#getMaxTextureSize
1921+
* @since 3.8.0
1922+
*
1923+
* @return {integer} ...
1924+
*/
1925+
getMaxTextureSize: function ()
1926+
{
1927+
return this.config.maxTextureSize;
1928+
},
1929+
18881930
/**
18891931
* [description]
18901932
*

0 commit comments

Comments
 (0)