diff options
Diffstat (limited to 'src/jogl/classes')
3 files changed, 34 insertions, 19 deletions
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() { |