aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/games/jogl/impl/GLDrawableFactoryImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/java/games/jogl/impl/GLDrawableFactoryImpl.java')
-rwxr-xr-xsrc/net/java/games/jogl/impl/GLDrawableFactoryImpl.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/net/java/games/jogl/impl/GLDrawableFactoryImpl.java b/src/net/java/games/jogl/impl/GLDrawableFactoryImpl.java
index be246db4e..b8c6a126c 100755
--- a/src/net/java/games/jogl/impl/GLDrawableFactoryImpl.java
+++ b/src/net/java/games/jogl/impl/GLDrawableFactoryImpl.java
@@ -42,6 +42,7 @@ package net.java.games.jogl.impl;
import java.awt.Component;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
+import net.java.games.gluegen.runtime.*; // for PROCADDRESS_VAR_PREFIX
import net.java.games.jogl.*;
/** Extends GLDrawableFactory with a few methods for handling
@@ -56,6 +57,37 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
public abstract GLDrawableImpl createOffscreenDrawable(GLCapabilities capabilities,
GLCapabilitiesChooser chooser);
+ /** Helper routine which resets a ProcAddressTable generated by the
+ GLEmitter by looking up anew all of its function pointers. */
+ public void resetProcAddressTable(Object table) {
+ Class tableClass = table.getClass();
+ java.lang.reflect.Field[] fields = tableClass.getDeclaredFields();
+
+ for (int i = 0; i < fields.length; ++i) {
+ String addressFieldName = fields[i].getName();
+ if (!addressFieldName.startsWith(ProcAddressHelper.PROCADDRESS_VAR_PREFIX)) {
+ // not a proc address variable
+ continue;
+ }
+ int startOfMethodName = ProcAddressHelper.PROCADDRESS_VAR_PREFIX.length();
+ String glFuncName = addressFieldName.substring(startOfMethodName);
+ try {
+ java.lang.reflect.Field addressField = tableClass.getDeclaredField(addressFieldName);
+ assert(addressField.getType() == Long.TYPE);
+ long newProcAddress = dynamicLookupFunction(glFuncName);
+ // set the current value of the proc address variable in the table object
+ addressField.setLong(table, newProcAddress);
+ } catch (Exception e) {
+ throw new GLException("Cannot get GL proc address for method \"" +
+ glFuncName + "\": Couldn't set value of field \"" + addressFieldName +
+ "\" in class " + tableClass.getName(), e);
+ }
+ }
+ }
+
+ /** Dynamically looks up the given function. */
+ public abstract long dynamicLookupFunction(String glFuncName);
+
public static GLDrawableFactoryImpl getFactoryImpl() {
return (GLDrawableFactoryImpl) getFactory();
}