public void stop() { if (!active) return; active = false; currentFrame = 0; endCallback.invoke(); }
public void pause() { if (!active) return; active = false; pauseCallback.invoke(); }
@Override public void onDrawFrame(GL10 gl) { loopFrame.invoke(); } }
@Override public void onSurfaceChanged(GL10 gl, int width, int height) { resized.invoke(); }
public static void forceRenderTasks(float delta) { synchronized (renderTasksLock) { SimpleCallback task; while ((task = renderTasks.poll()) != null) task.invoke(); } }
public static void forceUpdateTasks(float deltaTime) { synchronized (updateTasksLock) { SimpleCallback task; while ((task = updateTasks.poll()) != null) task.invoke(); } }
@Override protected void onPostExecute(SimpleCallback result) { if (!isCancelled()) result.invoke(); } }
@Override public void setIcon(FilePath filePath, SimpleCallback callback, UniCallback<Throwable> error) { setIcon(filePath.getPath()); callback.invoke(); }
private static UniCallback<SimpleCallback> chainCallback(UniCallback<SimpleCallback> newCB, UniCallback<SimpleCallback> oldCB) { // Create a new callback that chains the new callback and the old callback return (finalCallback) -> { // If the new callback is null, that means we are at the end of the initializer chains. // So call the final callback. if (newCB == null) finalCallback.invoke(); // Otherwise call the new callback which invokes the old callback and passes the finalCallback. else newCB.invoke(() -> oldCB.invoke(finalCallback)); }; }
@Override public void update(float delta) { if (!loader.isActive() && fontRenderer != null && font != null && dynamicProgram != null) loader.start(); if (loader.isDone()) doneCallback.invoke(); }
/** * Sets the icon for the window. * * @param imagePath The image to be used as an icon. * @param success The callback to be called upon successful icon set. * @param error The callback to be called upon an error. */ public void setIcon(FilePath imagePath, SimpleCallback success, UniCallback<Throwable> error) { SilenceEngine.io.getImageReader().readImage(imagePath, image -> { setIcon(image); success.invoke(); }, error); }
/** * Sets the icon for the window. * * @param imagePath The image to be used as an icon. * @param success The callback to be called upon successful icon set. */ public void setIcon(FilePath imagePath, SimpleCallback success) { SilenceEngine.io.getImageReader().readImage(imagePath, image -> { setIcon(image); success.invoke(); }); }
/** * Initializes SilenceEngine. Not to be called by the users, but will be called by the backends once the devices are * initialized. * * @param success Callback to be called after successful loading. */ public static void init(SimpleCallback success) { // Queue the default initializations (we call add directly since engine callbacks need to be the first). // All the callbacks registered by the user are called after the engine init callbacks are executed. callbacksOnInit.add(IGraphicsDevice::init); // Build the callback list to be called after initialization UniCallback<SimpleCallback> callbackOnInit = chainCallback(null, null); for (UniCallback<SimpleCallback> callback : callbacksOnInit) callbackOnInit = chainCallback(callback, callbackOnInit); // Call all the callbacks that are registered by extensions callbackOnInit.invoke(() -> { SilenceEngine.log.getRootLogger().info("Finished initialization, starting game"); success.invoke(); callbacksOnInit.clear(); }); }
@Override public void onSurfaceCreated(GL10 gl, EGLConfig config) { loopFrame = () -> { // Assume 100 seconds so that tasks are force flushed TaskManager.forceUpdateTasks(100); TaskManager.forceRenderTasks(100); }; resized = () -> { }; SilenceEngine.eventManager.clearAllHandlers(); SilenceEngine.gameLoop.onFocusLost(); startCallback.invoke(); }
function.invoke();
next.invoke(); }); });
LwjglInputDevice.pollControllers(); performLoopFrame[0].invoke(); window.swapBuffers();