diff --git a/src/java/org/lwjgl/Sys.java b/src/java/org/lwjgl/Sys.java index 4d4b9f24..5bf3468e 100644 --- a/src/java/org/lwjgl/Sys.java +++ b/src/java/org/lwjgl/Sys.java @@ -83,6 +83,7 @@ public final class Sys { */ public static final boolean DEBUG; + private static boolean _debug; static { try { @@ -100,6 +101,20 @@ public final class Sys { } } + /* + * Platforms. This will let you determine which platform you are running + * on, which is handy to know for some GL calls. + */ + + /** Windows platform */ + public static final int PLATFORM_WGL = 0; + + /** GLX (Linux/Unix) platform */ + public static final int PLATFORM_GLX = 1; + + /** Apply platform */ + public static final int PLATFORM_AGL = 2; + /** * @return the name of the native library to load */ @@ -207,5 +222,15 @@ public final class Sys { * @param message The message text for the alert. */ public static native void alert(String title, String message); + + /** + * Returns the operating system windowing platform. This will be one of the + * constants defined above. There is no "unknown" platform; a native library port + * has to provide a unique platform number for this mechanism to work. If the LWJGL + * is ported to, say, QNX, we will have a PLATFORM_QNX at the ready. + * + * @return the windowing system + */ + public static native int getPlatform(); } diff --git a/src/native/common/org_lwjgl_Sys.h b/src/native/common/org_lwjgl_Sys.h index ed575875..0b077904 100644 --- a/src/native/common/org_lwjgl_Sys.h +++ b/src/native/common/org_lwjgl_Sys.h @@ -19,6 +19,12 @@ extern "C" { /* Inaccessible static: LIBRARY_NAME */ /* Inaccessible static: DEBUG */ /* Inaccessible static: _debug */ +#undef org_lwjgl_Sys_PLATFORM_WGL +#define org_lwjgl_Sys_PLATFORM_WGL 0L +#undef org_lwjgl_Sys_PLATFORM_GLX +#define org_lwjgl_Sys_PLATFORM_GLX 1L +#undef org_lwjgl_Sys_PLATFORM_AGL +#define org_lwjgl_Sys_PLATFORM_AGL 2L /* Inaccessible static: class_000240 */ /* * Class: org_lwjgl_Sys @@ -76,6 +82,14 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Sys_setProcessPriority JNIEXPORT void JNICALL Java_org_lwjgl_Sys_alert (JNIEnv *, jclass, jstring, jstring); +/* + * Class: org_lwjgl_Sys + * Method: getPlatform + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_lwjgl_Sys_getPlatform + (JNIEnv *, jclass); + #ifdef __cplusplus } #endif diff --git a/src/native/win32/org_lwjgl_Sys.cpp b/src/native/win32/org_lwjgl_Sys.cpp index d7ae3c54..fa81e1f7 100644 --- a/src/native/win32/org_lwjgl_Sys.cpp +++ b/src/native/win32/org_lwjgl_Sys.cpp @@ -49,6 +49,21 @@ __int64 hires_timer_freq; // Hires timer frequency __int64 hires_timer_start; // Hires timer start __int64 hires_timer; // Hires timer current time +// Platform +#ifdef _WIN32 +#define PLATFORM 0 +#else +#ifdef _X11 +#define PLATFORM 1 +#else +#ifdef APPLE +#define PLATFORM 2 +#else +#error Unsupported Platform! +#endif +#endif + + /* * Class: org_lwjgl_Sys * Method: getDirectBufferAddress @@ -163,3 +178,15 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Sys_alert env->ReleaseStringUTFChars(message, eMessageText); env->ReleaseStringUTFChars(title, cTitleBarText); } + +/* + * Class: org_lwjgl_Sys + * Method: getPlatform + * Signature: ()I + */ +JNIEXPORT void JNICALL Java_org_lwjgl_Sys_getPlatform + (JNIEnv * env, jclass clazz) +{ + return org_lwjgl_Sys_PLATFORM_WGL; +} +