List of usage examples for com.badlogic.gdx Gdx net
Net net
To view the source code for com.badlogic.gdx Gdx net.
Click Source Link
From source file:at.therefactory.jewelthief.input.MenuScreenInputAdapter.java
License:Open Source License
@Override public boolean touchUp(int screenX, int screenY, int pointer, int button) { super.touchUp(screenX, screenY, pointer, button); Preferences prefs = JewelThief.getInstance().getPreferences(); numTouches = Math.max(0, numTouches - 1); if (menuScreen.buttonExitToMainMenu.isPressed()) { menuScreen.buttonExitToMainMenu.release(); menuScreen.setShowLicenseYOffset(0); menuScreen.setState(MenuScreen.MenuState.ShowMenu); } else if (menuScreen.getState().equals(MenuScreen.MenuState.ShowAbout)) { if (menuScreen.buttonShowLicense.isPressed()) { menuScreen.buttonShowLicense.release(); if (menuScreen.getShowLicenseYOffset() == 0) { menuScreen.setShowLicenseYOffset(54); } else { menuScreen.setShowLicenseYOffset(0); }/* ww w. j a v a 2 s . com*/ } else if (menuScreen.buttonSoundtrack.isPressed()) { menuScreen.buttonSoundtrack.release(); Gdx.net.openURI(URL_TO_SOUNDTRACK); } else if (menuScreen.buttonRate.isPressed()) { menuScreen.buttonRate.release(); Gdx.net.openURI(URL_TO_PLAY_STORE); } } else if (menuScreen.getState().equals(MenuScreen.MenuState.ShowHighscores)) { if (menuScreen.buttonUpdateHighscores.isPressed()) { menuScreen.buttonUpdateHighscores.release(); menuScreen.setFetchingHighscores(true); HttpServer.fetchHighscores(menuScreen, prefs.getString(PrefsKeys.ID), prefs.getString(PrefsKeys.PLAYER_NAME), prefs.getInteger(PrefsKeys.BEST_SCORE_NUM_JEWELS), prefs.getInteger(PrefsKeys.BEST_SCORE_NUM_SECONDS)); } } else if (menuScreen.getState().equals(MenuScreen.MenuState.ShowSettings)) { if (menuScreen.buttonChangePlayername.isPressed()) { menuScreen.buttonChangePlayername.release(); Gdx.input.getTextInput(listener, bundle.get(PLEASE_ENTER_YOUR_NAME), prefs.getString(PrefsKeys.PLAYER_NAME), ""); } else if (menuScreen.buttonToggleSound.isPressed()) { menuScreen.buttonToggleSound.release(); menuScreen.buttonToggleSound.nextState(); prefs.putBoolean(PrefsKeys.ENABLE_SOUND, !prefs.getBoolean(PrefsKeys.ENABLE_SOUND)); prefs.flush(); } else if (menuScreen.buttonToggleMusic.isPressed()) { menuScreen.buttonToggleMusic.release(); menuScreen.buttonToggleMusic.nextState(); prefs.putBoolean(PrefsKeys.ENABLE_MUSIC, !prefs.getBoolean(PrefsKeys.ENABLE_MUSIC)); prefs.flush(); if (prefs.getBoolean(PrefsKeys.ENABLE_MUSIC)) { JewelThief.getInstance().playMusicFile(true); } else { JewelThief.getInstance().pauseMusic(); } } else if (menuScreen.buttonChangeLanguage.isPressed()) { menuScreen.buttonChangeLanguage.release(); menuScreen.buttonChangeLanguage.nextState(); bundle = JewelThief.getInstance() .setLocale(menuScreen.buttonChangeLanguage.getState() == 0 ? "en" : "de"); menuScreen.setBundle(bundle); } else if (menuScreen.buttonResetHighscore.isPressed()) { menuScreen.buttonResetHighscore.release(); if (timestampLastClickOnResetHighscoreSettingButton > System.currentTimeMillis() - 1000) { timestampLastClickOnResetHighscoreSettingButton = 0; prefs.remove(PrefsKeys.MY_RANK); prefs.remove(PrefsKeys.BEST_SCORE); prefs.remove(PrefsKeys.BEST_SCORE_NUM_JEWELS); prefs.remove(PrefsKeys.BEST_SCORE_NUM_SECONDS); JewelThief.getInstance().toast(bundle.get(HIGHSCORE_IS_RESET), true); } else { timestampLastClickOnResetHighscoreSettingButton = System.currentTimeMillis(); JewelThief.getInstance().toast(bundle.get(TAP_AGAIN_TO_RESET_HIGHSCORE), false); } } } // main menu else { if (menuScreen.buttonStartSinglePlayerGame.isPressed()) { JewelThief.getInstance().showIntroScreen(); menuScreen.buttonStartSinglePlayerGame.release(); } else if (menuScreen.buttonShowHighscores.isPressed()) { deltaY = 0; menuScreen.setScrollbarPositionY(Config.INITIAL_SCROLLBAR_POSITION_Y); if (prefs.contains(PrefsKeys.CACHED_HIGHSCORES)) { menuScreen.setHighscores(prefs.getString(PrefsKeys.CACHED_HIGHSCORES).split("\n")); } menuScreen.setState(MenuScreen.MenuState.ShowHighscores); menuScreen.buttonShowHighscores.release(); } else if (menuScreen.buttonShowSettings.isPressed()) { menuScreen.setState(MenuScreen.MenuState.ShowSettings); menuScreen.buttonShowSettings.release(); } else if (menuScreen.buttonShowAbout.isPressed()) { menuScreen.setState(MenuScreen.MenuState.ShowAbout); menuScreen.buttonShowAbout.release(); } } lastDeltaY = -deltaY; touchDragging = false; return true; }
From source file:com.ahsgaming.valleyofbones.network.GameServer.java
License:Apache License
public void registerPublicServer() { Net.HttpRequest httpGet = new Net.HttpRequest(Net.HttpMethods.POST); httpGet.setUrl(String.format("%s/servers", globalServerUrl)); String content = String.format("{ \"name\": \"%s\", \"port\": \"%s\", \"version\": \"%s\" }", gameConfig.hostName, Integer.toString(gameConfig.hostPort), VOBGame.VERSION); // HashMap parameters = new HashMap(); // parameters.put("name", gameConfig.hostName); // parameters.put("port", Integer.toString(gameConfig.hostPort)); //// parameters.put("ip", Utils.getIPAddress(true)); httpGet.setContent(content);/* w w w .j a v a 2s. com*/ // System.out.println(HttpParametersUtils.convertHttpParameters(parameters)); Gdx.net.sendHttpRequest(httpGet, new Net.HttpResponseListener() { @Override public void handleHttpResponse(Net.HttpResponse httpResponse) { String response = httpResponse.getResultAsString(); switch (httpResponse.getStatus().getStatusCode()) { case 400: case 404: Gdx.app.log(LOG, "Failed to register with global server"); Gdx.app.log(LOG, response); break; case 200: Gdx.app.log(LOG, "Registered with global server"); Gdx.app.log(LOG, response); JsonReader reader = new JsonReader(); JsonValue result = reader.parse(response); if (result != null) publicServerId = result.getInt("id", -1); Gdx.app.log(LOG, Integer.toString(publicServerId)); break; default: Gdx.app.log(LOG, String.format("Unknown HTTP Status Code: %d", httpResponse.getStatus().getStatusCode())); Gdx.app.log(LOG, response); } } @Override public void failed(Throwable t) { Gdx.app.log(LOG, "Failed to register with global server"); t.printStackTrace(); } }); }
From source file:com.ahsgaming.valleyofbones.network.GameServer.java
License:Apache License
public void removePublicServer() { if (publicServerId >= 0) { Net.HttpRequest httpDelete = new Net.HttpRequest(Net.HttpMethods.DELETE); httpDelete.setUrl(String.format("%s/servers/%d", globalServerUrl, publicServerId)); Gdx.net.sendHttpRequest(httpDelete, new Net.HttpResponseListener() { @Override/*w w w .j a va2 s . co m*/ public void handleHttpResponse(Net.HttpResponse httpResponse) { Gdx.app.log(LOG, httpResponse.getResultAsString()); } @Override public void failed(Throwable t) { t.printStackTrace(); } }); } publicServerId = -1; }
From source file:com.ahsgaming.valleyofbones.network.GameServer.java
License:Apache License
public void sendPublicServerResult() { if (publicServerId >= 0) { Net.HttpRequest httpPost = new Net.HttpRequest(Net.HttpMethods.POST); httpPost.setUrl(String.format("%s/games", globalServerUrl)); String playersString = "{}"; if (controller.getPlayers().size >= 2) { playersString = String.format("{ \"%d\": %s, \"%d\": %s }", controller.getPlayers().get(0).getPlayerId(), controller.getPlayers().get(0).getKeyString(), //"\"" + controller.getPlayers().get(0).getPlayerName() + "\"", controller.getPlayers().get(1).getPlayerId(), controller.getPlayers().get(1).getKeyString()); }//ww w .ja v a 2 s .c o m String historyString = "["; boolean first = true; for (Command command : controller.getCommandHistory()) { if (first) { first = false; } else { historyString += ", "; } historyString += command.toJson(); } historyString += "]"; String content = String.format("{ \"game\": %s, \"version\": \"%s\", \"map\": \"%s\" }", "{ \"history\": " + historyString + ", \"result\": " + gameResult.winner + ", \"map\": \"" + controller.getMapName() + "\", \"players\": " + playersString + "}", VOBGame.VERSION, controller.getMapName()); httpPost.setContent(content); Gdx.net.sendHttpRequest(httpPost, new Net.HttpResponseListener() { @Override public void handleHttpResponse(Net.HttpResponse httpResponse) { String response = httpResponse.getResultAsString(); switch (httpResponse.getStatus().getStatusCode()) { case 400: case 404: Gdx.app.log(LOG, "Failed to upload game result"); Gdx.app.log(LOG, response); break; case 200: Gdx.app.log(LOG, "Uploaded game result"); Gdx.app.log(LOG, response); break; default: Gdx.app.log(LOG, "Unknown response code " + httpResponse.getStatus().getStatusCode()); Gdx.app.log(LOG, response); } } @Override public void failed(Throwable t) { t.printStackTrace(); } }); Gdx.app.log(LOG, httpPost.getContent()); } }
From source file:com.ahsgaming.valleyofbones.network.GameServer.java
License:Apache License
public void sendPublicServerUpdate() { Net.HttpRequest req = new Net.HttpRequest(Net.HttpMethods.PUT); req.setUrl(String.format("%s/servers/%d", globalServerUrl, publicServerId)); String content = String.format("{ \"players\": %d, \"status\": %d }", (gameStarted ? players.size : registeredPlayers.size), (gameStarted ? 1 : 0)); Gdx.app.log("LOG", content); req.setContent(content);//w w w. java2s . c o m Gdx.net.sendHttpRequest(req, new Net.HttpResponseListener() { @Override public void handleHttpResponse(Net.HttpResponse httpResponse) { switch (httpResponse.getStatus().getStatusCode()) { default: case 404: registerPublicServer(); serverPingTimeout = 60; break; case 200: Gdx.app.log(LOG, "Update success"); break; } Gdx.app.log(LOG, httpResponse.getResultAsString()); } @Override public void failed(Throwable t) { Gdx.app.log(LOG, "Update failed"); } }); }
From source file:com.ahsgaming.valleyofbones.screens.GameJoinScreen.java
License:Apache License
public void setupScreen() { Table table = new Table(getSkin()); table.setFillParent(true);// w ww .j a v a2s . c o m stage.addActor(table); table.add("Name:").pad(4).left(); lblNickname = new Label(game.profile.name, getSkin()); table.add(lblNickname).pad(4).left(); chkAuth = new CheckBox(" Authenticating...", getSkin()); table.add(chkAuth).colspan(2).left(); table.row(); table.add("Server Name", "small-grey"); table.add("Address", "small-grey"); table.add("Players", "small-grey"); table.add("Status", "small-grey"); table.row(); listNames = new List(new Object[] {}, getSkin()); listServers = new List(new Object[] {}, getSkin()); listPlayers = new List(new Object[] {}, getSkin()); listStatus = new List(new Object[] {}, getSkin()); table.add(listNames).pad(5); table.add(listServers).pad(5); table.add(listPlayers).pad(5); table.add(listStatus).pad(5); ChangeListener changeAll = new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { int index = ((List) actor).getSelectedIndex(); listNames.setSelectedIndex(index); listServers.setSelectedIndex(index); listPlayers.setSelectedIndex(index); listStatus.setSelectedIndex(index); ServerObj server = servers.get(index); txtJoinHostname.setText(String.format("%s:%d", server.ipAddr, server.port)); } }; listNames.addListener(changeAll); listServers.addListener(changeAll); listPlayers.addListener(changeAll); listStatus.addListener(changeAll); table.row(); lblJoinHostname = new Label("Join Server:", getSkin()); table.add(lblJoinHostname).pad(4).left(); txtJoinHostname = new TextField("", getSkin()); table.add(txtJoinHostname).pad(4).fillX().left().colspan(3); table.row(); btnCancel = new TextButton("Cancel", getSkin(), "cancel"); table.add(btnCancel).size(150, 50).pad(4); btnConnect = new TextButton("Join", getSkin()); table.add(btnConnect).size(150, 50).pad(4); btnSpectate = new TextButton("Spectate", getSkin()); table.add(btnSpectate).size(150, 50).pad(4); table.row(); lblStatus = new Label("", getSkin()); table.add(lblStatus).colspan(2).pad(4); btnCancel.addListener(new ClickListener() { /* (non-Javadoc) * @see com.badlogic.gdx.scenes.scene2d.utils.ClickListener#touchUp(com.badlogic.gdx.scenes.scene2d.InputEvent, float, float, int, int) */ @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); game.setScreen(game.getMainMenuScreen()); } }); btnConnect.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); Gdx.app.log(LOG, "btnConnect touched"); String host = txtJoinHostname.getText(); if (host.equals("")) { if (servers.size == 0) return; host = String.format("%s:%d", servers.get(listServers.getSelectedIndex()).ipAddr, servers.get(listServers.getSelectedIndex()).port); } GameSetupConfig cfg = new GameSetupConfig(); cfg.hostName = host.split(":")[0]; cfg.isHost = false; cfg.isMulti = true; cfg.hostPort = (host.indexOf(':') > -1 ? Integer.parseInt(host.split(":")[1]) : KryoCommon.tcpPort); cfg.playerName = game.profile.name; cfg.playerKey = (authPlayer != null ? authPlayer.key : ""); gsScreen = game.getGameSetupScreenMP(cfg); lblStatus.setText(String.format("Connecting to host %s", cfg.hostName)); Gdx.app.log(LOG, String.format("Attempting connection to host %s", cfg.hostName)); } }); btnSpectate.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); Gdx.app.log(LOG, "btnSpectate touched"); String host = txtJoinHostname.getText(); if (host.equals("")) { if (servers.size == 0) return; host = String.format("%s:%d", servers.get(listServers.getSelectedIndex()).ipAddr, servers.get(listServers.getSelectedIndex()).port); } GameSetupConfig cfg = new GameSetupConfig(); cfg.hostName = host.split(":")[0]; cfg.isHost = false; cfg.isMulti = true; cfg.isSpectator = true; cfg.hostPort = (host.indexOf(':') > -1 ? Integer.parseInt(host.split(":")[1]) : KryoCommon.tcpPort); cfg.playerName = game.profile.name; cfg.playerKey = (authPlayer != null ? authPlayer.key : ""); gsScreen = game.getGameSetupScreenMP(cfg); lblStatus.setText(String.format("Connecting to host %s", cfg.hostName)); Gdx.app.log(LOG, String.format("Attempting connection to host %s", cfg.hostName)); } }); servers = new Array<ServerObj>(); Net.HttpRequest httpGet = new Net.HttpRequest(Net.HttpMethods.GET); httpGet.setUrl(globalServerUrl); Gdx.net.sendHttpRequest(httpGet, new Net.HttpResponseListener() { @Override public void handleHttpResponse(Net.HttpResponse httpResponse) { String response = httpResponse.getResultAsString(); int code = httpResponse.getStatus().getStatusCode(); switch (code) { case 400: case 404: Gdx.app.log(LOG, "Server retrieval failed"); Gdx.app.log(LOG, response); break; case 200: Gdx.app.log(LOG, "Got server list"); JsonReader reader = new JsonReader(); JsonValue result = reader.parse(response); Gdx.app.log(LOG, response); for (JsonValue server : result) { if (server.getString("version", "").equals(VOBGame.VERSION)) servers.add(new ServerObj(server)); } break; default: Gdx.app.log(LOG, String.format("Unknown response code: %d", code)); Gdx.app.log(LOG, response); } updateServerList(); } @Override public void failed(Throwable t) { Gdx.app.log(LOG, "GET server request failed"); t.printStackTrace(); } }); // discover host new Thread() { public void run() { // for whatever reason, without this line the discoverHost call cant // access the network...not very forward compatible I guess System.setProperty("java.net.preferIPv4Stack", "true"); Client c = new Client(); c.start(); InetAddress iAddress = c.discoverHost(KryoCommon.udpPort, 5000); if (iAddress != null && txtJoinHostname.getText().equals("")) { // txtJoinHostname.setText(iAddress.getHostAddress()); servers.add(new ServerObj(-1, iAddress.getHostAddress(), KryoCommon.tcpPort, "LAN Server")); updateServerList(); } } }.start(); }
From source file:com.andgate.pokeadot.MainMenuScreen.java
License:Open Source License
public MainMenuScreen(final PokeADot newGame) { game = newGame;/*from w w w. j av a 2 s . co m*/ stage = new Stage(); Gdx.input.setInputProcessor(stage); final LabelStyle titleLabelStyle = new LabelStyle(game.largeFont, Color.CYAN); final Label titleLabel = new Label(Constants.GAME_NAME, titleLabelStyle); final TextButtonStyle buttonStyle = new TextButtonStyle(game.skin.getDrawable("default-round"), game.skin.getDrawable("default-round-down"), game.skin.getDrawable("default-round"), game.mediumFont); final TextButton playButton = new TextButton(PLAY_BUTTON_TEXT, buttonStyle); final TextButton practiceButton = new TextButton(PRACTICE_BUTTON_TEXT, buttonStyle); final TextButton buyButton = new TextButton(BUY_BUTTON_TEXT, buttonStyle); playButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { game.buttonPressedSound.play(); game.setScreen(new GameScreen(game, PokeADot.GameMode.PLAY)); MainMenuScreen.this.dispose(); } }); practiceButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { game.buttonPressedSound.play(); game.setScreen(new GameScreen(game, PokeADot.GameMode.PRACTICE)); MainMenuScreen.this.dispose(); } }); buyButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Gdx.net.openURI("https://play.google.com/store/apps/details?id=com.andgate.pokeadot"); } }); final LabelStyle currentHighScoreLabelStyle = new LabelStyle(game.smallFont, Color.ORANGE); final String currentHighScore = String.format("%.2f", HighScoreService.get().time); final Label currentHighScoreLabel = new Label("Best time: " + currentHighScore, currentHighScoreLabelStyle); Table table = new Table(); table.add(titleLabel).center().spaceBottom(25.0f).row(); table.add(currentHighScoreLabel).center().spaceBottom(25.0f).row(); float buttonWidth = practiceButton.getWidth(); table.add(playButton).width(buttonWidth).spaceBottom(20.0f).center().row(); table.add(practiceButton).spaceBottom(20.0f).center().row(); if (game.isFree) { table.add(buyButton).width(buttonWidth).spaceBottom(20.0f).center().row(); } table.setFillParent(true); stage.addActor(table); }
From source file:com.badlogic.gdx.backends.android.CardBoardAndroidApplication.java
License:Apache License
private void init(ApplicationListener listener, AndroidApplicationConfiguration config, boolean isForView) { if (this.getVersion() < MINIMUM_SDK) { throw new GdxRuntimeException("LibGDX requires Android API Level " + MINIMUM_SDK + " or later."); }/*w w w . j av a 2 s .com*/ graphics = new CardBoardGraphics(this, config, config.resolutionStrategy == null ? new FillResolutionStrategy() : config.resolutionStrategy); input = AndroidInputFactory.newAndroidInput(this, this, graphics.view, config); audio = new AndroidAudio(this, config); this.getFilesDir(); // workaround for Android bug #10515463 files = new AndroidFiles(this.getAssets(), this.getFilesDir().getAbsolutePath()); net = new AndroidNet(this); this.listener = listener; this.handler = new Handler(); this.useImmersiveMode = config.useImmersiveMode; this.hideStatusBar = config.hideStatusBar; // Add a specialized audio lifecycle listener addLifecycleListener(new LifecycleListener() { @Override public void resume() { // No need to resume audio here } @Override public void pause() { audio.pause(); } @Override public void dispose() { audio.dispose(); } }); Gdx.app = this; Gdx.input = this.getInput(); Gdx.audio = this.getAudio(); Gdx.files = this.getFiles(); Gdx.graphics = this.getGraphics(); Gdx.net = this.getNet(); if (!isForView) { try { requestWindowFeature(Window.FEATURE_NO_TITLE); } catch (Exception ex) { log("AndroidApplication", "Content already displayed, cannot request FEATURE_NO_TITLE", ex); } getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); setContentView(graphics.getView(), createLayoutParams()); setCardboardView((CardboardView) graphics.getView()); } createWakeLock(config.useWakelock); hideStatusBar(this.hideStatusBar); useImmersiveMode(this.useImmersiveMode); if (this.useImmersiveMode && getVersion() >= Build.VERSION_CODES.KITKAT) { try { Class<?> vlistener = Class.forName("com.badlogic.gdx.backends.android.AndroidVisibilityListener"); Object o = vlistener.newInstance(); Method method = vlistener.getDeclaredMethod("createListener", AndroidApplicationBase.class); method.invoke(o, this); } catch (Exception e) { log("AndroidApplication", "Failed to create AndroidVisibilityListener", e); } } }
From source file:com.badlogic.gdx.backends.android.CardBoardAndroidApplication.java
License:Apache License
@Override protected void onResume() { Gdx.app = this; Gdx.input = this.getInput(); Gdx.audio = this.getAudio(); Gdx.files = this.getFiles(); Gdx.graphics = this.getGraphics(); Gdx.net = this.getNet(); input.onResume();// ww w. j a v a2 s . c om if (graphics != null) { graphics.onResumeGLSurfaceView(); } if (!firstResume) { graphics.resume(); } else firstResume = false; this.isWaitingForAudio = true; if (this.wasFocusChanged == 1 || this.wasFocusChanged == -1) { this.audio.resume(); this.isWaitingForAudio = false; } super.onResume(); }
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;/*w w w . j av a2s . co m*/ 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); }