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/gluegen/opengl/GLEmitter.java | |
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/gluegen/opengl/GLEmitter.java')
-rw-r--r-- | src/net/java/games/gluegen/opengl/GLEmitter.java | 95 |
1 files changed, 70 insertions, 25 deletions
diff --git a/src/net/java/games/gluegen/opengl/GLEmitter.java b/src/net/java/games/gluegen/opengl/GLEmitter.java index 27cc07e2c..f6e26fd3b 100644 --- a/src/net/java/games/gluegen/opengl/GLEmitter.java +++ b/src/net/java/games/gluegen/opengl/GLEmitter.java @@ -44,6 +44,7 @@ import java.text.MessageFormat; import java.util.*; import net.java.games.gluegen.*; import net.java.games.gluegen.cgram.types.*; +import net.java.games.gluegen.runtime.*; /** * A subclass of JavaEmitter that modifies the normal emission of C and Java @@ -52,11 +53,12 @@ import net.java.games.gluegen.cgram.types.*; */ public class GLEmitter extends JavaEmitter { - public static final String PROCADDRESS_VAR_PREFIX = "_addressof_"; + public static final String PROCADDRESS_VAR_PREFIX = ProcAddressHelper.PROCADDRESS_VAR_PREFIX; protected static final String WRAP_PREFIX = "dispatch_"; private TypeDictionary typedefDictionary; private PrintWriter tableWriter; - private String tableClassName = "ProcAddressTable"; + private String tableClassPackage; + private String tableClassName; private int numProcAddressEntries; public void beginFunctions(TypeDictionary typedefDictionary, @@ -70,7 +72,7 @@ public class GLEmitter extends JavaEmitter cWriter().println(); } - if (((GLConfiguration)getConfig()).emitProcAddressTable()) + if (getGLConfig().emitProcAddressTable()) { beginGLProcAddressTable(); } @@ -79,7 +81,7 @@ public class GLEmitter extends JavaEmitter public void endFunctions() throws Exception { - if (((GLConfiguration)getConfig()).emitProcAddressTable()) + if (getGLConfig().emitProcAddressTable()) { endGLProcAddressTable(); } @@ -118,7 +120,7 @@ public class GLEmitter extends JavaEmitter // 9 is default # expanded bindings for void* ArrayList modifiedEmitters = new ArrayList(9); - if (((GLConfiguration)getConfig()).emitProcAddressTable()) + if (getGLConfig().emitProcAddressTable()) { // emit an entry in the GL proc address table for this method. emitGLProcAddressTableEntryForSymbol(sym); @@ -185,7 +187,7 @@ public class GLEmitter extends JavaEmitter return null; return baseJavaEmitter; } - return new JavaGLPAWrapperEmitter(baseJavaEmitter); + return new JavaGLPAWrapperEmitter(baseJavaEmitter, getGLConfig().getProcAddressTableExpr()); } private CMethodBindingEmitter generateModifiedEmitter(CMethodBindingEmitter baseCEmitter) @@ -205,11 +207,17 @@ public class GLEmitter extends JavaEmitter { String symName = sym.getName(); + GLConfiguration config = getGLConfig(); + // We should only wrap the GL symbol if its function pointer typedef has // been defined (most likely in glext.h). String funcPointerTypedefName = getGLFunctionPointerTypedefName(sym); boolean shouldWrap = typedefDictionary.containsKey(funcPointerTypedefName); //System.err.println(funcPointerTypedefName + " defined: " + shouldWrap); + + if (config.skipProcAddressGen(symName)) { + shouldWrap = false; + } if (!shouldWrap) { @@ -221,26 +229,27 @@ public class GLEmitter extends JavaEmitter private void beginGLProcAddressTable() throws Exception { - String implPackageName = getImplPackageName(); + tableClassPackage = getGLConfig().tableClassPackage(); + tableClassName = getGLConfig().tableClassName(); + + // Table defaults to going into the impl directory unless otherwise overridden + String implPackageName = tableClassPackage; + if (implPackageName == null) { + implPackageName = getImplPackageName(); + } String jImplRoot = getJavaOutputDir() + File.separator + CodeGenUtils.packageAsPath(implPackageName); - // HACK: until we have a way to make the impl dir different from the - // WindowsGLImpl dir and the interface dir - //tableWriter = openFile(jImplRoot + File.separator + tableClassName + ".java"); - File tmpFile = new File(jImplRoot); - tmpFile = tmpFile.getParentFile(); - tmpFile = new File(tmpFile, tableClassName + ".java"); - tableWriter = openFile(tmpFile.getPath()); - // tableWriter = openFile(jImplRoot + File.separator + ".." + File.separator + tableClassName + ".java"); + tableWriter = openFile(jImplRoot + File.separator + tableClassName + ".java"); CodeGenUtils.emitAutogeneratedWarning(tableWriter, this); - // HACK: until we have a way to make the impl dir different from the - // WindowsGLImpl dir and the interface dir - //tableWriter.println("package " + implPackageName + ";"); - tableWriter.println("package " + getJavaPackageName() + ".impl;"); + tableWriter.println("package " + implPackageName + ";"); + tableWriter.println(); + for (Iterator iter = getConfig().imports().iterator(); iter.hasNext(); ) { + tableWriter.println("import " + ((String) iter.next()) + ";"); + } tableWriter.println(); tableWriter.println("/**"); tableWriter.println(" * This table is a cache of the native pointers to OpenGL extension"); @@ -260,9 +269,6 @@ public class GLEmitter extends JavaEmitter private void endGLProcAddressTable() throws Exception { PrintWriter w = tableWriter; - w.print(" protected static long __PROCADDRESSINDEX__LASTINDEX = "); - w.print(numProcAddressEntries-1); - w.println(';'); w.println(); w.println(" /**"); @@ -301,30 +307,69 @@ public class GLEmitter extends JavaEmitter private void emitGLProcAddressTableEntryForSymbol(FunctionSymbol cFunc) { - tableWriter.print(" public static long "); + tableWriter.print(" public long "); tableWriter.print(PROCADDRESS_VAR_PREFIX); tableWriter.print(cFunc.getName()); tableWriter.println(";"); ++numProcAddressEntries; } + private GLConfiguration getGLConfig() { + return (GLConfiguration) getConfig(); + } + protected static class GLConfiguration extends JavaConfiguration { private boolean emitProcAddressTable = false; - + private String tableClassPackage; + private String tableClassName = "ProcAddressTable"; + private Set/*<String>*/ skipProcAddressGen = new HashSet(); + private String getProcAddressTableExpr = "context.getGLProcAddressTable()"; + protected void dispatch(String cmd, StringTokenizer tok, File file, String filename, int lineNo) throws IOException { if (cmd.equalsIgnoreCase("EmitProcAddressTable")) { emitProcAddressTable = readBoolean("EmitProcAddressTable", tok, filename, lineNo).booleanValue(); } + else if (cmd.equalsIgnoreCase("ProcAddressTablePackage")) + { + tableClassPackage = readString("ProcAddressTablePackage", tok, filename, lineNo); + } + else if (cmd.equalsIgnoreCase("ProcAddressTableClassName")) + { + tableClassName = readString("ProcAddressTableClassName", tok, filename, lineNo); + } + else if (cmd.equalsIgnoreCase("SkipProcAddressGen")) + { + String sym = readString("SkipProcAddressGen", tok, filename, lineNo); + skipProcAddressGen.add(sym); + } + else if (cmd.equalsIgnoreCase("GetProcAddressTableExpr")) + { + getProcAddressTableExpr = readGetProcAddressTableExpr(tok, filename, lineNo); + } else { super.dispatch(cmd,tok,file,filename,lineNo); } } - public boolean emitProcAddressTable() { return emitProcAddressTable; } + protected String readGetProcAddressTableExpr(StringTokenizer tok, String filename, int lineNo) { + try { + String restOfLine = tok.nextToken("\n\r\f"); + return restOfLine.trim(); + } catch (NoSuchElementException e) { + throw new RuntimeException("Error parsing \"GetProcAddressTableExpr\" command at line " + lineNo + + " in file \"" + filename + "\"", e); + } + } + + public boolean emitProcAddressTable() { return emitProcAddressTable; } + public String tableClassPackage() { return tableClassPackage; } + public String tableClassName() { return tableClassName; } + public boolean skipProcAddressGen (String name) { return skipProcAddressGen.contains(name); } + public String getProcAddressTableExpr() { return getProcAddressTableExpr; } } // end class GLConfiguration } |