aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/javax/media/opengl/glsl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2008-08-14 18:56:12 +0000
committerSven Gothel <[email protected]>2008-08-14 18:56:12 +0000
commit4e239b137b4f9c09470671b1273dd8093b22eb72 (patch)
tree19b2bcabfd9ca30c7381a77302f976430c76d839 /src/classes/javax/media/opengl/glsl
parent8beeca6fcb1b5fe98e7c04a208fc208014f35c1f (diff)
ShaderState:
- reset: - lookup attributes first and process, if available - update the location in the state Fixed: - Add: CullFace (lill speed enhancement with textures) - Note: APX 2500 doesn't support blending, disregarding the ES 2.0 spec Blending must be implemented in the shader. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1756 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/javax/media/opengl/glsl')
-rw-r--r--src/classes/javax/media/opengl/glsl/ShaderState.java65
1 files changed, 51 insertions, 14 deletions
diff --git a/src/classes/javax/media/opengl/glsl/ShaderState.java b/src/classes/javax/media/opengl/glsl/ShaderState.java
index 3d4983152..c6c1f2152 100644
--- a/src/classes/javax/media/opengl/glsl/ShaderState.java
+++ b/src/classes/javax/media/opengl/glsl/ShaderState.java
@@ -66,6 +66,13 @@ public class ShaderState {
public synchronized void attachShaderProgram(GL2ES2 gl, ShaderProgram prog) {
boolean prgInUse = false; // earmarked state
+ if(DEBUG) {
+ int curId = (null!=shaderProgram)?shaderProgram.id():-1;
+ int newId = (null!=prog)?prog.id():-1;
+ System.err.println("Info: attachShaderProgram: "+curId+" -> "+newId+"\n\t"+shaderProgram+"\n\t"+prog);
+ Throwable tX = new Throwable("Info: attachShaderProgram: Trace");
+ tX.printStackTrace();
+ }
if(null!=shaderProgram) {
if(shaderProgram.equals(prog)) {
// nothing to do ..
@@ -75,10 +82,7 @@ public class ShaderState {
return;
}
prgInUse = shaderProgram.inUse();
- }
- if(DEBUG) {
- Throwable tX = new Throwable("Info: attachShaderProgram: BEGIN "+shaderProgram+" -> "+prog);
- tX.printStackTrace();
+ shaderProgram.glUseProgram(gl, false);
}
// register new one
@@ -178,6 +182,9 @@ public class ShaderState {
if(0<=index) {
Integer idx = new Integer(index);
attribMap2Idx.put(name, idx);
+ if(DEBUG) {
+ System.err.println("Info: glGetAttribLocation: "+name+", loc: "+index);
+ }
} else if(verbose) {
Throwable tX = new Throwable("Info: glGetAttribLocation failed, no location for: "+name+", index: "+index);
tX.printStackTrace();
@@ -226,7 +233,7 @@ public class ShaderState {
return false;
}
if(DEBUG) {
- System.err.println("Info: glEnableVertexAttribArray: "+name);
+ System.err.println("Info: glEnableVertexAttribArray: "+name+", loc: "+index);
}
gl.glEnableVertexAttribArray(index);
return true;
@@ -429,17 +436,41 @@ public class ShaderState {
if(!shaderProgram.inUse()) throw new GLException("Program is not in use");
attribMap2Idx.clear();
+ /**
+ *
+ for(Iterator iter = enabledVertexAttribArraySet.iterator(); iter.hasNext(); ) {
+ glEnableVertexAttribArray(gl, (String) iter.next());
+ }
+ for(Iterator iter = vertexAttribMap2Data.values().iterator(); iter.hasNext(); ) {
+ GLArrayData data = (GLArrayData) iter.next();
+
+ ...
+ } */
+
for(Iterator iter = enabledVertexAttribArraySet.iterator(); iter.hasNext(); ) {
+ // get new location ..
String name = (String) iter.next();
- glEnableVertexAttribArray(gl, name);
+ int loc = glGetAttribLocation(gl, name);
+
+ // get & update data ..
GLArrayData data = getVertexAttribPointer(name);
+ data.setLocation(loc);
+ vertexAttribMap2Data.put(name, data);
+
+ if(0>loc) {
+ // not used in shader
+ System.err.println("*** skip: "+name);
+ continue;
+ }
+
+ // enable attrib, VBO and pass location/data
+ gl.glEnableVertexAttribArray(loc);
- if( data.isVBO() && data.getBuffer()==null ) {
- // make sure the VBO is bound again
- // in case this is only a VBO wrapped object (no buffer)
+ if( data.isVBO() ) {
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, data.getVBOName());
}
- glVertexAttribPointer(gl, data);
+
+ gl.glVertexAttribPointer(data);
}
}
@@ -561,13 +592,19 @@ public class ShaderState {
}
buf.append("], [");
for(Iterator iter = vertexAttribMap2Data.values().iterator(); iter.hasNext(); ) {
- buf.append("\n ");
- buf.append((GLArrayData) iter.next());
+ GLArrayData data = (GLArrayData) iter.next();
+ if(data.getLocation()>=0) {
+ buf.append("\n ");
+ buf.append(data);
+ }
}
buf.append("], [");
for(Iterator iter=uniformMap2Data.values().iterator(); iter.hasNext(); ) {
- buf.append("\n ");
- buf.append((GLUniformData) iter.next());
+ GLUniformData data = (GLUniformData) iter.next();
+ if(data.getLocation()>=0) {
+ buf.append("\n ");
+ buf.append(data);
+ }
}
buf.append("]");
return buf.toString();