Hi,
Was wondering if its possible to fully stop rendering loop if nothing is changing on the screen.
Checked code for the Engine and found this function, that stop rendering if focus is lost.
public _renderLoop(): void {
if (!this._contextWasLost) {
var shouldRender = true;
if (!this.renderEvenInBackground && this._windowIsBackground) {
shouldRender = false;
}
if (shouldRender) {
// Start new frame
this.beginFrame();
for (var index = 0; index < this._activeRenderLoops.length; index++) {
var renderFunction = this._activeRenderLoops[index];
renderFunction();
}
// Present
this.endFrame();
}
}
if (this._activeRenderLoops.length > 0) {
this._frameHandler = this._queueNewFrame(this._bindedRenderFunction, this.getHostWindow());
} else {
this._renderingQueueLaunched = false;
}
}
What about having possibility to manully stop it ? like this
public _renderLoop(): void {
if (!this._contextWasLost) {
var shouldRender = true;
if (!this.renderEvenInBackground && this._windowIsBackground) {
shouldRender = false;
}
if (shouldRender && !this.paused) {
// Start new frame
this.beginFrame();
for (var index = 0; index < this._activeRenderLoops.length; index++) {
var renderFunction = this._activeRenderLoops[index];
renderFunction();
}
// Present
this.endFrame();
}
}
if (this._activeRenderLoops.length > 0) {
this._frameHandler = this._queueNewFrame(this._bindedRenderFunction, this.getHostWindow());
} else {
this._renderingQueueLaunched = false;
}
}
Also should this part still be triggered even if render is blocked ?
if (this._activeRenderLoops.length > 0) {
this._frameHandler = this._queueNewFrame(this._bindedRenderFunction, this.getHostWindow());
} else {
this._renderingQueueLaunched = false;
}