aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl/util/glsl
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/util/glsl')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java90
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java40
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java129
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java86
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java6
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShader.java48
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShaderNVidia.java4
7 files changed, 202 insertions, 201 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java
index 7c6a40468..4a3e5b2e1 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java
@@ -96,7 +96,7 @@ public class ShaderCode {
*
* @throws IllegalArgumentException if <code>count</count> and <code>source.length</code> do not match
*/
- public ShaderCode(int type, int count, CharSequence[][] source) {
+ public ShaderCode(final int type, final int count, final CharSequence[][] source) {
if(source.length != count) {
throw new IllegalArgumentException("shader number ("+count+") and sourceFiles array ("+source.length+") of different lenght.");
}
@@ -126,7 +126,7 @@ public class ShaderCode {
* @param count number of shaders
* @param binary binary buffer containing the shader binaries,
*/
- public ShaderCode(int type, int count, int binFormat, Buffer binary) {
+ public ShaderCode(final int type, final int count, final int binFormat, final Buffer binary) {
switch (type) {
case GL2ES2.GL_VERTEX_SHADER:
case GL2ES2.GL_FRAGMENT_SHADER:
@@ -162,7 +162,7 @@ public class ShaderCode {
* @throws IllegalArgumentException if <code>count</count> and <code>sourceFiles.length</code> do not match
* @see #readShaderSource(Class, String)
*/
- public static ShaderCode create(GL2ES2 gl, int type, int count, Class<?> context, String[] sourceFiles, boolean mutableStringBuilder) {
+ public static ShaderCode create(final GL2ES2 gl, final int type, final int count, final Class<?> context, final String[] sourceFiles, final boolean mutableStringBuilder) {
if(null != gl && !ShaderUtil.isShaderCompilerAvailable(gl)) {
return null;
}
@@ -174,7 +174,7 @@ public class ShaderCode {
for(int i=0; i<sourceFiles.length; i++) {
try {
shaderSources[i][0] = readShaderSource(context, sourceFiles[i], mutableStringBuilder);
- } catch (IOException ioe) {
+ } catch (final IOException ioe) {
throw new RuntimeException("readShaderSource("+sourceFiles[i]+") error: ", ioe);
}
if(null == shaderSources[i][0]) {
@@ -201,12 +201,12 @@ public class ShaderCode {
* @see #readShaderBinary(Class, String)
* @see ShaderUtil#getShaderBinaryFormats(GL)
*/
- public static ShaderCode create(int type, int count, Class<?> context, int binFormat, String binaryFile) {
+ public static ShaderCode create(final int type, final int count, final Class<?> context, int binFormat, final String binaryFile) {
ByteBuffer shaderBinary = null;
if(null!=binaryFile && 0<=binFormat) {
try {
shaderBinary = readShaderBinary(context, binaryFile);
- } catch (IOException ioe) {
+ } catch (final IOException ioe) {
throw new RuntimeException("readShaderBinary("+binaryFile+") error: ", ioe);
}
if(null == shaderBinary) {
@@ -238,7 +238,7 @@ public class ShaderCode {
*
* @see #create(GL2ES2, int, Class, String, String, String, boolean)
*/
- public static String getFileSuffix(boolean binary, int type) {
+ public static String getFileSuffix(final boolean binary, final int type) {
switch (type) {
case GL2ES2.GL_VERTEX_SHADER:
return binary?SUFFIX_VERTEX_BINARY:SUFFIX_VERTEX_SOURCE;
@@ -261,7 +261,7 @@ public class ShaderCode {
*
* @see #create(GL2ES2, int, Class, String, String, String, boolean)
*/
- public static String getBinarySubPath(int binFormat) {
+ public static String getBinarySubPath(final int binFormat) {
switch (binFormat) {
case GLES2.GL_NVIDIA_PLATFORM_BINARY_NV:
return SUB_PATH_NVIDIA;
@@ -347,9 +347,9 @@ public class ShaderCode {
* @see ShaderUtil#getShaderBinaryFormats(GL)
* @see #getBinarySubPath(int)
*/
- public static ShaderCode create(GL2ES2 gl, int type, int count, Class<?> context,
- String srcRoot, String[] srcBasenames, String binRoot, String binBasename,
- boolean mutableStringBuilder) {
+ public static ShaderCode create(final GL2ES2 gl, final int type, final int count, final Class<?> context,
+ final String srcRoot, final String[] srcBasenames, final String binRoot, final String binBasename,
+ final boolean mutableStringBuilder) {
ShaderCode res = null;
final String srcPath[];
String srcPathString = null;
@@ -376,10 +376,10 @@ public class ShaderCode {
srcPath = null;
}
if( null!=binBasename ) {
- Set<Integer> binFmts = ShaderUtil.getShaderBinaryFormats(gl);
+ final Set<Integer> binFmts = ShaderUtil.getShaderBinaryFormats(gl);
final String binSuffix = getFileSuffix(true, type);
- for(Iterator<Integer> iter=binFmts.iterator(); iter.hasNext(); ) {
- int bFmt = iter.next().intValue();
+ for(final Iterator<Integer> iter=binFmts.iterator(); iter.hasNext(); ) {
+ final int bFmt = iter.next().intValue();
final String bFmtPath = getBinarySubPath(bFmt);
if(null==bFmtPath) continue;
binFileName = binRoot + '/' + bFmtPath + '/' + binBasename + "." + binSuffix;
@@ -447,8 +447,8 @@ public class ShaderCode {
*
* @see #create(GL2ES2, int, int, Class, String, String[], String, String)
*/
- public static ShaderCode create(GL2ES2 gl, int type, Class<?> context,
- String srcRoot, String binRoot, String basename, boolean mutableStringBuilder) {
+ public static ShaderCode create(final GL2ES2 gl, final int type, final Class<?> context,
+ final String srcRoot, final String binRoot, final String basename, final boolean mutableStringBuilder) {
return create(gl, type, 1, context, srcRoot, new String[] { basename }, binRoot, basename, mutableStringBuilder );
}
@@ -460,7 +460,7 @@ public class ShaderCode {
public int shaderType() { return shaderType; }
public String shaderTypeStr() { return shaderTypeStr(shaderType); }
- public static String shaderTypeStr(int type) {
+ public static String shaderTypeStr(final int type) {
switch (type) {
case GL2ES2.GL_VERTEX_SHADER:
return "VERTEX_SHADER";
@@ -480,10 +480,10 @@ public class ShaderCode {
public IntBuffer shader() { return shader; }
- public boolean compile(GL2ES2 gl) {
+ public boolean compile(final GL2ES2 gl) {
return compile(gl, null);
}
- public boolean compile(GL2ES2 gl, PrintStream verboseOut) {
+ public boolean compile(final GL2ES2 gl, final PrintStream verboseOut) {
if(isValid()) return true;
// Create & Compile the vertex/fragment shader objects
@@ -503,7 +503,7 @@ public class ShaderCode {
return valid;
}
- public void destroy(GL2ES2 gl) {
+ public void destroy(final GL2ES2 gl) {
if(isValid()) {
if(null!=gl) {
ShaderUtil.deleteShader(gl, shader());
@@ -521,7 +521,7 @@ public class ShaderCode {
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if(this==obj) { return true; }
if(obj instanceof ShaderCode) {
return id()==((ShaderCode)obj).id();
@@ -534,7 +534,7 @@ public class ShaderCode {
}
@Override
public String toString() {
- StringBuilder buf = new StringBuilder("ShaderCode[id="+id+", type="+shaderTypeStr()+", valid="+valid+", shader: ");
+ final StringBuilder buf = new StringBuilder("ShaderCode[id="+id+", type="+shaderTypeStr()+", valid="+valid+", shader: ");
for(int i=0; i<shader.remaining(); i++) {
buf.append(" "+shader.get(i));
}
@@ -546,7 +546,7 @@ public class ShaderCode {
return buf.toString();
}
- public void dumpShaderSource(PrintStream out) {
+ public void dumpShaderSource(final PrintStream out) {
if(null==shaderSource) {
out.println("<no shader source>");
return;
@@ -560,7 +560,7 @@ public class ShaderCode {
if(i>=sourceCount) {
out.println("<no shader source>");
} else {
- CharSequence[] src = shaderSource[i];
+ final CharSequence[] src = shaderSource[i];
int lineno=0;
for(int j=0; j<src.length; j++) {
@@ -572,7 +572,7 @@ public class ShaderCode {
lineno++;
out.printf("%4d: %s\n", lineno, line);
}
- } catch (IOException e) { /* impossible .. StringReader */ }
+ } catch (final IOException e) { /* impossible .. StringReader */ }
}
}
out.println("--------------------------------------------------------------");
@@ -593,7 +593,7 @@ public class ShaderCode {
*
* @throws IllegalStateException if the shader source's CharSequence is immutable, i.e. not of type <code>StringBuilder</code>
*/
- public int insertShaderSource(int shaderIdx, String tag, int fromIndex, CharSequence data) {
+ public int insertShaderSource(final int shaderIdx, final String tag, final int fromIndex, final CharSequence data) {
if(null==shaderSource) {
throw new IllegalStateException("no shader source");
}
@@ -650,7 +650,7 @@ public class ShaderCode {
*
* @throws IllegalStateException if the shader source's CharSequence is immutable, i.e. not of type <code>StringBuilder</code>
*/
- public int replaceInShaderSource(String oldName, String newName) {
+ public int replaceInShaderSource(final String oldName, final String newName) {
if(null==shaderSource) {
throw new IllegalStateException("no shader source");
}
@@ -670,9 +670,9 @@ public class ShaderCode {
final StringBuilder sb = (StringBuilder)src[j];
int curPos = 0;
while(curPos<sb.length()-oldNameLen+1) {
- int startIdx = sb.indexOf(oldName, curPos);
+ final int startIdx = sb.indexOf(oldName, curPos);
if(0<=startIdx) {
- int endIdx = startIdx + oldNameLen;
+ final int endIdx = startIdx + oldNameLen;
sb.replace(startIdx, endIdx, newName);
curPos = startIdx + newNameLen;
num++;
@@ -698,7 +698,7 @@ public class ShaderCode {
*
* @throws IllegalStateException if the shader source's CharSequence is immutable, i.e. not of type <code>StringBuilder</code>
*/
- public int insertShaderSource(int shaderIdx, int position, CharSequence data) {
+ public int insertShaderSource(final int shaderIdx, int position, final CharSequence data) {
if(null==shaderSource) {
throw new IllegalStateException("no shader source");
}
@@ -750,7 +750,7 @@ public class ShaderCode {
* @throws IllegalStateException if the shader source's CharSequence is immutable, i.e. not of type <code>StringBuilder</code>
* @see IOUtil#getResource(Class, String)
*/
- public int insertShaderSource(int shaderIdx, int position, Class<?> context, String path) throws IOException {
+ public int insertShaderSource(final int shaderIdx, final int position, final Class<?> context, final String path) throws IOException {
final CharSequence data = readShaderSource(context, path, true);
if( null != data ) {
return insertShaderSource(shaderIdx, position, data);
@@ -760,7 +760,7 @@ public class ShaderCode {
}
@SuppressWarnings("resource")
- private static int readShaderSource(Class<?> context, URLConnection conn, StringBuilder result, int lineno) throws IOException {
+ private static int readShaderSource(final Class<?> context, final URLConnection conn, final StringBuilder result, int lineno) throws IOException {
if(DEBUG_CODE) {
if(0 == lineno) {
result.append("// "+conn.getURL().toExternalForm()+"\n");
@@ -774,7 +774,7 @@ public class ShaderCode {
while ((line = reader.readLine()) != null) {
lineno++;
if (line.startsWith("#include ")) {
- String includeFile = line.substring(9).trim();
+ final String includeFile = line.substring(9).trim();
URLConnection nextConn = null;
// Try relative of current shader location
@@ -805,7 +805,7 @@ public class ShaderCode {
* @param result
* @throws IOException
*/
- public static void readShaderSource(Class<?> context, URLConnection conn, StringBuilder result) throws IOException {
+ public static void readShaderSource(final Class<?> context, final URLConnection conn, final StringBuilder result) throws IOException {
readShaderSource(context, conn, result, 0);
}
@@ -829,12 +829,12 @@ public class ShaderCode {
*
* @see IOUtil#getResource(Class, String)
*/
- public static CharSequence readShaderSource(Class<?> context, String path, boolean mutableStringBuilder) throws IOException {
- URLConnection conn = IOUtil.getResource(context, path);
+ public static CharSequence readShaderSource(final Class<?> context, final String path, final boolean mutableStringBuilder) throws IOException {
+ final URLConnection conn = IOUtil.getResource(context, path);
if (conn == null) {
return null;
}
- StringBuilder result = new StringBuilder();
+ final StringBuilder result = new StringBuilder();
readShaderSource(context, conn, result);
return mutableStringBuilder ? result : result.toString();
}
@@ -853,7 +853,7 @@ public class ShaderCode {
*
* @see IOUtil#getResource(Class, String)
*/
- public static ByteBuffer readShaderBinary(Class<?> context, String path) throws IOException {
+ public static ByteBuffer readShaderBinary(final Class<?> context, final String path) throws IOException {
final URLConnection conn = IOUtil.getResource(context, path);
if (conn == null) {
return null;
@@ -901,7 +901,7 @@ public class ShaderCode {
* @param behavior shall be either {@link #REQUIRE}, {@link #ENABLE}, {@link #DISABLE} or {@link #WARN}
* @return the complete extension directive
*/
- public static String createExtensionDirective(String extensionName, String behavior) {
+ public static String createExtensionDirective(final String extensionName, final String behavior) {
return "#extension " + extensionName + " : " + behavior + "\n";
}
@@ -913,7 +913,7 @@ public class ShaderCode {
* @param gl a GL context, which must have been made current once
* @return the index after the inserted data, maybe 0 if nothing has be inserted.
*/
- public final int addGLSLVersion(GL2ES2 gl) {
+ public final int addGLSLVersion(final GL2ES2 gl) {
return insertShaderSource(0, 0, gl.getContext().getGLSLVersionString());
}
@@ -929,7 +929,7 @@ public class ShaderCode {
* @param pos position within this mutable shader source.
* @return the index after the inserted data, maybe 0 if nothing has be inserted.
*/
- public final int addDefaultShaderPrecision(GL2ES2 gl, int pos) {
+ public final int addDefaultShaderPrecision(final GL2ES2 gl, int pos) {
final String defaultPrecision;
if( gl.isGLES3() ) {
switch ( shaderType ) {
@@ -973,7 +973,7 @@ public class ShaderCode {
}
/** Returns true, if GLSL version requires default precision, i.e. ES2 or GLSL [1.30 .. 1.50[. */
- public static final boolean requiresDefaultPrecision(GL2ES2 gl) {
+ public static final boolean requiresDefaultPrecision(final GL2ES2 gl) {
if( gl.isGLES() ) {
return true;
}
@@ -981,7 +981,7 @@ public class ShaderCode {
}
/** Returns true, if GL3 GLSL version requires default precision, i.e. GLSL [1.30 .. 1.50[. */
- public static final boolean requiresGL3DefaultPrecision(GL2ES2 gl) {
+ public static final boolean requiresGL3DefaultPrecision(final GL2ES2 gl) {
if( gl.isGL3() ) {
final VersionNumber glslVersion = gl.getContext().getGLSLVersionNumber();
return glslVersion.compareTo(GLContext.Version130) >= 0 && glslVersion.compareTo(GLContext.Version150) < 0 ;
@@ -1005,7 +1005,7 @@ public class ShaderCode {
* @see #addGLSLVersion(GL2ES2)
* @see #addDefaultShaderPrecision(GL2ES2, int)
*/
- public final int defaultShaderCustomization(GL2ES2 gl, boolean preludeVersion, boolean addDefaultPrecision) {
+ public final int defaultShaderCustomization(final GL2ES2 gl, final boolean preludeVersion, final boolean addDefaultPrecision) {
int pos;
if( preludeVersion ) {
pos = addGLSLVersion(gl);
@@ -1031,7 +1031,7 @@ public class ShaderCode {
* @see #addGLSLVersion(GL2ES2)
* @see #addDefaultShaderPrecision(GL2ES2, int)
*/
- public final int defaultShaderCustomization(GL2ES2 gl, boolean preludeVersion, String esDefaultPrecision) {
+ public final int defaultShaderCustomization(final GL2ES2 gl, final boolean preludeVersion, final String esDefaultPrecision) {
int pos;
if( preludeVersion ) {
pos = addGLSLVersion(gl);
diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java
index 3ac17b0c5..a9b0bddc6 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java
@@ -65,7 +65,7 @@ public class ShaderProgram {
*
* @see #release(GL2ES2, boolean)
*/
- public synchronized void destroy(GL2ES2 gl) {
+ public synchronized void destroy(final GL2ES2 gl) {
release(gl, true);
}
@@ -76,7 +76,7 @@ public class ShaderProgram {
*
* @see #release(GL2ES2, boolean)
*/
- public synchronized void release(GL2ES2 gl) {
+ public synchronized void release(final GL2ES2 gl) {
release(gl, false);
}
@@ -84,12 +84,12 @@ public class ShaderProgram {
* Detaches all shader codes and deletes the program.
* If <code>destroyShaderCode</code> is true it destroys the shader codes as well.
*/
- public synchronized void release(GL2ES2 gl, boolean destroyShaderCode) {
+ public synchronized void release(final GL2ES2 gl, final boolean destroyShaderCode) {
if( programLinked ) {
useProgram(gl, false);
}
- for(Iterator<ShaderCode> iter=allShaderCode.iterator(); iter.hasNext(); ) {
- ShaderCode shaderCode = iter.next();
+ for(final Iterator<ShaderCode> iter=allShaderCode.iterator(); iter.hasNext(); ) {
+ final ShaderCode shaderCode = iter.next();
if(attachedShaderCode.remove(shaderCode)) {
ShaderUtil.detachShader(gl, shaderProgram, shaderCode.shader());
}
@@ -115,11 +115,11 @@ public class ShaderProgram {
* <p>This command does not compile and attach the shader,
* use {@link #add(GL2ES2, ShaderCode)} for this purpose.</p>
*/
- public synchronized void add(ShaderCode shaderCode) throws GLException {
+ public synchronized void add(final ShaderCode shaderCode) throws GLException {
allShaderCode.add(shaderCode);
}
- public synchronized boolean contains(ShaderCode shaderCode) {
+ public synchronized boolean contains(final ShaderCode shaderCode) {
return allShaderCode.contains(shaderCode);
}
@@ -128,9 +128,9 @@ public class ShaderProgram {
* @param id
* @return
*/
- public synchronized ShaderCode getShader(int id) {
- for(Iterator<ShaderCode> iter=allShaderCode.iterator(); iter.hasNext(); ) {
- ShaderCode shaderCode = iter.next();
+ public synchronized ShaderCode getShader(final int id) {
+ for(final Iterator<ShaderCode> iter=allShaderCode.iterator(); iter.hasNext(); ) {
+ final ShaderCode shaderCode = iter.next();
if(shaderCode.id() == id) {
return shaderCode;
}
@@ -149,7 +149,7 @@ public class ShaderProgram {
* @param gl
* @return true if shader program is valid, i.e. not zero
*/
- public synchronized final boolean init(GL2ES2 gl) {
+ public synchronized final boolean init(final GL2ES2 gl) {
if( 0 == shaderProgram ) {
shaderProgram = gl.glCreateProgram();
}
@@ -163,7 +163,7 @@ public class ShaderProgram {
*
* @return true if the shader was successfully added, false if compilation failed.
*/
- public synchronized boolean add(GL2ES2 gl, ShaderCode shaderCode, PrintStream verboseOut) {
+ public synchronized boolean add(final GL2ES2 gl, final ShaderCode shaderCode, final PrintStream verboseOut) {
if( !init(gl) ) { return false; }
if( allShaderCode.add(shaderCode) ) {
if( !shaderCode.compile(gl, verboseOut) ) {
@@ -195,12 +195,12 @@ public class ShaderProgram {
* @see ShaderState#glResetAllVertexAttributes
* @see ShaderState#glResetAllVertexAttributes
*/
- public synchronized boolean replaceShader(GL2ES2 gl, ShaderCode oldShader, ShaderCode newShader, PrintStream verboseOut) {
+ public synchronized boolean replaceShader(final GL2ES2 gl, final ShaderCode oldShader, final ShaderCode newShader, final PrintStream verboseOut) {
if(!init(gl) || !newShader.compile(gl, verboseOut)) {
return false;
}
- boolean shaderWasInUse = inUse();
+ final boolean shaderWasInUse = inUse();
if(shaderWasInUse) {
useProgram(gl, false);
}
@@ -238,13 +238,13 @@ public class ShaderProgram {
*
* @see #init(GL2ES2)
*/
- public synchronized boolean link(GL2ES2 gl, PrintStream verboseOut) {
+ public synchronized boolean link(final GL2ES2 gl, final PrintStream verboseOut) {
if( !init(gl) ) {
programLinked = false; // mark unlinked due to user attempt to [re]link
return false;
}
- for(Iterator<ShaderCode> iter=allShaderCode.iterator(); iter.hasNext(); ) {
+ for(final Iterator<ShaderCode> iter=allShaderCode.iterator(); iter.hasNext(); ) {
final ShaderCode shaderCode = iter.next();
if(!shaderCode.compile(gl, verboseOut)) {
programLinked = false; // mark unlinked due to user attempt to [re]link
@@ -264,7 +264,7 @@ public class ShaderProgram {
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if(this == obj) { return true; }
if(obj instanceof ShaderProgram) {
return id()==((ShaderProgram)obj).id();
@@ -283,7 +283,7 @@ public class ShaderProgram {
}
sb.append("ShaderProgram[id=").append(id);
sb.append(", linked="+programLinked+", inUse="+programInUse+", program: "+shaderProgram+",");
- for(Iterator<ShaderCode> iter=allShaderCode.iterator(); iter.hasNext(); ) {
+ for(final Iterator<ShaderCode> iter=allShaderCode.iterator(); iter.hasNext(); ) {
sb.append(Platform.getNewline()).append(" ").append(iter.next());
}
sb.append("]");
@@ -299,11 +299,11 @@ public class ShaderProgram {
* Performs {@link GL2ES2#glValidateProgram(int)} via {@link ShaderUtil#isProgramExecStatusValid(GL, int, PrintStream)}.
* @see ShaderUtil#isProgramExecStatusValid(GL, int, PrintStream)
**/
- public synchronized boolean validateProgram(GL2ES2 gl, PrintStream verboseOut) {
+ public synchronized boolean validateProgram(final GL2ES2 gl, final PrintStream verboseOut) {
return ShaderUtil.isProgramExecStatusValid(gl, shaderProgram, verboseOut);
}
- public synchronized void useProgram(GL2ES2 gl, boolean on) {
+ public synchronized void useProgram(final GL2ES2 gl, boolean on) {
if(!programLinked) { throw new GLException("Program is not linked"); }
if(programInUse==on) { return; }
if( 0 == shaderProgram ) {
diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java
index 64dd589b8..c841f2f09 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java
@@ -41,6 +41,7 @@ import javax.media.opengl.GLUniformData;
import jogamp.opengl.Debug;
import com.jogamp.common.os.Platform;
+import com.jogamp.common.util.PropertyAccess;
import com.jogamp.opengl.util.GLArrayDataEditable;
/**
@@ -60,7 +61,7 @@ public class ShaderState {
static {
Debug.initSingleton();
- DEBUG = Debug.isPropertyDefined("jogl.debug.GLSLState", true);
+ DEBUG = PropertyAccess.isPropertyDefined("jogl.debug.GLSLState", true);
}
public ShaderState() {
@@ -68,12 +69,12 @@ public class ShaderState {
public boolean verbose() { return verbose; }
- public void setVerbose(boolean v) { verbose = DEBUG || v; }
+ public void setVerbose(final boolean v) { verbose = DEBUG || v; }
/**
* Returns the attached user object for the given name to this ShaderState.
*/
- public final Object getAttachedObject(String name) {
+ public final Object getAttachedObject(final String name) {
return attachedObjectsByString.get(name);
}
@@ -83,7 +84,7 @@ public class ShaderState {
*
* @return the previous mapped object or null if none
*/
- public final Object attachObject(String name, Object obj) {
+ public final Object attachObject(final String name, final Object obj) {
return attachedObjectsByString.put(name, obj);
}
@@ -92,7 +93,7 @@ public class ShaderState {
*
* @return the previous mapped object or null if none
*/
- public final Object detachObject(String name) {
+ public final Object detachObject(final String name) {
return attachedObjectsByString.remove(name);
}
@@ -103,7 +104,7 @@ public class ShaderState {
*
* @see com.jogamp.opengl.util.glsl.ShaderState#useProgram(GL2ES2, boolean)
*/
- public synchronized void useProgram(GL2ES2 gl, boolean on) throws GLException {
+ public synchronized void useProgram(final GL2ES2 gl, final boolean on) throws GLException {
if(null==shaderProgram) { throw new GLException("No program is attached"); }
if(on) {
if(shaderProgram.linked()) {
@@ -154,10 +155,10 @@ public class ShaderState {
*
* @throws GLException if program was not linked and linking fails
*/
- public synchronized boolean attachShaderProgram(GL2ES2 gl, ShaderProgram prog, boolean enable) throws GLException {
+ public synchronized boolean attachShaderProgram(final GL2ES2 gl, final ShaderProgram prog, final boolean enable) throws GLException {
if(verbose) {
- int curId = (null!=shaderProgram)?shaderProgram.id():-1;
- int newId = (null!=prog)?prog.id():-1;
+ final int curId = (null!=shaderProgram)?shaderProgram.id():-1;
+ final int newId = (null!=prog)?prog.id():-1;
System.err.println("ShaderState: attachShaderProgram: "+curId+" -> "+newId+" (enable: "+enable+")\n\t"+shaderProgram+"\n\t"+prog);
if(DEBUG) {
Thread.dumpStack();
@@ -213,7 +214,7 @@ public class ShaderState {
* @see #glReleaseAllUniforms
* @see #release(GL2ES2, boolean, boolean, boolean)
*/
- public synchronized void destroy(GL2ES2 gl) {
+ public synchronized void destroy(final GL2ES2 gl) {
release(gl, true, true, true);
attachedObjectsByString.clear();
}
@@ -225,7 +226,7 @@ public class ShaderState {
* @see #glReleaseAllUniforms
* @see #release(GL2ES2, boolean, boolean, boolean)
*/
- public synchronized void releaseAllData(GL2ES2 gl) {
+ public synchronized void releaseAllData(final GL2ES2 gl) {
release(gl, false, false, false);
}
@@ -234,12 +235,12 @@ public class ShaderState {
* @see #glReleaseAllUniforms
* @see ShaderProgram#release(GL2ES2, boolean)
*/
- public synchronized void release(GL2ES2 gl, boolean destroyBoundAttributes, boolean destroyShaderProgram, boolean destroyShaderCode) {
+ public synchronized void release(final GL2ES2 gl, final boolean destroyBoundAttributes, final boolean destroyShaderProgram, final boolean destroyShaderCode) {
if(null!=shaderProgram && shaderProgram.linked() ) {
shaderProgram.useProgram(gl, false);
}
if(destroyBoundAttributes) {
- for(Iterator<GLArrayData> iter = managedAttributes.iterator(); iter.hasNext(); ) {
+ for(final Iterator<GLArrayData> iter = managedAttributes.iterator(); iter.hasNext(); ) {
iter.next().destroy(gl);
}
}
@@ -265,8 +266,8 @@ public class ShaderState {
* @see #getAttribLocation(GL2ES2, String)
* @see GL2ES2#glGetAttribLocation(int, String)
*/
- public int getCachedAttribLocation(String name) {
- Integer idx = activeAttribLocationMap.get(name);
+ public int getCachedAttribLocation(final String name) {
+ final Integer idx = activeAttribLocationMap.get(name);
return (null!=idx)?idx.intValue():-1;
}
@@ -285,11 +286,11 @@ public class ShaderState {
* @see #glResetAllVertexAttributes
* @see ShaderProgram#glReplaceShader
*/
- public GLArrayData getAttribute(String name) {
+ public GLArrayData getAttribute(final String name) {
return activeAttribDataMap.get(name);
}
- public boolean isActiveAttribute(GLArrayData attribute) {
+ public boolean isActiveAttribute(final GLArrayData attribute) {
return attribute == activeAttribDataMap.get(attribute.getName());
}
@@ -313,7 +314,7 @@ public class ShaderState {
* @see #getAttribute(String)
* @see GLArrayData#associate(Object, boolean)
*/
- public void ownAttribute(GLArrayData attribute, boolean own) {
+ public void ownAttribute(final GLArrayData attribute, final boolean own) {
if(own) {
final int location = getCachedAttribLocation(attribute.getName());
if(0<=location) {
@@ -326,7 +327,7 @@ public class ShaderState {
attribute.associate(this, own);
}
- public boolean ownsAttribute(GLArrayData attribute) {
+ public boolean ownsAttribute(final GLArrayData attribute) {
return managedAttributes.contains(attribute);
}
@@ -343,7 +344,7 @@ public class ShaderState {
* @see #getAttribLocation(GL2ES2, String)
* @see #getCachedAttribLocation(String)
*/
- public void bindAttribLocation(GL2ES2 gl, int location, String name) {
+ public void bindAttribLocation(final GL2ES2 gl, final int location, final String name) {
if(null==shaderProgram) throw new GLException("No program is attached");
if(shaderProgram.linked()) throw new GLException("Program is already linked");
final Integer loc = new Integer(location);
@@ -366,7 +367,7 @@ public class ShaderState {
* @see #getCachedAttribLocation(String)
* @see #getAttribute(String)
*/
- public void bindAttribLocation(GL2ES2 gl, int location, GLArrayData data) {
+ public void bindAttribLocation(final GL2ES2 gl, final int location, final GLArrayData data) {
if(null==shaderProgram) throw new GLException("No program is attached");
if(shaderProgram.linked()) throw new GLException("Program is already linked");
final String name = data.getName();
@@ -391,7 +392,7 @@ public class ShaderState {
* @see #bindAttribLocation(GL2ES2, int, String)
* @see GL2ES2#glGetAttribLocation(int, String)
*/
- public int getAttribLocation(GL2ES2 gl, String name) {
+ public int getAttribLocation(final GL2ES2 gl, final String name) {
if(null==shaderProgram) throw new GLException("No program is attached");
int location = getCachedAttribLocation(name);
if(0>location) {
@@ -431,7 +432,7 @@ public class ShaderState {
* @see GL2ES2#glGetAttribLocation(int, String)
* @see #getAttribute(String)
*/
- public int getAttribLocation(GL2ES2 gl, GLArrayData data) {
+ public int getAttribLocation(final GL2ES2 gl, final GLArrayData data) {
if(null==shaderProgram) throw new GLException("No program is attached");
final String name = data.getName();
int location = getCachedAttribLocation(name);
@@ -441,7 +442,7 @@ public class ShaderState {
if(!shaderProgram.linked()) throw new GLException("Program is not linked");
location = data.setLocation(gl, shaderProgram.program());
if(0<=location) {
- Integer idx = new Integer(location);
+ final Integer idx = new Integer(location);
activeAttribLocationMap.put(name, idx);
if(DEBUG) {
System.err.println("ShaderState: glGetAttribLocation: "+name+", loc: "+location);
@@ -464,7 +465,7 @@ public class ShaderState {
/**
* @return true if the named attribute is enable
*/
- public final boolean isVertexAttribArrayEnabled(String name) {
+ public final boolean isVertexAttribArrayEnabled(final String name) {
final Boolean v = activedAttribEnabledMap.get(name);
return null != v && v.booleanValue();
}
@@ -472,11 +473,11 @@ public class ShaderState {
/**
* @return true if the {@link GLArrayData} attribute is enable
*/
- public final boolean isVertexAttribArrayEnabled(GLArrayData data) {
+ public final boolean isVertexAttribArrayEnabled(final GLArrayData data) {
return isVertexAttribArrayEnabled(data.getName());
}
- private boolean enableVertexAttribArray(GL2ES2 gl, String name, int location) {
+ private boolean enableVertexAttribArray(final GL2ES2 gl, final String name, int location) {
activedAttribEnabledMap.put(name, Boolean.TRUE);
if(0>location) {
location = getAttribLocation(gl, name);
@@ -515,7 +516,7 @@ public class ShaderState {
* @see #glVertexAttribPointer
* @see #getVertexAttribPointer
*/
- public boolean enableVertexAttribArray(GL2ES2 gl, String name) {
+ public boolean enableVertexAttribArray(final GL2ES2 gl, final String name) {
return enableVertexAttribArray(gl, name, -1);
}
@@ -541,7 +542,7 @@ public class ShaderState {
* @see #getVertexAttribPointer
* @see GLArrayDataEditable#enableBuffer(GL, boolean)
*/
- public boolean enableVertexAttribArray(GL2ES2 gl, GLArrayData data) {
+ public boolean enableVertexAttribArray(final GL2ES2 gl, final GLArrayData data) {
if(0 > data.getLocation()) {
getAttribLocation(gl, data);
} else {
@@ -551,7 +552,7 @@ public class ShaderState {
return enableVertexAttribArray(gl, data.getName(), data.getLocation());
}
- private boolean disableVertexAttribArray(GL2ES2 gl, String name, int location) {
+ private boolean disableVertexAttribArray(final GL2ES2 gl, final String name, int location) {
activedAttribEnabledMap.put(name, Boolean.FALSE);
if(0>location) {
location = getAttribLocation(gl, name);
@@ -591,7 +592,7 @@ public class ShaderState {
* @see #glVertexAttribPointer
* @see #getVertexAttribPointer
*/
- public boolean disableVertexAttribArray(GL2ES2 gl, String name) {
+ public boolean disableVertexAttribArray(final GL2ES2 gl, final String name) {
return disableVertexAttribArray(gl, name, -1);
}
@@ -616,7 +617,7 @@ public class ShaderState {
* @see #glVertexAttribPointer
* @see #getVertexAttribPointer
*/
- public boolean disableVertexAttribArray(GL2ES2 gl, GLArrayData data) {
+ public boolean disableVertexAttribArray(final GL2ES2 gl, final GLArrayData data) {
if(0 > data.getLocation()) {
getAttribLocation(gl, data);
}
@@ -641,7 +642,7 @@ public class ShaderState {
* @see #glVertexAttribPointer
* @see #getVertexAttribPointer
*/
- public boolean vertexAttribPointer(GL2ES2 gl, GLArrayData data) {
+ public boolean vertexAttribPointer(final GL2ES2 gl, final GLArrayData data) {
int location = data.getLocation();
if(0 > location) {
location = getAttribLocation(gl, data);
@@ -670,12 +671,12 @@ public class ShaderState {
* @see #glResetAllVertexAttributes
* @see ShaderProgram#glReplaceShader
*/
- public void releaseAllAttributes(GL2ES2 gl) {
+ public void releaseAllAttributes(final GL2ES2 gl) {
if(null!=shaderProgram) {
- for(Iterator<GLArrayData> iter = activeAttribDataMap.values().iterator(); iter.hasNext(); ) {
+ for(final Iterator<GLArrayData> iter = activeAttribDataMap.values().iterator(); iter.hasNext(); ) {
disableVertexAttribArray(gl, iter.next());
}
- for(Iterator<String> iter = activedAttribEnabledMap.keySet().iterator(); iter.hasNext(); ) {
+ for(final Iterator<String> iter = activedAttribEnabledMap.keySet().iterator(); iter.hasNext(); ) {
disableVertexAttribArray(gl, iter.next());
}
}
@@ -702,8 +703,8 @@ public class ShaderState {
* @see #glResetAllVertexAttributes
* @see ShaderProgram#glReplaceShader
*/
- public void disableAllVertexAttributeArrays(GL2ES2 gl, boolean removeFromState) {
- for(Iterator<String> iter = activedAttribEnabledMap.keySet().iterator(); iter.hasNext(); ) {
+ public void disableAllVertexAttributeArrays(final GL2ES2 gl, final boolean removeFromState) {
+ for(final Iterator<String> iter = activedAttribEnabledMap.keySet().iterator(); iter.hasNext(); ) {
final String name = iter.next();
if(removeFromState) {
activedAttribEnabledMap.remove(name);
@@ -715,7 +716,7 @@ public class ShaderState {
}
}
- private final void relocateAttribute(GL2ES2 gl, GLArrayData attribute) {
+ private final void relocateAttribute(final GL2ES2 gl, final GLArrayData attribute) {
// get new location .. note: 'activeAttribLocationMap' is cleared before
final String name = attribute.getName();
final int loc = attribute.setLocation(gl, shaderProgram.program());
@@ -760,19 +761,19 @@ public class ShaderState {
*
* @see #attachShaderProgram(GL2ES2, ShaderProgram)
*/
- private final void resetAllAttributes(GL2ES2 gl) {
+ private final void resetAllAttributes(final GL2ES2 gl) {
if(!shaderProgram.linked()) throw new GLException("Program is not linked");
activeAttribLocationMap.clear();
for(int i=0; i<managedAttributes.size(); i++) {
managedAttributes.get(i).setLocation(-1);
}
- for(Iterator<GLArrayData> iter = activeAttribDataMap.values().iterator(); iter.hasNext(); ) {
+ for(final Iterator<GLArrayData> iter = activeAttribDataMap.values().iterator(); iter.hasNext(); ) {
relocateAttribute(gl, iter.next());
}
}
- private final void setAttribute(GL2ES2 gl, GLArrayData attribute) {
+ private final void setAttribute(final GL2ES2 gl, final GLArrayData attribute) {
// get new location ..
final String name = attribute.getName();
final int loc = attribute.getLocation();
@@ -798,8 +799,8 @@ public class ShaderState {
/**
* preserves the attribute location .. (program not linked)
*/
- private final void setAllAttributes(GL2ES2 gl) {
- for(Iterator<GLArrayData> iter = activeAttribDataMap.values().iterator(); iter.hasNext(); ) {
+ private final void setAllAttributes(final GL2ES2 gl) {
+ for(final Iterator<GLArrayData> iter = activeAttribDataMap.values().iterator(); iter.hasNext(); ) {
setAttribute(gl, iter.next());
}
}
@@ -814,8 +815,8 @@ public class ShaderState {
* @return -1 if there is no such uniform available,
* otherwise >= 0
*/
- public final int getCachedUniformLocation(String name) {
- Integer idx = activeUniformLocationMap.get(name);
+ public final int getCachedUniformLocation(final String name) {
+ final Integer idx = activeUniformLocationMap.get(name);
return (null!=idx)?idx.intValue():-1;
}
@@ -833,7 +834,7 @@ public class ShaderState {
*
* @see #getUniform(String)
*/
- public void ownUniform(GLUniformData uniform) {
+ public void ownUniform(final GLUniformData uniform) {
final int location = getCachedUniformLocation(uniform.getName());
if(0<=location) {
uniform.setLocation(location);
@@ -842,7 +843,7 @@ public class ShaderState {
managedUniforms.add(uniform);
}
- public boolean ownsUniform(GLUniformData uniform) {
+ public boolean ownsUniform(final GLUniformData uniform) {
return managedUniforms.contains(uniform);
}
@@ -865,14 +866,14 @@ public class ShaderState {
* @see #getUniformLocation
* @see ShaderProgram#glReplaceShader
*/
- public final int getUniformLocation(GL2ES2 gl, String name) {
+ public final int getUniformLocation(final GL2ES2 gl, final String name) {
if(!shaderProgram.inUse()) throw new GLException("Program is not in use");
int location = getCachedUniformLocation(name);
if(0>location) {
if(!shaderProgram.linked()) throw new GLException("Program is not linked");
location = gl.glGetUniformLocation(shaderProgram.program(), name);
if(0<=location) {
- Integer idx = new Integer(location);
+ final Integer idx = new Integer(location);
activeUniformLocationMap.put(name, idx);
} else if(verbose) {
System.err.println("ShaderState: glUniform failed, no location for: "+name+", index: "+location);
@@ -904,7 +905,7 @@ public class ShaderState {
* @see #getUniformLocation
* @see ShaderProgram#glReplaceShader
*/
- public int getUniformLocation(GL2ES2 gl, GLUniformData data) {
+ public int getUniformLocation(final GL2ES2 gl, final GLUniformData data) {
if(!shaderProgram.inUse()) throw new GLException("Program is not in use");
final String name = data.getName();
int location = getCachedUniformLocation(name);
@@ -942,7 +943,7 @@ public class ShaderState {
* @see #getUniformLocation
* @see ShaderProgram#glReplaceShader
*/
- public boolean uniform(GL2ES2 gl, GLUniformData data) {
+ public boolean uniform(final GL2ES2 gl, final GLUniformData data) {
if(!shaderProgram.inUse()) throw new GLException("Program is not in use");
int location = data.getLocation();
if(0>location) {
@@ -964,7 +965,7 @@ public class ShaderState {
*
* @return the GLUniformData object, null if not previously set.
*/
- public GLUniformData getUniform(String name) {
+ public GLUniformData getUniform(final String name) {
return activeUniformDataMap.get(name);
}
@@ -972,7 +973,7 @@ public class ShaderState {
* Releases all mapped uniform data
* and loses all indices
*/
- public void releaseAllUniforms(GL2ES2 gl) {
+ public void releaseAllUniforms(final GL2ES2 gl) {
activeUniformDataMap.clear();
activeUniformLocationMap.clear();
managedUniforms.clear();
@@ -993,13 +994,13 @@ public class ShaderState {
*
* @see #attachShaderProgram(GL2ES2, ShaderProgram)
*/
- private final void resetAllUniforms(GL2ES2 gl) {
+ private final void resetAllUniforms(final GL2ES2 gl) {
if(!shaderProgram.inUse()) throw new GLException("Program is not in use");
activeUniformLocationMap.clear();
- for(Iterator<GLUniformData> iter = managedUniforms.iterator(); iter.hasNext(); ) {
+ for(final Iterator<GLUniformData> iter = managedUniforms.iterator(); iter.hasNext(); ) {
iter.next().setLocation(-1);
}
- for(Iterator<GLUniformData> iter = activeUniformDataMap.values().iterator(); iter.hasNext(); ) {
+ for(final Iterator<GLUniformData> iter = activeUniformDataMap.values().iterator(); iter.hasNext(); ) {
final GLUniformData data = iter.next();
final int loc = data.setLocation(gl, shaderProgram.program());
if( 0 <= loc ) {
@@ -1013,7 +1014,7 @@ public class ShaderState {
}
}
- public StringBuilder toString(StringBuilder sb, boolean alsoUnlocated) {
+ public StringBuilder toString(StringBuilder sb, final boolean alsoUnlocated) {
if(null==sb) {
sb = new StringBuilder();
}
@@ -1028,35 +1029,35 @@ public class ShaderState {
}
sb.append(Platform.getNewline()).append(" enabledAttributes [");
{
- Iterator<String> names = activedAttribEnabledMap.keySet().iterator();
- Iterator<Boolean> values = activedAttribEnabledMap.values().iterator();
+ final Iterator<String> names = activedAttribEnabledMap.keySet().iterator();
+ final Iterator<Boolean> values = activedAttribEnabledMap.values().iterator();
while( names.hasNext() ) {
sb.append(Platform.getNewline()).append(" ").append(names.next()).append(": ").append(values.next());
}
}
sb.append(Platform.getNewline()).append(" ],").append(" activeAttributes [");
- for(Iterator<GLArrayData> iter = activeAttribDataMap.values().iterator(); iter.hasNext(); ) {
+ for(final Iterator<GLArrayData> iter = activeAttribDataMap.values().iterator(); iter.hasNext(); ) {
final GLArrayData ad = iter.next();
if( alsoUnlocated || 0 <= ad.getLocation() ) {
sb.append(Platform.getNewline()).append(" ").append(ad);
}
}
sb.append(Platform.getNewline()).append(" ],").append(" managedAttributes [");
- for(Iterator<GLArrayData> iter = managedAttributes.iterator(); iter.hasNext(); ) {
+ for(final Iterator<GLArrayData> iter = managedAttributes.iterator(); iter.hasNext(); ) {
final GLArrayData ad = iter.next();
if( alsoUnlocated || 0 <= ad.getLocation() ) {
sb.append(Platform.getNewline()).append(" ").append(ad);
}
}
sb.append(Platform.getNewline()).append(" ],").append(" activeUniforms [");
- for(Iterator<GLUniformData> iter=activeUniformDataMap.values().iterator(); iter.hasNext(); ) {
+ for(final Iterator<GLUniformData> iter=activeUniformDataMap.values().iterator(); iter.hasNext(); ) {
final GLUniformData ud = iter.next();
if( alsoUnlocated || 0 <= ud.getLocation() ) {
sb.append(Platform.getNewline()).append(" ").append(ud);
}
}
sb.append(Platform.getNewline()).append(" ],").append(" managedUniforms [");
- for(Iterator<GLUniformData> iter = managedUniforms.iterator(); iter.hasNext(); ) {
+ for(final Iterator<GLUniformData> iter = managedUniforms.iterator(); iter.hasNext(); ) {
final GLUniformData ud = iter.next();
if( alsoUnlocated || 0 <= ud.getLocation() ) {
sb.append(Platform.getNewline()).append(" ").append(ud);
diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java
index ad5331a28..b927e8ceb 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java
@@ -43,49 +43,49 @@ import com.jogamp.common.nio.Buffers;
import com.jogamp.opengl.GLExtensions;
public class ShaderUtil {
- public static String getShaderInfoLog(GL _gl, int shaderObj) {
+ public static String getShaderInfoLog(final GL _gl, final int shaderObj) {
final GL2ES2 gl = _gl.getGL2ES2();
- int[] infoLogLength=new int[1];
+ final int[] infoLogLength=new int[1];
gl.glGetShaderiv(shaderObj, GL2ES2.GL_INFO_LOG_LENGTH, infoLogLength, 0);
if(infoLogLength[0]==0) {
return "(no info log)";
}
- int[] charsWritten=new int[1];
- byte[] infoLogBytes = new byte[infoLogLength[0]];
+ final int[] charsWritten=new int[1];
+ final byte[] infoLogBytes = new byte[infoLogLength[0]];
gl.glGetShaderInfoLog(shaderObj, infoLogLength[0], charsWritten, 0, infoLogBytes, 0);
return new String(infoLogBytes, 0, charsWritten[0]);
}
- public static String getProgramInfoLog(GL _gl, int programObj) {
+ public static String getProgramInfoLog(final GL _gl, final int programObj) {
final GL2ES2 gl = _gl.getGL2ES2();
- int[] infoLogLength=new int[1];
+ final int[] infoLogLength=new int[1];
gl.glGetProgramiv(programObj, GL2ES2.GL_INFO_LOG_LENGTH, infoLogLength, 0);
if(infoLogLength[0]==0) {
return "(no info log)";
}
- int[] charsWritten=new int[1];
- byte[] infoLogBytes = new byte[infoLogLength[0]];
+ final int[] charsWritten=new int[1];
+ final byte[] infoLogBytes = new byte[infoLogLength[0]];
gl.glGetProgramInfoLog(programObj, infoLogLength[0], charsWritten, 0, infoLogBytes, 0);
return new String(infoLogBytes, 0, charsWritten[0]);
}
- public static boolean isShaderStatusValid(GL _gl, int shaderObj, int name, PrintStream verboseOut) {
+ public static boolean isShaderStatusValid(final GL _gl, final int shaderObj, final int name, final PrintStream verboseOut) {
final GL2ES2 gl = _gl.getGL2ES2();
- int[] ires = new int[1];
+ final int[] ires = new int[1];
gl.glGetShaderiv(shaderObj, name, ires, 0);
- boolean res = ires[0]==1;
+ final boolean res = ires[0]==1;
if(!res && null!=verboseOut) {
verboseOut.println("Shader status invalid: "+ getShaderInfoLog(gl, shaderObj));
}
return res;
}
- public static boolean isShaderStatusValid(GL _gl, IntBuffer shaders, int name, PrintStream verboseOut) {
+ public static boolean isShaderStatusValid(final GL _gl, final IntBuffer shaders, final int name, final PrintStream verboseOut) {
boolean res = true;
for (int i = shaders.position(); i < shaders.limit(); i++) {
res = isShaderStatusValid(_gl, shaders.get(i), name, verboseOut) && res;
@@ -93,15 +93,15 @@ public class ShaderUtil {
return res;
}
- public static boolean isProgramStatusValid(GL _gl, int programObj, int name) {
+ public static boolean isProgramStatusValid(final GL _gl, final int programObj, final int name) {
final GL2ES2 gl = _gl.getGL2ES2();
- int[] ires = new int[1];
+ final int[] ires = new int[1];
gl.glGetProgramiv(programObj, name, ires, 0);
return ires[0]==1;
}
- public static boolean isProgramLinkStatusValid(GL _gl, int programObj, PrintStream verboseOut) {
+ public static boolean isProgramLinkStatusValid(final GL _gl, final int programObj, final PrintStream verboseOut) {
final GL2ES2 gl = _gl.getGL2ES2();
if(!gl.glIsProgram(programObj)) {
if(null!=verboseOut) {
@@ -130,7 +130,7 @@ public class ShaderUtil {
* </p>
* @see GL2ES2#glValidateProgram(int)
**/
- public static boolean isProgramExecStatusValid(GL _gl, int programObj, PrintStream verboseOut) {
+ public static boolean isProgramExecStatusValid(final GL _gl, final int programObj, final PrintStream verboseOut) {
final GL2ES2 gl = _gl.getGL2ES2();
gl.glValidateProgram(programObj);
if(!isProgramStatusValid(gl, programObj, GL2ES2.GL_VALIDATE_STATUS)) {
@@ -142,7 +142,7 @@ public class ShaderUtil {
return true;
}
- public static void createShader(GL _gl, int type, IntBuffer shaders) {
+ public static void createShader(final GL _gl, final int type, final IntBuffer shaders) {
final GL2ES2 gl = _gl.getGL2ES2();
for (int i = shaders.position(); i < shaders.limit(); i++) {
shaders.put(i, gl.glCreateShader(type));
@@ -154,7 +154,7 @@ public class ShaderUtil {
* {@link GL2ES2#GL_NUM_SHADER_BINARY_FORMATS} and {@link GL2ES2#GL_SHADER_BINARY_FORMATS}
* via {@link GL2ES2#glGetIntegerv(int, int[], int)}.
*/
- public static Set<Integer> getShaderBinaryFormats(GL _gl) {
+ public static Set<Integer> getShaderBinaryFormats(final GL _gl) {
final GL2ES2 gl = _gl.getGL2ES2();
final ProfileInformation info = getProfileInformation(gl);
if(null == info.shaderBinaryFormats) {
@@ -166,13 +166,13 @@ public class ShaderUtil {
final int err = gl.glGetError();
final int numFormats = GL.GL_NO_ERROR == err ? param[0] : 0;
if(numFormats>0) {
- int[] formats = new int[numFormats];
+ final int[] formats = new int[numFormats];
gl.glGetIntegerv(GL2ES2.GL_SHADER_BINARY_FORMATS, formats, 0);
for(int i=0; i<numFormats; i++) {
info.shaderBinaryFormats.add(new Integer(formats[i]));
}
}
- } catch (GLException gle) {
+ } catch (final GLException gle) {
System.err.println("Caught exception on thread "+Thread.currentThread().getName());
gle.printStackTrace();
}
@@ -182,7 +182,7 @@ public class ShaderUtil {
}
/** Returns true if a hader compiler is available, otherwise false. */
- public static boolean isShaderCompilerAvailable(GL _gl) {
+ public static boolean isShaderCompilerAvailable(final GL _gl) {
final GL2ES2 gl = _gl.getGL2ES2();
final ProfileInformation info = getProfileInformation(gl);
if(null==info.shaderCompilerAvailable) {
@@ -202,7 +202,7 @@ public class ShaderUtil {
}
info.shaderCompilerAvailable = new Boolean(v);
queryOK = true;
- } catch (GLException gle) {
+ } catch (final GLException gle) {
System.err.println("Caught exception on thread "+Thread.currentThread().getName());
gle.printStackTrace();
}
@@ -219,25 +219,25 @@ public class ShaderUtil {
}
/** Returns true if GeometryShader is supported, i.e. whether GLContext is &ge; 3.2 or ARB_geometry_shader4 extension is available. */
- public static boolean isGeometryShaderSupported(GL _gl) {
+ public static boolean isGeometryShaderSupported(final GL _gl) {
final GLContext ctx = _gl.getContext();
return ctx.getGLVersionNumber().compareTo(GLContext.Version320) >= 0 ||
ctx.isExtensionAvailable(GLExtensions.ARB_geometry_shader4);
}
- public static void shaderSource(GL _gl, int shader, CharSequence[] source)
+ public static void shaderSource(final GL _gl, final int shader, final CharSequence[] source)
{
final GL2ES2 gl = _gl.getGL2ES2();
if(!isShaderCompilerAvailable(_gl)) {
throw new GLException("No compiler is available");
}
- int count = (null!=source)?source.length:0;
+ final int count = (null!=source)?source.length:0;
if(count==0) {
throw new GLException("No sources specified");
}
- IntBuffer lengths = Buffers.newDirectIntBuffer(count);
+ final IntBuffer lengths = Buffers.newDirectIntBuffer(count);
for(int i=0; i<count; i++) {
lengths.put(i, source[i].length());
}
@@ -260,10 +260,10 @@ public class ShaderUtil {
}
}
- public static void shaderSource(GL _gl, IntBuffer shaders, CharSequence[][] sources)
+ public static void shaderSource(final GL _gl, final IntBuffer shaders, final CharSequence[][] sources)
{
- int sourceNum = (null!=sources)?sources.length:0;
- int shaderNum = (null!=shaders)?shaders.remaining():0;
+ final int sourceNum = (null!=sources)?sources.length:0;
+ final int shaderNum = (null!=shaders)?shaders.remaining():0;
if(shaderNum<=0 || sourceNum<=0 || shaderNum!=sourceNum) {
throw new GLException("Invalid number of shaders and/or sources: shaders="+
shaderNum+", sources="+sourceNum);
@@ -273,28 +273,28 @@ public class ShaderUtil {
}
}
- public static void shaderBinary(GL _gl, IntBuffer shaders, int binFormat, java.nio.Buffer bin)
+ public static void shaderBinary(final GL _gl, final IntBuffer shaders, final int binFormat, final java.nio.Buffer bin)
{
final GL2ES2 gl = _gl.getGL2ES2();
if(getShaderBinaryFormats(gl).size()<=0) {
throw new GLException("No binary formats are supported");
}
- int shaderNum = shaders.remaining();
+ final int shaderNum = shaders.remaining();
if(shaderNum<=0) {
throw new GLException("No shaders specified");
}
if(null==bin) {
throw new GLException("Null shader binary");
}
- int binLength = bin.remaining();
+ final int binLength = bin.remaining();
if(0>=binLength) {
throw new GLException("Empty shader binary (remaining == 0)");
}
gl.glShaderBinary(shaderNum, shaders, binFormat, bin, binLength);
}
- public static void compileShader(GL _gl, IntBuffer shaders)
+ public static void compileShader(final GL _gl, final IntBuffer shaders)
{
final GL2ES2 gl = _gl.getGL2ES2();
for (int i = shaders.position(); i < shaders.limit(); i++) {
@@ -302,7 +302,7 @@ public class ShaderUtil {
}
}
- public static void attachShader(GL _gl, int program, IntBuffer shaders)
+ public static void attachShader(final GL _gl, final int program, final IntBuffer shaders)
{
final GL2ES2 gl = _gl.getGL2ES2();
for (int i = shaders.position(); i < shaders.limit(); i++) {
@@ -310,7 +310,7 @@ public class ShaderUtil {
}
}
- public static void detachShader(GL _gl, int program, IntBuffer shaders)
+ public static void detachShader(final GL _gl, final int program, final IntBuffer shaders)
{
final GL2ES2 gl = _gl.getGL2ES2();
for (int i = shaders.position(); i < shaders.limit(); i++) {
@@ -318,7 +318,7 @@ public class ShaderUtil {
}
}
- public static void deleteShader(GL _gl, IntBuffer shaders)
+ public static void deleteShader(final GL _gl, final IntBuffer shaders)
{
final GL2ES2 gl = _gl.getGL2ES2();
for (int i = shaders.position(); i < shaders.limit(); i++) {
@@ -327,9 +327,9 @@ public class ShaderUtil {
}
}
- public static boolean createAndLoadShader(GL _gl, IntBuffer shader, int shaderType,
- int binFormat, java.nio.Buffer bin,
- PrintStream verboseOut)
+ public static boolean createAndLoadShader(final GL _gl, final IntBuffer shader, final int shaderType,
+ final int binFormat, final java.nio.Buffer bin,
+ final PrintStream verboseOut)
{
final GL2ES2 gl = _gl.getGL2ES2();
int err = gl.glGetError(); // flush previous errors ..
@@ -352,9 +352,9 @@ public class ShaderUtil {
return err == GL.GL_NO_ERROR;
}
- public static boolean createAndCompileShader(GL _gl, IntBuffer shader, int shaderType,
- CharSequence[][] sources,
- PrintStream verboseOut)
+ public static boolean createAndCompileShader(final GL _gl, final IntBuffer shader, final int shaderType,
+ final CharSequence[][] sources,
+ final PrintStream verboseOut)
{
final GL2ES2 gl = _gl.getGL2ES2();
int err = gl.glGetError(); // flush previous errors ..
@@ -390,7 +390,7 @@ public class ShaderUtil {
Set<Integer> shaderBinaryFormats = null;
}
- private static ProfileInformation getProfileInformation(GL gl) {
+ private static ProfileInformation getProfileInformation(final GL gl) {
final GLContext context = gl.getContext();
context.validateCurrent();
ProfileInformation data = (ProfileInformation) context.getAttachedObject(implObjectKey);
diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java
index 2f8884a3a..1ed875f27 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java
@@ -37,7 +37,7 @@ public class FixedFuncUtil {
* @see ShaderSelectionMode#COLOR_TEXTURE
* @see ShaderSelectionMode#COLOR_TEXTURE_LIGHT_PER_VERTEX
*/
- public static final GL2ES1 wrapFixedFuncEmul(GL gl, ShaderSelectionMode mode, PMVMatrix pmvMatrix, boolean force, boolean verbose) {
+ public static final GL2ES1 wrapFixedFuncEmul(final GL gl, final ShaderSelectionMode mode, final PMVMatrix pmvMatrix, final boolean force, final boolean verbose) {
if(gl.isGL2ES2() && ( !gl.isGL2ES1() || force ) ) {
final GL2ES2 es2 = gl.getGL2ES2();
final FixedFuncHook hook = new FixedFuncHook(es2, mode, pmvMatrix);
@@ -66,7 +66,7 @@ public class FixedFuncUtil {
* @see ShaderSelectionMode#COLOR_TEXTURE
* @see ShaderSelectionMode#COLOR_TEXTURE_LIGHT_PER_VERTEX
*/
- public static final GL2ES1 wrapFixedFuncEmul(GL gl, ShaderSelectionMode mode, PMVMatrix pmvMatrix) {
+ public static final GL2ES1 wrapFixedFuncEmul(final GL gl, final ShaderSelectionMode mode, final PMVMatrix pmvMatrix) {
return wrapFixedFuncEmul(gl, mode, null, false, false);
}
@@ -90,7 +90,7 @@ public class FixedFuncUtil {
* @see javax.media.opengl.fixedfunc.GLPointerFunc#glNormalPointer
* @see javax.media.opengl.fixedfunc.GLPointerFunc#glTexCoordPointer
*/
- public static String getPredefinedArrayIndexName(int glArrayIndex) {
+ public static String getPredefinedArrayIndexName(final int glArrayIndex) {
return GLPointerFuncUtil.getPredefinedArrayIndexName(glArrayIndex);
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShader.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShader.java
index 44fbf1c6d..f113be2b2 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShader.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShader.java
@@ -30,7 +30,7 @@ public abstract class CompileShader {
public abstract String getFragmentShaderCompiler();
- public void processOneShader(String resourceName)
+ public void processOneShader(final String resourceName)
throws IOException, UnsupportedEncodingException, InterruptedException
{
int type = -1;
@@ -49,11 +49,11 @@ public abstract class CompileShader {
suffixLen = 4;
type = GL2ES2.GL_VERTEX_SHADER;
}
- String justName = basename(resourceName);
+ final String justName = basename(resourceName);
outName = justName.substring(0, justName.length() - suffixLen) +
ShaderCode.getFileSuffix(true, type);
- URL resourceURL = IOUtil.getResource(null, resourceName).getURL();
- String dirName = dirname(resourceURL.getPath());
+ final URL resourceURL = IOUtil.getResource(null, resourceName).getURL();
+ final String dirName = dirname(resourceURL.getPath());
outName = dirName + File.separator + "bin" + File.separator +
ShaderCode.getBinarySubPath(getBinaryFormat()) + File.separator +
@@ -61,19 +61,19 @@ public abstract class CompileShader {
processOneShader(resourceName, outName, type);
}
- public void processOneShader(String resourceName, String outName, int type)
+ public void processOneShader(final String resourceName, final String outName, final int type)
throws IOException, UnsupportedEncodingException, InterruptedException
{
- URL resourceURL = IOUtil.getResource(null, resourceName).getURL();
- String dirName = dirname(resourceURL.getPath());
+ final URL resourceURL = IOUtil.getResource(null, resourceName).getURL();
+ final String dirName = dirname(resourceURL.getPath());
- CharSequence shader = ShaderCode.readShaderSource(null, resourceName, false);
+ final CharSequence shader = ShaderCode.readShaderSource(null, resourceName, false);
if(null==shader) {
System.err.println("Can't find shader source " + resourceName + " - ignored");
return;
}
System.err.println("Preprocessing: "+ resourceName+", in dir: "+dirName);
- String justName = basename(resourceName);
+ final String justName = basename(resourceName);
String processor;
switch (type) {
case GL2ES2.GL_VERTEX_SHADER:
@@ -85,26 +85,26 @@ public abstract class CompileShader {
default:
throw new GLException("Unknown shader type: "+type);
}
- File outputFile = new File(outName);
+ final File outputFile = new File(outName);
// Write shader to a file in java.io.tmpdir
- File tmpDir = new File(dirName+File.separator+"tmp");
+ final File tmpDir = new File(dirName+File.separator+"tmp");
tmpDir.mkdirs();
- File tmpFile = new File(tmpDir, justName);
- Writer writer = new BufferedWriter(new FileWriter(tmpFile));
+ final File tmpFile = new File(tmpDir, justName);
+ final Writer writer = new BufferedWriter(new FileWriter(tmpFile));
writer.write(shader.toString(), 0, shader.length());
writer.flush();
writer.close();
System.err.println("Preprocessed: "+ tmpFile.getAbsolutePath());
- File processorDir = getSDKCompilerDir();
+ final File processorDir = getSDKCompilerDir();
System.err.println("SDK: "+ processorDir.getAbsolutePath() + ", compiler: "+processor);
System.err.println("Output: "+ outputFile.getAbsolutePath());
// Run the tool
- Process process = Runtime.getRuntime().exec(new String[] {
+ final Process process = Runtime.getRuntime().exec(new String[] {
processorDir.getAbsolutePath() + File.separator + processor,
tmpFile.getAbsolutePath(),
outputFile.getAbsolutePath()
@@ -116,7 +116,7 @@ public abstract class CompileShader {
// tmpFile.delete();
}
- protected static String basename(String path) {
+ protected static String basename(final String path) {
int lastSlash = path.lastIndexOf("/");
if (lastSlash < 0) {
lastSlash = path.lastIndexOf("\\");
@@ -130,7 +130,7 @@ public abstract class CompileShader {
return basename;
}
- protected static String dirname(String path) {
+ protected static String dirname(final String path) {
int lastSlash = path.lastIndexOf("/");
if (lastSlash < 0) {
lastSlash = path.lastIndexOf("\\");
@@ -144,19 +144,19 @@ public abstract class CompileShader {
return dirname;
}
- public void run(String[] args) {
+ public void run(final String[] args) {
try {
for (int i = 0; i < args.length; i++) {
processOneShader(args[i]);
}
- } catch (Exception e) {
+ } catch (final Exception e) {
e.printStackTrace();
}
}
private static class StreamMonitor implements Runnable {
- private InputStream istream;
- public StreamMonitor(InputStream stream) {
+ private final InputStream istream;
+ public StreamMonitor(final InputStream stream) {
istream = stream;
new Thread(this, "Output Reader Thread").start();
}
@@ -164,7 +164,7 @@ public abstract class CompileShader {
@Override
public void run()
{
- byte[] buffer = new byte[4096];
+ final byte[] buffer = new byte[4096];
try {
int numRead = 0;
do {
@@ -175,10 +175,10 @@ public abstract class CompileShader {
}
} while (numRead >= 0);
}
- catch (IOException e) {
+ catch (final IOException e) {
try {
istream.close();
- } catch (IOException e2) {
+ } catch (final IOException e2) {
}
// Should allow clean exit when process shuts down
}
diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShaderNVidia.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShaderNVidia.java
index 215cf592b..9ff37c7ee 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShaderNVidia.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShaderNVidia.java
@@ -13,7 +13,7 @@ public class CompileShaderNVidia extends CompileShader {
private static final String NVAPSDK;
static {
- String nvapSDKProp = System.getProperty("NVAPSDK");
+ final String nvapSDKProp = System.getProperty("NVAPSDK");
if (nvapSDKProp != null) {
NVAPSDK = nvapSDKProp;
} else {
@@ -51,7 +51,7 @@ public class CompileShaderNVidia extends CompileShader {
return "glslf.bat";
}
- public static void main(String[] args) {
+ public static void main(final String[] args) {
new CompileShaderNVidia().run(args);
}
}