mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-08-08 14:18:26 +02:00
Fix taking screenshot not working when limiting FPS
This commit is contained in:
@@ -94,20 +94,22 @@ export class WebGL2Player {
|
||||
gl.uniform1f(gl.getUniformLocation(program, 'saturation'), this.options.saturation);
|
||||
}
|
||||
|
||||
drawFrame() {
|
||||
// Don't draw when FPS is 0
|
||||
if (this.targetFps === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Limit FPS
|
||||
if (this.targetFps < 60) {
|
||||
const currentTime = performance.now();
|
||||
const timeSinceLastFrame = currentTime - this.lastFrameTime;
|
||||
if (timeSinceLastFrame < this.frameInterval) {
|
||||
drawFrame(force=false) {
|
||||
if (!force) {
|
||||
// Don't draw when FPS is 0
|
||||
if (this.targetFps === 0) {
|
||||
return;
|
||||
}
|
||||
this.lastFrameTime = currentTime;
|
||||
|
||||
// Limit FPS
|
||||
if (this.targetFps < 60) {
|
||||
const currentTime = performance.now();
|
||||
const timeSinceLastFrame = currentTime - this.lastFrameTime;
|
||||
if (timeSinceLastFrame < this.frameInterval) {
|
||||
return;
|
||||
}
|
||||
this.lastFrameTime = currentTime;
|
||||
}
|
||||
}
|
||||
|
||||
const gl = this.gl!;
|
||||
|
@@ -64,7 +64,7 @@ export class Screenshot {
|
||||
const canvasContext = Screenshot.#canvasContext;
|
||||
|
||||
if ($player instanceof HTMLCanvasElement) {
|
||||
streamPlayer.getWebGL2Player().drawFrame();
|
||||
streamPlayer.getWebGL2Player().drawFrame(true);
|
||||
}
|
||||
canvasContext.drawImage($player, 0, 0, $canvas.width, $canvas.height);
|
||||
|
||||
|
Reference in New Issue
Block a user