From 90b35b802d61f007dcadfdf387fbaac8638a22cb Mon Sep 17 00:00:00 2001 From: SimonIT Date: Mon, 11 Nov 2024 23:57:50 +0100 Subject: [PATCH 1/7] fix: Wayland doesn't support setting window position and icon (#7497) --- .../backends/lwjgl3/Lwjgl3Application.java | 32 ++++++++++--------- .../gdx/backends/lwjgl3/Lwjgl3Window.java | 2 ++ 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/backends/gdx-backend-lwjgl3/src/com/badlogic/gdx/backends/lwjgl3/Lwjgl3Application.java b/backends/gdx-backend-lwjgl3/src/com/badlogic/gdx/backends/lwjgl3/Lwjgl3Application.java index 1ff27d76ec0..b28e501ea15 100644 --- a/backends/gdx-backend-lwjgl3/src/com/badlogic/gdx/backends/lwjgl3/Lwjgl3Application.java +++ b/backends/gdx-backend-lwjgl3/src/com/badlogic/gdx/backends/lwjgl3/Lwjgl3Application.java @@ -526,22 +526,24 @@ static long createGlfwWindow (Lwjgl3ApplicationConfiguration config, long shared Lwjgl3Window.setSizeLimits(windowHandle, config.windowMinWidth, config.windowMinHeight, config.windowMaxWidth, config.windowMaxHeight); if (config.fullscreenMode == null) { - if (config.windowX == -1 && config.windowY == -1) { // i.e., center the window - int windowWidth = Math.max(config.windowWidth, config.windowMinWidth); - int windowHeight = Math.max(config.windowHeight, config.windowMinHeight); - if (config.windowMaxWidth > -1) windowWidth = Math.min(windowWidth, config.windowMaxWidth); - if (config.windowMaxHeight > -1) windowHeight = Math.min(windowHeight, config.windowMaxHeight); - - long monitorHandle = GLFW.glfwGetPrimaryMonitor(); - if (config.windowMaximized && config.maximizedMonitor != null) { - monitorHandle = config.maximizedMonitor.monitorHandle; - } + if (GLFW.glfwGetPlatform() != GLFW.GLFW_PLATFORM_WAYLAND) { + if (config.windowX == -1 && config.windowY == -1) { // i.e., center the window + int windowWidth = Math.max(config.windowWidth, config.windowMinWidth); + int windowHeight = Math.max(config.windowHeight, config.windowMinHeight); + if (config.windowMaxWidth > -1) windowWidth = Math.min(windowWidth, config.windowMaxWidth); + if (config.windowMaxHeight > -1) windowHeight = Math.min(windowHeight, config.windowMaxHeight); + + long monitorHandle = GLFW.glfwGetPrimaryMonitor(); + if (config.windowMaximized && config.maximizedMonitor != null) { + monitorHandle = config.maximizedMonitor.monitorHandle; + } - GridPoint2 newPos = Lwjgl3ApplicationConfiguration.calculateCenteredWindowPosition( - Lwjgl3ApplicationConfiguration.toLwjgl3Monitor(monitorHandle), windowWidth, windowHeight); - GLFW.glfwSetWindowPos(windowHandle, newPos.x, newPos.y); - } else { - GLFW.glfwSetWindowPos(windowHandle, config.windowX, config.windowY); + GridPoint2 newPos = Lwjgl3ApplicationConfiguration.calculateCenteredWindowPosition( + Lwjgl3ApplicationConfiguration.toLwjgl3Monitor(monitorHandle), windowWidth, windowHeight); + GLFW.glfwSetWindowPos(windowHandle, newPos.x, newPos.y); + } else { + GLFW.glfwSetWindowPos(windowHandle, config.windowX, config.windowY); + } } if (config.windowMaximized) { diff --git a/backends/gdx-backend-lwjgl3/src/com/badlogic/gdx/backends/lwjgl3/Lwjgl3Window.java b/backends/gdx-backend-lwjgl3/src/com/badlogic/gdx/backends/lwjgl3/Lwjgl3Window.java index fb3258db9f1..8375c4bf5b0 100644 --- a/backends/gdx-backend-lwjgl3/src/com/badlogic/gdx/backends/lwjgl3/Lwjgl3Window.java +++ b/backends/gdx-backend-lwjgl3/src/com/badlogic/gdx/backends/lwjgl3/Lwjgl3Window.java @@ -238,6 +238,7 @@ public void postRunnable (Runnable runnable) { /** Sets the position of the window in logical coordinates. All monitors span a virtual surface together. The coordinates are * relative to the first monitor in the virtual surface. **/ public void setPosition (int x, int y) { + if (GLFW.glfwGetPlatform() == GLFW.GLFW_PLATFORM_WAYLAND) return; GLFW.glfwSetWindowPos(windowHandle, x, y); } @@ -325,6 +326,7 @@ static void setIcon (long windowHandle, String[] imagePaths, Files.FileType imag static void setIcon (long windowHandle, Pixmap[] images) { if (SharedLibraryLoader.os == Os.MacOsX) return; + if (GLFW.glfwGetPlatform() == GLFW.GLFW_PLATFORM_WAYLAND) return; GLFWImage.Buffer buffer = GLFWImage.malloc(images.length); Pixmap[] tmpPixmaps = new Pixmap[images.length]; From 276fb3acb9e5a031981d8215e37756f30acbccc7 Mon Sep 17 00:00:00 2001 From: Justin Shapcott Date: Tue, 12 Nov 2024 07:02:15 -0700 Subject: [PATCH 2/7] GWT - Calculate MD5 hash while copying file to avoid errors on very large files (#6853) --- .../preloader/PreloaderBundleGenerator.java | 78 ++++++++++++------- 1 file changed, 52 insertions(+), 26 deletions(-) diff --git a/backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/preloader/PreloaderBundleGenerator.java b/backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/preloader/PreloaderBundleGenerator.java index a6a981b680a..71be58911fb 100644 --- a/backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/preloader/PreloaderBundleGenerator.java +++ b/backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/preloader/PreloaderBundleGenerator.java @@ -19,6 +19,10 @@ import java.io.*; import java.math.BigInteger; import java.net.URLConnection; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.security.DigestInputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; @@ -28,7 +32,6 @@ import com.badlogic.gdx.backends.gwt.preloader.AssetFilter.AssetType; import com.badlogic.gdx.utils.GdxRuntimeException; -import com.badlogic.gdx.utils.StreamUtils; import com.google.gwt.core.ext.BadPropertyValueException; import com.google.gwt.core.ext.ConfigurationProperty; import com.google.gwt.core.ext.Generator; @@ -38,6 +41,8 @@ import com.google.gwt.user.rebind.ClassSourceFileComposerFactory; import com.google.gwt.user.rebind.SourceWriter; +import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; + /** Copies assets from the path specified in the modules gdx.assetpath configuration property to the war/ folder and generates the * assets.txt file. The type of a file is determined by an {@link AssetFilter}, which is either created by instantiating the class * specified in the gdx.assetfilterclass property, or falling back to the {@link DefaultAssetFilter}. @@ -90,14 +95,11 @@ public String generate (TreeLogger logger, GeneratorContext context, String type List classpathFiles = getClasspathFiles(context); for (String classpathFile : classpathFiles) { if (assetFilter.accept(classpathFile, false)) { + FileWrapper orig = target.child(classpathFile); + FileWrapper dest = target.child(orig.name()); try { - InputStream is = context.getClass().getClassLoader().getResourceAsStream(classpathFile); - byte[] bytes = StreamUtils.copyStreamToByteArray(is); - is.close(); - FileWrapper origFile = target.child(classpathFile); - FileWrapper destFile = target.child(fileNameWithMd5(origFile, bytes)); - destFile.writeBytes(bytes, false); - assets.add(new Asset(origFile.path(), destFile, assetFilter.getType(destFile.path()))); + InputStream resourceStream = context.getClass().getClassLoader().getResourceAsStream(classpathFile); + copy(resourceStream, dest.path(), dest, assetFilter, assets); } catch (IOException e) { e.printStackTrace(); } @@ -149,11 +151,9 @@ private void copyFile (FileWrapper source, String filePathOrig, FileWrapper dest ArrayList assets) { if (!filter.accept(filePathOrig, false)) return; try { - assets.add(new Asset(filePathOrig, dest, filter.getType(dest.path()))); - dest.write(source.read(), false); - } catch (Exception ex) { - throw new GdxRuntimeException("Error copying source file: " + source + "\n" // - + "To destination: " + dest, ex); + copy(source.read(), filePathOrig, dest, filter, assets); + } catch (IOException e) { + throw new GdxRuntimeException("Error copying source file: " + source + "\n" + "To destination: " + dest, e); } } @@ -167,12 +167,34 @@ private void copyDirectory (FileWrapper sourceDir, FileWrapper destDir, AssetFil FileWrapper destFile = destDir.child(srcFile.name()); copyDirectory(srcFile, destFile, filter, assets); } else { - FileWrapper destFile = destDir.child(fileNameWithMd5(srcFile, srcFile.readBytes())); + FileWrapper destFile = destDir.child(srcFile.name()); copyFile(srcFile, destDir.child(srcFile.name()).path(), destFile, filter, assets); } } } + private void copy (InputStream source, String filePathOrig, FileWrapper dest, AssetFilter filter, ArrayList assets) + throws IOException { + try (InputStream in = source) { + try { + // Calculate an MD5 hash while we copy the file + MessageDigest digest = MessageDigest.getInstance("MD5"); + DigestInputStream digestInputStream = new DigestInputStream(in, digest); + dest.write(digestInputStream, false); + + // Add the hash to the file name, then move the file to the new path + FileWrapper newDest = dest.parent().child(fileNameWithHash(dest, digest)); + Files.move(toPath(dest.file()), toPath(newDest.file()), REPLACE_EXISTING); + assets.add(new Asset(filePathOrig, newDest, filter.getType(dest.path()))); + } catch (NoSuchAlgorithmException e) { + // Fallback to a build timestamp if we can't calculate an MD5 hash + FileWrapper newDest = dest.parent().child(fileNameWithTimestamp(dest)); + newDest.write(in, false); + assets.add(new Asset(filePathOrig, newDest, filter.getType(dest.path()))); + } + } + } + private AssetFilter getAssetFilter (GeneratorContext context) { ConfigurationProperty assetFilterClassProperty; try { @@ -275,23 +297,27 @@ private String createDummyClass (TreeLogger logger, GeneratorContext context) { return packageName + "." + className; } - private static String fileNameWithMd5 (FileWrapper fw, byte[] bytes) { - String md5; - try { - MessageDigest digest = MessageDigest.getInstance("MD5"); - digest.update(bytes); - md5 = String.format("%032x", new BigInteger(1, digest.digest())); - } catch (NoSuchAlgorithmException e) { - // Fallback - md5 = String.valueOf(System.currentTimeMillis()); + private static String fileNameWithHash (FileWrapper fw, MessageDigest digest) { + String hash = String.format("%032x", new BigInteger(1, digest.digest())); + String nameWithHash = fw.nameWithoutExtension() + "-" + hash; + String extension = fw.extension(); + if (!extension.isEmpty() || fw.name().endsWith(".")) { + nameWithHash = nameWithHash + "." + extension; } + return nameWithHash; + } - String nameWithMd5 = fw.nameWithoutExtension() + "-" + md5; + private static String fileNameWithTimestamp (FileWrapper fw) { + String timestamp = String.valueOf(System.currentTimeMillis()); + String nameWithTimestamp = fw.nameWithoutExtension() + "-" + timestamp; String extension = fw.extension(); if (!extension.isEmpty() || fw.name().endsWith(".")) { - nameWithMd5 = nameWithMd5 + "." + extension; + nameWithTimestamp = nameWithTimestamp + "." + extension; } - return nameWithMd5; + return nameWithTimestamp; } + private static Path toPath (File file) { + return FileSystems.getDefault().getPath(file.getPath()); + } } From 1dd4b31438663455f975038245dd665bc38ef7cb Mon Sep 17 00:00:00 2001 From: Geolykt Date: Tue, 12 Nov 2024 23:58:12 +0100 Subject: [PATCH 3/7] Do not inline the version string (#7398) --- gdx/src/com/badlogic/gdx/Version.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdx/src/com/badlogic/gdx/Version.java b/gdx/src/com/badlogic/gdx/Version.java index a90cf64b814..b464cdd82b5 100644 --- a/gdx/src/com/badlogic/gdx/Version.java +++ b/gdx/src/com/badlogic/gdx/Version.java @@ -23,7 +23,7 @@ * @author mzechner */ public class Version { /** The current version of libGDX as a String in the major.minor.revision format **/ - public static final String VERSION = "1.13.1"; + public static final String VERSION = "1.13.1".toString(); /** The current major version of libGDX **/ public static final int MAJOR; From be482fa7df9f9e5ce81293264410e0c0b5a4d92d Mon Sep 17 00:00:00 2001 From: Tomski Date: Wed, 13 Nov 2024 14:56:17 +0000 Subject: [PATCH 4/7] Change defaults of SpriteBatch to use VBO instead of VertexArray on gl2/gles2.0 (#7486) --- gdx/src/com/badlogic/gdx/graphics/Mesh.java | 4 + .../gdx/graphics/g2d/SpriteBatch.java | 31 ++++-- .../gdx/tests/gwt/client/GwtTestWrapper.java | 6 ++ tests/gdx-tests-lwjgl3/build.gradle | 1 + .../gdx/tests/SpriteBatchPerformanceTest.java | 95 ++++++++++++++----- 5 files changed, 107 insertions(+), 30 deletions(-) diff --git a/gdx/src/com/badlogic/gdx/graphics/Mesh.java b/gdx/src/com/badlogic/gdx/graphics/Mesh.java index 4e3548d52bc..1b87e5a8242 100644 --- a/gdx/src/com/badlogic/gdx/graphics/Mesh.java +++ b/gdx/src/com/badlogic/gdx/graphics/Mesh.java @@ -487,6 +487,10 @@ public int getVertexSize () { return vertices.getAttributes().vertexSize; } + public IndexData getIndexData () { + return indices; + } + /** Sets whether to bind the underlying {@link VertexArray} or {@link VertexBufferObject} automatically on a call to one of the * render methods. Usually you want to use autobind. Manual binding is an expert functionality. There is a driver bug on the * MSM720xa chips that will fuck up memory if you manipulate the vertices and indices of a Mesh multiple times while it is diff --git a/gdx/src/com/badlogic/gdx/graphics/g2d/SpriteBatch.java b/gdx/src/com/badlogic/gdx/graphics/g2d/SpriteBatch.java index 04e12fdf4f2..e4310d85a84 100644 --- a/gdx/src/com/badlogic/gdx/graphics/g2d/SpriteBatch.java +++ b/gdx/src/com/badlogic/gdx/graphics/g2d/SpriteBatch.java @@ -38,7 +38,14 @@ public class SpriteBatch implements Batch { /** @deprecated Do not use, this field is for testing only and is likely to be removed. Sets the {@link VertexDataType} to be * used when gles 3 is not available, defaults to {@link VertexDataType#VertexArray}. */ - @Deprecated public static VertexDataType defaultVertexDataType = VertexDataType.VertexArray; + @Deprecated public static VertexDataType defaultVertexDataType = VertexDataType.VertexBufferObject; + + /** Used to completely override the vertex type used by SpriteBatch. This is useful for picking a specific vertex data type on + * construction of the sprite batch. Recommended to reset this back to defaultVertexDataType Once the batch has been created + * with this flag */ + @Deprecated public static VertexDataType overrideVertexType = null; + + private VertexDataType currentDataType; private Mesh mesh; @@ -101,7 +108,13 @@ public SpriteBatch (int size, ShaderProgram defaultShader) { VertexDataType vertexDataType = (Gdx.gl30 != null) ? VertexDataType.VertexBufferObjectWithVAO : defaultVertexDataType; - mesh = new Mesh(vertexDataType, false, size * 4, size * 6, + if (overrideVertexType != null) { + vertexDataType = overrideVertexType; + } + + currentDataType = vertexDataType; + + mesh = new Mesh(currentDataType, false, size * 4, size * 6, new VertexAttribute(Usage.Position, 2, ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE), new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0")); @@ -131,8 +144,8 @@ public SpriteBatch (int size, ShaderProgram defaultShader) { // Pre bind the mesh to force the upload of indices data. if (vertexDataType != VertexDataType.VertexArray) { - mesh.bind(shader); - mesh.unbind(shader); + mesh.getIndexData().bind(); + mesh.getIndexData().unbind(); } } @@ -962,9 +975,13 @@ public void flush () { lastTexture.bind(); Mesh mesh = this.mesh; mesh.setVertices(vertices, 0, idx); - Buffer indicesBuffer = (Buffer)mesh.getIndicesBuffer(false); - indicesBuffer.position(0); - indicesBuffer.limit(count); + + // Only upload indices for the vertex array type + if (currentDataType == VertexDataType.VertexArray) { + Buffer indicesBuffer = (Buffer)mesh.getIndicesBuffer(true); + indicesBuffer.position(0); + indicesBuffer.limit(count); + } if (blendingDisabled) { Gdx.gl.glDisable(GL20.GL_BLEND); diff --git a/tests/gdx-tests-gwt/src/com/badlogic/gdx/tests/gwt/client/GwtTestWrapper.java b/tests/gdx-tests-gwt/src/com/badlogic/gdx/tests/gwt/client/GwtTestWrapper.java index 188b34f7677..a7844d47199 100644 --- a/tests/gdx-tests-gwt/src/com/badlogic/gdx/tests/gwt/client/GwtTestWrapper.java +++ b/tests/gdx-tests-gwt/src/com/badlogic/gdx/tests/gwt/client/GwtTestWrapper.java @@ -77,6 +77,7 @@ import com.badlogic.gdx.tests.SortedSpriteTest; import com.badlogic.gdx.tests.SoundTest; import com.badlogic.gdx.tests.SpriteBatchShaderTest; +import com.badlogic.gdx.tests.SpriteBatchPerformanceTest; import com.badlogic.gdx.tests.SpriteCacheOffsetTest; import com.badlogic.gdx.tests.SpriteCacheTest; import com.badlogic.gdx.tests.StageTest; @@ -517,6 +518,11 @@ public GdxTest instance () { return new SpriteBatchShaderTest(); } }); + tests.add(new GwtInstancer() { + public GdxTest instance () { + return new SpriteBatchPerformanceTest(); + } + }); tests.add(new GwtInstancer() { public GdxTest instance () { return new SpriteCacheOffsetTest(); diff --git a/tests/gdx-tests-lwjgl3/build.gradle b/tests/gdx-tests-lwjgl3/build.gradle index ac2c168f9cf..54aaced37b5 100644 --- a/tests/gdx-tests-lwjgl3/build.gradle +++ b/tests/gdx-tests-lwjgl3/build.gradle @@ -55,5 +55,6 @@ tasks.register('dist', Jar) { from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } + duplicatesStrategy = DuplicatesStrategy.EXCLUDE with jar } diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/SpriteBatchPerformanceTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/SpriteBatchPerformanceTest.java index adcca372292..1e3f2de20c0 100644 --- a/tests/gdx-tests/src/com/badlogic/gdx/tests/SpriteBatchPerformanceTest.java +++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/SpriteBatchPerformanceTest.java @@ -16,14 +16,19 @@ package com.badlogic.gdx.tests; +import com.badlogic.gdx.Application; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.GL20; +import com.badlogic.gdx.graphics.Mesh; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.graphics.profiling.GLErrorListener; +import com.badlogic.gdx.graphics.profiling.GLProfiler; import com.badlogic.gdx.math.WindowedMean; import com.badlogic.gdx.tests.utils.GdxTest; import com.badlogic.gdx.tests.utils.GdxTestConfig; +import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.StringBuilder; @GdxTestConfig @@ -31,16 +36,47 @@ public class SpriteBatchPerformanceTest extends GdxTest { private Texture texture; private SpriteBatch spriteBatch; - private WindowedMean counter = new WindowedMean(10000); private StringBuilder stringBuilder = new StringBuilder(); private BitmapFont bitmapFont; + private static class PerfTest { + Mesh.VertexDataType vertexDataType; + WindowedMean counter = new WindowedMean(10000); + + PerfTest (Mesh.VertexDataType type) { + this.vertexDataType = type; + } + } + + private Array perfTests = new Array<>(); + @Override public void create () { texture = new Texture(Gdx.files.internal("data/badlogic.jpg")); spriteBatch = new SpriteBatch(8191); bitmapFont = new BitmapFont(); + + if (Gdx.graphics.isGL30Available()) { + perfTests.add(new PerfTest(Mesh.VertexDataType.VertexBufferObjectWithVAO)); + + if (Gdx.app.getType() != Application.ApplicationType.Desktop) { + perfTests.add(new PerfTest(Mesh.VertexDataType.VertexBufferObject)); + } + } else { + perfTests.add(new PerfTest(Mesh.VertexDataType.VertexArray)); + perfTests.add(new PerfTest(Mesh.VertexDataType.VertexBufferObject)); + } + + GLProfiler glProfiler = new GLProfiler(Gdx.graphics); + glProfiler.setListener(new GLErrorListener() { + @Override + public void onError (int error) { + System.out.println("GLProfiler: error: " + error); + } + }); + glProfiler.enable(); + } @Override @@ -49,39 +85,52 @@ public void render () { Gdx.gl20.glClearColor(0.2f, 0.2f, 0.2f, 1); Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT); - spriteBatch.begin(); + int draws = 100; + int spritesToFill = 8190; - // Accelerate the draws - for (int j = 0; j < 100; j++) { + for (PerfTest perfTest : perfTests) { + SpriteBatch.overrideVertexType = perfTest.vertexDataType; - // fill the batch - for (int i = 0; i < 8190; i++) { - spriteBatch.draw(texture, 0, 0, 1, 1); + SpriteBatch testingBatch = new SpriteBatch(8191); + Gdx.gl.glFlush(); + testingBatch.begin(); + for (int i = 0; i < draws; i++) { + for (int j = 0; j < spritesToFill; j++) { + testingBatch.draw(texture, 0, 0, 1, 1); + } + + long beforeFlush = System.nanoTime(); + testingBatch.flush(); + Gdx.gl.glFlush(); + long afterFlush = System.nanoTime(); + + perfTest.counter.addValue(afterFlush - beforeFlush); } - long beforeFlush = System.nanoTime(); - - spriteBatch.flush(); + testingBatch.end(); + testingBatch.dispose(); Gdx.gl.glFlush(); - long afterFlush = System.nanoTime(); - - counter.addValue(afterFlush - beforeFlush); - } - spriteBatch.end(); - spriteBatch.begin(); - stringBuilder.setLength(0); - if (counter.hasEnoughData()) { - stringBuilder.append("Mean Time ms: "); - stringBuilder.append(counter.getMean() / 1e6); - } else { - stringBuilder.append("Please wait, collecting data..."); + stringBuilder.setLength(0); + for (PerfTest perfTest : perfTests) { + stringBuilder.append("Type: "); + stringBuilder.append(perfTest.vertexDataType); + stringBuilder.append("\n"); + + if (perfTest.counter.hasEnoughData()) { + stringBuilder.append("Mean Time ms: "); + float nanoTimeMean = perfTest.counter.getMean(); + stringBuilder.append(nanoTimeMean / 1e6); + } else { + stringBuilder.append("Please wait, collecting data..."); + } + stringBuilder.append("\n\n"); } + bitmapFont.draw(spriteBatch, stringBuilder, 0, 400); - bitmapFont.draw(spriteBatch, stringBuilder, 0, 200); spriteBatch.end(); } From 444a8e5e6df2350c28fd94df33733cb5b58009ae Mon Sep 17 00:00:00 2001 From: obigu <1794492+obigu@users.noreply.github.com> Date: Wed, 13 Nov 2024 17:43:33 +0100 Subject: [PATCH 5/7] Upgrade gha XCode to 15.4 (#7511) * Upgrade gha XCode to 15.2 * Use latest available version --- .github/workflows/build-publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-publish.yml b/.github/workflows/build-publish.yml index b3bb7556d20..6692a968dd4 100644 --- a/.github/workflows/build-publish.yml +++ b/.github/workflows/build-publish.yml @@ -35,7 +35,7 @@ jobs: # See https://github.com/actions/virtual-environments/issues/2557 sudo mv /Library/Developer/CommandLineTools/SDKs/* /tmp sudo mv /Applications/Xcode.app /Applications/Xcode.app.bak - sudo mv /Applications/Xcode_14.3.1.app /Applications/Xcode.app + sudo mv /Applications/Xcode_15.4.0.app /Applications/Xcode.app sudo xcode-select -switch /Applications/Xcode.app /usr/bin/xcodebuild -version ./gradlew jniGen jnigenBuildIOS @@ -74,7 +74,7 @@ jobs: # See https://github.com/actions/virtual-environments/issues/2557 sudo mv /Library/Developer/CommandLineTools/SDKs/* /tmp sudo mv /Applications/Xcode.app /Applications/Xcode.app.bak - sudo mv /Applications/Xcode_14.3.1.app /Applications/Xcode.app + sudo mv /Applications/Xcode_15.4.0.app /Applications/Xcode.app sudo xcode-select -switch /Applications/Xcode.app /usr/bin/xcodebuild -version ./gradlew jniGen jnigenBuildMacOsX64 jnigenBuildMacOsXARM64 From e250805649d41f63a75e10636a85c8d004f04cfe Mon Sep 17 00:00:00 2001 From: obigu <1794492+obigu@users.noreply.github.com> Date: Wed, 13 Nov 2024 18:10:52 +0100 Subject: [PATCH 6/7] Fix #7509 Gdx.net.openURI not working on iOS 18.1 Simulator (#7510) * Fix #7509 * Generate MobiVM MetalANGLE backend --------- Co-authored-by: GitHub Action --- CHANGES | 1 + .../src/com/badlogic/gdx/backends/iosrobovm/IOSNet.java | 3 ++- .../src/com/badlogic/gdx/backends/iosrobovm/IOSNet.java | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 428dadeffc9..2696558f0e8 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,6 @@ [1.13.1] - iOS: Update to MobiVM 2.3.22 +- iOS: Fixes Gdx.openURI() not working on iOS 18.1 Simulator. - Change visibility of PolygonSpriteBatch.switchTexture() to protected - Added XmlReader.getChildren() and XmlReader.replaceChild() diff --git a/backends/gdx-backend-robovm-metalangle/src/com/badlogic/gdx/backends/iosrobovm/IOSNet.java b/backends/gdx-backend-robovm-metalangle/src/com/badlogic/gdx/backends/iosrobovm/IOSNet.java index cd41a4df9b3..c8ce76201f5 100644 --- a/backends/gdx-backend-robovm-metalangle/src/com/badlogic/gdx/backends/iosrobovm/IOSNet.java +++ b/backends/gdx-backend-robovm-metalangle/src/com/badlogic/gdx/backends/iosrobovm/IOSNet.java @@ -12,6 +12,7 @@ import com.badlogic.gdx.net.ServerSocketHints; import com.badlogic.gdx.net.Socket; import com.badlogic.gdx.net.SocketHints; +import org.robovm.apple.uikit.UIApplicationOpenURLOptions; /** DO NOT EDIT THIS FILE - it is machine generated */ public class IOSNet implements Net { @@ -59,7 +60,7 @@ public Socket newClientSocket (Protocol protocol, String host, int port, SocketH public boolean openURI (String URI) { NSURL url = new NSURL(URI); if (uiApp.canOpenURL(url)) { - uiApp.openURL(url); + uiApp.openURL(url, new UIApplicationOpenURLOptions(), null); return true; } return false; diff --git a/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSNet.java b/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSNet.java index d013ed708e6..5314a62c4a7 100644 --- a/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSNet.java +++ b/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSNet.java @@ -27,6 +27,7 @@ import com.badlogic.gdx.net.ServerSocketHints; import com.badlogic.gdx.net.Socket; import com.badlogic.gdx.net.SocketHints; +import org.robovm.apple.uikit.UIApplicationOpenURLOptions; public class IOSNet implements Net { @@ -72,7 +73,7 @@ public Socket newClientSocket (Protocol protocol, String host, int port, SocketH public boolean openURI (String URI) { NSURL url = new NSURL(URI); if (uiApp.canOpenURL(url)) { - uiApp.openURL(url); + uiApp.openURL(url, new UIApplicationOpenURLOptions(), null); return true; } return false; From 9886f3b6794b9ce745f4c7b869cb75c3649b417a Mon Sep 17 00:00:00 2001 From: Thomas Creutzenberg Date: Thu, 14 Nov 2024 14:55:57 +0100 Subject: [PATCH 7/7] Added FPSLogger.setBound() (#7424) --------- Co-authored-by: damios --- CHANGES | 1 + gdx/src/com/badlogic/gdx/graphics/FPSLogger.java | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/CHANGES b/CHANGES index 2696558f0e8..657b8e9b78c 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,7 @@ - iOS: Fixes Gdx.openURI() not working on iOS 18.1 Simulator. - Change visibility of PolygonSpriteBatch.switchTexture() to protected - Added XmlReader.getChildren() and XmlReader.replaceChild() +- API Addition: Added FPSLogger#setBound [1.13.0] - [BREAKING CHANGE] GWT: Updated to 2.11.0. `com.google.jsinterop:jsinterop-annotations:2.0.2:sources` must be added as a dependency to your html project dependencies. diff --git a/gdx/src/com/badlogic/gdx/graphics/FPSLogger.java b/gdx/src/com/badlogic/gdx/graphics/FPSLogger.java index fd8877aa971..12b86db54f3 100644 --- a/gdx/src/com/badlogic/gdx/graphics/FPSLogger.java +++ b/gdx/src/com/badlogic/gdx/graphics/FPSLogger.java @@ -37,6 +37,11 @@ public FPSLogger (int bound) { startTime = TimeUtils.nanoTime(); } + public void setBound (int bound) { + this.bound = bound; + startTime = TimeUtils.nanoTime(); + } + /** Logs the current frames per second to the console. */ public void log () { final long nanoTime = TimeUtils.nanoTime();