It could be really helpful to treat the natives parameters like the jars parameters, a list of items separated by ','
An example:
<applet code="org.lwjgl.util.applet.AppletLoader" archive="lwjgl_util_applet.jar" codebase="." width="640" height="480">
...
<param name="al_windows" value="windows_natives.jar, my_custom_natives-win.jar">
...
</applet>
I want to propose a patch but first I wanna know if there are no problems with this request and/or if exists another solution already.
for custom natives files from a seperate Jar file/s, It should probably be implemented as another tag (optional). It should be done using the following method to add them to the library path (as its unlikely that the lwjgl library property would be needed).
public void addDir(String nativeLibraryPath) throws IOException {
try {
Field field = ClassLoader.class.getDeclaredField("usr_paths");
field.setAccessible(true);
String[] paths = (String[])field.get(null);
for (int i = 0; i < paths.length; i++) {
if (nativeLibraryPath.equals(paths[i])) {
return;
}
}
String[] paths2 = new String[paths.length+1];
System.arraycopy(paths,0,paths2,0,paths.length);
paths2[paths.length] = nativeLibraryPath;
field.set(null,paths2);
System.setProperty("java.library.path", System.getProperty("java.library.path") + File.pathSeparator + nativeLibraryPath);
} catch (IllegalAccessException e) {
throw new IOException("Failed to get permissions to set library path");
} catch (NoSuchFieldException e) {
throw new IOException("Failed to get field handle to set library path");
}
}
this method should also be added as a way for the "java.library.path" property to find the default natives, as it currently seems to override the current library path, instead of adding the new one.
This is how I use the GAGE natives for the win32 timer.
Implemented :)
marked as fixed.
Tested!
Thanks.
@bobjob, custom natives are already supported and added to 'java.library.path', there was a recent fix (http://lwjgl.org/forum/index.php/topic,3697.0.html)too, so you should be able to use custom natives with no problems.
oh cool.
the version i of the appletLoader source I checked used this line:
System.setProperty("java.library.path", path + "natives");
has it been fixed not to override the current library paths, so something like:
System.setProperty("java.library.path", System.getProperty("java.library.path") + path + "natives");
yes its fixed, see patch from Nate in my previous post.