Fixed setDisplayMode
This commit is contained in:
parent
9849345f55
commit
0612deb69f
|
@ -88,6 +88,8 @@ public final class Display {
|
||||||
/** A unique context object, so we can track different contexts between creates() and destroys() */
|
/** A unique context object, so we can track different contexts between creates() and destroys() */
|
||||||
private static Display context;
|
private static Display context;
|
||||||
|
|
||||||
|
private static boolean window_created = false;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Sys.initialize();
|
Sys.initialize();
|
||||||
display_impl = createDisplayImplementation();
|
display_impl = createDisplayImplementation();
|
||||||
|
@ -182,7 +184,9 @@ public final class Display {
|
||||||
current_mode = mode;
|
current_mode = mode;
|
||||||
if (isCreated()) {
|
if (isCreated()) {
|
||||||
destroyWindow();
|
destroyWindow();
|
||||||
setFullscreen(mode.isFullscreen());
|
// If mode is not fullscreen capable, make sure we are in windowed mode
|
||||||
|
if (!mode.isFullscreen())
|
||||||
|
resetFullscreen();
|
||||||
try {
|
try {
|
||||||
if (fullscreen)
|
if (fullscreen)
|
||||||
switchDisplayMode();
|
switchDisplayMode();
|
||||||
|
@ -200,6 +204,8 @@ public final class Display {
|
||||||
* A native context must exist, and it will be attached to the window.
|
* A native context must exist, and it will be attached to the window.
|
||||||
*/
|
*/
|
||||||
private static void createWindow() throws LWJGLException {
|
private static void createWindow() throws LWJGLException {
|
||||||
|
if (window_created)
|
||||||
|
throw new InternalError("Window already created");
|
||||||
int window_x;
|
int window_x;
|
||||||
int window_y;
|
int window_y;
|
||||||
if (!fullscreen) {
|
if (!fullscreen) {
|
||||||
|
@ -221,9 +227,12 @@ public final class Display {
|
||||||
setTitle(title);
|
setTitle(title);
|
||||||
initControls();
|
initControls();
|
||||||
setVSyncEnabled(vsync);
|
setVSyncEnabled(vsync);
|
||||||
|
window_created = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void destroyWindow() {
|
private static void destroyWindow() {
|
||||||
|
if (!window_created)
|
||||||
|
throw new InternalError("Window already created");
|
||||||
// Automatically destroy keyboard, mouse, and controller
|
// Automatically destroy keyboard, mouse, and controller
|
||||||
if (Mouse.isCreated()) {
|
if (Mouse.isCreated()) {
|
||||||
Mouse.destroy();
|
Mouse.destroy();
|
||||||
|
@ -232,6 +241,7 @@ public final class Display {
|
||||||
Keyboard.destroy();
|
Keyboard.destroy();
|
||||||
}
|
}
|
||||||
display_impl.destroyWindow();
|
display_impl.destroyWindow();
|
||||||
|
window_created = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void switchDisplayMode() throws LWJGLException {
|
private static void switchDisplayMode() throws LWJGLException {
|
||||||
|
@ -343,6 +353,13 @@ public final class Display {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void resetFullscreen() {
|
||||||
|
if (Display.fullscreen) {
|
||||||
|
Display.fullscreen = false;
|
||||||
|
display_impl.resetDisplayMode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the fullscreen mode of the context. If no context has been created through create(),
|
* Set the fullscreen mode of the context. If no context has been created through create(),
|
||||||
* the mode will apply when create() is called. If fullscreen is true, the context will become
|
* the mode will apply when create() is called. If fullscreen is true, the context will become
|
||||||
|
|
Loading…
Reference in New Issue