Alert code & new displaymode code
This commit is contained in:
parent
d7e4f30547
commit
18f8302668
|
@ -198,19 +198,30 @@ JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_Display_getAvailableDisplayModes
|
|||
|
||||
// Allocate an array of DisplayModes big enough
|
||||
jclass displayModeClass = env->FindClass("org/lwjgl/DisplayMode");
|
||||
jobjectArray ret = env->NewObjectArray(n, displayModeClass, NULL);
|
||||
jmethodID displayModeConstructor = env->GetMethodID(displayModeClass, "<init>", "(IIII)V");
|
||||
|
||||
// Note the * 32 - this is because we are manufacturing available alpha/depth/stencil combos.
|
||||
jobjectArray ret = env->NewObjectArray(n * 32, displayModeClass, NULL);
|
||||
jmethodID displayModeConstructor = env->GetMethodID(displayModeClass, "<init>", "(IIIIIII)V");
|
||||
|
||||
i = n = 0;
|
||||
while (EnumDisplaySettings(NULL, i ++, &mode) != 0) {
|
||||
// Filter out indexed modes
|
||||
if (mode.dmBitsPerPel < 16) {
|
||||
if (mode.dmBitsPerPel <= 8) {
|
||||
continue;
|
||||
} else {
|
||||
jobject displayMode = env->NewObject(displayModeClass, displayModeConstructor, mode.dmPelsWidth, mode.dmPelsHeight,
|
||||
mode.dmBitsPerPel, mode.dmDisplayFrequency);
|
||||
jobject displayMode;
|
||||
|
||||
env->SetObjectArrayElement(ret, n ++, 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, mode.dmPelsWidth, mode.dmPelsHeight,
|
||||
mode.dmBitsPerPel, mode.dmDisplayFrequency, alphaBits, depthBits, stencilBits);
|
||||
|
||||
env->SetObjectArrayElement(ret, n ++, displayMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -258,16 +269,24 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_Display_nCreate
|
|||
oneShotInitialised = true;
|
||||
}
|
||||
|
||||
int windowflags;
|
||||
|
||||
if (fullscreen) {
|
||||
windowflags = WS_POPUP;
|
||||
} else {
|
||||
windowflags = WS_POPUP | WS_CAPTION;
|
||||
}
|
||||
|
||||
// Create the window now, using that class:
|
||||
hwnd = CreateWindow(
|
||||
WINDOWCLASSNAME,
|
||||
"LWJGL",
|
||||
WS_POPUP, // | WS_MAXIMIZE,
|
||||
windowflags,
|
||||
0, 0,
|
||||
width, height,
|
||||
NULL,
|
||||
NULL,
|
||||
GetModuleHandle(NULL),
|
||||
dll_handle,
|
||||
NULL);
|
||||
// And we never look at windowClass again...
|
||||
|
||||
|
@ -327,7 +346,7 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_Display_nCreate
|
|||
0, 0, 0, 0, // accum bits ignored
|
||||
(BYTE)depthBits,
|
||||
(BYTE)stencilBits,
|
||||
0, // One auxiliary buffer
|
||||
0, // No auxiliary buffer
|
||||
PFD_MAIN_PLANE, // main layer
|
||||
0, // reserved
|
||||
0, 0, 0 // layer masks ignored
|
||||
|
|
|
@ -42,6 +42,9 @@
|
|||
#include <windows.h>
|
||||
#include "org_lwjgl_Sys.h"
|
||||
|
||||
// Handle to the application's window
|
||||
extern HWND hwnd;
|
||||
|
||||
__int64 hires_timer_freq; // Hires timer frequency
|
||||
__int64 hires_timer_start; // Hires timer start
|
||||
__int64 hires_timer; // Hires timer current time
|
||||
|
@ -139,3 +142,24 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Sys_setProcessPriority
|
|||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_Sys
|
||||
* Method: alert
|
||||
* Signature: (Ljava/lang/String;Ljava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_Sys_alert
|
||||
(JNIEnv * env, jclass clazz, jstring title, jstring message)
|
||||
{
|
||||
jboolean copy = JNI_FALSE;
|
||||
const char * eMessageText = env->GetStringUTFChars(message, ©);
|
||||
const char * cTitleBarText = env->GetStringUTFChars(title, ©);
|
||||
MessageBox(hwnd, eMessageText, cTitleBarText, MB_OK | MB_TOPMOST);
|
||||
|
||||
#ifdef _DEBUG
|
||||
printf("*** Alert ***%s\n%s\n", cTitleBarText, eMessageText);
|
||||
#endif
|
||||
|
||||
env->ReleaseStringUTFChars(message, eMessageText);
|
||||
env->ReleaseStringUTFChars(title, cTitleBarText);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue