public LwjglAWTInput (LwjglAWTCanvas lwjglAwtCanvas) { this.lwjglAwtCanvas = lwjglAwtCanvas; setListeners(lwjglAwtCanvas.getCanvas()); try { robot = new Robot(GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()); } catch (HeadlessException e) { } catch (AWTException e) { } }
@Override public void initGL () { create(); }
void create () { try { setGlobals(); graphics.initiateGL(); canvas.setVSyncEnabled(graphics.config.vSyncEnabled); listener.create(); lastWidth = Math.max(1, graphics.getWidth()); lastHeight = Math.max(1, graphics.getHeight()); listener.resize(lastWidth, lastHeight); start(); } catch (Throwable ex) { stopped(); exception(ex); } }
/** Make the canvas' context current. It is highly recommended that the context is only made current inside the AWT thread (for * example in an overridden paintGL()). */ public void makeCurrent () { try { canvas.makeCurrent(); setGlobals(); } catch (Throwable ex) { exception(ex); } }
void render (boolean shouldRender) throws LWJGLException { if (!running) return; setGlobals(); canvas.setCursor(cursor); int width = Math.max(1, graphics.getWidth()); int height = Math.max(1, graphics.getHeight()); if (lastWidth != width || lastHeight != height) { lastWidth = width; lastHeight = height; Gdx.gl.glViewport(0, 0, lastWidth, lastHeight); resize(width, height); listener.resize(width, height); shouldRender = true; } if (executeRunnables()) shouldRender = true; // If one of the runnables set running to false, for example after an exit(). if (!running) return; shouldRender |= graphics.shouldRender(); input.processEvents(); if (audio != null) audio.update(); if (shouldRender) { graphics.updateTime(); graphics.frameId++; listener.render(); canvas.swapBuffers(); } Display.sync(getFrameRate() * instanceCount); }
public void stop () { if (!running) return; running = false; setGlobals(); Array<LifecycleListener> listeners = lifecycleListeners; // To allow destroying of OpenGL textures during disposal. if (canvas.isDisplayable()) { makeCurrent(); } else { error(logTag, "OpenGL context destroyed before application listener has had a chance to dispose of textures."); } synchronized (listeners) { for (LifecycleListener listener : listeners) { listener.pause(); listener.dispose(); } } listener.pause(); listener.dispose(); Gdx.app = null; Gdx.graphics = null; if (audio != null) { audio.dispose(); Gdx.audio = null; } if (files != null) Gdx.files = null; if (net != null) Gdx.net = null; instanceCount--; stopped(); }
setApplicationLogger(new LwjglApplicationLogger()); instanceCount++; exception(ex); return; if (Gdx.net == null) net = new LwjglNet(config); input = new LwjglAWTInput(this); setGlobals();
@Override public void debug (String tag, String message, Throwable exception) { if (logLevel >= LOG_DEBUG) getApplicationLogger().debug(tag, message, exception); }
protected int getFrameRate () { int frameRate = isActive() ? graphics.config.foregroundFPS : graphics.config.backgroundFPS; if (frameRate == -1) frameRate = 10; if (frameRate == 0) frameRate = graphics.config.backgroundFPS; if (frameRate == 0) frameRate = 30; return frameRate; }
/** Test whether the canvas' context is current. */ public boolean isCurrent () { try { return canvas.isCurrent(); } catch (Throwable ex) { exception(ex); return false; } }
@Override public long getNativeHeap () { return getJavaHeap(); }
void render (boolean shouldRender) throws LWJGLException { if (!running) return; setGlobals(); canvas.setCursor(cursor); int width = Math.max(1, graphics.getWidth()); int height = Math.max(1, graphics.getHeight()); if (lastWidth != width || lastHeight != height) { lastWidth = width; lastHeight = height; Gdx.gl.glViewport(0, 0, lastWidth, lastHeight); resize(width, height); listener.resize(width, height); shouldRender = true; } if (executeRunnables()) shouldRender = true; // If one of the runnables set running to false, for example after an exit(). if (!running) return; shouldRender |= graphics.shouldRender(); input.processEvents(); if (audio != null) audio.update(); if (shouldRender) { graphics.updateTime(); graphics.frameId++; listener.render(); canvas.swapBuffers(); } Display.sync(getFrameRate() * instanceCount); }
public void stop () { if (!running) return; running = false; setGlobals(); Array<LifecycleListener> listeners = lifecycleListeners; // To allow destroying of OpenGL textures during disposal. if (canvas.isDisplayable()) { makeCurrent(); } else { error(logTag, "OpenGL context destroyed before application listener has had a chance to dispose of textures."); } synchronized (listeners) { for (LifecycleListener listener : listeners) { listener.pause(); listener.dispose(); } } listener.pause(); listener.dispose(); Gdx.app = null; Gdx.graphics = null; if (audio != null) { audio.dispose(); Gdx.audio = null; } if (files != null) Gdx.files = null; if (net != null) Gdx.net = null; instanceCount--; stopped(); }
setApplicationLogger(new LwjglApplicationLogger()); instanceCount++; exception(ex); return; if (Gdx.net == null) net = new LwjglNet(config); input = new LwjglAWTInput(this); setGlobals();
@Override public void log (String tag, String message, Throwable exception) { if (logLevel >= LOG_INFO) getApplicationLogger().log(tag, message, exception); }
/** Make the canvas' context current. It is highly recommended that the context is only made current inside the AWT thread (for * example in an overridden paintGL()). */ public void makeCurrent () { try { canvas.makeCurrent(); setGlobals(); } catch (Throwable ex) { exception(ex); } }
protected int getFrameRate () { int frameRate = isActive() ? graphics.config.foregroundFPS : graphics.config.backgroundFPS; if (frameRate == -1) frameRate = 10; if (frameRate == 0) frameRate = graphics.config.backgroundFPS; if (frameRate == 0) frameRate = 30; return frameRate; }
/** Test whether the canvas' context is current. */ public boolean isCurrent () { try { return canvas.isCurrent(); } catch (Throwable ex) { exception(ex); return false; } }