summaryrefslogtreecommitdiffstats
path: root/src/java/com/sun/gluegen/opengl/GLEmitter.java
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2009-08-08 21:46:55 +0200
committerMichael Bien <[email protected]>2009-08-08 21:46:55 +0200
commitb6299864e65049d86eeeab04b62aa12d0ff82f83 (patch)
treed9681a6a7b48dc8cdfb8c648abd2e3c4c6cd8506 /src/java/com/sun/gluegen/opengl/GLEmitter.java
parent1d9fe1259f17c3beba2db8f9a7658b1c6ca3494f (diff)
parentbe85daf04cab1484cca214648a8c12aca0bd1fb2 (diff)
Merge branch 'master' of ssh://[email protected]/gluegen~gluegen-git
Diffstat (limited to 'src/java/com/sun/gluegen/opengl/GLEmitter.java')
-rw-r--r--src/java/com/sun/gluegen/opengl/GLEmitter.java111
1 files changed, 87 insertions, 24 deletions
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(";");
- }
-
}