/** * Request destruction of the Context. If the context is current, no context will be current after this call. * The context is destroyed when no thread has it current. */ public synchronized void destroy() throws LWJGLException { if ( destroyed ) return; destroy_requested = true; boolean was_current = isCurrent(); int error = GLES20.GL_NO_ERROR; if ( was_current ) { if ( org.lwjgl.opengles.GLContext.getCapabilities() != null && GLContext.getCapabilities().OpenGLES20 ) error = GLES20.glGetError(); try { releaseCurrent(); } catch (PowerManagementEventException e) { // Ignore } } checkDestroy(); if ( was_current && error != GLES20.GL_NO_ERROR ) throw new OpenGLException(error); }
/** Release the current context (if any). After this call, no context is current. */ public void releaseCurrent() throws LWJGLException, PowerManagementEventException { eglReleaseCurrent(drawable.getEGLDisplay()); org.lwjgl.opengles.GLContext.useContext(null); current_context_local.set(null); synchronized ( this ) { thread = null; checkDestroy(); } }
/** Make the context current */ public synchronized void makeCurrent() throws LWJGLException, PowerManagementEventException { checkAccess(); if ( destroyed ) throw new IllegalStateException("Context is destroyed"); thread = Thread.currentThread(); current_context_local.set(this); eglContext.makeCurrent(drawable.getEGLSurface()); org.lwjgl.opengles.GLContext.useContext(this); }
private void switchMode() throws LWJGLException { mode = findDisplayMode(1024, 600, Display.getDisplayMode().getBitsPerPixel()); try { Display.setDisplayModeAndFullscreen(mode); } catch (PowerManagementEventException e) { e.printStackTrace(); } }
/** Runs the main loop of the "test" */ private void mainLoop() { while ( !Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) && !Display.isCloseRequested() ) { if ( Display.isVisible() ) { // check keyboard input processKeyboard(); // do "game" logic, and render it logic(); render(); } else { // no need to render/paint if nothing has changed (ie. window // dragged over) if ( Display.isDirty() ) { render(); } // don't waste cpu time, sleep more try { Thread.sleep(100); } catch (InterruptedException inte) { } } // Update window try { Display.update(); Display.sync(60); } catch (PowerManagementEventException e) { e.printStackTrace(); } } }
/** Swap the buffers on the current context. Only valid for double-buffered contexts */ public static void swapBuffers() throws LWJGLException, PowerManagementEventException { ContextGLES current_context = getCurrentContext(); if ( current_context != null ) current_context.drawable.getEGLSurface().swapBuffers(); }