Example usage for com.badlogic.gdx.backends.lwjgl3 Lwjgl3ApplicationConfiguration Lwjgl3ApplicationConfiguration

List of usage examples for com.badlogic.gdx.backends.lwjgl3 Lwjgl3ApplicationConfiguration Lwjgl3ApplicationConfiguration

Introduction

In this page you can find the example usage for com.badlogic.gdx.backends.lwjgl3 Lwjgl3ApplicationConfiguration Lwjgl3ApplicationConfiguration.

Prototype

Lwjgl3ApplicationConfiguration

Source Link

Usage

From source file:com.agateau.pixelwheels.desktop.DesktopLauncher.java

License:Apache License

public static void main(String[] arg) {
    Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
    config.setWindowedMode(PwStageScreen.WIDTH, PwStageScreen.HEIGHT);
    config.setTitle("Pixel Wheels");
    config.setPreferencesConfig(".config/agateau.com", Files.FileType.External);
    config.useVsync(true);/*from   ww  w  .  ja v a2 s . c om*/
    FileUtils.appName = "pixelwheels";
    new Lwjgl3Application(new PwGame(), config);
}

From source file:com.badlogic.gdx.tests.lwjgl.Lwjgl3DebugStarter.java

License:Apache License

public static void main(String[] argv) {
    GdxTest test = new GdxTest() {
        float r = 0;
        SpriteBatch batch;/*w w w.  j a va 2s  .c om*/
        BitmapFont font;

        @Override
        public void create() {
            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);
                    return false;
                }
            });
        }

        @Override
        public void render() {
            Gdx.gl.glClearColor(r, 0, 0, 1);
            Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
            batch.getProjectionMatrix().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
            batch.begin();
            font.draw(batch, Gdx.input.getDeltaX() + ", " + Gdx.input.getDeltaY(), 0, 20);
            batch.end();
            if (Gdx.input.justTouched()) {
                System.out.println("Just touched");
            }
            if (Gdx.input.isKeyJustPressed(Keys.ANY_KEY)) {
                System.out.println("Pressed any key");
            }
        }
    };
    Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
    config.width = 960;
    config.height = 600;
    config.vSyncEnabled = false;
    config.useHDPI = true;
    new Lwjgl3Application(test, config);
}

From source file:com.badlogic.gdx.tests.lwjgl3.Lwjgl3DebugStarter.java

License:Apache License

public static void main(String[] argv) throws NoSuchFieldException, SecurityException, ClassNotFoundException {
    GdxTest test = new GdxTest() {
        float r = 0;
        SpriteBatch batch;/*from w  w w  .j  a  va2  s.  c om*/
        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 created(Lwjgl3Window window) {
            Gdx.app.log("Window", "created");
        }

        @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);
}

From source file:com.badlogic.gdx.tests.lwjgl3.Lwjgl3TestStarter.java

License:Apache License

public static void main(String[] argv) {
    System.setProperty("java.awt.headless", "true");
    Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
    config.setWindowedMode(640, 480);//from  w  w  w .  j a  v a 2s  . co m

    new Lwjgl3Application(new TestChooser(), config);
}

From source file:com.kotcrab.vis.editor.Main.java

License:Apache License

public static void main(String[] args) throws Exception {
    App.init();/*from w  ww . j  a v a  2s  .c om*/
    if (OsUtils.isMac())
        System.setProperty("java.awt.headless", "true");

    LaunchConfiguration launchConfig = new LaunchConfiguration();

    //TODO: needs some better parser
    for (int i = 0; i < args.length; i++) {
        String arg = args[i];
        if (arg.equals("--scale-ui")) {
            launchConfig.scaleUIEnabled = true;
            continue;
        }

        if (arg.equals("--project")) {
            if (i + 1 >= args.length) {
                throw new IllegalStateException("Not enough parameters for --project <project path>");
            }

            launchConfig.projectPath = args[i + 1];
            i++;
            continue;
        }

        if (arg.equals("--scene")) {
            if (i + 1 >= args.length) {
                throw new IllegalStateException("Not enough parameters for --scene <scene path>");
            }

            launchConfig.scenePath = args[i + 1];
            i++;
            continue;
        }

        Log.warn("Unrecognized command line argument: " + arg);
    }

    launchConfig.verify();

    editor = new Editor(launchConfig);

    Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
    config.setWindowedMode(1280, 720);
    config.setWindowSizeLimits(1, 1, 9999, 9999);
    config.useVsync(true);
    config.setIdleFPS(2);
    config.setWindowListener(new Lwjgl3WindowAdapter() {
        @Override
        public boolean closeRequested() {
            editor.requestExit();
            return false;
        }
    });

    try {
        new Lwjgl3Application(editor, config);
        Log.dispose();
    } catch (Exception e) {
        Log.exception(e);
        Log.fatal("Uncaught exception occurred, error report will be saved");
        Log.flush();

        if (App.eventBus != null)
            App.eventBus.post(new ExceptionEvent(e, true));

        try {
            File crashReport = new CrashReporter(Log.getLogFile().file()).processReport();
            if (new File(App.TOOL_CRASH_REPORTER_PATH).exists() == false) {
                Log.warn("Crash reporting tool not present, skipping crash report sending.");
            } else {
                CommandLine cmdLine = new CommandLine(PlatformUtils.getJavaBinPath());
                cmdLine.addArgument("-jar");
                cmdLine.addArgument(App.TOOL_CRASH_REPORTER_PATH);
                cmdLine.addArgument(ApplicationUtils.getRestartCommand().replace("\"", "%"));
                cmdLine.addArgument(crashReport.getAbsolutePath(), false);
                DefaultExecutor executor = new DefaultExecutor();
                executor.setStreamHandler(new PumpStreamHandler(null, null, null));
                executor.execute(cmdLine);
            }
        } catch (IOException ex) {
            ex.printStackTrace();
        }

        Log.dispose();
        System.exit(-3);
    } catch (ExceptionInInitializerError err) {
        if (OsUtils.isMac() && err.getCause() instanceof IllegalStateException) {
            if (ExceptionUtils.getStackTrace(err).contains("XstartOnFirstThread")) {
                System.out.println(
                        "Application was not launched on first thread. Restarting with -XstartOnFirstThread, add VM argument -XstartOnFirstThread to avoid this.");
                ApplicationUtils.startNewInstance();
            }
        }

        throw err;
    }
}

From source file:com.mbrlabs.demo.desktop.lwjgl3.DesktopLauncher.java

License:Apache License

public static void main(String[] arg) {
    Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
    new Lwjgl3Application(new MundusDemo(), config);
}

From source file:com.mbrlabs.mundus.Main.java

License:Apache License

public static void main(String[] arg) {
    // Start Log instance
    Log.init();//from www .j  ava2 s .c  om
    Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
    config.setTitle(TITLE);
    Log.info(TAG, "Starting [{}]", TITLE);

    // Set initial window size. See issue #11
    DisplayMode dm = Lwjgl3ApplicationConfiguration.getDisplayMode();
    if (System.getProperties().getProperty("os.name").toLowerCase().contains("mac")) {
        config.setWindowedMode((int) (dm.width * 0.80f), (int) (dm.height * 0.80f));
    } else {
        config.setWindowedMode((int) (dm.width * 0.95f), (int) (dm.height * 0.95f));
    }
    config.setWindowPosition(-1, -1);

    config.setWindowListener(new Lwjgl3WindowAdapter() {
        @Override
        public boolean closeRequested() {
            if (closeListener != null) {
                closeListener.onCloseRequested();
                return false;
            }
            return true;
        }
    });
    new Lwjgl3Application(new Editor(), config);
    Log.info(TAG, "Shutting down [{}]", TITLE);
}

From source file:com.nsoft.boxuniverse.main.Main.java

License:Open Source License

public static void main(String[] args) {

    Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
    config.setWindowedMode(1280, 720);// ww  w . j av a 2  s.co  m
    //config.setFullscreenMode( Lwjgl3ApplicationConfiguration.getDisplayMode());
    config.setTitle("Box Universe");
    config.useOpenGL3(true, 3, 2);
    app = new Lwjgl3Application(new Game(), config);
}

From source file:nl.colorize.multimedialib.renderer.libgdx.GDXRenderer.java

License:Apache License

@Override
public void initialize() {
    Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
    config.setWindowedMode(screenBounds.getWidth(), screenBounds.getHeight());
    config.setDecorated(true);/* w w w .  j  a  v a  2  s.  co  m*/

    if (windowTitle != null) {
        config.setTitle(windowTitle);
    }
    if (windowIcon != null) {
        config.setWindowIcon(Files.FileType.Internal, windowIcon.getPath());
    }

    input = new GDXInput();
    app = new Lwjgl3Application(this, config);
}