*** empty log message ***
This commit is contained in:
parent
ba01e888fb
commit
4a13ffa90f
|
@ -134,18 +134,6 @@ public final class Sys {
|
||||||
|
|
||||||
PLATFORM = System.getProperty("org.lwjgl.Sys.platform", "org.lwjgl.SwingAdapter");
|
PLATFORM = System.getProperty("org.lwjgl.Sys.platform", "org.lwjgl.SwingAdapter");
|
||||||
|
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
|
||||||
public void run() {
|
|
||||||
Display.destroy();
|
|
||||||
if (Keyboard.isCreated())
|
|
||||||
Keyboard.destroy();
|
|
||||||
if (Mouse.isCreated())
|
|
||||||
Mouse.destroy();
|
|
||||||
if (Controller.isCreated())
|
|
||||||
Controller.destroy();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -64,6 +64,11 @@ public final class Display {
|
||||||
current_mode = init();
|
current_mode = init();
|
||||||
assert current_mode != null;
|
assert current_mode != null;
|
||||||
System.out.println("Current mode "+current_mode);
|
System.out.println("Current mode "+current_mode);
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||||
|
public void run() {
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Timer for sync() */
|
/** Timer for sync() */
|
||||||
|
@ -83,6 +88,9 @@ public final class Display {
|
||||||
|
|
||||||
/** Fullscreen */
|
/** Fullscreen */
|
||||||
private static boolean fullscreen;
|
private static boolean fullscreen;
|
||||||
|
|
||||||
|
/** VSync */
|
||||||
|
private static boolean vsync;
|
||||||
|
|
||||||
/** Tracks VBO state for the window context */
|
/** Tracks VBO state for the window context */
|
||||||
private static VBOTracker vbo_tracker;
|
private static VBOTracker vbo_tracker;
|
||||||
|
@ -167,6 +175,7 @@ public final class Display {
|
||||||
if (title != null)
|
if (title != null)
|
||||||
nSetTitle(title);
|
nSetTitle(title);
|
||||||
initControls();
|
initControls();
|
||||||
|
nSetVSyncEnabled(vsync);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native void nCreateWindow(DisplayMode mode, boolean fullscreen) throws LWJGLException;
|
private static native void nCreateWindow(DisplayMode mode, boolean fullscreen) throws LWJGLException;
|
||||||
|
@ -587,6 +596,13 @@ public final class Display {
|
||||||
destroyWindow();
|
destroyWindow();
|
||||||
destroyContext();
|
destroyContext();
|
||||||
context = null;
|
context = null;
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Reset display mode if fullscreen. This method is also called from the shutdown hook added in Sys
|
||||||
|
*/
|
||||||
|
private static void reset() {
|
||||||
if (fullscreen)
|
if (fullscreen)
|
||||||
resetDisplayMode();
|
resetDisplayMode();
|
||||||
}
|
}
|
||||||
|
@ -617,9 +633,9 @@ public final class Display {
|
||||||
* @param sync true to synchronize; false to ignore synchronization
|
* @param sync true to synchronize; false to ignore synchronization
|
||||||
*/
|
*/
|
||||||
public static void setVSyncEnabled(boolean sync) {
|
public static void setVSyncEnabled(boolean sync) {
|
||||||
if (!isCreated())
|
vsync = sync;
|
||||||
throw new IllegalStateException("Cannot set vsync state of uncreated window");
|
if (isCreated())
|
||||||
nSetVSyncEnabled(sync);
|
nSetVSyncEnabled(vsync);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native void nSetVSyncEnabled(boolean sync);
|
private static native void nSetVSyncEnabled(boolean sync);
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
package org.lwjgl.test.opengl;
|
package org.lwjgl.test.opengl;
|
||||||
|
|
||||||
import org.lwjgl.opengl.Display;
|
import org.lwjgl.opengl.Display;
|
||||||
|
import org.lwjgl.LWJGLException;
|
||||||
import org.lwjgl.opengl.DisplayMode;
|
import org.lwjgl.opengl.DisplayMode;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
@ -219,7 +220,9 @@ public class FullScreenWindowedTest {
|
||||||
* Cleans up the test
|
* Cleans up the test
|
||||||
*/
|
*/
|
||||||
private void cleanup() {
|
private void cleanup() {
|
||||||
|
// Display.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a displaymode, if one such is available
|
* Retrieves a displaymode, if one such is available
|
||||||
*
|
*
|
||||||
|
@ -235,6 +238,11 @@ public class FullScreenWindowedTest {
|
||||||
DisplayMode[] modes = Display.getAvailableDisplayModes();
|
DisplayMode[] modes = Display.getAvailableDisplayModes();
|
||||||
for (int i = 0; i < modes.length; i++) {
|
for (int i = 0; i < modes.length; i++) {
|
||||||
if (modes[i].getWidth() == width && modes[i].getHeight() == height && modes[i].getBitsPerPixel() >= bpp && modes[i].getFrequency() <= 60) {
|
if (modes[i].getWidth() == width && modes[i].getHeight() == height && modes[i].getBitsPerPixel() >= bpp && modes[i].getFrequency() <= 60) {
|
||||||
|
try {
|
||||||
|
Display.setDisplayMode(modes[i]);
|
||||||
|
} catch (LWJGLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
return modes[i];
|
return modes[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue