Search in sources :

Example 1 with Lwjgl3Graphics

use of com.badlogic.gdx.backends.lwjgl3.Lwjgl3Graphics in project skin-composer by raeleus.

the class Uninstaller method dragWindow.

@Override
public void dragWindow(int x, int y) {
    Lwjgl3Window window = ((Lwjgl3Graphics) Gdx.graphics).getWindow();
    window.setPosition(x, y);
}
Also used : Lwjgl3Graphics(com.badlogic.gdx.backends.lwjgl3.Lwjgl3Graphics) Lwjgl3Window(com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window)

Example 2 with Lwjgl3Graphics

use of com.badlogic.gdx.backends.lwjgl3.Lwjgl3Graphics in project skin-composer by raeleus.

the class Installer method dragWindow.

@Override
public void dragWindow(int x, int y) {
    Lwjgl3Window window = ((Lwjgl3Graphics) Gdx.graphics).getWindow();
    window.setPosition(x, y);
}
Also used : Lwjgl3Graphics(com.badlogic.gdx.backends.lwjgl3.Lwjgl3Graphics) Lwjgl3Window(com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window)

Example 3 with Lwjgl3Graphics

use of com.badlogic.gdx.backends.lwjgl3.Lwjgl3Graphics in project gaiasky by langurmonkey.

the class GuiRegistry method notify.

@Override
public void notify(final Event event, Object source, final Object... data) {
    if (current != null) {
        Stage ui = current.getGuiStage();
        // Treats windows that can appear in any GUI
        switch(event) {
            case SHOW_SEARCH_ACTION:
                if (searchDialog == null) {
                    searchDialog = new SearchDialog(skin, ui, sceneGraph, true);
                } else {
                    searchDialog.clearText();
                }
                if (!searchDialog.isVisible() | !searchDialog.hasParent())
                    searchDialog.show(ui);
                break;
            case SHOW_QUIT_ACTION:
                if (!removeModeChangePopup() && !removeControllerGui()) {
                    if (GLFW.glfwGetInputMode(((Lwjgl3Graphics) Gdx.graphics).getWindow().getWindowHandle(), GLFW.GLFW_CURSOR) == GLFW.GLFW_CURSOR_DISABLED) {
                        // Release mouse if captured
                        GLFW.glfwSetInputMode(((Lwjgl3Graphics) Gdx.graphics).getWindow().getWindowHandle(), GLFW.GLFW_CURSOR, GLFW.GLFW_CURSOR_NORMAL);
                    } else {
                        Runnable quitRunnable = data.length > 0 ? (Runnable) data[0] : null;
                        if (Settings.settings.program.exitConfirmation) {
                            QuitWindow quit = new QuitWindow(ui, skin);
                            if (data.length > 0) {
                                quit.setAcceptRunnable(quitRunnable);
                            }
                            quit.show(ui);
                        } else {
                            if (quitRunnable != null)
                                quitRunnable.run();
                            GaiaSky.postRunnable(() -> Gdx.app.exit());
                        }
                    }
                }
                break;
            case CAMERA_MODE_CMD:
                removeModeChangePopup();
                break;
            case SHOW_ABOUT_ACTION:
                if (aboutWindow == null)
                    aboutWindow = new AboutWindow(ui, skin);
                if (!aboutWindow.isVisible() || !aboutWindow.hasParent())
                    aboutWindow.show(ui);
                break;
            case SHOW_PREFERENCES_ACTION:
                Array<Actor> prefs = getElementsOfType(PreferencesWindow.class);
                if (prefs.isEmpty()) {
                    if (preferencesWindow == null) {
                        preferencesWindow = new PreferencesWindow(ui, skin, GaiaSky.instance.getGlobalResources());
                    }
                    if (!preferencesWindow.isVisible() || !preferencesWindow.hasParent())
                        preferencesWindow.show(ui);
                } else {
                    // Close current windows
                    for (Actor pref : prefs) {
                        if (pref instanceof PreferencesWindow) {
                            ((PreferencesWindow) pref).cancel();
                            ((PreferencesWindow) pref).hide();
                        }
                    }
                }
                break;
            case SHOW_PER_OBJECT_VISIBILITY_ACTION:
                if (indVisWindow == null) {
                    final ISceneGraph sg = GaiaSky.instance.sceneGraph;
                    indVisWindow = new IndividualVisibilityWindow(sg, ui, skin);
                }
                if (!indVisWindow.isVisible() || !indVisWindow.hasParent())
                    indVisWindow.show(ui);
                break;
            case SHOW_SLAVE_CONFIG_ACTION:
                if (MasterManager.hasSlaves()) {
                    if (slaveConfigWindow == null)
                        slaveConfigWindow = new SlaveConfigWindow(ui, skin);
                    if (!slaveConfigWindow.isVisible() || !slaveConfigWindow.hasParent())
                        slaveConfigWindow.show(ui);
                }
                break;
            case SHOW_LOAD_CATALOG_ACTION:
                if (lastOpenLocation == null && Settings.settings.program.fileChooser.lastLocation != null && !Settings.settings.program.fileChooser.lastLocation.isEmpty()) {
                    try {
                        lastOpenLocation = Paths.get(Settings.settings.program.fileChooser.lastLocation);
                    } catch (Exception e) {
                        lastOpenLocation = null;
                    }
                }
                if (lastOpenLocation == null) {
                    lastOpenLocation = SysUtils.getUserHome();
                } else if (!Files.exists(lastOpenLocation) || !Files.isDirectory(lastOpenLocation)) {
                    lastOpenLocation = SysUtils.getHomeDir();
                }
                FileChooser fc = new FileChooser(I18n.txt("gui.loadcatalog"), skin, ui, lastOpenLocation, FileChooser.FileChooserTarget.FILES);
                fc.setShowHidden(Settings.settings.program.fileChooser.showHidden);
                fc.setShowHiddenConsumer((showHidden) -> Settings.settings.program.fileChooser.showHidden = showHidden);
                fc.setAcceptText(I18n.txt("gui.loadcatalog"));
                fc.setFileFilter(pathname -> pathname.getFileName().toString().endsWith(".vot") || pathname.getFileName().toString().endsWith(".csv") || pathname.getFileName().toString().endsWith(".fits") || pathname.getFileName().toString().endsWith(".json"));
                fc.setAcceptedFiles("*.vot, *.csv, *.fits, *.json");
                fc.setResultListener((success, result) -> {
                    if (success) {
                        if (Files.exists(result) && Files.exists(result)) {
                            // Load selected file
                            try {
                                String fileName = result.getFileName().toString();
                                if (fileName.endsWith(".json")) {
                                    // Load internal JSON catalog file
                                    GaiaSky.instance.getExecutorService().execute(() -> {
                                        try {
                                            logger.info(I18n.txt("notif.catalog.loading", fileName));
                                            final Array<SceneGraphNode> objects = SceneGraphJsonLoader.loadJsonFile(Gdx.files.absolute(result.toAbsolutePath().toString()));
                                            logger.info(I18n.txt("notif.catalog.loaded", objects.size, I18n.txt("gui.objects")));
                                            GaiaSky.postRunnable(() -> {
                                                // THIS WILL BLOCK
                                                for (SceneGraphNode node : objects) {
                                                    node.initialize();
                                                }
                                                for (SceneGraphNode node : objects) {
                                                    EventManager.publish(Event.SCENE_GRAPH_ADD_OBJECT_NO_POST_CMD, this, node, true);
                                                }
                                                while (!GaiaSky.instance.assetManager.isFinished()) {
                                                    // Busy wait
                                                    try {
                                                        Thread.sleep(100);
                                                    } catch (InterruptedException e) {
                                                        logger.error(e);
                                                    }
                                                }
                                                for (SceneGraphNode node : objects) {
                                                    node.doneLoading(GaiaSky.instance.assetManager);
                                                }
                                                GaiaSky.postRunnable(GaiaSky.instance::touchSceneGraph);
                                            });
                                        } catch (Exception e) {
                                            logger.error(I18n.txt("notif.error", fileName), e);
                                        }
                                    });
                                } else {
                                    final DatasetLoadDialog dld = new DatasetLoadDialog(I18n.txt("gui.dsload.title") + ": " + fileName, fileName, skin, ui);
                                    Runnable doLoad = () -> {
                                        GaiaSky.instance.getExecutorService().execute(() -> {
                                            DatasetOptions datasetOptions = dld.generateDatasetOptions();
                                            // Load dataset
                                            GaiaSky.instance.scripting().loadDataset(datasetOptions.catalogName, result.toAbsolutePath().toString(), CatalogInfoSource.UI, datasetOptions, true);
                                            // Select first
                                            CatalogInfo ci = this.catalogManager.get(datasetOptions.catalogName);
                                            if (datasetOptions.type.isSelectable() && ci != null && ci.object != null) {
                                                if (ci.object instanceof ParticleGroup) {
                                                    ParticleGroup pg = (ParticleGroup) ci.object;
                                                    if (pg.data() != null && !pg.data().isEmpty() && pg.isVisibilityOn()) {
                                                        EventManager.publish(Event.CAMERA_MODE_CMD, this, CameraManager.CameraMode.FOCUS_MODE);
                                                        EventManager.publish(Event.FOCUS_CHANGE_CMD, this, pg.getRandomParticleName());
                                                    }
                                                } else if (ci.object.children != null && !ci.object.children.isEmpty() && ci.object.children.get(0).isVisibilityOn()) {
                                                    EventManager.publish(Event.CAMERA_MODE_CMD, this, CameraManager.CameraMode.FOCUS_MODE);
                                                    EventManager.publish(Event.FOCUS_CHANGE_CMD, this, ci.object.children.get(0));
                                                }
                                                // Open UI datasets
                                                GaiaSky.instance.scripting().maximizeInterfaceWindow();
                                                GaiaSky.instance.scripting().expandGuiComponent("DatasetsComponent");
                                            } else {
                                                logger.info("No data loaded (did the load crash?)");
                                            }
                                        });
                                    };
                                    dld.setAcceptRunnable(doLoad);
                                    dld.show(ui);
                                }
                                lastOpenLocation = result.getParent();
                                Settings.settings.program.fileChooser.lastLocation = lastOpenLocation.toAbsolutePath().toString();
                                return true;
                            } catch (Exception e) {
                                logger.error(I18n.txt("notif.error", result.getFileName()), e);
                                return false;
                            }
                        } else {
                            logger.error("Selection must be a file: " + result.toAbsolutePath());
                            return false;
                        }
                    } else {
                        // Still, update last location
                        if (!Files.isDirectory(result)) {
                            lastOpenLocation = result.getParent();
                        } else {
                            lastOpenLocation = result;
                        }
                        Settings.settings.program.fileChooser.lastLocation = lastOpenLocation.toAbsolutePath().toString();
                    }
                    return false;
                });
                fc.show(ui);
                break;
            case SHOW_KEYFRAMES_WINDOW_ACTION:
                if (keyframesWindow == null) {
                    keyframesWindow = new KeyframesWindow(ui, skin);
                }
                if (!keyframesWindow.isVisible() || !keyframesWindow.hasParent())
                    keyframesWindow.show(ui, 0, 0);
                break;
            case UI_THEME_RELOAD_INFO:
                if (keyframesWindow != null) {
                    keyframesWindow.dispose();
                    keyframesWindow = null;
                }
                this.skin = (Skin) data[0];
                break;
            case MODE_POPUP_CMD:
                if (Settings.settings.runtime.displayGui) {
                    ModePopupInfo mpi = (ModePopupInfo) data[0];
                    String name = (String) data[1];
                    if (mpi != null) {
                        // Add
                        Float seconds = (Float) data[2];
                        float pad10 = 16f;
                        float pad5 = 8f;
                        float pad3 = 4.8f;
                        if (modeChangeTable != null) {
                            modeChangeTable.remove();
                        }
                        modeChangeTable = new Table(skin);
                        modeChangeTable.setName("mct-" + name);
                        modeChangeTable.setBackground("table-bg");
                        modeChangeTable.pad(pad10);
                        // Fill up table
                        OwnLabel ttl = new OwnLabel(mpi.title, skin, "hud-header");
                        modeChangeTable.add(ttl).left().padBottom(pad10).row();
                        OwnLabel dsc = new OwnLabel(mpi.header, skin);
                        modeChangeTable.add(dsc).left().padBottom(pad5 * 3f).row();
                        Table keysTable = new Table(skin);
                        for (Pair<String[], String> m : mpi.mappings) {
                            HorizontalGroup keysGroup = new HorizontalGroup();
                            keysGroup.space(pad3);
                            String[] keys = m.getFirst();
                            String action = m.getSecond();
                            for (int i = 0; i < keys.length; i++) {
                                TextButton key = new TextButton(keys[i], skin, "key");
                                key.pad(0, pad3, 0, pad3);
                                key.pad(pad5);
                                keysGroup.addActor(key);
                                if (i < keys.length - 1) {
                                    keysGroup.addActor(new OwnLabel("+", skin));
                                }
                            }
                            keysTable.add(keysGroup).right().padBottom(pad5).padRight(pad10 * 2f);
                            keysTable.add(new OwnLabel(action, skin)).left().padBottom(pad5).row();
                        }
                        modeChangeTable.add(keysTable).center().row();
                        if (mpi.warn != null && !mpi.warn.isEmpty()) {
                            modeChangeTable.add(new OwnLabel(mpi.warn, skin, "mono-pink")).left().padTop(pad10).padBottom(pad5).row();
                        }
                        OwnTextButton closeButton = new OwnTextButton(I18n.txt("gui.ok") + " [esc]", skin);
                        closeButton.pad(pad3, pad10, pad3, pad10);
                        closeButton.addListener(event1 -> {
                            if (event1 instanceof ChangeEvent) {
                                removeModeChangePopup();
                                return true;
                            }
                            return false;
                        });
                        modeChangeTable.add(closeButton).right().padTop(pad10 * 2f);
                        modeChangeTable.pack();
                        // Add table to UI
                        Container mct = new Container<>(modeChangeTable);
                        mct.setFillParent(true);
                        mct.top();
                        mct.pad(pad10 * 2, 0, 0, 0);
                        ui.addActor(mct);
                        startModePopupInfoThread(modeChangeTable, seconds);
                    } else {
                        // Remove
                        if (modeChangeTable != null && modeChangeTable.hasParent() && modeChangeTable.getName().equals("mct-" + name)) {
                            modeChangeTable.remove();
                            modeChangeTable = null;
                        }
                    }
                }
                break;
            case DISPLAY_GUI_CMD:
                boolean displayGui = (Boolean) data[0];
                if (!displayGui) {
                    // Remove processor
                    inputMultiplexer.removeProcessor(current.getGuiStage());
                } else {
                    // Add processor
                    inputMultiplexer.addProcessor(0, current.getGuiStage());
                }
                break;
            case SHOW_RESTART_ACTION:
                String text;
                if (data.length > 0) {
                    text = (String) data[0];
                } else {
                    text = I18n.txt("gui.restart.default");
                }
                GenericDialog restart = new GenericDialog(I18n.txt("gui.restart.title"), skin, ui) {

                    @Override
                    protected void build() {
                        content.clear();
                        content.add(new OwnLabel(text, skin)).left().padBottom(pad10 * 2f).row();
                    }

                    @Override
                    protected void accept() {
                        // Shut down
                        GaiaSky.postRunnable(() -> {
                            Gdx.app.exit();
                            // Attempt restart
                            Path workingDir = Path.of(System.getProperty("user.dir"));
                            Path[] scripts;
                            if (SysUtils.isWindows()) {
                                scripts = new Path[] { workingDir.resolve("gaiasky.exe"), workingDir.resolve("gaiasky.bat"), workingDir.resolve("gradlew.bat") };
                            } else {
                                scripts = new Path[] { workingDir.resolve("gaiasky"), workingDir.resolve("gradlew") };
                            }
                            for (Path file : scripts) {
                                if (Files.exists(file) && Files.isRegularFile(file) && Files.isExecutable(file)) {
                                    try {
                                        if (file.getFileName().toString().contains("gaiasky")) {
                                            // Just use the script
                                            final ArrayList<String> command = new ArrayList<>();
                                            command.add(file.toString());
                                            final ProcessBuilder builder = new ProcessBuilder(command);
                                            builder.start();
                                        } else if (file.getFileName().toString().contains("gradlew")) {
                                            // Gradle script
                                            final ArrayList<String> command = new ArrayList<>();
                                            command.add(file.toString());
                                            command.add("core:run");
                                            final ProcessBuilder builder = new ProcessBuilder(command);
                                            builder.start();
                                        }
                                        break;
                                    } catch (IOException e) {
                                        logger.error(e, "Error running Gaia Sky");
                                    }
                                }
                            }
                        });
                    }

                    @Override
                    protected void cancel() {
                    // Nothing
                    }

                    @Override
                    public void dispose() {
                    // Nothing
                    }
                };
                restart.setAcceptText(I18n.txt("gui.yes"));
                restart.setCancelText(I18n.txt("gui.no"));
                restart.buildSuper();
                restart.show(ui);
                break;
            case UI_RELOAD_CMD:
                reloadUI((GlobalResources) data[0]);
                break;
            default:
                break;
        }
    }
}
Also used : OwnTextButton(gaiasky.util.scene2d.OwnTextButton) SceneGraphNode(gaiasky.scenegraph.SceneGraphNode) ArrayList(java.util.ArrayList) Lwjgl3Graphics(com.badlogic.gdx.backends.lwjgl3.Lwjgl3Graphics) Actor(com.badlogic.gdx.scenes.scene2d.Actor) FileChooser(gaiasky.util.scene2d.FileChooser) Stage(com.badlogic.gdx.scenes.scene2d.Stage) DatasetOptions(gaiasky.data.group.DatasetOptions) OwnTextButton(gaiasky.util.scene2d.OwnTextButton) Path(java.nio.file.Path) ParticleGroup(gaiasky.scenegraph.ParticleGroup) IOException(java.io.IOException) IOException(java.io.IOException) ISceneGraph(gaiasky.scenegraph.ISceneGraph) ChangeEvent(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent) OwnLabel(gaiasky.util.scene2d.OwnLabel)

Example 4 with Lwjgl3Graphics

use of com.badlogic.gdx.backends.lwjgl3.Lwjgl3Graphics in project libgdx by libgdx.

the class Lwjgl3DebugStarter method main.

public static void main(String[] argv) throws NoSuchFieldException, SecurityException, ClassNotFoundException {
    GdxTest test = new GdxTest() {

        float r = 0;

        SpriteBatch batch;

        BitmapFont font;

        FPSLogger fps = new FPSLogger();

        Texture texture;

        @Override
        public void create() {
            BufferedImage image = new BufferedImage(10, 10, BufferedImage.TYPE_4BYTE_ABGR);
            texture = new Texture("data/badlogic.jpg");
            batch = new SpriteBatch();
            font = new BitmapFont();
            Gdx.input.setInputProcessor(new InputAdapter() {

                @Override
                public boolean keyDown(int keycode) {
                    System.out.println("Key down: " + Keys.toString(keycode));
                    return false;
                }

                @Override
                public boolean keyUp(int keycode) {
                    System.out.println("Key up: " + Keys.toString(keycode));
                    return false;
                }

                @Override
                public boolean keyTyped(char character) {
                    System.out.println("Key typed: '" + character + "', " + (int) character);
                    if (character == 'f') {
                        Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
                    //							DisplayMode[] modes = Gdx.graphics.getDisplayModes();
                    //							for(DisplayMode mode: modes) {
                    //								if(mode.width == 1920 && mode.height == 1080) {
                    //									Gdx.graphics.setFullscreenMode(mode);
                    //									break;
                    //								}
                    //							}
                    }
                    if (character == 'w') {
                        Gdx.graphics.setWindowedMode(MathUtils.random(400, 800), MathUtils.random(400, 800));
                    }
                    if (character == 'e') {
                        throw new GdxRuntimeException("derp");
                    }
                    if (character == 'c') {
                        Gdx.input.setCursorCatched(!Gdx.input.isCursorCatched());
                    }
                    Lwjgl3Window window = ((Lwjgl3Graphics) Gdx.graphics).getWindow();
                    if (character == 'v') {
                        window.setVisible(false);
                    }
                    if (character == 's') {
                        window.setVisible(true);
                    }
                    if (character == 'q') {
                        window.closeWindow();
                    }
                    if (character == 'i') {
                        window.iconifyWindow();
                    }
                    if (character == 'm') {
                        window.maximizeWindow();
                    }
                    if (character == 'r') {
                        window.restoreWindow();
                    }
                    if (character == 'u') {
                        Gdx.net.openURI("https://google.com");
                    }
                    return false;
                }
            });
        }

        long start = System.nanoTime();

        @Override
        public void render() {
            Gdx.gl.glClearColor(1, 0, 0, 1);
            Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
            HdpiUtils.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
            batch.getProjectionMatrix().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
            batch.begin();
            font.draw(batch, Gdx.graphics.getWidth() + "x" + Gdx.graphics.getHeight() + ", " + Gdx.graphics.getBackBufferWidth() + "x" + Gdx.graphics.getBackBufferHeight() + ", " + Gdx.input.getX() + ", " + Gdx.input.getY() + ", " + Gdx.input.getDeltaX() + ", " + Gdx.input.getDeltaY(), 0, 20);
            batch.draw(texture, Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY());
            batch.end();
            fps.log();
        }

        @Override
        public void resize(int width, int height) {
            Gdx.app.log("Test", "Resized " + width + "x" + height);
        }

        @Override
        public void resume() {
            Gdx.app.log("Test", "resuming");
        }

        @Override
        public void pause() {
            Gdx.app.log("Test", "pausing");
        }

        @Override
        public void dispose() {
            Gdx.app.log("Test", "disposing");
        }
    };
    Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
    config.setWindowedMode(640, 480);
    config.setWindowListener(new Lwjgl3WindowListener() {

        @Override
        public void iconified(boolean isIconified) {
            Gdx.app.log("Window", "iconified: " + (isIconified ? "true" : "false"));
        }

        @Override
        public void maximized(boolean isMaximized) {
            Gdx.app.log("Window", "maximized: " + (isMaximized ? "true" : "false"));
        }

        @Override
        public void focusLost() {
            Gdx.app.log("Window", "focus lost");
        }

        @Override
        public void focusGained() {
            Gdx.app.log("Window", "focus gained");
        }

        @Override
        public boolean closeRequested() {
            Gdx.app.log("Window", "closing");
            return false;
        }

        @Override
        public void filesDropped(String[] files) {
            for (String file : files) {
                Gdx.app.log("Window", "File dropped: " + file);
            }
        }

        @Override
        public void refreshRequested() {
            Gdx.app.log("Window", "refreshRequested");
        }
    });
    for (DisplayMode mode : Lwjgl3ApplicationConfiguration.getDisplayModes()) {
        System.out.println(mode.width + "x" + mode.height);
    }
    System.setProperty("java.awt.headless", "true");
    new Lwjgl3Application(test, config);
}
Also used : InputAdapter(com.badlogic.gdx.InputAdapter) Lwjgl3Application(com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application) GdxTest(com.badlogic.gdx.tests.utils.GdxTest) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Texture(com.badlogic.gdx.graphics.Texture) BufferedImage(java.awt.image.BufferedImage) Lwjgl3ApplicationConfiguration(com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration) FPSLogger(com.badlogic.gdx.graphics.FPSLogger) GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException) DisplayMode(com.badlogic.gdx.Graphics.DisplayMode) Lwjgl3Window(com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window) Lwjgl3WindowListener(com.badlogic.gdx.backends.lwjgl3.Lwjgl3WindowListener) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont)

Example 5 with Lwjgl3Graphics

use of com.badlogic.gdx.backends.lwjgl3.Lwjgl3Graphics in project skin-composer by raeleus.

the class DesktopLauncher method centerWindow.

@Override
public void centerWindow(Graphics graphics) {
    Lwjgl3Graphics g = (Lwjgl3Graphics) graphics;
    Graphics.DisplayMode mode = g.getDisplayMode();
    Lwjgl3Window window = g.getWindow();
    window.setPosition(mode.width / 2 - g.getWidth() / 2, mode.height / 2 - g.getHeight() / 2);
}
Also used : Graphics(com.badlogic.gdx.Graphics) Lwjgl3Graphics(com.badlogic.gdx.backends.lwjgl3.Lwjgl3Graphics) Lwjgl3Graphics(com.badlogic.gdx.backends.lwjgl3.Lwjgl3Graphics) Lwjgl3Window(com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window)

Aggregations

Lwjgl3Graphics (com.badlogic.gdx.backends.lwjgl3.Lwjgl3Graphics)6 Lwjgl3Window (com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window)5 Lwjgl3Application (com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application)2 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)2 com.badlogic.gdx (com.badlogic.gdx)1 Graphics (com.badlogic.gdx.Graphics)1 DisplayMode (com.badlogic.gdx.Graphics.DisplayMode)1 InputAdapter (com.badlogic.gdx.InputAdapter)1 AssetManager (com.badlogic.gdx.assets.AssetManager)1 FileHandleResolver (com.badlogic.gdx.assets.loaders.FileHandleResolver)1 InternalFileHandleResolver (com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver)1 Lwjgl3ApplicationConfiguration (com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration)1 Lwjgl3WindowConfiguration (com.badlogic.gdx.backends.lwjgl3.Lwjgl3WindowConfiguration)1 Lwjgl3WindowListener (com.badlogic.gdx.backends.lwjgl3.Lwjgl3WindowListener)1 FPSLogger (com.badlogic.gdx.graphics.FPSLogger)1 GL20 (com.badlogic.gdx.graphics.GL20)1 Format (com.badlogic.gdx.graphics.Pixmap.Format)1 Texture (com.badlogic.gdx.graphics.Texture)1 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)1 FrameBuffer (com.badlogic.gdx.graphics.glutils.FrameBuffer)1