mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-19 09:39:25 -04:00
[LWJGLX] Avoid re-creating window on resize
This commit is contained in:
parent
68e8f57e96
commit
06f1d58993
@ -853,7 +853,7 @@ public class Display {
|
|||||||
|
|
||||||
public static void setDisplayMode(DisplayMode dm) throws LWJGLException {
|
public static void setDisplayMode(DisplayMode dm) throws LWJGLException {
|
||||||
mode = dm;
|
mode = dm;
|
||||||
newCurrentWindow(GLFW.glfwCreateWindow(dm.getWidth(), dm.getHeight(), windowTitle, 0, 0));
|
GLFW.glfwSetWindowSize(Window.handle, dm.getWidth(), dm.getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DisplayMode getDisplayMode() {
|
public static DisplayMode getDisplayMode() {
|
||||||
@ -917,7 +917,9 @@ public class Display {
|
|||||||
public static void setTitle(String title) {
|
public static void setTitle(String title) {
|
||||||
windowTitle = title;
|
windowTitle = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getTitle() { return windowTitle; }
|
public static String getTitle() { return windowTitle; }
|
||||||
|
|
||||||
public static boolean isCloseRequested() {
|
public static boolean isCloseRequested() {
|
||||||
return glfwWindowShouldClose(Window.handle) == true;
|
return glfwWindowShouldClose(Window.handle) == true;
|
||||||
}
|
}
|
||||||
@ -965,8 +967,7 @@ public class Display {
|
|||||||
glfwWindowHint(GLFW_RESIZABLE, displayResizable ? GL_TRUE : GL_FALSE);
|
glfwWindowHint(GLFW_RESIZABLE, displayResizable ? GL_TRUE : GL_FALSE);
|
||||||
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
|
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
|
||||||
|
|
||||||
newCurrentWindow(GLFW.glfwCreateWindow(width.get(), height.get(), windowTitle,
|
GLFW.glfwSetWindowSize(Window.handle, width.get(), height.get());
|
||||||
GLFW.glfwGetWindowMonitor(Window.handle), NULL));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
displayResizable = resizable;
|
displayResizable = resizable;
|
||||||
@ -976,10 +977,9 @@ public class Display {
|
|||||||
return displayResizable;
|
return displayResizable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setDisplayModeAndFullscreen(DisplayMode mode) throws LWJGLException {
|
public static void setDisplayModeAndFullscreen(DisplayMode dm) throws LWJGLException {
|
||||||
Display.mode = mode;
|
Display.mode = dm;
|
||||||
newCurrentWindow(glfwCreateWindow(mode.getWidth(), mode.getHeight(), windowTitle,
|
GLFW.glfwSetWindowSize(Window.handle, dm.getWidth(), dm.getHeight());
|
||||||
mode.isFullscreenCapable() ? glfwGetPrimaryMonitor() : NULL, NULL));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setFullscreen(boolean fullscreen) throws LWJGLException {
|
public static void setFullscreen(boolean fullscreen) throws LWJGLException {
|
||||||
@ -999,11 +999,7 @@ public class Display {
|
|||||||
glfwWindowHint(GLFW_RESIZABLE, displayResizable ? GL_TRUE : GL_FALSE);
|
glfwWindowHint(GLFW_RESIZABLE, displayResizable ? GL_TRUE : GL_FALSE);
|
||||||
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
|
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
|
||||||
|
|
||||||
if (fullscreen)
|
GLFW.glfwSetWindowSize(Window.handle, width.get(), height.get());
|
||||||
newCurrentWindow(glfwCreateWindow(width.get(), height.get(), windowTitle,
|
|
||||||
glfwGetPrimaryMonitor(), NULL));
|
|
||||||
else
|
|
||||||
newCurrentWindow(glfwCreateWindow(width.get(), height.get(), windowTitle, NULL, NULL));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
displayFullscreen = fullscreen;
|
displayFullscreen = fullscreen;
|
||||||
@ -1057,26 +1053,6 @@ public class Display {
|
|||||||
return display_impl;
|
return display_impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void newCurrentWindow(long newWindow) {
|
|
||||||
if (Window.handle != MemoryUtil.NULL)
|
|
||||||
glfwDestroyWindow(Window.handle);
|
|
||||||
Window.handle = newWindow;
|
|
||||||
//try {
|
|
||||||
//Mouse.setNativeCursor(Mouse.getCurrentCursor());
|
|
||||||
//} catch (LWJGLException e) {
|
|
||||||
// System.err.println("Failed to set new window cursor!");
|
|
||||||
// e.printStackTrace();
|
|
||||||
//}
|
|
||||||
GLFW.glfwSetWindowTitle(newWindow, windowTitle);
|
|
||||||
Window.setCallbacks();
|
|
||||||
|
|
||||||
// glfwMakeContextCurrent(Window.handle);
|
|
||||||
context = org.lwjgl.opengl.GLContext.createFromCurrent();
|
|
||||||
|
|
||||||
glfwSwapInterval(0);
|
|
||||||
glfwShowWindow(Window.handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
static class Window {
|
static class Window {
|
||||||
static long handle;
|
static long handle;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user