aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/sun
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/com/sun')
-rw-r--r--src/java/com/sun/gluegen/opengl/BuildComposablePipeline.java38
-rw-r--r--src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java40
-rwxr-xr-xsrc/java/com/sun/gluegen/opengl/GLConfiguration.java18
-rw-r--r--src/java/com/sun/gluegen/opengl/GLEmitter.java111
-rwxr-xr-xsrc/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java30
5 files changed, 189 insertions, 48 deletions
diff --git a/src/java/com/sun/gluegen/opengl/BuildComposablePipeline.java b/src/java/com/sun/gluegen/opengl/BuildComposablePipeline.java
index 89176f557..b52047bbf 100644
--- a/src/java/com/sun/gluegen/opengl/BuildComposablePipeline.java
+++ b/src/java/com/sun/gluegen/opengl/BuildComposablePipeline.java
@@ -330,15 +330,29 @@ public class BuildComposablePipeline
PrintWriter output = new PrintWriter(new BufferedWriter(new FileWriter(file)));
+ List baseInterfaces = Arrays.asList(baseInterfaceClass.getInterfaces());
HashSet clazzList = new HashSet();
clazzList.add(baseInterfaceClass);
- clazzList.addAll(Arrays.asList(baseInterfaceClass.getInterfaces()));
+ clazzList.addAll(baseInterfaces);
+ int ifNamesNumber = clazzList.size();
- String[] ifNames = new String[clazzList.size()];
+ // keep original order ..
+ clazzList.clear();
+ String[] ifNames = new String[ifNamesNumber];
{
int i=0;
- for (Iterator iter=clazzList.iterator(); iter.hasNext(); ) {
- ifNames[i++] = new String(((Class)iter.next()).getName());
+
+ for (Iterator iter=baseInterfaces.iterator(); iter.hasNext(); ) {
+ Class ifClass = (Class)iter.next();
+ if(!clazzList.contains(ifClass)) {
+ ifNames[i++] = new String(ifClass.getName());
+ clazzList.add(ifClass);
+ }
+ }
+
+ if(null!=baseInterfaceClass && !clazzList.contains(baseInterfaceClass)) {
+ ifNames[i++] = new String(baseInterfaceClass.getName());
+ clazzList.add(baseInterfaceClass);
}
}
@@ -619,6 +633,7 @@ public class BuildComposablePipeline
emitGLIsMethod(output, "GLES2");
emitGLIsMethod(output, "GL2ES1");
emitGLIsMethod(output, "GL2ES2");
+ emitGLIsMethod(output, "GL2GL3");
output.println(" public boolean isGLES() {");
output.println(" return isGLES2() || isGLES1();");
output.println(" }");
@@ -648,6 +663,7 @@ public class BuildComposablePipeline
emitGLGetMethod(output, "GLES2");
emitGLGetMethod(output, "GL2ES1");
emitGLGetMethod(output, "GL2ES2");
+ emitGLGetMethod(output, "GL2GL3");
output.println(" public GLProfile getGLProfile() {");
output.println(" return "+getDownstreamObjectName()+".getGLProfile();");
output.println(" }");
@@ -744,9 +760,9 @@ public class BuildComposablePipeline
output.println(" * ");
output.println("<PRE>");
if(null!=prologNameOpt) {
- output.println(" drawable.setGL( new "+className+"( drawable.getGL().getGL2ES2(), new "+prologNameOpt+"( drawable.getGL().getGL2ES2() ) ) );");
+ output.println(" GL gl = drawable.setGL( new "+className+"( drawable.getGL().getGL2ES2(), new "+prologNameOpt+"( drawable.getGL().getGL2ES2() ) ) );");
} else {
- output.println(" drawable.setGL( new "+className+"( drawable.getGL().getGL2ES2() ) );");
+ output.println(" GL gl = drawable.setGL( new "+className+"( drawable.getGL().getGL2ES2() ) );");
}
output.println("</PRE>");
output.println("*/");
@@ -896,7 +912,7 @@ public class BuildComposablePipeline
output.println(" Sample code which installs this pipeline: </P>");
output.println();
output.println("<PRE>");
- output.println(" drawable.setGL(new DebugGL(drawable.getGL()));");
+ output.println(" GL gl = drawable.setGL(new DebugGL(drawable.getGL()));");
output.println("</PRE>");
output.println("*/");
}
@@ -1034,7 +1050,7 @@ public class BuildComposablePipeline
output.println(" before and after each OpenGL method call. Sample code which installs this pipeline: </P>");
output.println();
output.println("<PRE>");
- output.println(" drawable.setGL(new TraceGL(drawable.getGL(), System.err));");
+ output.println(" GL gl = drawable.setGL(new TraceGL(drawable.getGL(), System.err));");
output.println("</PRE>");
output.println("*/");
}
@@ -1055,7 +1071,7 @@ public class BuildComposablePipeline
output.println("printIndent();");
}
- output.print(" println(");
+ output.print(" print(");
printFunctionCallString(output, m);
output.println(");");
}
@@ -1093,10 +1109,10 @@ public class BuildComposablePipeline
} else if(params[i].equals(int.class)) {
output.print("+\"<"+params[i].getName()+"> 0x\"+Integer.toHexString(arg"+i+").toUpperCase()");
} else {
- output.print("+\"<"+params[i].getName()+">\"+arg"+i);
+ output.print("+\"<"+params[i].getName()+"> \"+arg"+i);
}
if ( i < params.length-1) {
- output.print("+\",\"");
+ output.print("+\", \"");
}
}
output.print("+\")\"");
diff --git a/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java b/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java
index 4226f4612..a6c0cfc97 100644
--- a/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java
+++ b/src/java/com/sun/gluegen/opengl/BuildStaticGLInfo.java
@@ -91,17 +91,23 @@ import java.util.regex.*;
public class BuildStaticGLInfo
{
// Handles function pointer
+ protected static int funcIdentifierGroup = 10;
protected static Pattern funcPattern =
- Pattern.compile("^(GLAPI|GL_API|GL_APICALL|EGLAPI|extern)?(\\s*)(\\w+)(\\*)?(\\s+)(GLAPIENTRY|GL_APIENTRY|APIENTRY|EGLAPIENTRY|WINAPI)?(\\s*)([ew]?gl\\w+)\\s?(\\(.*)");
+ Pattern.compile("^(GLAPI|GL_API|GL_APICALL|EGLAPI|extern)?(\\s*)((unsigned|const)\\s+)?(\\w+)(\\s*\\*)?(\\s+)(GLAPIENTRY|GL_APIENTRY|APIENTRY|EGLAPIENTRY|WINAPI)?(\\s*)([ew]?gl\\w+)\\s?(\\(.*)");
+
protected static Pattern associationPattern =
- Pattern.compile("\\#ifndef ([EW]?GL[X]?_[A-Za-z0-9_]+)");
+ Pattern.compile("\\#ifndef ([CEW]?GL[XU]?_[A-Za-z0-9_]+)(.*)");
+
+ protected static int defineIdentifierGroup = 1;
protected static Pattern definePattern =
- Pattern.compile("\\#define ([EW]?GL[X]?_[A-Za-z0-9_]+)\\s*([A-Za-z0-9_]+)");
+ Pattern.compile("\\#define ([CEW]?GL[XU]?_[A-Za-z0-9_]+)\\s*([A-Za-z0-9_]+)(.*)");
+
// Maps function / #define names to the names of the extensions they're declared in
protected Map declarationToExtensionMap = new HashMap();
// Maps extension names to Set of identifiers (both #defines and
// function names) this extension declares
protected Map/*<String, Set<String>*/ extensionToDeclarationMap = new HashMap();
+ protected boolean debug = false;
/**
* The first argument is the package to which the StaticGLInfo class
@@ -113,6 +119,7 @@ public class BuildStaticGLInfo
{
if (args.length > 0 && args[0].equals("-test")) {
BuildStaticGLInfo builder = new BuildStaticGLInfo();
+ builder.setDebug(true);
String[] newArgs = new String[args.length - 1];
System.arraycopy(args, 1, newArgs, 0, args.length - 1);
builder.parse(newArgs);
@@ -157,6 +164,9 @@ public class BuildStaticGLInfo
}
}
+ public void setDebug(boolean v) {
+ debug = v;
+ }
/** Parses the supplied C header files and adds the function
associations contained therein to the internal map. */
@@ -173,14 +183,20 @@ public class BuildStaticGLInfo
String line, activeAssociation = null;
Matcher m = null;
while ((line = reader.readLine()) != null) {
+ int type = 0; // 1-define, 2-function
// see if we're inside a #ifndef GL_XXX block and matching a function
if (activeAssociation != null) {
String identifier = null;
if ((m = funcPattern.matcher(line)).matches()) {
- identifier = m.group(8);
+ identifier = m.group(funcIdentifierGroup).trim();
+ type =2;
} else if ((m = definePattern.matcher(line)).matches()) {
- identifier = m.group(1);
+ identifier = m.group(defineIdentifierGroup).trim();
+ type =1;
} else if (line.startsWith("#endif")) {
+ if(debug) {
+ System.err.println("END ASSOCIATION BLOCK: <" + activeAssociation + ">");
+ }
activeAssociation = null;
}
if ((identifier != null) &&
@@ -188,13 +204,17 @@ public class BuildStaticGLInfo
// Handles #ifndef GL_... #define GL_...
!identifier.equals(activeAssociation)) {
addAssociation(identifier, activeAssociation);
- // System.err.println(" ADDING ASSOCIATION: " + identifier + " " + activeAssociation);
+ if(debug) {
+ System.err.println(" ADDING ASSOCIATION: <" + identifier + "> <" + activeAssociation + "> ; type "+type);
+ }
}
} else if ((m = associationPattern.matcher(line)).matches()) {
// found a new #ifndef GL_XXX block
- activeAssociation = m.group(1);
+ activeAssociation = m.group(1).trim();
- // System.err.println("FOUND NEW ASSOCIATION BLOCK: " + activeAssociation);
+ if(debug) {
+ System.err.println("BEGIN ASSOCIATION BLOCK: <" + activeAssociation + ">");
+ }
}
}
reader.close();
@@ -204,12 +224,12 @@ public class BuildStaticGLInfo
for (Iterator i1 = extensionToDeclarationMap.keySet().iterator(); i1.hasNext(); ) {
String name = (String) i1.next();
Set decls = (Set) extensionToDeclarationMap.get(name);
- System.out.println(name + ":");
+ System.out.println("<"+name+"> :");
List l = new ArrayList();
l.addAll(decls);
Collections.sort(l);
for (Iterator i2 = l.iterator(); i2.hasNext(); ) {
- System.out.println(" " + (String) i2.next());
+ System.out.println(" <" + (String) i2.next() + ">");
}
}
}
diff --git a/src/java/com/sun/gluegen/opengl/GLConfiguration.java b/src/java/com/sun/gluegen/opengl/GLConfiguration.java
index 3013848dc..9352bcba2 100755
--- a/src/java/com/sun/gluegen/opengl/GLConfiguration.java
+++ b/src/java/com/sun/gluegen/opengl/GLConfiguration.java
@@ -59,7 +59,8 @@ public class GLConfiguration extends ProcAddressConfiguration {
// This directive is off by default but can help automatically
// indicate which extensions have been folded into the core OpenGL
// namespace, and if not, then why not
- private boolean autoUnifyExtensions;
+ private boolean autoUnifyExtensions=false;
+ private boolean allowNonGLExtensions=false;
public GLConfiguration(GLEmitter emitter) {
super();
@@ -82,6 +83,10 @@ public class GLConfiguration extends ProcAddressConfiguration {
String sym = readString("RenameExtensionIntoCore", tok, filename, lineNo);
extensionsRenamedIntoCore.add(sym);
}
+ else if (cmd.equalsIgnoreCase("AllowNonGLExtensions"))
+ {
+ allowNonGLExtensions = readBoolean("AllowNonGLExtensions", tok, filename, lineNo).booleanValue();
+ }
else if (cmd.equalsIgnoreCase("AutoUnifyExtensions"))
{
autoUnifyExtensions = readBoolean("AutoUnifyExtensions", tok, filename, lineNo).booleanValue();
@@ -209,14 +214,14 @@ public class GLConfiguration extends ProcAddressConfiguration {
ignoredExtensions.contains(extension)) {
return true;
}
- boolean isGLFunc = GLExtensionNames.isGLFunction(symbol);
boolean isGLEnum = GLExtensionNames.isGLEnumeration(symbol);
+ boolean isGLFunc = GLExtensionNames.isGLFunction(symbol);
if(isGLFunc || isGLEnum) {
if(GLExtensionNames.isExtensionVEN(symbol, isGLFunc)) {
String extSuffix = GLExtensionNames.getExtensionSuffix(symbol, isGLFunc);
if( getDropUniqVendorExtensions(extSuffix) ) {
if(DEBUG_IGNORES) {
- System.err.println("Ignore UniqVendorEXT: "+symbol);
+ System.err.println("Ignore UniqVendorEXT: "+symbol+", vendor "+extSuffix);
}
return true;
}
@@ -249,6 +254,13 @@ public class GLConfiguration extends ProcAddressConfiguration {
return autoUnifyExtensions;
}
+ /** If true, accept all non encapsulated defines and functions,
+ * as it is mandatory for GL declarations. */
+ public boolean getAllowNonGLExtensions() {
+ return allowNonGLExtensions;
+ }
+
+
/** shall the non unified (uniq) vendor extensions be dropped ? */
public boolean getDropUniqVendorExtensions(String extName) {
return dropUniqVendorExtensions.contains(extName);
diff --git a/src/java/com/sun/gluegen/opengl/GLEmitter.java b/src/java/com/sun/gluegen/opengl/GLEmitter.java
index fff9d7e94..4ca2e698b 100644
--- a/src/java/com/sun/gluegen/opengl/GLEmitter.java
+++ b/src/java/com/sun/gluegen/opengl/GLEmitter.java
@@ -85,9 +85,15 @@ public class GLEmitter extends ProcAddressEmitter
// renaming mechanisms that are built elsewhere.
GLConfiguration config = getGLConfig();
+ Set extensionsRenamedIntoCore = config.getExtensionsRenamedIntoCore();
BuildStaticGLInfo glInfo = config.getGLInfo();
- for (Iterator iter = config.getExtensionsRenamedIntoCore().iterator();
- iter.hasNext(); ) {
+ if(null==glInfo) {
+ if(extensionsRenamedIntoCore.size()>0) {
+ throw new RuntimeException("ExtensionRenamedIntoCore (num: "+extensionsRenamedIntoCore.size()+"), but no GLHeader");
+ }
+ return;
+ }
+ for (Iterator iter = extensionsRenamedIntoCore.iterator(); iter.hasNext(); ) {
String extension = (String) iter.next();
Set/*<String>*/ declarations = glInfo.getDeclarations(extension);
if (declarations != null) {
@@ -305,6 +311,83 @@ public class GLEmitter extends ProcAddressEmitter
return bufferObjectMethodBindings.containsKey(binding);
}
+ public void emitDefine(ConstantDefinition def, String optionalComment) throws Exception {
+ BuildStaticGLInfo glInfo = getGLConfig().getGLInfo();
+ if(null==glInfo) {
+ throw new Exception("No GLInfo for: "+def);
+ }
+ String symbolRenamed = def.getName();
+ StringBuffer newComment = new StringBuffer();
+ newComment.append("Part of <code>");
+ if(0==addExtensionsOfSymbols2Buffer(newComment, ", ", symbolRenamed, def.getAliasedNames())) {
+ if(def.isEnum()) {
+ String enumName = def.getEnumName();
+ if(null!=enumName) {
+ newComment.append(enumName);
+ } else {
+ newComment.append("CORE ENUM");
+ }
+ } else {
+ if(getGLConfig().getAllowNonGLExtensions()) {
+ newComment.append("CORE DEF");
+ } else {
+ // Note: All GL defines must be contained within an extension marker !
+ // #ifndef GL_EXT_lala
+ // #define GL_EXT_lala 1
+ // ...
+ // #endif
+ if(JavaConfiguration.DEBUG_IGNORES) {
+ StringBuffer sb = new StringBuffer();
+ JavaEmitter.addStrings2Buffer(sb, ", ", symbolRenamed, def.getAliasedNames());
+ System.err.println("Dropping marker: "+sb.toString());
+ }
+ return;
+ }
+ }
+ }
+ newComment.append("</code>");
+
+ if(null!=optionalComment) {
+ newComment.append("<br>");
+ newComment.append(optionalComment);
+ }
+
+ super.emitDefine(def, newComment.toString());
+ }
+
+ public int addExtensionsOfSymbols2Buffer(StringBuffer buf, String sep, String first, Collection col) {
+ BuildStaticGLInfo glInfo = getGLConfig().getGLInfo();
+ if(null==glInfo) {
+ throw new RuntimeException("No GLInfo for: "+first);
+ }
+ int num = 0;
+ if(null==buf) buf=new StringBuffer();
+ String extensionName;
+
+ Iterator iter=col.iterator();
+ if(null!=first) {
+ extensionName = glInfo.getExtension(first);
+ if(null!=extensionName) {
+ buf.append(extensionName);
+ if( iter.hasNext() ) {
+ buf.append(sep);
+ }
+ num++;
+ }
+ }
+ while( iter.hasNext() ) {
+ extensionName = glInfo.getExtension((String)iter.next());
+ if(null!=extensionName) {
+ buf.append(extensionName);
+ if( iter.hasNext() ) {
+ buf.append(sep);
+ }
+ num++;
+ }
+ }
+ return num;
+ }
+
//----------------------------------------------------------------------
// Internals only below this point
//
@@ -319,10 +402,9 @@ public class GLEmitter extends ProcAddressEmitter
for (Iterator iter = superEmitters.iterator(); iter.hasNext(); ) {
JavaMethodBindingEmitter emitter = (JavaMethodBindingEmitter) iter.next();
if (emitter instanceof ProcAddressJavaMethodBindingEmitter) {
- emitters.add(new GLJavaMethodBindingEmitter((ProcAddressJavaMethodBindingEmitter) emitter, this, bufferObjectVariant));
- } else {
- emitters.add(emitter);
+ emitter = new GLJavaMethodBindingEmitter((ProcAddressJavaMethodBindingEmitter) emitter, this, bufferObjectVariant);
}
+ emitters.add(emitter);
}
}
@@ -385,23 +467,4 @@ public class GLEmitter extends ProcAddressEmitter
w.flush();
w.close();
}
-
- protected void emitProcAddressTableEntryForSymbol(FunctionSymbol cFunc)
- {
- emitProcAddressTableEntryForString(cFunc.getName());
- }
-
- protected void emitProcAddressTableEntryForString(String str)
- {
- // Deal gracefully with forced proc address generation in the face
- // of having the function pointer typedef in the header file too
- if (emittedTableEntries.contains(str))
- return;
- emittedTableEntries.add(str);
- tableWriter.print(" public long ");
- tableWriter.print(PROCADDRESS_VAR_PREFIX);
- tableWriter.print(str);
- tableWriter.println(";");
- }
-
}
diff --git a/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java b/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java
index c6a030935..662e75b51 100755
--- a/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java
+++ b/src/java/com/sun/gluegen/opengl/GLJavaMethodBindingEmitter.java
@@ -52,6 +52,7 @@ import com.sun.gluegen.procaddress.*;
public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmitter {
protected boolean bufferObjectVariant;
protected GLEmitter glEmitter;
+ protected CommentEmitter glCommentEmitter = new GLCommentEmitter();
public GLJavaMethodBindingEmitter(JavaMethodBindingEmitter methodToWrap,
boolean callThroughProcAddress,
@@ -66,6 +67,7 @@ public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmit
emitter);
this.bufferObjectVariant = bufferObjectVariant;
this.glEmitter=emitter;
+ setCommentEmitter(glCommentEmitter);
}
public GLJavaMethodBindingEmitter(ProcAddressJavaMethodBindingEmitter methodToWrap,
@@ -74,6 +76,7 @@ public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmit
super(methodToWrap);
this.bufferObjectVariant = bufferObjectVariant;
this.glEmitter=emitter;
+ setCommentEmitter(glCommentEmitter);
}
public GLJavaMethodBindingEmitter(GLJavaMethodBindingEmitter methodToWrap) {
@@ -100,4 +103,31 @@ public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmit
return name;
}
+
+ protected class GLCommentEmitter
+ extends JavaMethodBindingEmitter.DefaultCommentEmitter
+ {
+ protected void emitBindingCSignature(MethodBinding binding, PrintWriter writer) {
+ super.emitBindingCSignature(binding, writer);
+
+ String symbolRenamed = binding.getName();
+ StringBuffer newComment = new StringBuffer();
+ newComment.append("<br>Part of <code>");
+ if(0==glEmitter.addExtensionsOfSymbols2Buffer(newComment, ", ", symbolRenamed, binding.getAliasedNames())) {
+ if(glEmitter.getGLConfig().getAllowNonGLExtensions()) {
+ newComment.append("CORE FUNC");
+ } else {
+ StringBuffer sb = new StringBuffer();
+ JavaEmitter.addStrings2Buffer(sb, ", ", symbolRenamed, binding.getAliasedNames());
+ RuntimeException ex = new RuntimeException("Couldn't find extension to: "+binding+" ; "+sb.toString());
+ ex.printStackTrace();
+ glEmitter.getGLConfig().getGLInfo().dump();
+ // glEmitter.getGLConfig().dumpRenames();
+ throw ex;
+ }
+ }
+ newComment.append("</code>");
+ writer.print(newComment.toString());
+ }
+ }
}