Search code examples
javalibgdx

Noob question using legacy LWJGL with canvas


Just installed libGDX & android studio yesterday. My boss wants to use libGDX & javaFX (for UI) together in a project.

My assumptions: It sounds like I can do that by using a canvas. LWJGL3 does not support a canvas backend. So i need to use the legacy LWJGL2

My question: How in an existing project do I add legacy support and the libraries?

My current compile is failing with: error: package com.badlogic.gdx.backends.lwjgl does not exist import com.badlogic.gdx.backends.lwjgl.LwjglAWTCanvas


Solution

  • There are instructions here for migrating from lwjgl2 to lwjgl3, so you can follow them in reverse.

    Basically, change your module's dependency from com.badlogicgames.gdx:gdx-backend-lwjgl3 to com.badlogicgames.gdx:gdx-backend-lwjgl and change your launcher class to use LwjglApplication instead of Lwjgl3Application. The associated application configuration class works a bit differently, too. It uses public fields instead of setter methods.