Add a public DisplayMode constructor
This commit is contained in:
parent
0baf3a81f2
commit
b88624e608
|
@ -104,10 +104,12 @@ public final class Display {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the entire list of display modes as an array, in no
|
* Returns the entire list of possible fullscreen display modes as an array, in no
|
||||||
* particular order. Any given mode is not guaranteed to be available and
|
* particular order. Any given mode is not guaranteed to be available and
|
||||||
* the only certain way to check is to call create() and make sure it works.
|
* the only certain way to check is to call create() and make sure it works.
|
||||||
* Only non-palette-indexed modes are returned (ie. bpp will be 16, 24, or 32).
|
* Only non-palette-indexed modes are returned (ie. bpp will be 16, 24, or 32).
|
||||||
|
* Only DisplayModes from this call can be used when the Display is in fullscreen
|
||||||
|
* mode.
|
||||||
*
|
*
|
||||||
* @return an array of all display modes the system reckons it can handle.
|
* @return an array of all display modes the system reckons it can handle.
|
||||||
*/
|
*/
|
||||||
|
@ -161,7 +163,7 @@ public final class Display {
|
||||||
destroyWindow();
|
destroyWindow();
|
||||||
try {
|
try {
|
||||||
if (fullscreen)
|
if (fullscreen)
|
||||||
switchDisplayMode(mode);
|
switchDisplayMode();
|
||||||
createWindow();
|
createWindow();
|
||||||
} catch (LWJGLException e) {
|
} catch (LWJGLException e) {
|
||||||
destroyContext();
|
destroyContext();
|
||||||
|
@ -200,7 +202,13 @@ public final class Display {
|
||||||
|
|
||||||
private static native void nDestroyWindow();
|
private static native void nDestroyWindow();
|
||||||
|
|
||||||
private static native void switchDisplayMode(DisplayMode mode) throws LWJGLException;
|
private static void switchDisplayMode() throws LWJGLException {
|
||||||
|
if (!current_mode.isFullscreen())
|
||||||
|
throw new LWJGLException("The current DisplayMode instance cannot be used for fullscreen mode");
|
||||||
|
nSwitchDisplayMode(current_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static native void nSwitchDisplayMode(DisplayMode mode) throws LWJGLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset the display mode to whatever it was when LWJGL was initialized.
|
* Reset the display mode to whatever it was when LWJGL was initialized.
|
||||||
|
@ -353,6 +361,8 @@ public final class Display {
|
||||||
* mode returned by getDisplayMode(). The native cursor position is also reset.
|
* mode returned by getDisplayMode(). The native cursor position is also reset.
|
||||||
*
|
*
|
||||||
* @param fullscreen Specify the fullscreen mode of the context.
|
* @param fullscreen Specify the fullscreen mode of the context.
|
||||||
|
* @throws LWJGLException If fullscreen is true, and the current DisplayMode instance is not
|
||||||
|
* from getAvailableDisplayModes() or if the mode switch fails.
|
||||||
*/
|
*/
|
||||||
public static void setFullscreen(boolean fullscreen) throws LWJGLException {
|
public static void setFullscreen(boolean fullscreen) throws LWJGLException {
|
||||||
if (Display.fullscreen != fullscreen) {
|
if (Display.fullscreen != fullscreen) {
|
||||||
|
@ -362,7 +372,7 @@ public final class Display {
|
||||||
destroyWindow();
|
destroyWindow();
|
||||||
try {
|
try {
|
||||||
if (fullscreen)
|
if (fullscreen)
|
||||||
switchDisplayMode(current_mode);
|
switchDisplayMode();
|
||||||
else
|
else
|
||||||
resetDisplayMode();
|
resetDisplayMode();
|
||||||
createWindow();
|
createWindow();
|
||||||
|
@ -537,7 +547,7 @@ public final class Display {
|
||||||
if (isCreated())
|
if (isCreated())
|
||||||
throw new IllegalStateException("Only one LWJGL context may be instantiated at any one time.");
|
throw new IllegalStateException("Only one LWJGL context may be instantiated at any one time.");
|
||||||
if (fullscreen)
|
if (fullscreen)
|
||||||
switchDisplayMode(current_mode);
|
switchDisplayMode();
|
||||||
try {
|
try {
|
||||||
GLContext.loadOpenGLLibrary();
|
GLContext.loadOpenGLLibrary();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -46,17 +46,38 @@ public final class DisplayMode {
|
||||||
|
|
||||||
/** properties of the display mode */
|
/** properties of the display mode */
|
||||||
private final int width, height, bpp, freq;
|
private final int width, height, bpp, freq;
|
||||||
|
/** If true, this instance can be used for fullscreen modes */
|
||||||
|
private final boolean fullscreen;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a display mode.
|
* Construct a display mode. DisplayModes constructed through the
|
||||||
*
|
* public constructor can only be used to specify the dimensions of
|
||||||
|
* the Display in windowed mode. To get the available DisplayModes for
|
||||||
|
* fullscreen modes, use Display.getAvailableDisplayModes().
|
||||||
|
*
|
||||||
|
* @param width The Display width.
|
||||||
|
* @param height The Display height.
|
||||||
* @see Display
|
* @see Display
|
||||||
*/
|
*/
|
||||||
private DisplayMode(int width, int height, int bpp, int freq) {
|
public DisplayMode(int width, int height) {
|
||||||
|
this(width, height, 0, 0, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
DisplayMode(int width, int height, int bpp, int freq) {
|
||||||
|
this(width, height, bpp, freq, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private DisplayMode(int width, int height, int bpp, int freq, boolean fullscreen) {
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
this.bpp = bpp;
|
this.bpp = bpp;
|
||||||
this.freq = freq;
|
this.freq = freq;
|
||||||
|
this.fullscreen = fullscreen;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** True iff this instance can be used for fullscreen modes */
|
||||||
|
boolean isFullscreen() {
|
||||||
|
return fullscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getWidth() {
|
public int getWidth() {
|
||||||
|
|
|
@ -14,7 +14,6 @@ extern "C" {
|
||||||
/* Inaccessible static: title */
|
/* Inaccessible static: title */
|
||||||
/* Inaccessible static: fullscreen */
|
/* Inaccessible static: fullscreen */
|
||||||
/* Inaccessible static: vsync */
|
/* Inaccessible static: vsync */
|
||||||
/* Inaccessible static: vbo_tracker */
|
|
||||||
/* Inaccessible static: context */
|
/* Inaccessible static: context */
|
||||||
/* Inaccessible static: timeLate */
|
/* Inaccessible static: timeLate */
|
||||||
/*
|
/*
|
||||||
|
@ -43,10 +42,10 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_nDestroyWindow
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: org_lwjgl_opengl_Display
|
* Class: org_lwjgl_opengl_Display
|
||||||
* Method: switchDisplayMode
|
* Method: nSwitchDisplayMode
|
||||||
* Signature: (Lorg/lwjgl/opengl/DisplayMode;)V
|
* Signature: (Lorg/lwjgl/opengl/DisplayMode;)V
|
||||||
*/
|
*/
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_switchDisplayMode
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_nSwitchDisplayMode
|
||||||
(JNIEnv *, jclass, jobject);
|
(JNIEnv *, jclass, jobject);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -602,7 +602,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_opengl_Display_nGetAvailableDispla
|
||||||
return getAvailableDisplayModes(env);
|
return getAvailableDisplayModes(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_switchDisplayMode(JNIEnv *env, jclass clazz, jobject mode) {
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_nSwitchDisplayMode(JNIEnv *env, jclass clazz, jobject mode) {
|
||||||
switchDisplayMode(env, mode);
|
switchDisplayMode(env, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -615,7 +615,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_nDestroyWindow(JNIEnv *env,
|
||||||
closeWindow(display_hwnd, display_hdc);
|
closeWindow(display_hwnd, display_hdc);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_switchDisplayMode(JNIEnv *env, jclass clazz, jobject mode) {
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Display_nSwitchDisplayMode(JNIEnv *env, jclass clazz, jobject mode) {
|
||||||
switchDisplayMode(env, mode);
|
switchDisplayMode(env, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue