diff options
author | Kenneth Russel <[email protected]> | 2005-07-19 01:53:36 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2005-07-19 01:53:36 +0000 |
commit | 74adb7cc4ba59369964b562e3c84988f63025296 (patch) | |
tree | 0a850c1110afa161eeadb930c4035eb310b79f84 /src/net/java/games/jogl/impl/GLDrawableFactoryImpl.java | |
parent | b01ac27a7d6ae4863490537e1ba8749795cd84de (diff) |
Added workaround for problem loading JAWT library on X11 platforms
before the AWT toolkit had been loaded. Added check for
jogl.gljpanel.nosw system property to diagnose problems with pbuffer
support. Fixed bootstrapping problem with GLX where its function
pointer table needed to be initialized before the first OpenGL context
was created in the case where a pbuffer was the first thing created.
Moved helper functions for resetting proc address table and dynamic
function lookup to GLDrawableFactoryImpl from GLContextImpl.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JSR-231@331 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/net/java/games/jogl/impl/GLDrawableFactoryImpl.java')
-rwxr-xr-x | src/net/java/games/jogl/impl/GLDrawableFactoryImpl.java | 32 |
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(); } |