Skip to content

Commit 06f4efc

Browse files
committed
Cache max texture size value
1 parent 21cb868 commit 06f4efc

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

flixel/FlxGame.hx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,12 @@ class FlxGame extends Sprite
334334
addChild(postProcessLayer);
335335
#end
336336

337+
// We have to call this after a stage is created
338+
// otherwise it will fail and cause a crash
339+
#if FLX_OPENGL_AVAILABLE
340+
FlxG.bitmap.setMaxTextureSize();
341+
#end
342+
337343
// Creating the debugger overlay
338344
#if FLX_DEBUG
339345
debugger = new FlxDebugger(FlxG.stage.stageWidth, FlxG.stage.stageHeight);

flixel/system/frontEnds/BitmapFrontEnd.hx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class BitmapFrontEnd
2727
*
2828
* @see https://opengl.gpuinfo.org/displaycapability.php?name=GL_MAX_TEXTURE_SIZE
2929
*/
30-
public var maxTextureSize(get, never):Int;
30+
public var maxTextureSize(default, null):Int;
3131
#end
3232

3333
/**
@@ -393,12 +393,10 @@ class BitmapFrontEnd
393393
}
394394

395395
#if FLX_OPENGL_AVAILABLE
396-
function get_maxTextureSize():Int
396+
@:allow(flixel.FlxGame)
397+
function setMaxTextureSize():Void
397398
{
398-
if (FlxG.stage.window.context.attributes.hardware)
399-
return cast GL.getParameter(GL.MAX_TEXTURE_SIZE);
400-
401-
return -1;
399+
maxTextureSize = FlxG.stage.window.context.attributes.hardware ? cast GL.getParameter(GL.MAX_TEXTURE_SIZE) : -1;
402400
}
403401
#end
404402

0 commit comments

Comments
 (0)