protected void initInThread() { created.set(true); logger.info("OGLESContext create"); logger.log(Level.INFO, "Running on thread: {0}", Thread.currentThread().getName()); // Setup unhandled Exception Handler Thread.currentThread() .setUncaughtExceptionHandler( new Thread.UncaughtExceptionHandler() { public void uncaughtException(Thread thread, Throwable thrown) { listener.handleError("Exception thrown in " + thread.toString(), thrown); } }); if (clientOpenGLESVersion < 2) { throw new UnsupportedOperationException("OpenGL ES 2.0 is not supported on this device"); } timer = new AndroidTimer(); renderer = new OGLESShaderRenderer(); renderer.initialize(); listener.initialize(); JmeSystem.setSoftTextDialogInput(this); needClose.set(false); renderable.set(true); }
// SystemListener:update @Override public void onDrawFrame(GL10 gl) { if (needClose.get()) { deinitInThread(); return; } if (renderable.get()) { if (!created.get()) { throw new IllegalStateException("onDrawFrame without create"); } long milliStart = System.currentTimeMillis(); listener.update(); if (autoFlush) { renderer.onFrame(); } long milliDelta = System.currentTimeMillis() - milliStart; // Enforce a FPS cap if (milliDelta < minFrameDuration) { // logger.log(Level.INFO, "Time per frame {0}", milliDelta); try { Thread.sleep(minFrameDuration - milliDelta); } catch (InterruptedException e) { } } } }
protected void waitFor(boolean createdVal) { while (renderable.get() != createdVal) { try { Thread.sleep(10); } catch (InterruptedException ex) { } } }