diff options
author | kbr <[email protected]> | 2007-06-29 00:15:57 +0000 |
---|---|---|
committer | kbr <[email protected]> | 2007-06-29 00:15:57 +0000 |
commit | 3d36ce1bac06911920714bd3e801002c0f533f68 (patch) | |
tree | 03c93653adaec162b7d07f7f0f366d15dac340ab | |
parent | 9f39a3c23f127d02dbcf51800cd88b40ceed7329 (diff) |
Incorporated changes from Ultraq on javagaming.org forums for properly
looking up EFX entry points
git-svn-id: file:///home/mbien/NetBeansProjects/JOGAMP/joal-sync/git-svn/../svn-server-sync/joal/trunk@557 03bf7f67-59de-4072-a415-9a990d468a3f
-rwxr-xr-x | src/java/net/java/games/joal/impl/ALProcAddressLookup.java | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/java/net/java/games/joal/impl/ALProcAddressLookup.java b/src/java/net/java/games/joal/impl/ALProcAddressLookup.java index 5a188c7..c7bdc53 100755 --- a/src/java/net/java/games/joal/impl/ALProcAddressLookup.java +++ b/src/java/net/java/games/joal/impl/ALProcAddressLookup.java @@ -33,6 +33,8 @@ package net.java.games.joal.impl; +import java.lang.reflect.Field; + import net.java.games.joal.*; import com.sun.gluegen.runtime.*; @@ -80,6 +82,13 @@ public class ALProcAddressLookup { // per-ALcontext ALProcAddressTables and per-ALCdevice // ALCProcAddressTables. ProcAddressHelper.resetProcAddressTable(alTable, lookup); + + // The above only manages to find addresses for the core OpenAL + // functions. The below uses alGetProcAddress() to find the addresses + // of extensions such as EFX, just as in the C++ examples of the + // OpenAL 1.1 SDK. + useALGetProcAddress(); + alTableInitialized = true; } } @@ -111,4 +120,40 @@ public class ALProcAddressLookup { public static ALCProcAddressTable getALCProcAddressTable() { return alcTable; } + + + /** + * Retrieves the values of the OpenAL functions using alGetProcAddress(). + */ + private static void useALGetProcAddress() { + String addrOfPrefix = "_addressof_"; + ALImpl al = (ALImpl) ALFactory.getAL(); + + Field[] fields = ALProcAddressTable.class.getFields(); + for (int i = 0; i < fields.length; i++) { + Field field = fields[i]; + + // Skip non-address fields + String fieldname = field.getName(); + if (!fieldname.startsWith(addrOfPrefix)) { + continue; + } + try { + String functionname = fieldname.substring(addrOfPrefix.length()); + long fieldval = field.getLong(alTable); + + // Skip fields which have already been valued + if (fieldval != 0) { + continue; + } + + // Get the address + long procAddressVal = al.alGetProcAddress(functionname); + field.setLong(alTable, procAddressVal); + } + catch (Exception ex) { + throw new RuntimeException("Unable to repopulate ALProcAddressTable values", ex); + } + } + } } |