public LwjglApplication (ApplicationListener listener, LwjglApplicationConfiguration config) { this(listener, config, new LwjglGraphics(config)); }
void create () { try { graphics.setupDisplay(); listener.resize(Math.max(1, graphics.getWidth()), Math.max(1, graphics.getHeight())); int lastWidth = Math.max(1, graphics.getWidth()); int lastHeight = Math.max(1, graphics.getHeight());
@Override public void mouseEntered (MouseEvent e) { touchX = e.getX(); touchY = e.getY(); checkCatched(e); lwjglAwtCanvas.graphics.requestRendering(); }
/** * Only needed when setupDisplay() is not called. */ void initiateGL() { extractVersion(); extractExtensions(); initiateGLInstances(); }
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); } }
graphics.setupDisplay(); } catch (LWJGLException e) { throw new GdxRuntimeException(e); graphics.resize = true; int lastWidth = graphics.getWidth(); int lastHeight = graphics.getHeight(); Gdx.gl.glViewport(0, 0, graphics.config.width, graphics.config.height); if (listener != null) listener.resize(graphics.config.width, graphics.config.height); graphics.requestRendering(); shouldRender |= graphics.shouldRender(); input.processEvents(); if (audio != null) audio.update(); int frameRate = isActive ? graphics.config.foregroundFPS : graphics.config.backgroundFPS; if (shouldRender) { graphics.updateTime(); graphics.frameId++; listener.render();
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); }
displayCreated = setWindowedMode(config.width, config.height); } else { DisplayMode bestMode = null; for(DisplayMode mode: getDisplayModes()) { if(mode.width == config.width && mode.height == config.height) { if(bestMode == null || bestMode.refreshRate < this.getDisplayMode().refreshRate) { bestMode = mode; bestMode = this.getDisplayMode(); displayCreated = setFullscreenMode(bestMode); config = config.setDisplayModeCallback.onFailure(config); if (config != null) { displayCreated = setWindowedMode(config.width, config.height); createDisplayPixelFormat(config.useGL30, config.gles30ContextMajorVersion, config.gles30ContextMinorVersion); initiateGL();
@Override public void run () { graphics.setVSync(graphics.config.vSyncEnabled); try { LwjglApplication.this.mainLoop(); } catch (Throwable t) { if (audio != null) audio.dispose(); Gdx.input.setCursorCatched(false); if (t instanceof RuntimeException) throw (RuntimeException)t; else throw new GdxRuntimeException(t); } } };
System.out.println("LwjglGraphics: OpenGL " + gles30ContextMajor + "." + gles30ContextMinor + "+ core profile (GLES 3.0) not supported."); createDisplayPixelFormat(false, gles30ContextMajor, gles30ContextMinor); return; if (getDisplayMode().bitsPerPixel == 16) { bufferFormat = new BufferFormat(5, 6, 5, 0, 16, 8, 0, false); if (getDisplayMode().bitsPerPixel == 24) { bufferFormat = new BufferFormat(8, 8, 8, 0, 16, 8, 0, false); if (getDisplayMode().bitsPerPixel == 32) { bufferFormat = new BufferFormat(8, 8, 8, 8, 16, 8, 0, false); softwareMode = true; System.setProperty("org.lwjgl.opengl.Display.allowSoftwareOpenGL", "true"); createDisplayPixelFormat(useGL30, gles30ContextMajor, gles30ContextMinor); return; if (getDisplayMode().bitsPerPixel == 16) { bufferFormat = new BufferFormat(5, 6, 5, 0, 8, 0, 0, false); if (getDisplayMode().bitsPerPixel == 24) { bufferFormat = new BufferFormat(8, 8, 8, 0, 8, 0, 0, false); if (getDisplayMode().bitsPerPixel == 32) { bufferFormat = new BufferFormat(8, 8, 8, 8, 8, 0, 0, false);
@Override public int getBackBufferWidth () { return getWidth(); }
@Override public int getBackBufferHeight () { return getHeight(); }
graphics.setupDisplay(); } catch (LWJGLException e) { throw new GdxRuntimeException(e); graphics.resize = true; int lastWidth = graphics.getWidth(); int lastHeight = graphics.getHeight(); Gdx.gl.glViewport(0, 0, graphics.config.width, graphics.config.height); if (listener != null) listener.resize(graphics.config.width, graphics.config.height); graphics.requestRendering(); shouldRender |= graphics.shouldRender(); input.processEvents(); if (audio != null) audio.update(); int frameRate = isActive ? graphics.config.foregroundFPS : graphics.config.backgroundFPS; if (shouldRender) { graphics.updateTime(); graphics.frameId++; listener.render();
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); }
displayCreated = setWindowedMode(config.width, config.height); } else { DisplayMode bestMode = null; for(DisplayMode mode: getDisplayModes()) { if(mode.width == config.width && mode.height == config.height) { if(bestMode == null || bestMode.refreshRate < this.getDisplayMode().refreshRate) { bestMode = mode; bestMode = this.getDisplayMode(); displayCreated = setFullscreenMode(bestMode); config = config.setDisplayModeCallback.onFailure(config); if (config != null) { displayCreated = setWindowedMode(config.width, config.height); createDisplayPixelFormat(config.useGL30, config.gles30ContextMajorVersion, config.gles30ContextMinorVersion); initiateGL();
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); } }
/** * Only needed when setupDisplay() is not called. */ void initiateGL() { extractVersion(); extractExtensions(); initiateGLInstances(); }
@Override public void run () { graphics.setVSync(graphics.config.vSyncEnabled); try { LwjglApplication.this.mainLoop(); } catch (Throwable t) { if (audio != null) audio.dispose(); Gdx.input.setCursorCatched(false); if (t instanceof RuntimeException) throw (RuntimeException)t; else throw new GdxRuntimeException(t); } } };