diff options
author | Kenneth Russel <[email protected]> | 2003-07-03 00:09:30 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2003-07-03 00:09:30 +0000 |
commit | 93d272a0525ec57aa3cd584f15cde6cf2a637e0c (patch) | |
tree | 3d6c9f2a305539d26c7449566bbb0d72bf74b12c /src/net/java/games/jogl/impl/windows | |
parent | 37d90a0da397a1958fb101051170a60f871fb8cc (diff) |
Added pbuffer support to JOGL on X11; HWShadowmapsSimple and
ProceduralTexturePhysics demos are now working on Linux with the
appropriate hardware. Moved core GLX routines out of the public GLX
interface; this allowed XVisualInfo (and the new GLXFBConfig) to be
removed from the public API. Added support to GlueGen for returning
arrays of pointers as arrays of StructAccessors in Java and for
choosing the typedef name for a pointer-to-struct if the struct itself
does not have a typedef name. Added support to GLEmitter to emit
ProcAddressTables under arbitrary names and to support arbitrary
mechanisms for fetching those tables. Made GLU (on all platforms) and
GLX (on X11) be dynamically linked. Refactored ProcAddressTable
filling to be mostly shared code. Tested changes on Linux, Mac OS X
and Windows.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@17 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/net/java/games/jogl/impl/windows')
-rw-r--r-- | src/net/java/games/jogl/impl/windows/WindowsGLContext.java | 83 | ||||
-rw-r--r-- | src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java | 4 |
2 files changed, 27 insertions, 60 deletions
diff --git a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsGLContext.java index 4575b6210..5a6021acf 100644 --- a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java +++ b/src/net/java/games/jogl/impl/windows/WindowsGLContext.java @@ -41,7 +41,7 @@ package net.java.games.jogl.impl.windows; import java.awt.Component; import java.util.*; -import net.java.games.gluegen.opengl.*; // for PROCADDRESS_VAR_PREFIX +import net.java.games.gluegen.runtime.*; // for PROCADDRESS_VAR_PREFIX import net.java.games.jogl.*; import net.java.games.jogl.impl.*; @@ -53,6 +53,11 @@ public abstract class WindowsGLContext extends GLContext { private boolean wglGetExtensionsStringEXTAvailable; private static final Map/*<String, String>*/ functionNameMap; private static final Map/*<String, String>*/ extensionNameMap; + // Table that holds the addresses of the native C-language entry points for + // OpenGL functions. + private GLProcAddressTable glProcAddressTable; + // Handle to GLU32.dll + private long hglu32; static { functionNameMap = new HashMap(); @@ -132,72 +137,34 @@ public abstract class WindowsGLContext extends GLContext { protected abstract void swapBuffers() throws GLException; + protected long dynamicLookupFunction(String glFuncName) { + long res = WGL.wglGetProcAddress(glFuncName); + if (res == 0) { + // GLU routines aren't known to the OpenGL function lookup + if (hglu32 == 0) { + hglu32 = WGL.LoadLibraryA("GLU32"); + if (hglu32 == 0) { + throw new GLException("Error loading GLU32.DLL"); + } + } + res = WGL.GetProcAddress(hglu32, glFuncName); + } + return res; + } protected void resetGLFunctionAvailability() { super.resetGLFunctionAvailability(); - resetGLProcAddressTable(); - } - - protected void resetGLProcAddressTable() { - if (DEBUG) { System.err.println("!!! Initializing OpenGL extension address table"); } - - net.java.games.jogl.impl.ProcAddressTable table = getGLProcAddressTable(); - - // if GL is no longer an interface, we'll have to re-implement the code - // below so it only iterates through gl methods (a non-interface might - // have constructors, custom methods, etc). For now we assume all methods - // will be gl methods. - GL gl = getGL(); - - 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(GLEmitter.PROCADDRESS_VAR_PREFIX)) - { - // not a proc address variable - continue; - } - int startOfMethodName = GLEmitter.PROCADDRESS_VAR_PREFIX.length(); - String glFuncName = addressFieldName.substring(startOfMethodName); - try - { - java.lang.reflect.Field addressField = tableClass.getDeclaredField(addressFieldName); - assert(addressField.getType() == Long.TYPE); - // get the current value of the proc address variable in the table object - long oldProcAddress = addressField.getLong(table); - long newProcAddress = WGL.wglGetProcAddress(glFuncName); - /* - System.err.println( - "!!! Address=" + (newProcAddress == 0 - ? "<NULL> " - : ("0x" + - Long.toHexString(newProcAddress))) + - "\tGL func: " + glFuncName); - */ - // set the current value of the proc address variable in the table object - addressField.setLong(gl, newProcAddress); - } catch (Exception e) { - throw new GLException( - "Cannot get GL proc address for method \"" + - glFuncName + "\": Couldn't get value of field \"" + addressFieldName + - "\" in class " + tableClass.getName(), e); - } - } - + resetProcAddressTable(getGLProcAddressTable()); } - public net.java.games.jogl.impl.ProcAddressTable getGLProcAddressTable() { + public GLProcAddressTable getGLProcAddressTable() { if (glProcAddressTable == null) { // FIXME: cache ProcAddressTables by capability bits so we can // share them among contexts with the same capabilities - glProcAddressTable = - new net.java.games.jogl.impl.ProcAddressTable(); + glProcAddressTable = new GLProcAddressTable(); } return glProcAddressTable; } @@ -234,10 +201,6 @@ public abstract class WindowsGLContext extends GLContext { // Internals only below this point // - // Table that holds the addresses of the native C-language entry points for - // OpenGL functions. - private net.java.games.jogl.impl.ProcAddressTable glProcAddressTable; - protected JAWT getJAWT() { if (jawt == null) { JAWT j = new JAWT(); diff --git a/src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java index 300e9cb85..484c8f8af 100644 --- a/src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java +++ b/src/net/java/games/jogl/impl/windows/WindowsPbufferGLContext.java @@ -119,6 +119,10 @@ public class WindowsPbufferGLContext extends WindowsGLContext { public void createPbuffer(long parentHdc, long parentHglrc) { GL gl = getGL(); + // Must initally grab OpenGL function pointers while parent's + // context is current because otherwise we don't have the wgl + // extensions available to us + resetGLFunctionAvailability(); int[] iattributes = new int [2*MAX_ATTRIBS]; float[] fattributes = new float[2*MAX_ATTRIBS]; |