Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add external canvas usage to RuntimeGamePixiRenderer #7199

Merged
merged 6 commits into from
Nov 29, 2024

Conversation

danvervlad
Copy link
Contributor

This PR introduces the useCanvas method in the RuntimeGamePixiRenderer class, enabling developers to provide an external canvas for rendering instead of relying on the internally created one.

@danvervlad danvervlad marked this pull request as ready for review November 28, 2024 09:26
@danvervlad danvervlad changed the title Add useCanvas method to RuntimeGamePixiRenderer for external canvas integration Add useCanvas method to RuntimeGamePixiRenderer for external canvas usage Nov 28, 2024
@@ -189,6 +189,120 @@ namespace gdjs {
gameCanvas.focus();
}

useCanvas(gameCanvas: HTMLCanvasElement): void {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a lot of copy from the createStandardCanvas function. Could you rework createStandardCanvas so that it's using useCanvas under the hood?

Also, the name is probably not showing this is an important operation enough, that just can't be redone a second time. So I think it should be called initializeForCanvas

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for review! I've refactored createStandardCanvas, renamed useCanvas, updated runtimegame.dispose() and added tests.

@danvervlad danvervlad force-pushed the feature/add-use-custom-canvas branch 2 times, most recently from 8f2b5df to 6febb37 Compare November 29, 2024 13:45
@danvervlad danvervlad changed the title Add useCanvas method to RuntimeGamePixiRenderer for external canvas usage Add method to RuntimeGamePixiRenderer for external canvas usage Nov 29, 2024
@danvervlad danvervlad changed the title Add method to RuntimeGamePixiRenderer for external canvas usage Add external canvas usage to RuntimeGamePixiRenderer Nov 29, 2024
Copy link
Owner

@4ian 4ian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Many thanks for setting up these tests, they will be helpful to ensure this continues to work in the future and that the dispose method properly get rid of DOM elements.

@4ian 4ian merged commit 35fd7e9 into 4ian:master Nov 29, 2024
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants