mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-03-28 16:14:47 +01:00
Win32: Moved some Win32Display.getVersion code to java
This commit is contained in:
parent
77412a26a2
commit
39cb1c580d
|
|
@ -79,7 +79,10 @@ final class Win32Display implements DisplayImplementation {
|
|||
return null;
|
||||
}
|
||||
|
||||
public native String getVersion();
|
||||
public String getVersion() {
|
||||
return nGetVersion(getAdapter());
|
||||
}
|
||||
private native String nGetVersion(String driver);
|
||||
public native DisplayMode init() throws LWJGLException;
|
||||
public native void setTitle(String title);
|
||||
public native boolean isCloseRequested();
|
||||
|
|
|
|||
|
|
@ -276,65 +276,7 @@ void restoreDisplayMode(void) {
|
|||
}
|
||||
}
|
||||
|
||||
static char * getDriver() {
|
||||
#define MY_BUFSIZE 256
|
||||
|
||||
HKEY hKey;
|
||||
static TCHAR szAdapterKey[MY_BUFSIZE], szDriverValue[MY_BUFSIZE];
|
||||
DWORD dwBufLen = MY_BUFSIZE;
|
||||
LONG lRet;
|
||||
|
||||
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
||||
TEXT("HARDWARE\\DeviceMap\\Video"),
|
||||
0,
|
||||
KEY_QUERY_VALUE,
|
||||
&hKey) != ERROR_SUCCESS) return NULL;
|
||||
|
||||
lRet = RegQueryValueEx(hKey,
|
||||
TEXT("\\Device\\Video0"),
|
||||
NULL,
|
||||
NULL,
|
||||
(LPBYTE)szAdapterKey,
|
||||
&dwBufLen);
|
||||
|
||||
RegCloseKey(hKey);
|
||||
|
||||
if(lRet != ERROR_SUCCESS) return NULL;
|
||||
|
||||
printfDebug("Adapter key: %s\n", szAdapterKey);
|
||||
|
||||
// szAdapterKey now contains something like \Registry\Machine\System\CurrentControlSet\Control\Video\{B70DBD2A-90C4-41CF-A58E-F3BA69F1A6BC}\0000
|
||||
// We'll check for the first chunk:
|
||||
if (strnicmp("\\Registry\\Machine", szAdapterKey, 17) == 0) {
|
||||
// Yes, it's right, so let's look for that key now
|
||||
|
||||
TCHAR szDriverKey[MY_BUFSIZE];
|
||||
strcpy(szDriverKey, &szAdapterKey[18]);
|
||||
|
||||
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
||||
TEXT(szDriverKey),
|
||||
0,
|
||||
KEY_QUERY_VALUE,
|
||||
&hKey) != ERROR_SUCCESS) return NULL;
|
||||
|
||||
lRet = RegQueryValueEx(hKey,
|
||||
TEXT("InstalledDisplayDrivers"),
|
||||
NULL,
|
||||
NULL,
|
||||
(LPBYTE)szDriverValue,
|
||||
&dwBufLen);
|
||||
|
||||
RegCloseKey(hKey);
|
||||
|
||||
}
|
||||
|
||||
if(lRet != ERROR_SUCCESS) return NULL;
|
||||
|
||||
return szDriverValue;
|
||||
}
|
||||
|
||||
|
||||
jstring getVersion(JNIEnv * env)
|
||||
jstring getVersion(JNIEnv * env, char *driver)
|
||||
{
|
||||
jstring ret = NULL;
|
||||
|
||||
|
|
@ -343,7 +285,6 @@ jstring getVersion(JNIEnv * env)
|
|||
DWORD dwInfoSize;
|
||||
LPVOID lpInfoBuff;
|
||||
BOOL bRetval;
|
||||
char *driver = getDriver();
|
||||
|
||||
if (driver == NULL) {
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -52,6 +52,6 @@ extern int getGammaRampLength(void);
|
|||
extern void setGammaRamp(JNIEnv * env, jobject gammaRampBuffer);
|
||||
extern jobject initDisplay(JNIEnv * env);
|
||||
extern jstring getAdapter(JNIEnv * env);
|
||||
extern jstring getVersion(JNIEnv * env);
|
||||
extern jstring getVersion(JNIEnv * env, char *driver);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -362,8 +362,15 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_setGammaRamp(JNIEnv *e
|
|||
setGammaRamp(env, gamma_buffer);
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_org_lwjgl_opengl_Win32Display_getVersion(JNIEnv *env, jobject self) {
|
||||
return getVersion(env);
|
||||
JNIEXPORT jstring JNICALL Java_org_lwjgl_opengl_Win32Display_nGetVersion(JNIEnv *env, jobject self, jstring driver) {
|
||||
char *driver_str;
|
||||
jstring result;
|
||||
driver_str = GetStringNativeChars(env, driver);
|
||||
if (driver_str == NULL)
|
||||
return NULL;
|
||||
result = getVersion(env, driver_str);
|
||||
free(driver_str);
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_Win32Display_init(JNIEnv *env, jobject self) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue