diff options
author | Kenneth Russel <[email protected]> | 2009-05-22 22:21:29 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2009-05-22 22:21:29 +0000 |
commit | be3d7e5c1cf5d4d0342da36c3ab3eae91da51ec1 (patch) | |
tree | 611c2d01c4bcc6b3519ead48cb279f59b0b7ca0c /src/jogl/classes/com/sun/opengl | |
parent | cccddaeb39ad19a4e8c77fdff1d4950f48e32e8e (diff) |
Refactored shader-related utility routines from core GL2ES2 class into
ShaderUtil class. Added GLContext.getAttachedObject(String) and
putAttachedObject(String, Object) to allow arbitrarily named objects
to be attached to GLContext. Removed explicitly defined toString()
operations on GL implementations which were problematic and which
would have required downward references into com.sun.opengl.util.glsl
package after this refactoring.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1909 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/jogl/classes/com/sun/opengl')
-rw-r--r-- | src/jogl/classes/com/sun/opengl/util/glsl/ShaderCode.java | 20 | ||||
-rw-r--r-- | src/jogl/classes/com/sun/opengl/util/glsl/ShaderProgram.java | 12 |
2 files changed, 16 insertions, 16 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; } |