/** * <code>update</code> recalulates the frame rate based on the previous * call to update. It is assumed that update is called each frame. */ public void update() { long curTime = getTime(); lastTPF = (curTime - oldTime) * (1.0f / LWJGL_TIMER_RES); lastFPS = 1.0f / lastTPF; oldTime = curTime; }
private ByteBuffer[] imagesToByteBuffers(Object[] images) { ByteBuffer[] out = new ByteBuffer[images.length]; for (int i = 0; i < images.length; i++) { BufferedImage image = (BufferedImage) images[i]; out[i] = imageToByteBuffer(image); } return out; }
/** * Convert array of images to array of {@link GLFWImage}. */ private GLFWImage[] imagesToGLFWImages(final Object[] images) { final GLFWImage[] out = new GLFWImage[images.length]; for (int i = 0; i < images.length; i++) { final BufferedImage image = (BufferedImage) images[i]; out[i] = imageToGLFWImage(image); } return out; }
public void internalCreate() { timer = new LwjglTimer(); synchronized (createdLock) { created.set(true); createdLock.notifyAll(); } if (renderable.get()) { initContextFirstTime(); } else { assert getType() == Type.Canvas; } }
/** * De-initialize in the OpenGL thread. */ protected void deinitInThread(){ destroyContext(); listener.destroy(); logger.fine("Display destroyed."); super.internalDestroy(); }
/** * De-initialize in the OpenGL thread. */ protected void deinitInThread() { listener.destroy(); destroyContext(); super.internalDestroy(); LOGGER.fine("Display destroyed."); }
public void destroy() { destroy(false); }
public void create() { create(false); }
/** * Hide the active cursor within the display. */ public void hideActiveCursor() { if (!context.isRenderable()) { return; } if (cursorVisible) { glfwSetInputMode(context.getWindowHandle(), GLFW_CURSOR, GLFW_CURSOR_HIDDEN); } }
public LwjglCanvas(){ super(); canvas = new GLCanvas(); }
public void destroy(boolean waitFor){ needClose.set(true); if (waitFor) waitFor(false); }
/** * Constructor builds a <code>Timer</code> object. All values will be * initialized to its default values. */ public LwjglTimer() { reset(); logger.log(Level.FINE, "Timer resolution: {0} ticks per second", LWJGL_TIMER_RES); }
/** * De-initialize in the OpenGL thread. */ protected void deinitInThread() { listener.destroy(); destroyContext(); super.internalDestroy(); LOGGER.fine("Display destroyed."); }
public void setCursorVisible(boolean visible){ cursorVisible = visible; if (!context.isRenderable()) return; Mouse.setGrabbed(!visible); }
/** * Create the context. */ public void create() { create(false); }
/** * Destroy the context. */ public void destroy() { destroy(false); }
public void destroy() { destroy(false); }
public void create() { create(false); }
@Override public float getTimeInSeconds() { return getTime() * INV_LWJGL_TIMER_RES; }
@Override public void setCursorVisible(boolean visible) { cursorVisible = visible; if (!context.isRenderable()) { return; } if (cursorVisible) { glfwSetInputMode(context.getWindowHandle(), GLFW_CURSOR, GLFW_CURSOR_NORMAL); } else { glfwSetInputMode(context.getWindowHandle(), GLFW_CURSOR, GLFW_CURSOR_DISABLED); } }