Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions src/com/base/engine/core/LibraryLoader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.base.engine.core;
import java.lang.reflect.Field;
import java.util.Arrays;


public class LibraryLoader {

public static void loadNativeLibrarys() throws Exception {
if(System.getProperty("os.name").equals("Mac OS X")) {
addLibraryPath("lib/natives/macosx");
} else if(System.getProperty("os.name").equals("Linux")) {
addLibraryPath("lib/natives/linux");
} else if(System.getProperty("os.name").equals("Solaris")) {
addLibraryPath("lib/natives/solaris");
} else {
addLibraryPath("lib/natives/windows");
if(System.getProperty("os.arch").equals("amd64") || System.getProperty("os.arch").equals("x86_64")) {
System.loadLibrary("OpenAL64");
} else {
System.loadLibrary("OpenAL32");
}
}
}

private static void addLibraryPath(String s) throws Exception {
final Field usr_paths_field = ClassLoader.class.getDeclaredField("usr_paths");
usr_paths_field.setAccessible(true);

final String[] paths = (String[]) usr_paths_field.get(null);

for(String path : paths) {
if(path.equals(s)) {
return;
}
}

final String[] new_paths = Arrays.copyOf(paths, paths.length + 1);
new_paths[paths.length - 1] = s;
usr_paths_field.set(null, new_paths);
}

}
6 changes: 6 additions & 0 deletions src/com/base/game/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ public class Main
{
public static void main(String[] args)
{
try {
LibraryLoader.loadNativeLibrarys();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
CoreEngine engine = new CoreEngine(800, 600, 60, new TestGame());
engine.createWindow("3D Game Engine");
engine.start();
Expand Down