/** * Crates a window and its associated OpenGL context, by taking into account the resolution of the screen and the * monitor that the window should be made full screen on, and another window if you want to share the context of the * other window. * * @param width The desired width, in screen coordinates, of the window. This must be greater than zero. * @param height The desired height, in screen coordinates, of the window. This must be greater than zero. * @param monitor The monitor to use for full screen mode, or {@code null} to use windowed mode. * @param share The window whose context to share resources with, or {@code null} to not share resources. */ public Window(int width, int height, Monitor monitor, Window share) { this(width, height, "SilenceEngine Window | SilenceEngine " + SilenceEngine.getVersionString(), monitor, share); }
public static void start(Game game) { SilenceEngine.log = new GwtLogDevice(); SilenceEngine.display = new GwtDisplayDevice(); SilenceEngine.input = new GwtInputDevice(); SilenceEngine.io = new GwtIODevice(); SilenceEngine.graphics = new GwtGraphicsDevice(); SilenceEngine.audio = new GwtAudioDevice(); SilenceEngine.display.setTitle("SilenceEngine " + SilenceEngine.getVersionString()); SilenceEngine.display.setIcon(FilePath.getResourceFile("engine_resources/icon.png")); SilenceEngine.init(() -> { game.init(); // Prevent fullscreen requests in init SilenceEngine.display.setFullscreen(false); AnimationScheduler.get().requestAnimationFrame(GwtRuntime::frameLoop); }); }
SilenceEngine.init(() ->
/** * 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(); }); }
SilenceEngine.init(() ->