Skip to content

Commit

Permalink
Remove unused API method to initialize game rendering [skip ci] (#7235)
Browse files Browse the repository at this point in the history
  • Loading branch information
4ian authored Dec 18, 2024
1 parent b6d8170 commit 02d44bb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
22 changes: 13 additions & 9 deletions GDJS/Runtime/pixi-renderers/runtimegame-pixi-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace gdjs {
/**
* Create the canvas on which the game will be rendered, inside the specified DOM element, and
* setup the rendering of the game.
* If you want to use your own canvas, use `initializeForCanvas` instead.
* If you want to use your own canvas, use `initializeRenderers` and `initializeCanvas` instead.
*
* @param parentElement The parent element to which the canvas will be added.
*/
Expand All @@ -72,20 +72,18 @@ namespace gdjs {
const gameCanvas = document.createElement('canvas');
parentElement.appendChild(gameCanvas);

this.initializeForCanvas(gameCanvas);
this.initializeRenderers(gameCanvas);
this.initializeCanvas(gameCanvas);
}

/**
* Setup the rendering of the game to use a canvas that was already created.
* @param gameCanvas The canvas to use.
* Set up the rendering of the game for the given canvas.
*
* In most cases, you can use `createStandardCanvas` instead to initialize the game.
*/
initializeForCanvas(gameCanvas: HTMLCanvasElement): void {
initializeRenderers(gameCanvas: HTMLCanvasElement): void {
this._throwIfDisposed();
this.initializeRenderers(gameCanvas);
this.initializeCanvas(gameCanvas);
}

initializeRenderers(gameCanvas: HTMLCanvasElement): void {
if (typeof THREE !== 'undefined') {
this._threeRenderer = new THREE.WebGLRenderer({
canvas: gameCanvas,
Expand Down Expand Up @@ -136,6 +134,10 @@ namespace gdjs {
delete this._pixiRenderer.plugins.accessibility;
}

/**
* Set up the game canvas so that it covers the size required by the game
* and has a container for DOM elements required by the game.
*/
initializeCanvas(gameCanvas: HTMLCanvasElement): void {
// Add the renderer view element to the DOM
this._gameCanvas = gameCanvas;
Expand Down Expand Up @@ -537,6 +539,8 @@ namespace gdjs {

/**
* Add the standard events handler.
*
* The game canvas must have been initialized before calling this.
*/
bindStandardEvents(
manager: gdjs.InputManager,
Expand Down
3 changes: 2 additions & 1 deletion GDJS/tests/tests/game-canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ describe('gdjs.RuntimeGameRenderer canvas tests', () => {
it('should correctly initialize external canvas and create domElementsContainer', () => {
const gameCanvas = document.createElement('canvas');
gameContainer.appendChild(gameCanvas);
renderer.initializeForCanvas(gameCanvas);
renderer.initializeRenderers(gameCanvas);
renderer.initializeCanvas(gameCanvas);

const actualGameCanvas = renderer.getCanvas();
const actualDomElementsContainer = renderer.getDomElementContainer();
Expand Down

0 comments on commit 02d44bb

Please sign in to comment.