Hey there,
I need to make the game change resolution during fights (to be precise I need 960x540 during exploration and 1920x1080 in combat).
Initially i solved the problem re-initializing the Graphics class each time i needed to change resolution, but apparently that creates a lot of garbage and after a few iterations it starts to slow down, break and the console gives this message "WARNING: Too many active WebGL contexts. Oldest context will be lost".
I tried another way by basically calling this function
The problem with this method is that if res scales up it increases the window size too and if done in full screen it scales the contents and i see only the top left corner. I tried some workarounds but are very scuffed, like switching full screen mode 2 times in the span of 2 cycles, which kinda solves the problem. Anyway this whole solution can work but I feel like there must be an easier and cleaner way.
TL;DR I need to change resolution on command in-game, keeping the same window size if windowed mode and not giving problems if done while in full screen.
Does anyone know how to either clear the garbage before re-initializing graphics or change resolution in real time?
I need to make the game change resolution during fights (to be precise I need 960x540 during exploration and 1920x1080 in combat).
Initially i solved the problem re-initializing the Graphics class each time i needed to change resolution, but apparently that creates a lot of garbage and after a few iterations it starts to slow down, break and the console gives this message "WARNING: Too many active WebGL contexts. Oldest context will be lost".
I tried another way by basically calling this function
Code:
SceneManager.changeGraphicResolution = function(width, height) {
this._screenWidth = width;
this._screenHeight = height;
Graphics._width = width;
Graphics._height = height;
var resizeWidth = this._screenWidth - window.innerWidth;
var resizeHeight = this._screenHeight - window.innerHeight;
window.resizeBy(resizeWidth, resizeHeight);
};
TL;DR I need to change resolution on command in-game, keeping the same window size if windowed mode and not giving problems if done while in full screen.
Does anyone know how to either clear the garbage before re-initializing graphics or change resolution in real time?