Reverted display mode selection
This commit is contained in:
parent
df1d611624
commit
0d620e9125
|
@ -110,13 +110,19 @@ public final class Display {
|
|||
* destroyed.
|
||||
*
|
||||
* @param displayMode A display mode to choose
|
||||
* @param alpha Minimun number of alpha bits on the display
|
||||
* @param depth Minimun number of depth bits on the display
|
||||
* @param stencil Minimun number of stencil bits on the display
|
||||
* @param fullscreen Whether to create the display fullscreen
|
||||
* @param title The title for the application
|
||||
* @throws Exception if the display mode could not be set
|
||||
* @see #destroy()
|
||||
*/
|
||||
public static void create(
|
||||
DisplayMode displayMode,
|
||||
DisplayMode displayMode,
|
||||
int alpha,
|
||||
int depth,
|
||||
int stencil,
|
||||
boolean fullscreen,
|
||||
String title)
|
||||
throws Exception {
|
||||
|
@ -129,9 +135,9 @@ public final class Display {
|
|||
displayMode.height,
|
||||
displayMode.bpp,
|
||||
displayMode.freq,
|
||||
displayMode.alpha,
|
||||
displayMode.depth,
|
||||
displayMode.stencil,
|
||||
alpha,
|
||||
depth,
|
||||
stencil,
|
||||
fullscreen,
|
||||
title)) {
|
||||
throw new Exception("Failed to set display mode to " + displayMode);
|
||||
|
@ -274,4 +280,4 @@ public final class Display {
|
|||
public static boolean isCloseRequested() {
|
||||
return closeRequested;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,21 +46,18 @@ package org.lwjgl;
|
|||
public final class DisplayMode {
|
||||
|
||||
/** properties of the display mode */
|
||||
public final int width, height, bpp, freq, alpha, depth, stencil;
|
||||
public final int width, height, bpp, freq;
|
||||
|
||||
/**
|
||||
* Construct a display mode.
|
||||
*
|
||||
* @see Display
|
||||
*/
|
||||
private DisplayMode(int width, int height, int bpp, int freq, int alpha, int depth, int stencil) {
|
||||
private DisplayMode(int width, int height, int bpp, int freq) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.bpp = bpp;
|
||||
this.freq = freq;
|
||||
this.alpha = alpha;
|
||||
this.depth = depth;
|
||||
this.stencil = stencil;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,10 +74,7 @@ public final class DisplayMode {
|
|||
return dm.width == width
|
||||
&& dm.height == dm.height
|
||||
&& dm.bpp == bpp
|
||||
&& dm.freq == freq
|
||||
&& dm.alpha == alpha
|
||||
&& dm.depth == depth
|
||||
&& dm.stencil == stencil;
|
||||
&& dm.freq == freq;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,7 +83,7 @@ public final class DisplayMode {
|
|||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
public int hashCode() {
|
||||
return width ^ height ^ freq ^ bpp ^ alpha ^ (depth << 8) ^ (stencil << 24);
|
||||
return width ^ height ^ freq ^ bpp;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -106,13 +100,7 @@ public final class DisplayMode {
|
|||
sb.append(bpp);
|
||||
sb.append(" @");
|
||||
sb.append(freq);
|
||||
sb.append("Hz ");
|
||||
sb.append(alpha);
|
||||
sb.append("bit alpha, ");
|
||||
sb.append(depth);
|
||||
sb.append("bit depth, ");
|
||||
sb.append(stencil);
|
||||
sb.append("bit stencil");
|
||||
sb.append("Hz");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ public class ControllerCreationTest {
|
|||
|
||||
private void setupDisplay(boolean fullscreen) {
|
||||
try {
|
||||
Display.create(displayMode, fullscreen, "MouseTest");
|
||||
Display.create(displayMode, 0, 0, 0, fullscreen, "MouseTest");
|
||||
gl = new GL();
|
||||
gl.create();
|
||||
|
||||
|
@ -223,4 +223,4 @@ public class ControllerCreationTest {
|
|||
ControllerCreationTest cct = new ControllerCreationTest();
|
||||
cct.executeTest();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ public class MouseCreationTest {
|
|||
|
||||
private void setupDisplay(boolean fullscreen) {
|
||||
try {
|
||||
Display.create(displayMode, fullscreen, "MouseTest");
|
||||
Display.create(displayMode, 0, 0, 0, fullscreen, "MouseTest");
|
||||
gl = new GL();
|
||||
gl.create();
|
||||
|
||||
|
@ -226,4 +226,4 @@ public class MouseCreationTest {
|
|||
MouseCreationTest mt = new MouseCreationTest();
|
||||
mt.executeTest();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ public class MouseTest {
|
|||
|
||||
private void setupDisplay(boolean fullscreen) {
|
||||
try {
|
||||
Display.create(displayMode, fullscreen, "MouseTest");
|
||||
Display.create(displayMode, 0, 0, 0, fullscreen, "MouseTest");
|
||||
gl = new GL();
|
||||
gl.create();
|
||||
|
||||
|
@ -193,4 +193,4 @@ public class MouseTest {
|
|||
MouseTest mt = new MouseTest();
|
||||
mt.executeTest();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ public class MovingSoundTest extends BasicTest {
|
|||
break;
|
||||
}
|
||||
}
|
||||
Display.create(modes[mode], false, "MovingSoundTest");
|
||||
Display.create(modes[mode], 0, 0, 0, false, "MovingSoundTest");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
exit(-1);
|
||||
|
@ -256,4 +256,4 @@ public class MovingSoundTest extends BasicTest {
|
|||
MovingSoundTest movingSoundTest = new MovingSoundTest();
|
||||
movingSoundTest.execute(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public final class Game {
|
|||
}
|
||||
|
||||
//select above found displaymode
|
||||
Display.create(modes[mode], false, "LWJGL Game Example");
|
||||
Display.create(modes[mode], 0, 16, 0, false, "LWJGL Game Example");
|
||||
System.out.println("Created display.");
|
||||
} catch (Exception e) {
|
||||
System.err.println("Failed to create display due to " + e);
|
||||
|
|
|
@ -81,7 +81,7 @@ public class Grass {
|
|||
}
|
||||
// For now let's just pick a mode we're certain to have
|
||||
|
||||
Display.create(modes[mode], false, "Grass");
|
||||
Display.create(modes[mode], 0, 16, 0, false, "Grass");
|
||||
System.out.println("Created display.");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -12,7 +12,7 @@ extern "C" {
|
|||
/* Inaccessible static: mode */
|
||||
/* Inaccessible static: handle */
|
||||
/* Inaccessible static: closeRequested */
|
||||
/* Inaccessible static: class_000240 */
|
||||
/* Inaccessible static: class_00024org_00024lwjgl_00024Display */
|
||||
/*
|
||||
* Class: org_lwjgl_Display
|
||||
* Method: nGetAvailableDisplayModes
|
||||
|
|
|
@ -84,7 +84,7 @@ struct pixelformat {
|
|||
int stencil;
|
||||
};
|
||||
|
||||
static int fillFormat(struct pixelformat *formats, int index, int bpp, int depth, int alpha, int stencil) {
|
||||
/*static int fillFormat(struct pixelformat *formats, int index, int bpp, int depth, int alpha, int stencil) {
|
||||
for (int i = 0; i < index; i++)
|
||||
if (formats[i].bpp == bpp &&
|
||||
formats[i].depth == depth &&
|
||||
|
@ -114,7 +114,7 @@ static struct pixelformat *getGLXAvailablePixelFormats(Display *disp, int screen
|
|||
int bpp, depth, alpha, stencil;
|
||||
int val;
|
||||
if (glXGetFBConfigAttrib(disp, configs[i], GLX_RED_SIZE, &val) != 0) {
|
||||
free(formats);
|
||||
ree(formats);
|
||||
return NULL;
|
||||
}
|
||||
bpp = val;
|
||||
|
@ -147,7 +147,7 @@ static struct pixelformat *getGLXAvailablePixelFormats(Display *disp, int screen
|
|||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*/
|
||||
static XVisualInfo *chooseVisual(Display *disp, int screen, int bpp, int depth, int alpha, int stencil) {
|
||||
int bpe;
|
||||
switch (bpp) {
|
||||
|
@ -174,7 +174,7 @@ static XVisualInfo *chooseVisual(Display *disp, int screen, int bpp, int depth,
|
|||
return glXChooseVisual(disp, screen, attriblist);
|
||||
}
|
||||
|
||||
static struct pixelformat *getAvailablePixelFormats(Display *disp, int screen, int *length) {
|
||||
/*static struct pixelformat *getAvailablePixelFormats(Display *disp, int screen, int *length) {
|
||||
struct pixelformat *formats = getGLXAvailablePixelFormats(disp, screen, length);
|
||||
if (formats != NULL)
|
||||
return formats;
|
||||
|
@ -194,6 +194,7 @@ static struct pixelformat *getAvailablePixelFormats(Display *disp, int screen, i
|
|||
}
|
||||
return formats;
|
||||
}
|
||||
*/
|
||||
|
||||
static void waitMapped(Display *disp, Window win) {
|
||||
XEvent event;
|
||||
|
@ -470,6 +471,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_Display_nGetAvailableDisplayModes
|
|||
}
|
||||
|
||||
screen = DefaultScreen(disp);
|
||||
int bpp = XDefaultDepth(disp, screen);
|
||||
|
||||
if (!loadGL(disp, screen)) {
|
||||
#ifdef _DEBUG
|
||||
|
@ -486,19 +488,21 @@ JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_Display_nGetAvailableDisplayModes
|
|||
return NULL;
|
||||
}
|
||||
int num_pixelformats;
|
||||
struct pixelformat *formats = getAvailablePixelFormats(disp, screen, &num_pixelformats);
|
||||
// struct pixelformat *formats = getAvailablePixelFormats(disp, screen, &num_pixelformats);
|
||||
// Allocate an array of DisplayModes big enough
|
||||
jclass displayModeClass = env->FindClass("org/lwjgl/DisplayMode");
|
||||
jobjectArray ret = env->NewObjectArray(num_modes*num_pixelformats, displayModeClass, NULL);
|
||||
jmethodID displayModeConstructor = env->GetMethodID(displayModeClass, "<init>", "(IIIIIII)V");
|
||||
jobjectArray ret = env->NewObjectArray(num_modes/**num_pixelformats*/, displayModeClass, NULL);
|
||||
jmethodID displayModeConstructor = env->GetMethodID(displayModeClass, "<init>", "(IIII)V");
|
||||
|
||||
for (i = 0; i < num_modes; i++) {
|
||||
for (int j = 0; j < num_pixelformats; j++) {
|
||||
/* for (int j = 0; j < num_pixelformats; j++) {
|
||||
jobject displayMode = env->NewObject(displayModeClass, displayModeConstructor, avail_modes[i]->hdisplay, avail_modes[i]->vdisplay, formats[j].bpp, 0, formats[j].alpha, formats[j].depth, formats[j].stencil);
|
||||
env->SetObjectArrayElement(ret, i*num_pixelformats + j, displayMode);
|
||||
}
|
||||
}*/
|
||||
jobject displayMode = env->NewObject(displayModeClass, displayModeConstructor, avail_modes[i]->hdisplay, avail_modes[i]->vdisplay, bpp, 0);
|
||||
env->SetObjectArrayElement(ret, i, displayMode);
|
||||
}
|
||||
free(formats);
|
||||
// free(formats);
|
||||
XFree(avail_modes);
|
||||
XCloseDisplay(disp);
|
||||
return ret;
|
||||
|
|
|
@ -288,125 +288,101 @@ JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_Display_nGetAvailableDisplayModes
|
|||
* Choose displaymodes using NT codepath (multiple displaydevices)
|
||||
*/
|
||||
jobjectArray GetAvailableDisplayModesNT(JNIEnv * env) {
|
||||
int i = 0, j = 0, n = 0;
|
||||
int AvailableModes = 0;
|
||||
int i = 0, j = 0, n = 0;
|
||||
int AvailableModes = 0;
|
||||
|
||||
DISPLAY_DEVICE DisplayDevice;
|
||||
DEVMODE DevMode;
|
||||
DISPLAY_DEVICE DisplayDevice;
|
||||
DEVMODE DevMode;
|
||||
|
||||
DevMode.dmSize = sizeof(DEVMODE);
|
||||
DisplayDevice.cb = sizeof(DISPLAY_DEVICE);
|
||||
DevMode.dmSize = sizeof(DEVMODE);
|
||||
DisplayDevice.cb = sizeof(DISPLAY_DEVICE);
|
||||
|
||||
//enumerate all displays, and all of their displaymodes
|
||||
while(EnumDisplayDevices(NULL, i++, &DisplayDevice, 0) != 0) {
|
||||
while(EnumDisplaySettings(DisplayDevice.DeviceName, j++, &DevMode) != 0) {
|
||||
if (DevMode.dmBitsPerPel <=8) {
|
||||
continue;
|
||||
}
|
||||
AvailableModes++;
|
||||
}
|
||||
}
|
||||
while(EnumDisplayDevices(NULL, i++, &DisplayDevice, 0) != 0) {
|
||||
while(EnumDisplaySettings(DisplayDevice.DeviceName, j++, &DevMode) != 0) {
|
||||
if (DevMode.dmBitsPerPel > 8) {
|
||||
AvailableModes++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
printf("Found %d displaymodes\n", AvailableModes);
|
||||
printf("Found %d displaymodes\n", AvailableModes);
|
||||
#endif
|
||||
|
||||
// now that we have the count create the classes, and add 'em all - we'll remove dups in Java
|
||||
// Allocate an array of DisplayModes big enough
|
||||
// now that we have the count create the classes, and add 'em all - we'll remove dups in Java
|
||||
// Allocate an array of DisplayModes big enough
|
||||
jclass displayModeClass = env->FindClass("org/lwjgl/DisplayMode");
|
||||
|
||||
// Note the * 16 - this is because we are manufacturing available alpha/depth/stencil combos.
|
||||
jobjectArray ret = env->NewObjectArray(AvailableModes * 16, displayModeClass, NULL);
|
||||
jmethodID displayModeConstructor = env->GetMethodID(displayModeClass, "<init>", "(IIIIIII)V");
|
||||
jobjectArray ret = env->NewObjectArray(AvailableModes, displayModeClass, NULL);
|
||||
jmethodID displayModeConstructor = env->GetMethodID(displayModeClass, "<init>", "(IIII)V");
|
||||
|
||||
i = 0, j = 0, n = 0;
|
||||
while(EnumDisplayDevices(NULL, i++, &DisplayDevice, 0) != 0) {
|
||||
while(EnumDisplaySettings(DisplayDevice.DeviceName, j++, &DevMode) != 0) {
|
||||
// Filter out indexed modes
|
||||
if (DevMode.dmBitsPerPel <= 8) {
|
||||
continue;
|
||||
} else {
|
||||
jobject displayMode;
|
||||
i = 0, j = 0, n = 0;
|
||||
while(EnumDisplayDevices(NULL, i++, &DisplayDevice, 0) != 0) {
|
||||
while(EnumDisplaySettings(DisplayDevice.DeviceName, j++, &DevMode) != 0) {
|
||||
// Filter out indexed modes
|
||||
if (DevMode.dmBitsPerPel > 8) {
|
||||
jobject displayMode;
|
||||
displayMode = env->NewObject(displayModeClass, displayModeConstructor,
|
||||
DevMode.dmPelsWidth, DevMode.dmPelsHeight,
|
||||
DevMode.dmBitsPerPel, DevMode.dmDisplayFrequency);
|
||||
|
||||
for (int depthBits = 0; depthBits <= 24; depthBits += 8) {
|
||||
for (int stencilBits = 0; stencilBits <= 8; stencilBits += 8) {
|
||||
for (int alphaBits = 0; alphaBits <= 8; alphaBits += 8) {
|
||||
|
||||
displayMode = env->NewObject( displayModeClass, displayModeConstructor,
|
||||
DevMode.dmPelsWidth, DevMode.dmPelsHeight,
|
||||
DevMode.dmBitsPerPel, DevMode.dmDisplayFrequency,
|
||||
alphaBits, depthBits, stencilBits);
|
||||
|
||||
env->SetObjectArrayElement(ret, n++, displayMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
env->SetObjectArrayElement(ret, n++, displayMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Choose displaymodes using 9x codepath (single displaydevice)
|
||||
*/
|
||||
jobjectArray GetAvailableDisplayModes9x(JNIEnv * env) {
|
||||
int i = 0, j = 0, n = 0;
|
||||
int AvailableModes = 0;
|
||||
int i = 0, j = 0, n = 0;
|
||||
int AvailableModes = 0;
|
||||
|
||||
DEVMODE DevMode;
|
||||
DEVMODE DevMode;
|
||||
|
||||
DevMode.dmSize = sizeof(DEVMODE);
|
||||
DevMode.dmSize = sizeof(DEVMODE);
|
||||
|
||||
//enumerate all displaymodes
|
||||
while(EnumDisplaySettings(NULL, j++, &DevMode) != 0) {
|
||||
if (DevMode.dmBitsPerPel <=8) {
|
||||
continue;
|
||||
}
|
||||
AvailableModes++;
|
||||
}
|
||||
//enumerate all displaymodes
|
||||
while(EnumDisplaySettings(NULL, j++, &DevMode) != 0) {
|
||||
if (DevMode.dmBitsPerPel > 8) {
|
||||
AvailableModes++;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
printf("Found %d displaymodes\n", AvailableModes);
|
||||
printf("Found %d displaymodes\n", AvailableModes);
|
||||
#endif
|
||||
|
||||
// now that we have the count create the classes, and add 'em all - we'll remove dups in Java
|
||||
// Allocate an array of DisplayModes big enough
|
||||
// now that we have the count create the classes, and add 'em all - we'll remove dups in Java
|
||||
// Allocate an array of DisplayModes big enough
|
||||
jclass displayModeClass = env->FindClass("org/lwjgl/DisplayMode");
|
||||
|
||||
// Note the * 16 - this is because we are manufacturing available alpha/depth/stencil combos.
|
||||
jobjectArray ret = env->NewObjectArray(AvailableModes * 16, displayModeClass, NULL);
|
||||
jmethodID displayModeConstructor = env->GetMethodID(displayModeClass, "<init>", "(IIIIIII)V");
|
||||
jmethodID displayModeConstructor = env->GetMethodID(displayModeClass, "<init>", "(IIII)V");
|
||||
|
||||
i = 0, j = 0, n = 0;
|
||||
while(EnumDisplaySettings(NULL, j++, &DevMode) != 0) {
|
||||
// Filter out indexed modes
|
||||
if (DevMode.dmBitsPerPel <= 8) {
|
||||
continue;
|
||||
} else {
|
||||
jobject displayMode;
|
||||
for (int depthBits = 0; depthBits <= 24; depthBits += 8) {
|
||||
for (int stencilBits = 0; stencilBits <= 8; stencilBits += 8) {
|
||||
for (int alphaBits = 0; alphaBits <= 8; alphaBits += 8) {
|
||||
|
||||
displayMode = env->NewObject( displayModeClass, displayModeConstructor,
|
||||
DevMode.dmPelsWidth, DevMode.dmPelsHeight,
|
||||
DevMode.dmBitsPerPel, DevMode.dmDisplayFrequency,
|
||||
alphaBits, depthBits, stencilBits);
|
||||
|
||||
env->SetObjectArrayElement(ret, n++, displayMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
i = 0, j = 0, n = 0;
|
||||
while(EnumDisplaySettings(NULL, j++, &DevMode) != 0) {
|
||||
// Filter out indexed modes
|
||||
if (DevMode.dmBitsPerPel > 8) {
|
||||
jobject displayMode;
|
||||
displayMode = env->NewObject(displayModeClass, displayModeConstructor,
|
||||
DevMode.dmPelsWidth, DevMode.dmPelsHeight,
|
||||
DevMode.dmBitsPerPel, DevMode.dmDisplayFrequency);
|
||||
env->SetObjectArrayElement(ret, n++, displayMode);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_Display
|
||||
* Method: nCreate
|
||||
* Signature: (IIIIZ)Z
|
||||
* Signature: (IIIIIIIZLjava/lang/String;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_lwjgl_Display_nCreate
|
||||
(JNIEnv * env, jclass clazz, jint width, jint height, jint bpp, jint freq,
|
||||
|
|
Loading…
Reference in New Issue