Support resizable for iPadOS Stage Manager
On iPadOS, PojavLauncher can be launched in portrait mode Declare controller support in Info.plist Sync LWJGL changes from Android repo
This commit is contained in:
1 parent
583ba327a8
commit
8ca77a1b73
17 files changed
+295
-198
No files matched your search
@@ -998,6 +998,7 @@ public class GLFW
|
||||
|
||||
public static void glfwSetWindowSize(long window, int width, int height) {
|
||||
try {
|
||||
internalChangeMonitorSize(width, height);
|
||||
internalGetWindow(window).width = width;
|
||||
internalGetWindow(window).height = height;
|
||||
System.out.println("GLFW: Set size for window " + window + ", width=" + width + ", height=" + height);
|
||||
@@ -1090,8 +1091,7 @@ public class GLFW
|
||||
break;
|
||||
case CallbackBridge.EVENT_TYPE_FRAMEBUFFER_SIZE:
|
||||
case CallbackBridge.EVENT_TYPE_WINDOW_SIZE:
|
||||
internalChangeMonitorSize((int)dataArr[1], (int)dataArr[2]);
|
||||
glfwSetWindowSize(ptr, Tools.mGLFWWindowWidth, Tools.mGLFWWindowHeight);
|
||||
glfwSetWindowSize(ptr, (int)dataArr[1], (int)dataArr[2]);
|
||||
if ((int)dataArr[0] == CallbackBridge.EVENT_TYPE_FRAMEBUFFER_SIZE && mGLFWFramebufferSizeCallback != null) {
|
||||
mGLFWFramebufferSizeCallback.invoke(ptr, Tools.mGLFWWindowWidth, Tools.mGLFWWindowHeight);
|
||||
} else if ((int)dataArr[0] == CallbackBridge.EVENT_TYPE_WINDOW_SIZE && mGLFWWindowSizeCallback != null) {
|
||||
|
||||
@@ -82,12 +82,6 @@ public class Display {
|
||||
|
||||
mode = desktopDisplayMode = new DisplayMode(monitorWidth, monitorHeight, monitorBitPerPixel, monitorRefreshRate);
|
||||
LWJGLUtil.log("Initial mode: " + desktopDisplayMode);
|
||||
|
||||
// additional code workaround not called yet!
|
||||
LWJGLUtil.log("Calling Display.create()");
|
||||
try {
|
||||
create();
|
||||
} catch (LWJGLException e) {throw new RuntimeException(e);}
|
||||
}
|
||||
|
||||
public static void setSwapInterval(int value) {
|
||||
@@ -342,6 +336,7 @@ public class Display {
|
||||
latestWidth = width;
|
||||
latestHeight = height;
|
||||
|
||||
//System.out.println("Window size callback");
|
||||
if(parent != null) parent.setSize(width, height);
|
||||
}
|
||||
};
|
||||
@@ -419,7 +414,7 @@ public class Display {
|
||||
Display.drawable = drawable;
|
||||
context = org.lwjgl.opengl.GLContext.createFromCurrent();
|
||||
|
||||
glfwSwapInterval(0);
|
||||
//glfwSwapInterval(0);
|
||||
glfwShowWindow(Window.handle);
|
||||
|
||||
Mouse.create();
|
||||
@@ -767,6 +762,7 @@ public class Display {
|
||||
|
||||
public static void setVSyncEnabled(boolean sync) {
|
||||
vsyncEnabled = sync;
|
||||
glfwSwapInterval(vsyncEnabled ? 1 : 0);
|
||||
}
|
||||
|
||||
public static long getWindow() {
|
||||
@@ -857,7 +853,7 @@ public class Display {
|
||||
|
||||
public static void setDisplayMode(DisplayMode dm) throws LWJGLException {
|
||||
mode = dm;
|
||||
GLFW.glfwSetWindowSize(Window.handle, dm.getWidth(), dm.getHeight());
|
||||
if(isCreated) GLFW.glfwSetWindowSize(Window.handle, dm.getWidth(), dm.getHeight());
|
||||
}
|
||||
|
||||
public static DisplayMode getDisplayMode() {
|
||||
@@ -1029,6 +1025,10 @@ public class Display {
|
||||
}
|
||||
}
|
||||
|
||||
public static void setDisplayConfiguration(float gamma, float brightness, float contrast) throws LWJGLException {
|
||||
// ignore call, this is required for a1.1.1
|
||||
}
|
||||
|
||||
public static java.lang.String getAdapter() {
|
||||
// TODO
|
||||
return "GeNotSupportedAdapter";
|
||||
@@ -1047,8 +1047,9 @@ public class Display {
|
||||
* - the desired frame rate, in frames per second
|
||||
*/
|
||||
public static void sync(int fps) {
|
||||
if (vsyncEnabled)
|
||||
Sync.sync(fps);
|
||||
/*if (vsyncEnabled)
|
||||
Sync.sync(60);
|
||||
else*/ Sync.sync(fps);
|
||||
}
|
||||
|
||||
public static Drawable getDrawable() {
|
||||
|
||||
@@ -48,6 +48,10 @@ class Sync {
|
||||
/** The time to sleep/yield until the next frame */
|
||||
private static long nextFrame = 0;
|
||||
|
||||
/** The time since last frame **/
|
||||
private static long lastFrameTime = 0;
|
||||
private static long lastDelay = 0;
|
||||
|
||||
/** whether the initialisation code has run */
|
||||
private static boolean initialised = false;
|
||||
|
||||
@@ -67,6 +71,38 @@ class Sync {
|
||||
public static void sync(int fps) {
|
||||
if (fps <= 0)
|
||||
return;
|
||||
|
||||
preciseSync(fps);
|
||||
}
|
||||
|
||||
/** Fast, more cpu friendly way of syncing, although can be off the mark at times */
|
||||
private static void fastSync(int fps){
|
||||
if (!initialised){
|
||||
initialised = true;
|
||||
lastFrameTime = getTime();
|
||||
}
|
||||
|
||||
// Dumbass implementation I guess
|
||||
long currentFrameTime = getTime();
|
||||
long deltaMs = (currentFrameTime - lastFrameTime)/1000000;
|
||||
long deltaFrame = 1000/fps;
|
||||
if(deltaMs < deltaFrame){ // skip the Thread sleep if the opportunity is available
|
||||
try {
|
||||
Thread.sleep(Math.min((deltaFrame - deltaMs) + lastDelay, deltaFrame));
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
lastDelay = 0;
|
||||
}else{
|
||||
// Store how late the device is I guess
|
||||
lastDelay = deltaMs - deltaFrame;
|
||||
}
|
||||
|
||||
lastFrameTime = getTime();
|
||||
}
|
||||
|
||||
/** Precise, more cpu intensive way of syncing */
|
||||
private static void preciseSync(int fps){
|
||||
if (!initialised)
|
||||
initialise();
|
||||
|
||||
@@ -76,7 +112,7 @@ class Sync {
|
||||
for (long t0 = getTime(), t1; (nextFrame - t0) > sleepDurations.avg(); t0 = t1) {
|
||||
Thread.sleep(1);
|
||||
sleepDurations.add((t1 = getTime()) - t0); // update average
|
||||
// sleep time
|
||||
// sleep time
|
||||
}
|
||||
|
||||
// slowly dampen sleep average if too high to avoid yielding too
|
||||
@@ -88,7 +124,7 @@ class Sync {
|
||||
for (long t0 = getTime(), t1; (nextFrame - t0) > yieldDurations.avg(); t0 = t1) {
|
||||
Thread.yield();
|
||||
yieldDurations.add((t1 = getTime()) - t0); // update average
|
||||
// yield time
|
||||
// yield time
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
@@ -111,27 +147,6 @@ class Sync {
|
||||
yieldDurations.init((int) (-(getTime() - getTime()) * 1.333));
|
||||
|
||||
nextFrame = getTime();
|
||||
|
||||
String osName = System.getProperty("os.name");
|
||||
|
||||
if (osName.startsWith("Win")) {
|
||||
// On windows the sleep functions can be highly inaccurate by
|
||||
// over 10ms making in unusable. However it can be forced to
|
||||
// be a bit more accurate by running a separate sleeping daemon
|
||||
// thread.
|
||||
Thread timerAccuracyThread = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(Long.MAX_VALUE);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
timerAccuracyThread.setName("LWJGL Timer");
|
||||
timerAccuracyThread.setDaemon(true);
|
||||
timerAccuracyThread.start();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user