Skip to content

Commit

Permalink
also move this into its own file
Browse files Browse the repository at this point in the history
  • Loading branch information
obiot committed Dec 28, 2022
1 parent 3852592 commit 14941d1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
17 changes: 2 additions & 15 deletions src/application/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import state from "./../state/state.js";
import World from "./../physics/world.js";
import { onresize } from "./resize.js";
import { defaultSettings } from "./settings.js";
import { consoleHeader } from "./header.js";

/**
* Select the HTML5 Canvas renderer
Expand Down Expand Up @@ -229,21 +230,7 @@ const AUTO = 2;
}

if (this.settings.consoleHeader !== false) {
var renderType = typeof this.settings.renderer === "number" ? (this.renderer instanceof CanvasRenderer ? "CANVAS" : "WebGL" + this.renderer.WebGLVersion) : "Custom";
var audioType = device.hasWebAudio ? "Web Audio" : "HTML5 Audio";
var gpu_renderer = (typeof this.renderer.GPURenderer === "string") ? " (" + this.renderer.GPURenderer + ")" : "";
// output video information in the console
console.log(
renderType + " renderer" + gpu_renderer + " | " +
audioType + " | " +
"pixel ratio " + device.devicePixelRatio + " | " +
(device.platform.nodeJS ? "node.js" : device.platform.isMobile ? "mobile" : "desktop") + " | " +
device.getScreenOrientation() + " | " +
device.language
);
console.log( "resolution: " + "requested " + this.settings.width + "x" + this.settings.height +
", got " + this.renderer.getWidth() + "x" + this.renderer.getHeight()
);
consoleHeader(this);
}

// create a new physic world
Expand Down
26 changes: 26 additions & 0 deletions src/application/header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as device from "../system/device";
import CanvasRenderer from "../video/canvas/canvas_renderer";

/**
* display information
* @param {Application} game - the game application instance calling this function
*/
export function consoleHeader(app) {
var renderType = typeof app.settings.renderer === "number" ? (app.renderer instanceof CanvasRenderer ? "CANVAS" : "WebGL" + app.renderer.WebGLVersion) : "Custom";
var audioType = device.hasWebAudio ? "Web Audio" : "HTML5 Audio";
var gpu_renderer = (typeof app.renderer.GPURenderer === "string") ? " (" + app.renderer.GPURenderer + ")" : "";

// output video information in the console
console.log(
renderType + " renderer" + gpu_renderer + " | " +
audioType + " | " +
"pixel ratio " + device.devicePixelRatio + " | " +
(device.platform.nodeJS ? "node.js" : device.platform.isMobile ? "mobile" : "desktop") + " | " +
device.getScreenOrientation() + " | " +
device.language
);

console.log( "resolution: " + "requested " + app.settings.width + "x" + app.settings.height +
", got " + app.renderer.getWidth() + "x" + app.renderer.getHeight()
);
}

0 comments on commit 14941d1

Please sign in to comment.