Console support for libGDX is a hotly debated topic. This page tries to give a broad overview of how you might go about getting your game to work on your favourite consoles, including Xbox, PlayStation and Nintendo Switch.
The General Idea
The main obstacle of getting libGDX games to run on consoles is that there is no JVM for those platforms. So to overcome this, you either need to transpile your code base to a language which can run on your target platform or compile your application in such a way. Inspiration for these approaches can be drawn from libGDX’s Web backend (which uses GWT to transpile Java source code to Javascript) and iOS backend (which uses the RoboVM ahead-of-time compiler).
In addition, you need a custom libGDX backend with bindings for the device in question.
Successful Examples
There are a couple of games, which have successfully done this in the past:
- Orangepixel’s games, which are transpiled to C#[1]
- Pathway, which uses a custom fork of RoboVM and a SDL backend[2]
- Slay the Spire, which was ported by Sickhead Games first to C# and then to C++[3]
Other Resources
The following resources may also help you if you want to look into supporting libGDX on consoles:
- Graal Native Image might prove useful
- The Javascript code produced by GWT/TeaVM could be used in a UWP app; see here and here for some thoughts on this approach
- IKVM (which was used by libGDX in the past) could prove as another viable option
- Anuken’s Ark has a SDL backend here; SDL has a working port for Nintendo Switch
- TheLogicMaster has a working PoC of a Nintendo Switch homebrew backend over at SwitchGDX, which uses a custom fork of CodenameOne’s ParparVM to transpile Java code to C++
- TeaVM can also be used to generate C code, see the example here
- A similar goal is being pursued by the mini2Dx project with their KAVA transpiler.