aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/javax/media
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
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')
-rw-r--r--src/classes/javax/media/opengl/GLArrayData.java23
-rw-r--r--src/classes/javax/media/opengl/GLArrayDataClient.java24
-rw-r--r--src/classes/javax/media/opengl/glsl/ShaderState.java65
3 files changed, 90 insertions, 22 deletions
diff --git a/src/classes/javax/media/opengl/GLArrayData.java b/src/classes/javax/media/opengl/GLArrayData.java
index 8fe5194d1..096506242 100644
--- a/src/classes/javax/media/opengl/GLArrayData.java
+++ b/src/classes/javax/media/opengl/GLArrayData.java
@@ -140,8 +140,31 @@ public interface GLArrayData {
*/
public void seal(GL gl, boolean seal);
+ /**
+ * Enables/disables the buffer, which implies
+ * the client state, binding the VBO
+ * and transfering the data if not done yet.
+ *
+ * The above will only be executed,
+ * if the buffer is disabled,
+ * or 'setEnableAlways' was called with 'true'.
+ *
+ * @see #setEnableAlways(boolean)
+ */
public void enableBuffer(GL gl, boolean enable);
+ /**
+ * Affects the behavior of 'enableBuffer'.
+ *
+ * The default is 'false'
+ *
+ * This is usefull when you mix up
+ * GLArrayData usage with conventional GL array calls.
+ *
+ * @see #enableBuffer(GL, boolean)
+ */
+ public void setEnableAlways(boolean always);
+
//
// Data modification ..
//
diff --git a/src/classes/javax/media/opengl/GLArrayDataClient.java b/src/classes/javax/media/opengl/GLArrayDataClient.java
index d1dec974c..a8da6c0a1 100644
--- a/src/classes/javax/media/opengl/GLArrayDataClient.java
+++ b/src/classes/javax/media/opengl/GLArrayDataClient.java
@@ -148,20 +148,26 @@ public class GLArrayDataClient implements GLArrayData {
}
}
- public void enableBuffer(GL gl, boolean enable)
- {
- if(enable) {
- checkSeal(true);
- if(null!=buffer) {
- buffer.rewind();
- }
+ public void enableBuffer(GL gl, boolean enable) {
+ if(enableBufferAlways && enable) {
+ bufferEnabled = false;
}
- if(bufferEnabled != enable && components>0) {
+ if( bufferEnabled != enable && components>0 ) {
+ if(enable) {
+ checkSeal(true);
+ if(null!=buffer) {
+ buffer.rewind();
+ }
+ }
enableBufferGLImpl(gl, enable);
bufferEnabled = enable;
}
}
+ public void setEnableAlways(boolean always) {
+ enableBufferAlways = always;
+ }
+
//
// Data modification ..
//
@@ -444,6 +450,7 @@ public class GLArrayDataClient implements GLArrayData {
this.sealed=false;
this.sealedGL=false;
this.bufferEnabled=false;
+ this.enableBufferAlways=false;
this.bufferWritten=false;
if(null==buffer) {
growBuffer(initialSize);
@@ -514,5 +521,6 @@ public class GLArrayDataClient implements GLArrayData {
protected boolean sealed, sealedGL;
protected boolean bufferEnabled;
protected boolean bufferWritten;
+ protected boolean enableBufferAlways;
}
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();