summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl/util
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-04-28 08:12:26 +0200
committerSven Gothel <[email protected]>2011-04-28 08:12:26 +0200
commita66acbec16c339db66d5f9242f44b3b539808b99 (patch)
treebdbc522c74619bcb8accd0b8a70751350904ebd0 /src/jogl/classes/com/jogamp/opengl/util
parentb7f5600f842e4e438eba51711b4aa9b23d5789bc (diff)
ShaderState Switch Program: Only disable current program if no new one; Better toString formating
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/util')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java2
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java25
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java38
3 files changed, 36 insertions, 29 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java
index 20b032a41..c6a52a33e 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java
@@ -245,7 +245,7 @@ public class ShaderCode {
return id;
}
public String toString() {
- StringBuffer buf = new StringBuffer("ShaderCode [id="+id+", type="+shaderTypeStr()+", valid="+valid+", shader: ");
+ StringBuffer buf = new StringBuffer("ShaderCode[id="+id+", type="+shaderTypeStr()+", valid="+valid+", shader: ");
for(int i=0; i<shader.remaining(); i++) {
buf.append(" "+shader.get(i));
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java
index b622571e7..e04a8c534 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java
@@ -30,6 +30,8 @@ package com.jogamp.opengl.util.glsl;
import javax.media.opengl.*;
+import com.jogamp.common.os.Platform;
+
import java.util.HashSet;
import java.util.Iterator;
import java.io.PrintStream;
@@ -262,18 +264,23 @@ public class ShaderProgram {
return id;
}
- public String toString() {
- StringBuffer buf = new StringBuffer();
- buf.append("ShaderProgram[id="+id);
- buf.append(", linked="+programLinked+", inUse="+programInUse+", program: "+shaderProgram+", [");
+ public StringBuilder toString(StringBuilder sb) {
+ if(null == sb) {
+ sb = new StringBuilder();
+ }
+ sb.append("ShaderProgram[id=").append(id);
+ sb.append(", linked="+programLinked+", inUse="+programInUse+", program: "+shaderProgram+",");
for(Iterator<ShaderCode> iter=allShaderCode.iterator(); iter.hasNext(); ) {
- buf.append(iter.next());
- buf.append(" ");
+ sb.append(Platform.getNewline()).append(" ").append(iter.next());
}
- buf.append("]");
- return buf.toString();
+ sb.append("]");
+ return sb;
}
-
+
+ public String toString() {
+ return toString(null).toString();
+ }
+
protected synchronized void useProgram(GL2ES2 gl, boolean on) {
if(!programLinked) throw new GLException("Program is not linked");
if(programInUse==on) return;
diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java
index f8fe987d7..a5290b958 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java
@@ -43,6 +43,7 @@ import javax.media.opengl.GLUniformData;
import jogamp.opengl.Debug;
+import com.jogamp.common.os.Platform;
import com.jogamp.common.util.IntObjectHashMap;
import com.jogamp.opengl.util.GLArrayDataEditable;
@@ -202,7 +203,11 @@ public class ShaderState {
return;
}
prgInUse = shaderProgram.inUse();
- useProgram(gl, false);
+
+ if(prgInUse && null == prog) {
+ // only disable if in use _and_ no new prog shall be used
+ useProgram(gl, false);
+ }
resetAllShaderData = true;
}
@@ -936,34 +941,29 @@ public class ShaderState {
sb = new StringBuilder();
}
- sb.append("ShaderState[");
- sb.append(shaderProgram.toString());
- sb.append(", enabledAttributes: [");
+ sb.append("ShaderState[ ");
+ sb.append(Platform.getNewline()).append(" ").append(shaderProgram.toString());
+ sb.append(Platform.getNewline()).append(" enabledAttributes [");
for(Iterator<String> iter = enabledAttributes.iterator(); iter.hasNext(); ) {
- sb.append("\n ");
- sb.append((String)iter.next());
+ sb.append(Platform.getNewline()).append(" ").append(iter.next());
}
- sb.append("], activeAttributes [");
+ sb.append(Platform.getNewline()).append(" ],").append(" activeAttributes [");
for(Iterator<GLArrayData> iter = activeAttribDataMap.values().iterator(); iter.hasNext(); ) {
- sb.append("\n ");
- sb.append(iter.next());
+ sb.append(Platform.getNewline()).append(" ").append(iter.next());
}
- sb.append("], managedAttributes [");
+ sb.append(Platform.getNewline()).append(" ],").append(" managedAttributes [");
for(Iterator<GLArrayData> iter = managedAttributes.iterator(); iter.hasNext(); ) {
- sb.append("\n ");
- sb.append(iter.next());
+ sb.append(Platform.getNewline()).append(" ").append(iter.next());
}
- sb.append("], activeUniforms [");
+ sb.append(Platform.getNewline()).append(" ],").append(" activeUniforms [");
for(Iterator<GLUniformData> iter=activeUniformDataMap.values().iterator(); iter.hasNext(); ) {
- sb.append("\n ");
- sb.append(iter.next());
+ sb.append(Platform.getNewline()).append(" ").append(iter.next());
}
- sb.append("], managedUniforms [");
+ sb.append(Platform.getNewline()).append(" ],").append(" managedUniforms [");
for(Iterator<GLUniformData> iter = managedUniforms.iterator(); iter.hasNext(); ) {
- sb.append("\n ");
- sb.append(iter.next());
+ sb.append(Platform.getNewline()).append(" ").append(iter.next());
}
- sb.append("]");
+ sb.append(Platform.getNewline()).append(" ]").append(Platform.getNewline()).append("]");
return sb;
}