diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/PojavLauncher.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/PojavLauncher.java index 00a7717d..b8883107 100644 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/PojavLauncher.java +++ b/JavaApp/src/main/java/net/kdt/pojavlaunch/PojavLauncher.java @@ -1,6 +1,8 @@ package net.kdt.pojavlaunch; +import java.beans.Beans; import java.io.*; +import java.lang.reflect.Field; import java.util.*; import java.util.concurrent.*; @@ -15,15 +17,20 @@ public class PojavLauncher { private static float currProgress, maxProgress; public static void main(String[] args) throws Throwable { - /* - try { - Runtime.getRuntime().exec("/usr/bin/true"); - } catch (IOException e) {} - */ + // Skip calling to com.apple.eawt.Application.nativeInitializeApplicationDelegate() + Beans.setDesignTime(true); try { + // Some places use macOS-specific code, which is unavailable on iOS + // In this case, try to get it to use Linux-specific code instead. + com.apple.eawt.Application.getApplication(); + Class clazz = Class.forName("com.apple.eawt.Application"); + Field field = clazz.getDeclaredField("sApplication"); + field.setAccessible(true); + field.set(null, null); sun.font.FontUtilities.isLinux = true; } catch (Throwable th) { // Not on JRE8, ignore exception + //Tools.showError(th); } Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/Tools.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/Tools.java index e3965723..3b848d00 100644 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/Tools.java +++ b/JavaApp/src/main/java/net/kdt/pojavlaunch/Tools.java @@ -321,8 +321,6 @@ public final class Tools e.printStackTrace(pw); pw.flush(); - System.err.println(sw.toString()); - UIKit.showError(title, sw.toString(), exitIfOk); /* diff --git a/JavaApp/src/main/java/net/kdt/pojavlaunch/utils/JSONUtils.java b/JavaApp/src/main/java/net/kdt/pojavlaunch/utils/JSONUtils.java index b622d6e4..c36a3f5f 100644 --- a/JavaApp/src/main/java/net/kdt/pojavlaunch/utils/JSONUtils.java +++ b/JavaApp/src/main/java/net/kdt/pojavlaunch/utils/JSONUtils.java @@ -13,6 +13,9 @@ public class JSONUtils { public static String insertSingleJSONValue(String value, Map keyValueMap) { String valueInserted = value; for (Map.Entry keyValue : keyValueMap.entrySet()) { + if (keyValue.getValue() == null) { + keyValue.setValue(""); + } valueInserted = valueInserted.replace("${" + keyValue.getKey() + "}", keyValue.getValue()); } return valueInserted; diff --git a/JavaApp/src/main/java/org/lwjgl/glfw/GLFW.java b/JavaApp/src/main/java/org/lwjgl/glfw/GLFW.java index 61495265..80d905c4 100644 --- a/JavaApp/src/main/java/org/lwjgl/glfw/GLFW.java +++ b/JavaApp/src/main/java/org/lwjgl/glfw/GLFW.java @@ -518,12 +518,11 @@ public class GLFW mGLFWVideoMode = new GLFWVidMode(ByteBuffer.allocateDirect(GLFWVidMode.SIZEOF)); internalChangeMonitorSize(Tools.mGLFWWindowWidth, Tools.mGLFWWindowHeight); -/* memPutInt(mGLFWVideoMode.address() + (long) mGLFWVideoMode.REDBITS, 8); memPutInt(mGLFWVideoMode.address() + (long) mGLFWVideoMode.GREENBITS, 8); memPutInt(mGLFWVideoMode.address() + (long) mGLFWVideoMode.BLUEBITS, 8); memPutInt(mGLFWVideoMode.address() + (long) mGLFWVideoMode.REFRESHRATE, 60); -*/ + // A way to generate key code names Field[] thisFieldArr = GLFW.class.getFields(); try { @@ -912,7 +911,9 @@ public class GLFW try { // long __result = nglfwGetVideoModes(monitor, memAddress(count)); long __result = memAddress(stack.callocLong(1)); - return GLFWVidMode.createSafe(__result, 1); + GLFWVidMode.Buffer buffer = GLFWVidMode.createSafe(__result, 1); + buffer.put(glfwGetVideoMode(monitor)); + return buffer; } finally { stack.setPointer(stackPointer); } diff --git a/JavaApp/src/main/java/org/lwjgl/glfw/GLFWVidMode.java b/JavaApp/src/main/java/org/lwjgl/glfw/GLFWVidMode.java index a86e1b4a..5e06259d 100644 --- a/JavaApp/src/main/java/org/lwjgl/glfw/GLFWVidMode.java +++ b/JavaApp/src/main/java/org/lwjgl/glfw/GLFWVidMode.java @@ -50,12 +50,12 @@ public class GLFWVidMode extends Struct { /** The struct member offsets. */ public static final int - WIDTH, - HEIGHT, - REDBITS, - GREENBITS, - BLUEBITS, - REFRESHRATE; + WIDTH, + HEIGHT, + REDBITS, + GREENBITS, + BLUEBITS, + REFRESHRATE; static { Layout layout = __struct( @@ -140,13 +140,13 @@ public class GLFWVidMode extends Struct { /** Unsafe version of {@link #height}. */ public static int nheight(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.HEIGHT); } /** Unsafe version of {@link #redBits}. */ - public static int nredBits(long struct) { return 8; } // UNSAFE.getInt(null, struct + GLFWVidMode.REDBITS); } + public static int nredBits(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.REDBITS); } /** Unsafe version of {@link #greenBits}. */ - public static int ngreenBits(long struct) { return 8; } // UNSAFE.getInt(null, struct + GLFWVidMode.GREENBITS); } + public static int ngreenBits(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.GREENBITS); } /** Unsafe version of {@link #blueBits}. */ - public static int nblueBits(long struct) { return 8; } // UNSAFE.getInt(null, struct + GLFWVidMode.BLUEBITS); } + public static int nblueBits(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.BLUEBITS); } /** Unsafe version of {@link #refreshRate}. */ - public static int nrefreshRate(long struct) { return 60; } // UNSAFE.getInt(null, struct + GLFWVidMode.REFRESHRATE); } + public static int nrefreshRate(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.REFRESHRATE); } // ----------------------------------- @@ -201,4 +201,4 @@ public class GLFWVidMode extends Struct { } -} +} \ No newline at end of file diff --git a/JavaApp/src/main/java/org/lwjgl/glfw/GLFWVidMode.java.real b/JavaApp/src/main/java/org/lwjgl/glfw/GLFWVidMode.java.real deleted file mode 100644 index 5e06259d..00000000 --- a/JavaApp/src/main/java/org/lwjgl/glfw/GLFWVidMode.java.real +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright LWJGL. All rights reserved. - * License terms: https://www.lwjgl.org/license - * MACHINE GENERATED FILE, DO NOT EDIT - */ -package org.lwjgl.glfw; - -import javax.annotation.*; - -import java.nio.*; - -import org.lwjgl.system.*; - -import static org.lwjgl.system.MemoryUtil.*; - -/** - * Describes a single video mode. - * - *

Member documentation

- * - * - * - *

Layout

- * - *

- * struct GLFWvidmode {
- *     int width;
- *     int height;
- *     int redBits;
- *     int greenBits;
- *     int blueBits;
- *     int refreshRate;
- * }
- */ -@NativeType("struct GLFWvidmode") -public class GLFWVidMode extends Struct { - - /** The struct size in bytes. */ - public static final int SIZEOF; - - /** The struct alignment in bytes. */ - public static final int ALIGNOF; - - /** The struct member offsets. */ - public static final int - WIDTH, - HEIGHT, - REDBITS, - GREENBITS, - BLUEBITS, - REFRESHRATE; - - static { - Layout layout = __struct( - __member(4), - __member(4), - __member(4), - __member(4), - __member(4), - __member(4) - ); - - SIZEOF = layout.getSize(); - ALIGNOF = layout.getAlignment(); - - WIDTH = layout.offsetof(0); - HEIGHT = layout.offsetof(1); - REDBITS = layout.offsetof(2); - GREENBITS = layout.offsetof(3); - BLUEBITS = layout.offsetof(4); - REFRESHRATE = layout.offsetof(5); - } - - /** - * Creates a {@code GLFWVidMode} instance at the current position of the specified {@link ByteBuffer} container. Changes to the buffer's content will be - * visible to the struct instance and vice versa. - * - *

The created instance holds a strong reference to the container object.

- */ - public GLFWVidMode(ByteBuffer container) { - super(memAddress(container), __checkContainer(container, SIZEOF)); - } - - @Override - public int sizeof() { return SIZEOF; } - - /** Returns the value of the {@code width} field. */ - public int width() { return nwidth(address()); } - /** Returns the value of the {@code height} field. */ - public int height() { return nheight(address()); } - /** Returns the value of the {@code redBits} field. */ - public int redBits() { return nredBits(address()); } - /** Returns the value of the {@code greenBits} field. */ - public int greenBits() { return ngreenBits(address()); } - /** Returns the value of the {@code blueBits} field. */ - public int blueBits() { return nblueBits(address()); } - /** Returns the value of the {@code refreshRate} field. */ - public int refreshRate() { return nrefreshRate(address()); } - - // ----------------------------------- - - /** Returns a new {@code GLFWVidMode} instance for the specified memory address. */ - public static GLFWVidMode create(long address) { - return wrap(GLFWVidMode.class, address); - } - - /** Like {@link #create(long) create}, but returns {@code null} if {@code address} is {@code NULL}. */ - @Nullable - public static GLFWVidMode createSafe(long address) { - return address == NULL ? null : wrap(GLFWVidMode.class, address); - } - - /** - * Create a {@link GLFWVidMode.Buffer} instance at the specified memory. - * - * @param address the memory address - * @param capacity the buffer capacity - */ - public static GLFWVidMode.Buffer create(long address, int capacity) { - return wrap(Buffer.class, address, capacity); - } - - /** Like {@link #create(long, int) create}, but returns {@code null} if {@code address} is {@code NULL}. */ - @Nullable - public static GLFWVidMode.Buffer createSafe(long address, int capacity) { - return address == NULL ? null : wrap(Buffer.class, address, capacity); - } - - // ----------------------------------- - - /** Unsafe version of {@link #width}. */ - public static int nwidth(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.WIDTH); } - /** Unsafe version of {@link #height}. */ - public static int nheight(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.HEIGHT); } - /** Unsafe version of {@link #redBits}. */ - public static int nredBits(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.REDBITS); } - /** Unsafe version of {@link #greenBits}. */ - public static int ngreenBits(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.GREENBITS); } - /** Unsafe version of {@link #blueBits}. */ - public static int nblueBits(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.BLUEBITS); } - /** Unsafe version of {@link #refreshRate}. */ - public static int nrefreshRate(long struct) { return UNSAFE.getInt(null, struct + GLFWVidMode.REFRESHRATE); } - - // ----------------------------------- - - /** An array of {@link GLFWVidMode} structs. */ - public static class Buffer extends StructBuffer { - - private static final GLFWVidMode ELEMENT_FACTORY = GLFWVidMode.create(-1L); - - /** - * Creates a new {@code GLFWVidMode.Buffer} instance backed by the specified container. - * - * Changes to the container's content will be visible to the struct buffer instance and vice versa. The two buffers' position, limit, and mark values - * will be independent. The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided - * by {@link GLFWVidMode#SIZEOF}, and its mark will be undefined. - * - *

The created buffer instance holds a strong reference to the container object.

- */ - public Buffer(ByteBuffer container) { - super(container, container.remaining() / SIZEOF); - } - - public Buffer(long address, int cap) { - super(address, null, -1, 0, cap, cap); - } - - Buffer(long address, @Nullable ByteBuffer container, int mark, int pos, int lim, int cap) { - super(address, container, mark, pos, lim, cap); - } - - @Override - protected Buffer self() { - return this; - } - - @Override - protected GLFWVidMode getElementFactory() { - return ELEMENT_FACTORY; - } - - /** Returns the value of the {@code width} field. */ - public int width() { return GLFWVidMode.nwidth(address()); } - /** Returns the value of the {@code height} field. */ - public int height() { return GLFWVidMode.nheight(address()); } - /** Returns the value of the {@code redBits} field. */ - public int redBits() { return GLFWVidMode.nredBits(address()); } - /** Returns the value of the {@code greenBits} field. */ - public int greenBits() { return GLFWVidMode.ngreenBits(address()); } - /** Returns the value of the {@code blueBits} field. */ - public int blueBits() { return GLFWVidMode.nblueBits(address()); } - /** Returns the value of the {@code refreshRate} field. */ - public int refreshRate() { return GLFWVidMode.nrefreshRate(address()); } - - } - -} \ No newline at end of file diff --git a/JavaApp/src/main/java/org/lwjgl/input/Controllers.java b/JavaApp/src/main/java/org/lwjgl/input/Controllers.java index 2f75057b..c3ccff3c 100644 --- a/JavaApp/src/main/java/org/lwjgl/input/Controllers.java +++ b/JavaApp/src/main/java/org/lwjgl/input/Controllers.java @@ -19,8 +19,8 @@ public static int getControllerCount() { ctrlr.poll(); } public static boolean next() { - ctrlr.poll(); - return true; + //ctrlr.poll(); + return false;//true; } public static boolean isCreated() { return true; @@ -76,4 +76,4 @@ public static int getControllerCount() { public static float getEventYAxisValue() { return ctrlr.getYAxisValue(); } -} \ No newline at end of file +} diff --git a/JavaApp/src/main/java/org/lwjgl/input/GLFWController.java b/JavaApp/src/main/java/org/lwjgl/input/GLFWController.java index c593759a..4921949f 100644 --- a/JavaApp/src/main/java/org/lwjgl/input/GLFWController.java +++ b/JavaApp/src/main/java/org/lwjgl/input/GLFWController.java @@ -50,7 +50,7 @@ public class GLFWController implements Controller{ @Override public boolean isButtonPressed(int index) { - return (buttonData.get(index) == 1); + return (buttonData.remaining() > index) && (buttonData.get(index) == 1); } @Override diff --git a/JavaApp/src/main/java/org/lwjgl/openal/AL.java b/JavaApp/src/main/java/org/lwjgl/openal/AL.java index 9b75b4b3..8c2a288f 100644 --- a/JavaApp/src/main/java/org/lwjgl/openal/AL.java +++ b/JavaApp/src/main/java/org/lwjgl/openal/AL.java @@ -54,7 +54,62 @@ public final class AL { static ALCapabilities alCaps; private static boolean created_lwjgl2 = false; - + + /** + * Creates an OpenAL instance. Using this constructor will cause OpenAL to + * open the device using supplied device argument, and create a context using the context values + * supplied. + * + * @param deviceArguments Arguments supplied to native device + * @param contextFrequency Frequency for mixing output buffer, in units of Hz (Common values include 11025, 22050, and 44100). + * @param contextRefresh Refresh intervalls, in units of Hz. + * @param contextSynchronized Flag, indicating a synchronous context.* + */ + public static void create(String deviceArguments, int contextFrequency, int contextRefresh, boolean contextSynchronized) + throws LWJGLException { + create(deviceArguments, contextFrequency, contextRefresh, contextSynchronized, true); + } + + /** + * @param openDevice Whether to automatically open the device + * @see #create(String, int, int, boolean) + */ + public static void create(String deviceArguments, int contextFrequency, int contextRefresh, boolean contextSynchronized, boolean openDevice) + throws LWJGLException { + if (alContext == MemoryUtil.NULL && openDevice) { + //ALDevice alDevice = ALDevice.create(); + long alDevice = ALC10.alcOpenDevice(deviceArguments); + if(alDevice == MemoryUtil.NULL){ + throw new LWJGLException("Cannot open the device"); + } + + IntBuffer attribs = BufferUtils.createIntBuffer(16); + + attribs.put(ALC10.ALC_FREQUENCY); + attribs.put(contextFrequency); + + attribs.put(ALC10.ALC_REFRESH); + attribs.put(contextRefresh); + + attribs.put(ALC10.ALC_SYNC); + attribs.put(contextSynchronized ? ALC10.ALC_TRUE : ALC10.ALC_FALSE); + + attribs.put(0); + attribs.flip(); + + long contextHandle = ALC10.alcCreateContext(alDevice, attribs); + ALC10.alcMakeContextCurrent(contextHandle); + //alContext = new ALContext(alDevice, contextHandle); + alContext = ALC10.alcCreateContext(contextHandle, (IntBuffer)null); + alContextCaps = ALC.createCapabilities(alContext); + + alCaps = AL.createCapabilities(alContextCaps); + + alcDevice = new ALCdevice(alDevice); + created_lwjgl2 = true; + } + } + public static void create() throws LWJGLException { if (alContext == MemoryUtil.NULL) { //ALDevice alDevice = ALDevice.create(); diff --git a/JavaApp/src/main/java/org/lwjgl/opengl/Display.java b/JavaApp/src/main/java/org/lwjgl/opengl/Display.java index 37e1ce7a..b761cd78 100644 --- a/JavaApp/src/main/java/org/lwjgl/opengl/Display.java +++ b/JavaApp/src/main/java/org/lwjgl/opengl/Display.java @@ -949,7 +949,7 @@ public class Display { } else { glfwSetWindowIcon(Window.handle, new GLFWImage.Buffer(icons[0])); } - } catch (NullPointerException e) { + } catch (Exception e) { LWJGLUtil.log("Couldn't set icon"); e.printStackTrace(); } @@ -982,8 +982,10 @@ public class Display { } public static void setDisplayModeAndFullscreen(DisplayMode dm) throws LWJGLException { - Display.mode = dm; - GLFW.glfwSetWindowSize(Window.handle, dm.getWidth(), dm.getHeight()); + if(Window.handle != 0) { + Display.mode = dm; + GLFW.glfwSetWindowSize(Window.handle, dm.getWidth(), dm.getHeight()); + } } public static void setFullscreen(boolean fullscreen) throws LWJGLException { diff --git a/JavaApp/src/main/java/org/lwjgl/opengl/DisplayMode.java b/JavaApp/src/main/java/org/lwjgl/opengl/DisplayMode.java index 23bd84ac..424801a6 100644 --- a/JavaApp/src/main/java/org/lwjgl/opengl/DisplayMode.java +++ b/JavaApp/src/main/java/org/lwjgl/opengl/DisplayMode.java @@ -60,7 +60,7 @@ public final class DisplayMode { * @see Display */ public DisplayMode(int width, int height) { - this(width, height, 0, 0, false); + this(width, height, 0, 0, true); } DisplayMode(int width, int height, int bpp, int freq) { diff --git a/Natives/MinecraftResourceUtils.m b/Natives/MinecraftResourceUtils.m index ffbbe26f..11703584 100644 --- a/Natives/MinecraftResourceUtils.m +++ b/Natives/MinecraftResourceUtils.m @@ -243,6 +243,10 @@ static AFURLSessionManager* manager; return; } if (json[@"inheritsFrom"] == nil) { + if (json[@"assetIndex"] == nil) { + success(json); + return; + } ++mainProgress.completedUnitCount; [self downloadClientJson:json[@"assetIndex"] progress:mainProgress callback:callback success:^(NSMutableDictionary *assetJson){ json[@"assetIndexObj"] = assetJson; diff --git a/Natives/egl_bridge.m b/Natives/egl_bridge.m index 837eec64..c2699e6e 100644 --- a/Natives/egl_bridge.m +++ b/Natives/egl_bridge.m @@ -480,13 +480,13 @@ void* pojavCreateContext(void* contextSrc) { EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE }; - EGLContext* ctx = eglCreateContext_p(potatoBridge.eglDisplay, config, (void*)contextSrc, ctx_attribs); + EGLContext* ctx = eglCreateContext_p(potatoBridge.eglDisplay, config, contextSrc, ctx_attribs); if (!ctx) { debugLog("EGLBridge: Failed to create context: 0x%x, returning previous one.", eglGetError_p()); return potatoBridge.eglContext; } potatoBridge.eglContext = ctx; - debugLog("EGLBridge: Created CTX pointer = %p",ctx); + debugLog("EGLBridge: Created CTX pointer = %p (source = %p)", ctx, contextSrc); //(*env)->ThrowNew(env,(*env)->FindClass(env,"java/lang/Exception"),"Trace exception"); return (void *)ctx; } diff --git a/Natives/ios_uikit_bridge.m b/Natives/ios_uikit_bridge.m index 11f7b19a..99ae5acc 100644 --- a/Natives/ios_uikit_bridge.m +++ b/Natives/ios_uikit_bridge.m @@ -45,6 +45,8 @@ JNIEXPORT void JNICALL Java_net_kdt_pojavlaunch_uikit_UIKit_showError(JNIEnv* en (*env)->ReleaseStringUTFChars(env, title, title_c); (*env)->ReleaseStringUTFChars(env, message, message_c); + NSLog(@"Dialog shown: %@: %@", title_o, message_o); + dispatch_async(dispatch_get_main_queue(), ^{ UIAlertController* alert = [UIAlertController diff --git a/Natives/resources/Frameworks/libOSMesa.8.dylib.framework/libOSMesa.8.dylib b/Natives/resources/Frameworks/libOSMesa.8.dylib.framework/libOSMesa.8.dylib old mode 100755 new mode 100644 index 6891110a..8c7a816c Binary files a/Natives/resources/Frameworks/libOSMesa.8.dylib.framework/libOSMesa.8.dylib and b/Natives/resources/Frameworks/libOSMesa.8.dylib.framework/libOSMesa.8.dylib differ