[Mobile] Update LibGDX to 1.10.0, Update Mobile Dev to LWJGL3

refer here for LibGDX Migration/Changes: https://libgdx.com/news/2021/04/the-ultimate-migration-guide
This commit is contained in:
Anthony Calosa
2021-04-19 21:41:34 +08:00
parent 539c94f36f
commit a5e8b88e32
6 changed files with 25 additions and 25 deletions

View File

@@ -87,7 +87,7 @@
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-backend-android</artifactId>
<version>1.9.13</version>
<version>1.10.0</version>
</dependency>
</dependencies>

View File

@@ -68,7 +68,7 @@
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-backend-robovm</artifactId>
<version>1.9.13</version>
<version>1.10.0</version>
</dependency>
</dependencies>
</project>

View File

@@ -59,19 +59,19 @@
</dependency>
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-backend-lwjgl</artifactId>
<version>1.9.13</version>
<artifactId>gdx-backend-lwjgl3</artifactId>
<version>1.10.0</version>
</dependency>
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-platform</artifactId>
<version>1.9.13</version>
<version>1.10.0</version>
<classifier>natives-desktop</classifier>
</dependency>
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-freetype-platform</artifactId>
<version>1.9.13</version>
<version>1.10.0</version>
<classifier>natives-desktop</classifier>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-cli/commons-cli -->

View File

@@ -9,6 +9,7 @@ import java.io.OutputStream;
import javax.imageio.ImageIO;
import com.badlogic.gdx.graphics.glutils.HdpiMode;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
@@ -17,9 +18,9 @@ import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.badlogic.gdx.backends.lwjgl.LwjglClipboard;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Clipboard;
import forge.Forge;
import forge.assets.AssetsDownloader;
@@ -85,8 +86,8 @@ public class Main {
// Fullscreen width and height for desktop mode (desktopMode = true)
// Can be specified inside the file fullscreen_resolution.ini to override default (in the format WxH, e.g. 1920x1080)
int desktopScreenWidth = LwjglApplicationConfiguration.getDesktopDisplayMode().width;
int desktopScreenHeight = LwjglApplicationConfiguration.getDesktopDisplayMode().height;
int desktopScreenWidth = Lwjgl3ApplicationConfiguration.getDisplayMode().width;
int desktopScreenHeight = Lwjgl3ApplicationConfiguration.getDisplayMode().height;
boolean fullscreenFlag = true;
if (FileUtil.doesFileExist(desktopModeAssetsDir + "screen_resolution.ini")) {
res = FileUtil.readFileToString(desktopModeAssetsDir + "screen_resolution.ini").split("x");
@@ -97,17 +98,18 @@ public class Main {
}
}
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.resizable = false;
config.width = desktopMode ? desktopScreenWidth : screenWidth;
config.height = desktopMode ? desktopScreenHeight : screenHeight;
config.fullscreen = desktopMode && fullscreenFlag;
config.title = "Forge";
config.useHDPI = desktopMode; // enable HiDPI on Mac OS
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
config.setResizable(false);
config.setWindowedMode(desktopMode ? desktopScreenWidth : screenWidth, desktopMode ? desktopScreenHeight : screenHeight);
if (desktopMode && fullscreenFlag)
config.setFullscreenMode(Lwjgl3ApplicationConfiguration.getDisplayMode());
config.setTitle("Forge");
if (desktopMode)
config.setHdpiMode(HdpiMode.Logical);
ForgePreferences prefs = FModel.getPreferences();
boolean propertyConfig = prefs != null && prefs.getPrefBoolean(ForgePreferences.FPref.UI_NETPLAY_COMPAT);
new LwjglApplication(Forge.getApp(new LwjglClipboard(), new DesktopAdapter(switchOrientationFile),//todo get totalRAM && isTabletDevice
new Lwjgl3Application(Forge.getApp(new Lwjgl3Clipboard(), new DesktopAdapter(switchOrientationFile),//todo get totalRAM && isTabletDevice
desktopMode ? desktopModeAssetsDir : assetsDir, propertyConfig, false, 0, false, 0, "", ""), config);
}

View File

@@ -48,12 +48,12 @@
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx</artifactId>
<version>1.9.13</version>
<version>1.10.0</version>
</dependency>
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-freetype</artifactId>
<version>1.9.13</version>
<version>1.10.0</version>
</dependency>
</dependencies>

View File

@@ -681,12 +681,11 @@ public class Graphics {
batch.draw(image, adjustX(x), adjustY(y, h), w, h);
} else {
batch.end();
shaderOutline.begin();
shaderOutline.bind();
shaderOutline.setUniformf("u_viewportInverse", new Vector2(1f / w, 1f / h));
shaderOutline.setUniformf("u_offset", 3f);
shaderOutline.setUniformf("u_step", Math.min(1f, w / 70f));
shaderOutline.setUniformf("u_color", new Vector3(glowColor.r, glowColor.g, glowColor.b));
shaderOutline.end();
batch.setShader(shaderOutline);
batch.begin();
//glow
@@ -705,12 +704,11 @@ public class Graphics {
batch.draw(image, adjustX(x), adjustY(yBox, h), w, h);
} else {
batch.end();
shaderOutline.begin();
shaderOutline.bind();
shaderOutline.setUniformf("u_viewportInverse", new Vector2(1f / w, 1f / h));
shaderOutline.setUniformf("u_offset", 3f);
shaderOutline.setUniformf("u_step", Math.min(1f, w / 70f));
shaderOutline.setUniformf("u_color", new Vector3(glowColor.r, glowColor.g, glowColor.b));
shaderOutline.end();
batch.setShader(shaderOutline);
batch.begin();
//glow