public static void main(String[] args) { SpringApplication.run(HeadlessServerLauncher.class, args); ServerSettings.isHeadless = true; LwjglNativesLoader.load(); Gdx.files = new LwjglFiles(); HeadlessNativesLoader.load(); MockGraphics mockGraphics = new MockGraphics(); Gdx.graphics = mockGraphics; HeadlessNet headlessNet = new HeadlessNet(); Gdx.net = headlessNet; Gdx.gl = new NullGL20(); Gdx.gl20 = new NullGL20(); Gdx.gl30 = new NullGL30(); HeadlessApplicationConfiguration config = new HeadlessApplicationConfiguration(); new HeadlessApplication(new GameServer(), config); }
/** * Initializes a headless GDX platform for testing. */ public static synchronized void init() { if (Gdx.gl instanceof MockGL) { // Already initialized return; } HeadlessNativesLoader.load(); Gdx.app = new GdxAppStub(); Gdx.files = new HeadlessFiles(); Gdx.net = new HeadlessNet(); Gdx.graphics = new MockGraphics(); Gdx.gl20 = MockGL.newInstance(); Gdx.gl = Gdx.gl20; Gdx.audio = new MockAudio(); Gdx.input = new MockInput(); }
public HeadlessApplication(ApplicationListener listener, HeadlessApplicationConfiguration config) { if (config == null) config = new HeadlessApplicationConfiguration(); HeadlessNativesLoader.load(); this.listener = listener; this.files = new HeadlessFiles(); this.net = new HeadlessNet(); // the following elements are not applicable for headless applications // they are only implemented as mock objects this.graphics = new MockGraphics(); this.audio = new MockAudio(); this.input = new MockInput(); Gdx.app = this; Gdx.files = files; Gdx.net = net; Gdx.audio = audio; Gdx.graphics = graphics; Gdx.input = input; renderInterval = config.renderInterval > 0 ? (long)(config.renderInterval * 1000000000f) : (config.renderInterval < 0 ? -1 : 0); initialize(); }