public LwjglApplication (ApplicationListener listener, LwjglApplicationConfiguration config, LwjglGraphics graphics) { LwjglNativesLoader.load(); if (config.title == null) config.title = listener.getClass().getSimpleName(); this.graphics = graphics; if (!LwjglApplicationConfiguration.disableAudio) audio = new OpenALAudio(config.audioDeviceSimultaneousSources, config.audioDeviceBufferCount, config.audioDeviceBufferSize); files = new LwjglFiles(); input = new LwjglInput(); net = new LwjglNet(); this.listener = listener; this.preferencesdir = config.preferencesDirectory; Gdx.app = this; Gdx.graphics = graphics; Gdx.audio = audio; Gdx.files = files; Gdx.input = input; Gdx.net = net; initialize(); }
private void initialiseLibGDX() { if (!LwjglApplicationConfiguration.disableAudio) { try { audio = new OpenALAudio(config.audioDeviceSimultaneousSources, config.audioDeviceBufferCount, config.audioDeviceBufferSize); } catch (Throwable t) { log("LwjglApplication", "Couldn't initialize audio, disabling audio", t); LwjglApplicationConfiguration.disableAudio = true; } } preferencesdir = config.preferencesDirectory; Gdx.app = this; Gdx.graphics = graphics; Gdx.audio = audio; Gdx.files = files; Gdx.input = input; Gdx.net = net; }
@Override protected AudioDevice createAudioDevice() { // It could be done like this : // AudioDevice device = Gdx.audio.newAudioDevice(config.sampleRate, config.outputChannels < 2); // but we need to align buffer size : Pd.process and device.write. int samplePerFrame = config.bufferSize; int samplePerBuffer = samplePerFrame * config.outputChannels; int bufferSizeBytes = samplePerBuffer * 2; return new OpenALAudioDevice((OpenALAudio)Gdx.audio, config.sampleRate, config.outputChannels<2, bufferSizeBytes, config.bufferCount); }
public static void init() { try { Field field = OpenALAudio.class.getDeclaredField("soundIdToSource"); field.setAccessible(true); soundIdToSource = (LongMap<Integer>) field.get(Gdx.audio); } catch (Exception e) { throw new RuntimeException("Error getting soundIdToSource", e); } }
/** * Starts the game loop and initializes OpenAL and other H4X dependant * stuff as overriding initialization was impossible... H4X FTW! */ @Override protected void start() { LwjglNativesLoader.load(); audio = new OpenALAudio(audioDeviceSimultaneousSources, audioDeviceBufferCount, audioDeviceBufferSize); Gdx.audio = audio; hiddenFPS = config.hiddenFPS; foregroundFPS = config.foregroundFPS; backgroundFPS = config.backgroundFPS; super.start(); }
private void initialize (ApplicationListener listener, LwjglApplicationConfiguration config) { LwjglNativesLoader.load(); canvas = new Canvas() { private final Dimension minSize = new Dimension(1, 1); public final void addNotify () { super.addNotify(); if (SharedLibraryLoader.isMac) { EventQueue.invokeLater(new Runnable() { public void run () { create(); } }); } else create(); } public final void removeNotify () { stop(); super.removeNotify(); } public Dimension getMinimumSize () { return minSize; } }; canvas.setSize(1, 1); canvas.setIgnoreRepaint(true); graphics = new LwjglGraphics(canvas, config) { public void setTitle (String title) { super.setTitle(title); LwjglCanvas.this.setTitle(title); } public boolean setDisplayMode (int width, int height, boolean fullscreen) { if (!super.setDisplayMode(width, height, fullscreen)) return false; if (!fullscreen) LwjglCanvas.this.setDisplayMode(width, height); return true; } public boolean setDisplayMode (DisplayMode displayMode) { if (!super.setDisplayMode(displayMode)) return false; LwjglCanvas.this.setDisplayMode(displayMode.width, displayMode.height); return true; } }; graphics.setVSync(config.vSyncEnabled); if (!LwjglApplicationConfiguration.disableAudio) audio = new OpenALAudio(); files = new LwjglFiles(); input = new LwjglInput(); net = new LwjglNet(); this.listener = listener; Gdx.app = this; Gdx.graphics = graphics; Gdx.audio = audio; Gdx.files = files; Gdx.input = input; Gdx.net = net; }