/** * Main. * * @param args the args * @throws IOException the io exception */ public static void main(final String[] args) { // need to disable to work on macos Configuration.GLFW_CHECK_THREAD0.set(false); // use jemalloc Configuration.MEMORY_ALLOCATOR.set("jemalloc"); // JavaFX System.setProperty("prism.lcdtext", "false"); System.setProperty("prism.text", "t2k"); System.setProperty("javafx.animation.fullspeed", "false"); final EditorConfig editorConfig = EditorConfig.getInstance(); final OpenGLVersion openGLVersion = editorConfig.getOpenGLVersion(); // set a render if it isn't override if(System.getProperty("jfx.background.render") == null) { System.setProperty("jfx.background.render", openGLVersion.getRender()); } System.setProperty(LWJGLBufferAllocator.PROPERTY_CONCURRENT_BUFFER_ALLOCATOR, "true"); // some settings for the render of JavaFX System.setProperty("prism.printrendergraph", "false"); System.setProperty("javafx.pulseLogger", "false"); //System.setProperty("prism.cacheshapes", "true"); //System.setProperty("prism.scrollcacheopt", "true"); //System.setProperty("prism.allowhidpi", "true"); //System.setProperty("prism.order", "sw"); //System.setProperty("prism.showdirty", "true"); //System.setProperty("prism.showoverdraw", "true"); //System.setProperty("prism.debug", "true"); //System.setProperty("prism.verbose", "true"); CommandLineConfig.args(args); JmeToJFXApplication application; try { application = Editor.prepareToStart(); } catch (final Throwable e) { printError(e); System.exit(-1); return; } InitializeManager.register(InitializationManager.class); InitializeManager.register(ClasspathManager.class); InitializeManager.register(ResourceManager.class); InitializeManager.register(JavaFXImageManager.class); InitializeManager.register(FileIconManager.class); InitializeManager.register(WorkspaceManager.class); InitializeManager.register(PluginManager.class); InitializeManager.register(RemoteControlManager.class); InitializeManager.initialize(); new EditorThread(new ThreadGroup("LWJGL"), () -> startJMEApplication(application), "LWJGL Render").start(); }
public static void start(Game game) { // Check for -XstartOnFirstThread on Mac OS X if (getPlatform() == SilenceEngine.Platform.MACOSX) checkForXstartOnFirstThread(); Configuration.DEBUG.set(Game.DEVELOPMENT); SilenceEngine.log = new LwjglLogDevice(); SilenceEngine.io = new LwjglIODevice(); SilenceEngine.display = new LwjglDisplayDevice(); SilenceEngine.input = new LwjglInputDevice(); SilenceEngine.graphics = new LwjglGraphicsDevice(); SilenceEngine.audio = new LwjglAudioDevice(); // Set AWT fix on Mac OS X if (getPlatform() == SilenceEngine.Platform.MACOSX) System.setProperty("java.awt.headless", "true"); Window window = ((LwjglDisplayDevice) SilenceEngine.display).window; final SimpleCallback[] performLoopFrame = { () -> { // Assume 100 seconds so that tasks are force flushed TaskManager.forceUpdateTasks(100); TaskManager.forceRenderTasks(100); } }; final boolean[] gameDone = { false }; // Stop events from happening until game is initialized SilenceEngine.eventManager.waitUntil(() -> gameDone[0]); // Initiate setting the icon SilenceEngine.display.setIcon(FilePath.getResourceFile("engine_resources/icon.png"), () -> { // Initialize SilenceEngine SilenceEngine.init(() -> { // Call the game's init method game.init(); gameDone[0] = true; // Replace the callback so that we now perform the game loop instead of flushing // tasks in TaskManager. performLoopFrame[0] = SilenceEngine.gameLoop::performLoopFrame; // Raise a resize event now SilenceEngine.eventManager.raiseResizeEvent(); }); }); // The native event loop while (!window.shouldClose()) { GLFW3.pollEvents(); LwjglInputDevice.pollControllers(); performLoopFrame[0].invoke(); window.swapBuffers(); } // Raise the dispose event finally SilenceEngine.eventManager.raiseDisposeEvent(); }