aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmake/config/jogl/gl-if-gl2_es2.cfg19
-rw-r--r--make/config/jogl/gl-impl-CustomJavaCode-gl2_es2.java260
-rwxr-xr-xmake/config/jogl/gl-impl-CustomJavaCode-gles1.java4
-rw-r--r--src/jogl/classes/com/sun/opengl/util/glsl/ShaderCode.java20
-rw-r--r--src/jogl/classes/com/sun/opengl/util/glsl/ShaderProgram.java12
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java21
6 files changed, 34 insertions, 302 deletions
diff --git a/make/config/jogl/gl-if-gl2_es2.cfg b/make/config/jogl/gl-if-gl2_es2.cfg
index 832c32ee5..5345c3ba1 100755
--- a/make/config/jogl/gl-if-gl2_es2.cfg
+++ b/make/config/jogl/gl-if-gl2_es2.cfg
@@ -39,25 +39,6 @@ GLHeader GL/glext.h
# Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums
TagNativeBinding true
-CustomJavaCode GL2ES2 public String glGetShaderInfoLog(int shaderObj);
-CustomJavaCode GL2ES2 public String glGetProgramInfoLog(int programObj);
-CustomJavaCode GL2ES2 public boolean glIsShaderStatusValid(int shaderObj, int name);
-CustomJavaCode GL2ES2 public boolean glIsShaderStatusValid(int shaderObj, int name, PrintStream verboseOut);
-CustomJavaCode GL2ES2 public boolean glIsShaderStatusValid(IntBuffer shaders, int name);
-CustomJavaCode GL2ES2 public boolean glIsShaderStatusValid(IntBuffer shaders, int name, PrintStream verboseOut);
-CustomJavaCode GL2ES2 public boolean glIsProgramStatusValid(int programObj, int name);
-CustomJavaCode GL2ES2 public boolean glIsProgramValid(int programObj);
-CustomJavaCode GL2ES2 public boolean glIsProgramValid(int programObj, PrintStream verboseOut);
-CustomJavaCode GL2ES2 public boolean glShaderCompilerAvailable();
-CustomJavaCode GL2ES2 public void glShaderSource(int shader, java.lang.String[] source);
-CustomJavaCode GL2ES2 public void glShaderSource(IntBuffer shaders, java.lang.String[][] sources);
-CustomJavaCode GL2ES2 public Set glGetShaderBinaryFormats();
-CustomJavaCode GL2ES2 public void glShaderBinary(IntBuffer shaders, int binFormat, java.nio.Buffer bin);
-CustomJavaCode GL2ES2 public void glCreateShader(int type, IntBuffer shaders);
-CustomJavaCode GL2ES2 public void glCompileShader(IntBuffer shaders);
-CustomJavaCode GL2ES2 public void glAttachShader(int program, IntBuffer shaders);
-CustomJavaCode GL2ES2 public void glDetachShader(int program, IntBuffer shaders);
-CustomJavaCode GL2ES2 public void glDeleteShader(IntBuffer shaders);
CustomJavaCode GL2ES2 public void glVertexAttribPointer(GLArrayData array);
CustomJavaCode GL2ES2 public void glUniform(GLUniformData data);
CustomJavaCode GL2ES2
diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl2_es2.java b/make/config/jogl/gl-impl-CustomJavaCode-gl2_es2.java
index 2f3710eb2..0d0daf463 100644
--- a/make/config/jogl/gl-impl-CustomJavaCode-gl2_es2.java
+++ b/make/config/jogl/gl-impl-CustomJavaCode-gl2_es2.java
@@ -1,242 +1,3 @@
- public String glGetShaderInfoLog(int shaderObj) {
- int[] infoLogLength=new int[1];
- glGetShaderiv(shaderObj, GL_INFO_LOG_LENGTH, infoLogLength, 0);
-
- if(infoLogLength[0]==0) {
- return "(InfoLog null)";
- }
- int[] charsWritten=new int[1];
- byte[] infoLogBytes = new byte[infoLogLength[0]];
- glGetShaderInfoLog(shaderObj, infoLogLength[0], charsWritten, 0, infoLogBytes, 0);
-
- return new String(infoLogBytes, 0, charsWritten[0]);
- }
-
- public String glGetProgramInfoLog(int programObj) {
- int[] infoLogLength=new int[1];
- glGetProgramiv(programObj, GL_INFO_LOG_LENGTH, infoLogLength, 0);
-
- if(infoLogLength[0]==0) {
- return "(InfoLog null)";
- }
- int[] charsWritten=new int[1];
- byte[] infoLogBytes = new byte[infoLogLength[0]];
- glGetProgramInfoLog(programObj, infoLogLength[0], charsWritten, 0, infoLogBytes, 0);
-
- return new String(infoLogBytes, 0, charsWritten[0]);
- }
-
- public boolean glIsShaderStatusValid(int shaderObj, int name) {
- return glIsShaderStatusValid(shaderObj, name, null);
- }
- public boolean glIsShaderStatusValid(int shaderObj, int name, PrintStream verboseOut) {
- int[] ires = new int[1];
- glGetShaderiv(shaderObj, name, ires, 0);
-
- boolean res = ires[0]==1;
- if(!res && null!=verboseOut) {
- verboseOut.println("Shader status invalid: "+glGetShaderInfoLog(shaderObj));
- }
- return res;
- }
- public boolean glIsShaderStatusValid(IntBuffer shaders, int name) {
- return glIsShaderStatusValid(shaders, name, null);
- }
- public boolean glIsShaderStatusValid(IntBuffer shaders, int name, PrintStream verboseOut) {
- boolean res = true;
- shaders.rewind();
- while(shaders.hasRemaining()) {
- res = glIsShaderStatusValid(shaders.get(), name, verboseOut) && res;
- }
- shaders.rewind();
- return res;
- }
-
- public boolean glIsProgramStatusValid(int programObj, int name) {
- int[] ires = new int[1];
- glGetProgramiv(programObj, name, ires, 0);
-
- return ires[0]==1;
- }
-
- public boolean glIsProgramValid(int programObj) {
- return glIsProgramValid(programObj, null);
- }
- public boolean glIsProgramValid(int programObj, PrintStream verboseOut) {
- int[] ires = new int[1];
- if(!glIsProgram(programObj)) {
- if(null!=verboseOut) {
- verboseOut.println("Program name invalid: "+programObj);
- }
- return false;
- }
- if(!glIsProgramStatusValid(programObj, GL_LINK_STATUS)) {
- if(null!=verboseOut) {
- verboseOut.println("Program link failed: "+programObj+"\n\t"+ glGetProgramInfoLog(programObj));
- }
- return false;
- }
- if ( !isGLES2() || glShaderCompilerAvailable() ) {
- // failed on APX2500 (ES2.0, no compiler) for valid programs
- glValidateProgram(programObj);
- if(!glIsProgramStatusValid(programObj, GL_VALIDATE_STATUS)) {
- if(null!=verboseOut) {
- verboseOut.println("Program validation failed: "+programObj+"\n\t"+ glGetProgramInfoLog(programObj));
- }
- return false;
- }
- }
- return true;
- }
-
- public void glCreateShader(int type, IntBuffer shaders) {
- shaders.clear();
- while(shaders.hasRemaining()) {
- shaders.put(glCreateShader(type));
- }
- shaders.rewind();
- }
-
- private Boolean shaderCompilerAvailable = null;
- private Set shaderBinaryFormats = null;
-
- public Set glGetShaderBinaryFormats()
- {
- if(null==shaderBinaryFormats) {
- if(getContext()!=GLContext.getCurrent()) {
- return new HashSet(0); // bail out
- }
- HashSet formatSet = new HashSet();
-
- int[] param = new int[1];
-
- glGetIntegerv(GL2ES2.GL_NUM_SHADER_BINARY_FORMATS, param, 0);
- int numFormats = param[0];
- if(numFormats>0) {
- int[] formats = new int[numFormats];
- glGetIntegerv(GL2ES2.GL_SHADER_BINARY_FORMATS, formats, 0);
- shaderBinaryFormats = new HashSet(numFormats);
- for(int i=0; i<numFormats; i++) {
- shaderBinaryFormats.add(new Integer(formats[i]));
- }
- } else {
- shaderBinaryFormats = new HashSet(0);
- }
- }
- return shaderBinaryFormats;
- }
-
-
- public boolean glShaderCompilerAvailable() {
- if(null==shaderCompilerAvailable) {
- if(getContext()!=GLContext.getCurrent()) {
- return false; // bail out
- }
- Set bfs = glGetShaderBinaryFormats();
- if(isGLES2()) {
- byte[] param = new byte[1];
- glGetBooleanv(GL2ES2.GL_SHADER_COMPILER, param, 0);
- boolean v = param[0]!=(byte)0x00;
- if(!v && bfs.size()==0) {
- // no supported binary formats, hence a compiler must be available!
- v = true;
- }
- shaderCompilerAvailable = new Boolean(v);
- } else if( isGL2() || isGL2ES2() ) {
- shaderCompilerAvailable = new Boolean(true);
- } else {
- throw new GLException("invalid profile");
- }
- }
- return shaderCompilerAvailable.booleanValue();
- }
-
- public void glShaderSource(int shader, java.lang.String[] source)
- {
- if(!glShaderCompilerAvailable()) {
- throw new GLException("no compiler is available");
- }
-
- int count = (null!=source)?source.length:0;
- if(count<=0) {
- throw new GLException("Method \"glShaderSource\" called with invalid length of source: "+count);
- }
- IntBuffer length = InternalBufferUtil.newIntBuffer(count);
- for(int i=0; i<count; i++) {
- length.put(source[i].length());
- }
- length.flip();
- glShaderSource(shader, count, source, length);
- }
-
- public void glShaderSource(IntBuffer shaders, java.lang.String[][] sources)
- {
- int sourceNum = (null!=sources)?sources.length:0;
- int shaderNum = (null!=shaders)?shaders.remaining():0;
- if(shaderNum<=0 || sourceNum<=0 || shaderNum!=sourceNum) {
- throw new GLException("Method \"glShaderSource\" called with invalid number of shaders and/or sources: shaders="+
- shaderNum+", sources="+sourceNum);
- }
- for(int i=0; i<sourceNum; i++) {
- glShaderSource(shaders.get(i), sources[i]);
- }
- }
-
- public void glShaderBinary(IntBuffer shaders, int binFormat, java.nio.Buffer bin)
- {
- if(glGetShaderBinaryFormats().size()<=0) {
- throw new GLException("no binary formats are supported");
- }
-
- int shaderNum = shaders.remaining();
- if(shaderNum<=0) {
- throw new GLException("Method \"glShaderBinary\" called with shaders number <= 0");
- }
- if(null==bin) {
- throw new GLException("Method \"glShaderBinary\" without binary (null)");
- }
- int binLength = bin.remaining();
- if(0>=binLength) {
- throw new GLException("Method \"glShaderBinary\" without binary (remaining == 0)");
- }
- glShaderBinary(shaderNum, shaders, binFormat, bin, binLength);
- }
-
- public void glCompileShader(IntBuffer shaders)
- {
- shaders.rewind();
- while(shaders.hasRemaining()) {
- glCompileShader(shaders.get());
- }
- shaders.rewind();
- }
-
- public void glAttachShader(int program, IntBuffer shaders)
- {
- shaders.rewind();
- while(shaders.hasRemaining()) {
- glAttachShader(program, shaders.get());
- }
- shaders.rewind();
- }
-
- public void glDetachShader(int program, IntBuffer shaders)
- {
- shaders.rewind();
- while(shaders.hasRemaining()) {
- glDetachShader(program, shaders.get());
- }
- shaders.rewind();
- }
-
- public void glDeleteShader(IntBuffer shaders) {
- shaders.rewind();
- while(shaders.hasRemaining()) {
- glDeleteShader(shaders.get());
- }
- shaders.clear();
- }
-
public void glVertexAttribPointer(GLArrayData array) {
if(array.getComponentNumber()==0) return;
if(array.isVBO()) {
@@ -297,24 +58,3 @@
}
}
}
-
- public final String toString() {
- StringBuffer buf = new StringBuffer();
- buf.append(getClass().getName());
- if (isGL2ES2()) {
- buf.append(" [GLSL compiler: ");
- buf.append(glShaderCompilerAvailable());
- Set bfs = glGetShaderBinaryFormats();
- buf.append(", binary formats ");
- buf.append(bfs.size());
- buf.append(":");
- for(Iterator iter=bfs.iterator(); iter.hasNext(); ) {
- buf.append(" ");
- buf.append(((Integer)(iter.next())).intValue());
- }
- buf.append("]");
- }
- return buf.toString();
- }
-
-
diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java
index a7c42a81d..9e2e1f55d 100755
--- a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java
+++ b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java
@@ -304,10 +304,6 @@ native private long dispatch_glMapBuffer(int target, int access, long glProcAddr
native private ByteBuffer newDirectByteBuffer(long addr, int capacity);
- public final String toString() {
- return getClass().getName();
- }
-
public void glVertexPointer(GLArrayData array) {
if(array.getComponentNumber()==0) return;
if(array.isVBO()) {
diff --git a/src/jogl/classes/com/sun/opengl/util/glsl/ShaderCode.java b/src/jogl/classes/com/sun/opengl/util/glsl/ShaderCode.java
index cba5f91b3..6e7512e6a 100644
--- a/src/jogl/classes/com/sun/opengl/util/glsl/ShaderCode.java
+++ b/src/jogl/classes/com/sun/opengl/util/glsl/ShaderCode.java
@@ -50,7 +50,7 @@ public class ShaderCode {
}
public static ShaderCode create(GL2ES2 gl, int type, int number, Class context, String[] sourceFiles) {
- if(!gl.glShaderCompilerAvailable()) return null;
+ if(!ShaderUtil.isShaderCompilerAvailable(gl)) return null;
String[][] shaderSources = null;
if(null!=sourceFiles) {
@@ -108,7 +108,7 @@ public class ShaderCode {
String srcFileName = null;
String binFileName = null;
- if(gl.glShaderCompilerAvailable()) {
+ if(ShaderUtil.isShaderCompilerAvailable(gl)) {
String srcPath[] = new String[1];
srcFileName = srcRoot + '/' + basename + "." + getFileSuffix(false, type);
srcPath[0] = srcFileName;
@@ -117,7 +117,7 @@ public class ShaderCode {
return res;
}
}
- Set binFmts = gl.glGetShaderBinaryFormats();
+ Set binFmts = ShaderUtil.getShaderBinaryFormats(gl);
for(Iterator iter=binFmts.iterator(); null==res && iter.hasNext(); ) {
int bFmt = ((Integer)(iter.next())).intValue();
String bFmtPath = getBinarySubPath(bFmt);
@@ -143,14 +143,14 @@ public class ShaderCode {
verboseOut.println("createAndLoadShader: Pre GL Error: 0x"+Integer.toHexString(err));
}
- gl.glCreateShader(shaderType, shader);
+ ShaderUtil.createShader(gl, shaderType, shader);
err = gl.glGetError();
if(err!=GL.GL_NO_ERROR) {
throw new GLException("createAndLoadShader: CreateShader failed, GL Error: 0x"+Integer.toHexString(err));
}
- gl.glShaderBinary(shader, binFormat, bin);
+ ShaderUtil.shaderBinary(gl, shader, binFormat, bin);
err = gl.glGetError();
if(err!=GL.GL_NO_ERROR && null!=verboseOut) {
@@ -168,25 +168,25 @@ public class ShaderCode {
verboseOut.println("createAndCompileShader: Pre GL Error: 0x"+Integer.toHexString(err));
}
- gl.glCreateShader(shaderType, shader);
+ ShaderUtil.createShader(gl, shaderType, shader);
err = gl.glGetError();
if(err!=GL.GL_NO_ERROR) {
throw new GLException("createAndCompileShader: CreateShader failed, GL Error: 0x"+Integer.toHexString(err));
}
- gl.glShaderSource(shader, sources);
+ ShaderUtil.shaderSource(gl, shader, sources);
err = gl.glGetError();
if(err!=GL.GL_NO_ERROR) {
throw new GLException("createAndCompileShader: ShaderSource failed, GL Error: 0x"+Integer.toHexString(err));
}
- gl.glCompileShader(shader);
+ ShaderUtil.compileShader(gl, shader);
err = gl.glGetError();
if(err!=GL.GL_NO_ERROR && null!=verboseOut) {
verboseOut.println("createAndCompileShader: CompileShader failed, GL Error: 0x"+Integer.toHexString(err));
}
- return gl.glIsShaderStatusValid(shader, gl.GL_COMPILE_STATUS, verboseOut) && err == GL.GL_NO_ERROR;
+ return ShaderUtil.isShaderStatusValid(gl, shader, gl.GL_COMPILE_STATUS, verboseOut) && err == GL.GL_NO_ERROR;
}
/**
@@ -245,7 +245,7 @@ public class ShaderCode {
public void destroy(GL2ES2 gl) {
if(isValid()) {
if(null!=gl) {
- gl.glDeleteShader(shader());
+ ShaderUtil.deleteShader(gl, shader());
}
valid=false;
}
diff --git a/src/jogl/classes/com/sun/opengl/util/glsl/ShaderProgram.java b/src/jogl/classes/com/sun/opengl/util/glsl/ShaderProgram.java
index 7973c471f..c06eae383 100644
--- a/src/jogl/classes/com/sun/opengl/util/glsl/ShaderProgram.java
+++ b/src/jogl/classes/com/sun/opengl/util/glsl/ShaderProgram.java
@@ -65,7 +65,7 @@ public class ShaderProgram {
glUseProgram(gl, false);
for(Iterator iter=shaderMap.values().iterator(); iter.hasNext(); ) {
ShaderCode shaderCode = (ShaderCode) iter.next();
- gl.glDetachShader(shaderProgram, shaderCode.shader());
+ ShaderUtil.detachShader(gl, shaderProgram, shaderCode.shader());
if(releaseShaderToo) {
shaderCode.destroy(gl);
}
@@ -125,14 +125,14 @@ public class ShaderProgram {
if(oldShaderID>=0) {
ShaderCode oldShader = (ShaderCode) shaderMap.remove(new Integer(oldShaderID));
if(null!=oldShader) {
- gl.glDetachShader(shaderProgram, oldShader.shader());
+ ShaderUtil.detachShader(gl, shaderProgram, oldShader.shader());
}
}
add(newShader);
- gl.glAttachShader(shaderProgram, newShader.shader());
+ ShaderUtil.attachShader(gl, shaderProgram, newShader.shader());
gl.glLinkProgram(shaderProgram);
- if ( ! gl.glIsProgramValid(shaderProgram, System.err) ) {
+ if ( ! ShaderUtil.isProgramValid(gl, shaderProgram, System.err) ) {
return false;
}
@@ -154,13 +154,13 @@ public class ShaderProgram {
if(!shaderCode.compile(gl, verboseOut)) {
return false;
}
- gl.glAttachShader(shaderProgram, shaderCode.shader());
+ ShaderUtil.attachShader(gl, shaderProgram, shaderCode.shader());
}
// Link the program
gl.glLinkProgram(shaderProgram);
- programLinked = gl.glIsProgramValid(shaderProgram, System.err);
+ programLinked = ShaderUtil.isProgramValid(gl, shaderProgram, System.err);
return programLinked;
}
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index 5a4631560..8c3ca9c5b 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -201,21 +201,36 @@ public abstract class GLContext {
public abstract void setGL(GL gl);
/**
- * Returns the attached user object for the given name to this GLContext/GL.
+ * Returns the attached user object for the given name to this GLContext.
*/
public Object getAttachedObject(int name) {
return attachedObjects.get(new Integer(name));
}
/**
- * Sets the attached user object for the given name to this GLContext/GL.
- * Returns the previous set object or null.
+ * Returns the attached user object for the given name to this GLContext.
+ */
+ public Object getAttachedObject(String name) {
+ return attachedObjects.get(name);
+ }
+
+ /**
+ * Sets the attached user object for the given name to this GLContext.
+ * Returns the previously set object or null.
*/
public Object putAttachedObject(int name, Object obj) {
return attachedObjects.put(new Integer(name), obj);
}
/**
+ * Sets the attached user object for the given name to this GLContext.
+ * Returns the previously set object or null.
+ */
+ public Object putAttachedObject(String name, Object obj) {
+ return attachedObjects.put(name, obj);
+ }
+
+ /**
* Classname, GL, GLDrawable
*/
public final String toString() {