Display.getVersion() crashes...

Started by Simon Felix, May 21, 2006, 15:39:30

Previous topic - Next topic

Simon Felix

lwjgl 0.99

java.lang.NullPointerException
    at org.lwjgl.opengl.Win32Display.nGetVersion(Native Method)
    at org.lwjgl.opengl.Win32Display.getVersion(Unknown Source)
    at org.lwjgl.opengl.Display.getVersion(Unknown Source)
    at Cultris.main(Unknown Source)





the line
Display.getVersion()

crashes sometimes with above exception. i just know that the system where lwjgl crashed has a nVidia-card and win98.



\src\native\win32\org_lwjgl_opengl_Display.c
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;
}


i suspect that the function GetStringNativeChars throws the NPE. that would mean that driver==null.


\src\java\org\lwjgl\opengl\Win32Display.java:
public String getVersion() {
	return nGetVersion(getAdapter());
}


that in turn means that getAdapter() returns null.


public String getAdapter() {
	try {
		String adapter_string = Win32Registry.queryRegistrationKey(
				Win32Registry.HKEY_LOCAL_MACHINE,
				"HARDWARE\\DeviceMap\\Video",
				"\\Device\\Video0");
		String root_key = "\\registry\\machine\\";
		if (adapter_string.toLowerCase().startsWith(root_key)) {
			String driver_value = Win32Registry.queryRegistrationKey(
					Win32Registry.HKEY_LOCAL_MACHINE,
					adapter_string.substring(root_key.length()),
					"InstalledDisplayDrivers");
			return driver_value;
		}
	} catch (LWJGLException e) {
		LWJGLUtil.log("Exception occurred while querying registry: " + e);
	}
	return null;
}




and ideas? suggestions?

soon i'll know which graphics-card & -driver the system has.
Download Cultris II, the fastest Tetris clone from http://gewaltig.net/

Simon Felix

graphics card is a NVIDIA GeForce FX 5200.
Download Cultris II, the fastest Tetris clone from http://gewaltig.net/

Evil-Devil

I suggest to use another Registry Entry. As Windows stores some values at multiple place and with minor differences the have to be one entry that is common on all platforms back to Win98 or even Win95. Else those Sys Tools won't show i.e. different names for the graphics card.

Simon Felix

the guy with the problem installed a 77-series driver from nvidia as well as the newest nvidia driver (80-series).


i think lwjgl shouldn't throw a npe when it cannot determine the version...
Download Cultris II, the fastest Tetris clone from http://gewaltig.net/

Matzon