diff options
author | Harvey Harrison <[email protected]> | 2013-10-17 22:27:27 -0700 |
---|---|---|
committer | Harvey Harrison <[email protected]> | 2013-10-17 22:27:27 -0700 |
commit | 5e9c02bce7b241a0bf95c8abca9a91cd25e51ed3 (patch) | |
tree | 78e913afc74a64e519d69dfb9aa886dd41ec16ed /src/jogl/classes/jogamp/opengl/util/glsl | |
parent | 2ebf1bf35928e35ded6e38df64dee7aa578ae3c7 (diff) |
jogl: remove all trailing whitespace
Signed-off-by: Harvey Harrison <[email protected]>
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/util/glsl')
6 files changed, 209 insertions, 209 deletions
diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java index 3c468f358..2d74fa532 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java +++ b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandler.java @@ -41,23 +41,23 @@ import com.jogamp.opengl.util.GLArrayDataEditable; import com.jogamp.opengl.util.glsl.ShaderState; /** - * Used for 1:1 GLSL arrays, i.e. where the buffer data - * represents this array only. + * Used for 1:1 GLSL arrays, i.e. where the buffer data + * represents this array only. */ -public class GLSLArrayHandler extends GLVBOArrayHandler implements GLArrayHandler { - +public class GLSLArrayHandler extends GLVBOArrayHandler implements GLArrayHandler { + public GLSLArrayHandler(GLArrayDataEditable ad) { super(ad); } - + public final void setSubArrayVBOName(int vboName) { throw new UnsupportedOperationException(); } - + public final void addSubHandler(GLArrayHandlerFlat handler) { throw new UnsupportedOperationException(); } - + public final void enableState(GL gl, boolean enable, Object ext) { final GL2ES2 glsl = gl.getGL2ES2(); if( null != ext ) { @@ -66,12 +66,12 @@ public class GLSLArrayHandler extends GLVBOArrayHandler implements GLArrayHandle enableSimple(glsl, enable); } } - + private final void enableShaderState(GL2ES2 glsl, boolean enable, ShaderState st) { if(enable) { /* * This would be the non optimized code path: - * + * if(ad.isVBO()) { glsl.glBindBuffer(ad.getVBOTarget(), ad.getVBOName()); if(!ad.isVBOWritten()) { @@ -108,13 +108,13 @@ public class GLSLArrayHandler extends GLVBOArrayHandler implements GLArrayHandle } else if(null!=buffer) { st.vertexAttribPointer(glsl, ad); } - + st.enableVertexAttribArray(glsl, ad); } else { st.disableVertexAttribArray(glsl, ad); } } - + private final void enableSimple(GL2ES2 glsl, boolean enable) { final int location = ad.getLocation(); if( 0 > location ) { @@ -123,7 +123,7 @@ public class GLSLArrayHandler extends GLVBOArrayHandler implements GLArrayHandle if(enable) { /* * This would be the non optimized code path: - * + * if(ad.isVBO()) { glsl.glBindBuffer(ad.getVBOTarget(), ad.getVBOName()); if(!ad.isVBOWritten()) { diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java index 855406db3..a5f78b5d6 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java +++ b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerFlat.java @@ -37,7 +37,7 @@ import com.jogamp.opengl.util.GLArrayDataWrapper; import com.jogamp.opengl.util.glsl.ShaderState; /** - * Used for interleaved GLSL arrays, i.e. where the buffer data itself is handled + * Used for interleaved GLSL arrays, i.e. where the buffer data itself is handled * separately and interleaves many arrays. */ public class GLSLArrayHandlerFlat implements GLArrayHandlerFlat { @@ -50,7 +50,7 @@ public class GLSLArrayHandlerFlat implements GLArrayHandlerFlat { public GLArrayDataWrapper getData() { return ad; } - + public final void syncData(GL gl, Object ext) { final GL2ES2 glsl = gl.getGL2ES2(); if( null != ext ) { @@ -62,7 +62,7 @@ public class GLSLArrayHandlerFlat implements GLArrayHandlerFlat { } /** * Due to probable application VBO switching, this might not make any sense .. - * + * if(!written) { st.vertexAttribPointer(glsl, ad); } else if(st.getAttribLocation(glsl, ad) >= 0) { @@ -94,7 +94,7 @@ public class GLSLArrayHandlerFlat implements GLArrayHandlerFlat { } else { glsl.glDisableVertexAttribArray(location); } - } + } } - } + } } diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java index c2048d652..bcc146d78 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java +++ b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLArrayHandlerInterleaved.java @@ -40,8 +40,8 @@ import jogamp.opengl.util.GLVBOArrayHandler; import com.jogamp.opengl.util.GLArrayDataEditable; /** - * Interleaved fixed function arrays, i.e. where this buffer data - * represents many arrays. + * Interleaved fixed function arrays, i.e. where this buffer data + * represents many arrays. */ public class GLSLArrayHandlerInterleaved extends GLVBOArrayHandler implements GLArrayHandler { private List<GLArrayHandlerFlat> subArrays = new ArrayList<GLArrayHandlerFlat>(); @@ -49,13 +49,13 @@ public class GLSLArrayHandlerInterleaved extends GLVBOArrayHandler implements GL public GLSLArrayHandlerInterleaved(GLArrayDataEditable ad) { super(ad); } - + public final void setSubArrayVBOName(int vboName) { for(int i=0; i<subArrays.size(); i++) { subArrays.get(i).getData().setVBOName(vboName); - } + } } - + public final void addSubHandler(GLArrayHandlerFlat handler) { subArrays.add(handler); } @@ -63,9 +63,9 @@ public class GLSLArrayHandlerInterleaved extends GLVBOArrayHandler implements GL private final void syncSubData(GL gl, Object ext) { for(int i=0; i<subArrays.size(); i++) { subArrays.get(i).syncData(gl, ext); - } - } - + } + } + public final void enableState(GL gl, boolean enable, Object ext) { if(enable) { if(!ad.isVBO()) { @@ -78,7 +78,7 @@ public class GLSLArrayHandlerInterleaved extends GLVBOArrayHandler implements GL } for(int i=0; i<subArrays.size(); i++) { subArrays.get(i).enableState(gl, enable, ext); - } + } } } diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLTextureRaster.java b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLTextureRaster.java index eaf8dc30a..dba408554 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLTextureRaster.java +++ b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLTextureRaster.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package jogamp.opengl.util.glsl; import java.nio.FloatBuffer; @@ -45,33 +45,33 @@ import javax.media.opengl.fixedfunc.GLMatrixFunc; public class GLSLTextureRaster { private final boolean textureVertFlipped; private final int textureUnit; - + private ShaderProgram sp; private PMVMatrix pmvMatrix; private GLUniformData pmvMatrixUniform; private GLUniformData activeTexUniform; private GLArrayDataServer interleavedVBO; - + public GLSLTextureRaster(int textureUnit, boolean textureVertFlipped) { this.textureVertFlipped = textureVertFlipped; this.textureUnit = textureUnit; } - + public int getTextureUnit() { return textureUnit; } static final String shaderBasename = "texture01_xxx"; static final String shaderSrcPath = "../../shader"; static final String shaderBinPath = "../../shader/bin"; - + public void init(GL2ES2 gl) { // Create & Compile the shader objects - final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(), + final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(), shaderSrcPath, shaderBinPath, shaderBasename, true); - final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(), + final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(), shaderSrcPath, shaderBinPath, shaderBasename, true); rsVp.defaultShaderCustomization(gl, true, true); rsFp.defaultShaderCustomization(gl, true, true); - + // Create & Link the shader program sp = new ShaderProgram(); sp.add(rsVp); @@ -80,13 +80,13 @@ public class GLSLTextureRaster { throw new GLException("Couldn't link program: "+sp); } sp.useProgram(gl, true); - + // setup mgl_PMVMatrix pmvMatrix = new PMVMatrix(); pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION); pmvMatrix.glLoadIdentity(); pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW); - pmvMatrix.glLoadIdentity(); + pmvMatrix.glLoadIdentity(); pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); // P, Mv if( pmvMatrixUniform.setLocation(gl, sp.program()) < 0 ) { throw new GLException("Couldn't locate "+pmvMatrixUniform+" in shader: "+sp); @@ -105,9 +105,9 @@ public class GLSLTextureRaster { } else { s_quadTexCoords = s_quadTexCoords00; } - + interleavedVBO = GLArrayDataServer.createGLSLInterleaved(3+2, GL.GL_FLOAT, false, 2*4, GL.GL_STATIC_DRAW); - { + { final GLArrayData vArrayData = interleavedVBO.addGLSLSubArray("mgl_Vertex", 3, GL.GL_ARRAY_BUFFER); if( vArrayData.setLocation(gl, sp.program()) < 0 ) { throw new GLException("Couldn't locate "+vArrayData+" in shader: "+sp); @@ -116,15 +116,15 @@ public class GLSLTextureRaster { if( tArrayData.setLocation(gl, sp.program()) < 0 ) { throw new GLException("Couldn't locate "+tArrayData+" in shader: "+sp); } - final FloatBuffer ib = (FloatBuffer)interleavedVBO.getBuffer(); + final FloatBuffer ib = (FloatBuffer)interleavedVBO.getBuffer(); for(int i=0; i<4; i++) { ib.put(s_quadVertices, i*3, 3); ib.put(s_quadTexCoords, i*2, 2); - } + } } interleavedVBO.seal(gl, true); interleavedVBO.enableBuffer(gl, false); - + sp.useProgram(gl, false); } @@ -133,14 +133,14 @@ public class GLSLTextureRaster { pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION); pmvMatrix.glLoadIdentity(); pmvMatrix.glOrthof(-1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 10.0f); - + pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); pmvMatrix.glLoadIdentity(); - + sp.useProgram(gl, true); gl.glUniform(pmvMatrixUniform); sp.useProgram(gl, false); - } + } } public void dispose(GL2ES2 gl) { @@ -162,34 +162,34 @@ public class GLSLTextureRaster { } public void display(GL2ES2 gl) { - if(null != sp) { - sp.useProgram(gl, true); + if(null != sp) { + sp.useProgram(gl, true); interleavedVBO.enableBuffer(gl, true); - + gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4); - - interleavedVBO.enableBuffer(gl, false); + + interleavedVBO.enableBuffer(gl, false); sp.useProgram(gl, false); } } - - private static final float[] s_quadVertices = { + + private static final float[] s_quadVertices = { -1f, -1f, 0f, // LB 1f, -1f, 0f, // RB -1f, 1f, 0f, // LT - 1f, 1f, 0f // RT + 1f, 1f, 0f // RT }; - private static final float[] s_quadTexCoords00 = { + private static final float[] s_quadTexCoords00 = { 0f, 0f, // LB 1f, 0f, // RB - 0f, 1f, // LT + 0f, 1f, // LT 1f, 1f // RT }; - private static final float[] s_quadTexCoords01 = { + private static final float[] s_quadTexCoords01 = { 0f, 1f, // LB 1f, 1f, // RB - 0f, 0f, // LT + 0f, 0f, // LT 1f, 0f // RT - }; + }; } diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java index 6d5b16def..d86940e04 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java +++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java @@ -77,7 +77,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun * @param mode TODO * @param pmvMatrix optional pass through PMVMatrix for the {@link FixedFuncHook} and {@link FixedFuncPipeline} */ - public FixedFuncHook(GL2ES2 gl, ShaderSelectionMode mode, PMVMatrix pmvMatrix, + public FixedFuncHook(GL2ES2 gl, ShaderSelectionMode mode, PMVMatrix pmvMatrix, Class<?> shaderRootClass, String shaderSrcRoot, String shaderBinRoot, String vertexColorFile, String vertexColorLightFile, String fragmentColorFile, String fragmentColorTextureFile) { @@ -90,14 +90,14 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun this.pmvMatrix = new PMVMatrix(); } - fixedFunction = new FixedFuncPipeline(this.gl, mode, this.pmvMatrix, shaderRootClass, shaderSrcRoot, + fixedFunction = new FixedFuncPipeline(this.gl, mode, this.pmvMatrix, shaderRootClass, shaderSrcRoot, shaderBinRoot, vertexColorFile, vertexColorLightFile, fragmentColorFile, fragmentColorTextureFile); } public boolean verbose() { return fixedFunction.verbose(); } public void setVerbose(boolean v) { fixedFunction.setVerbose(v); } - + public void destroy() { fixedFunction.destroy(gl); fixedFunction = null; @@ -111,16 +111,16 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun public PMVMatrix getMatrix() { return pmvMatrix; } // - // FixedFuncHookIf - hooks + // FixedFuncHookIf - hooks // public void glDrawArrays(int mode, int first, int count) { fixedFunction.glDrawArrays(gl, mode, first, count); } public void glDrawElements(int mode, int count, int type, java.nio.Buffer indices) { - fixedFunction.glDrawElements(gl, mode, count, type, indices); + fixedFunction.glDrawElements(gl, mode, count, type, indices); } public void glDrawElements(int mode, int count, int type, long indices_buffer_offset) { - fixedFunction.glDrawElements(gl, mode, count, type, indices_buffer_offset); + fixedFunction.glDrawElements(gl, mode, count, type, indices_buffer_offset); } public void glActiveTexture(int texture) { @@ -136,7 +136,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun if(fixedFunction.glEnable(cap, false)) { gl.glDisable(cap); } - } + } public void glGetFloatv(int pname, java.nio.FloatBuffer params) { if(PMVMatrix.isMatrixGetName(pname)) { pmvMatrix.glGetFloatv(pname, params); @@ -165,7 +165,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun } gl.glGetIntegerv(pname, params, params_offset); } - + public void glTexEnvi(int target, int pname, int value) { fixedFunction.glTexEnvi(target, pname, value); } @@ -179,7 +179,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun fixedFunction.glBindTexture(target, texture); gl.glBindTexture(target, texture); } - public void glTexImage2D(int target, int level, int internalformat, int width, int height, int border, + public void glTexImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, Buffer pixels) { // align internalformat w/ format, an ES2 requirement switch(internalformat) { @@ -212,8 +212,8 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun public void glPointParameterfv(int pname, java.nio.FloatBuffer params) { fixedFunction.glPointParameterfv(pname, params); } - - // + + // // MatrixIf // public int glGetMatrixMode() { @@ -253,29 +253,29 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun pmvMatrix.glScalef(x, y, z); } public void glOrtho(double left, double right, double bottom, double top, double near_val, double far_val) { - glOrthof((float) left, (float) right, (float) bottom, (float) top, (float) near_val, (float) far_val); + glOrthof((float) left, (float) right, (float) bottom, (float) top, (float) near_val, (float) far_val); } public void glOrthof(float left, float right, float bottom, float top, float zNear, float zFar) { pmvMatrix.glOrthof(left, right, bottom, top, zNear, zFar); } public void glFrustum(double left, double right, double bottom, double top, double zNear, double zFar) { - glFrustumf((float) left, (float) right, (float) bottom, (float) top, (float) zNear, (float) zFar); + glFrustumf((float) left, (float) right, (float) bottom, (float) top, (float) zNear, (float) zFar); } public void glFrustumf(float left, float right, float bottom, float top, float zNear, float zFar) { pmvMatrix.glFrustumf(left, right, bottom, top, zNear, zFar); } - // + // // LightingIf // public void glColor4f(float red, float green, float blue, float alpha) { fixedFunction.glColor4f(gl, red, green, blue, alpha); } - + public void glColor4ub(byte red, byte green, byte blue, byte alpha) { - glColor4f(ValueConv.byte_to_float(red, false), - ValueConv.byte_to_float(green, false), - ValueConv.byte_to_float(blue, false), + glColor4f(ValueConv.byte_to_float(red, false), + ValueConv.byte_to_float(green, false), + ValueConv.byte_to_float(blue, false), ValueConv.byte_to_float(alpha, false) ); } public void glLightfv(int light, int pname, java.nio.FloatBuffer params) { @@ -299,17 +299,17 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun // public void glShadeModel(int mode) { fixedFunction.glShadeModel(gl, mode); - } + } public void glAlphaFunc(int func, float ref) { fixedFunction.glAlphaFunc(func, ref); } - - /** ES2 supports CullFace implicit + + /** ES2 supports CullFace implicit public void glCullFace(int faceName) { fixedFunction.glCullFace(faceName); gl.glCullFace(faceName); } */ - + // // PointerIf // @@ -340,7 +340,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun } public void glVertexPointer(int size, int type, int stride, java.nio.Buffer pointer) { - glVertexPointer(GLArrayDataWrapper.createFixed(GL_VERTEX_ARRAY, size, type, GLBuffers.isGLTypeFixedPoint(type), stride, + glVertexPointer(GLArrayDataWrapper.createFixed(GL_VERTEX_ARRAY, size, type, GLBuffers.isGLTypeFixedPoint(type), stride, pointer, 0, 0, 0, GL.GL_ARRAY_BUFFER)); } public void glVertexPointer(int size, int type, int stride, long pointer_buffer_offset) { @@ -348,7 +348,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun if(vboName==0) { throw new GLException("no GL_ARRAY_BUFFER VBO bound"); } - glVertexPointer(GLArrayDataWrapper.createFixed(GL_VERTEX_ARRAY, size, type, GLBuffers.isGLTypeFixedPoint(type), stride, + glVertexPointer(GLArrayDataWrapper.createFixed(GL_VERTEX_ARRAY, size, type, GLBuffers.isGLTypeFixedPoint(type), stride, null, vboName, pointer_buffer_offset, GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER)); } @@ -368,7 +368,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun fixedFunction.glColorPointer(gl, array); } public void glColorPointer(int size, int type, int stride, java.nio.Buffer pointer) { - glColorPointer(GLArrayDataWrapper.createFixed(GL_COLOR_ARRAY, size, type, GLBuffers.isGLTypeFixedPoint(type), stride, + glColorPointer(GLArrayDataWrapper.createFixed(GL_COLOR_ARRAY, size, type, GLBuffers.isGLTypeFixedPoint(type), stride, pointer, 0, 0, 0, GL.GL_ARRAY_BUFFER)); } public void glColorPointer(int size, int type, int stride, long pointer_buffer_offset) { @@ -376,7 +376,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun if(vboName==0) { throw new GLException("no GL_ARRAY_BUFFER VBO bound"); } - glColorPointer(GLArrayDataWrapper.createFixed(GL_COLOR_ARRAY, size, type, GLBuffers.isGLTypeFixedPoint(type), stride, + glColorPointer(GLArrayDataWrapper.createFixed(GL_COLOR_ARRAY, size, type, GLBuffers.isGLTypeFixedPoint(type), stride, null, vboName, pointer_buffer_offset, GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER)); } @@ -399,7 +399,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun fixedFunction.glNormalPointer(gl, array); } public void glNormalPointer(int type, int stride, java.nio.Buffer pointer) { - glNormalPointer(GLArrayDataWrapper.createFixed(GL_NORMAL_ARRAY, 3, type, GLBuffers.isGLTypeFixedPoint(type), stride, + glNormalPointer(GLArrayDataWrapper.createFixed(GL_NORMAL_ARRAY, 3, type, GLBuffers.isGLTypeFixedPoint(type), stride, pointer, 0, 0, 0, GL.GL_ARRAY_BUFFER)); } public void glNormalPointer(int type, int stride, long pointer_buffer_offset) { @@ -407,7 +407,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun if(vboName==0) { throw new GLException("no GL_ARRAY_BUFFER VBO bound"); } - glNormalPointer(GLArrayDataWrapper.createFixed(GL_NORMAL_ARRAY, 3, type, GLBuffers.isGLTypeFixedPoint(type), stride, + glNormalPointer(GLArrayDataWrapper.createFixed(GL_NORMAL_ARRAY, 3, type, GLBuffers.isGLTypeFixedPoint(type), stride, null, vboName, pointer_buffer_offset, GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER)); } @@ -428,7 +428,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun } public void glTexCoordPointer(int size, int type, int stride, java.nio.Buffer pointer) { glTexCoordPointer( - GLArrayDataWrapper.createFixed(GL_TEXTURE_COORD_ARRAY, size, type, GLBuffers.isGLTypeFixedPoint(type), stride, + GLArrayDataWrapper.createFixed(GL_TEXTURE_COORD_ARRAY, size, type, GLBuffers.isGLTypeFixedPoint(type), stride, pointer, 0, 0, 0, GL.GL_ARRAY_BUFFER)); } public void glTexCoordPointer(int size, int type, int stride, long pointer_buffer_offset) { @@ -437,7 +437,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun throw new GLException("no GL_ARRAY_BUFFER VBO bound"); } glTexCoordPointer( - GLArrayDataWrapper.createFixed(GL_TEXTURE_COORD_ARRAY, size, type, GLBuffers.isGLTypeFixedPoint(type), stride, + GLArrayDataWrapper.createFixed(GL_TEXTURE_COORD_ARRAY, size, type, GLBuffers.isGLTypeFixedPoint(type), stride, null, vboName, pointer_buffer_offset, GL.GL_STATIC_DRAW, GL.GL_ARRAY_BUFFER) ); } diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java index 5349745ea..187fdb309 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java +++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java @@ -59,25 +59,25 @@ import com.jogamp.opengl.util.glsl.ShaderState; import com.jogamp.opengl.util.glsl.fixedfunc.ShaderSelectionMode; /** - * + * * <p> - * Note: Certain GL FFP state values (e.g.: alphaTestFunc and cullFace) - * are mapped to a lower number range so they can be stored in low precision storage, + * Note: Certain GL FFP state values (e.g.: alphaTestFunc and cullFace) + * are mapped to a lower number range so they can be stored in low precision storage, * i.e. in a 'lowp int' (GL ES2). * </p> */ public class FixedFuncPipeline { protected static final boolean DEBUG; - + static { Debug.initSingleton(); DEBUG = Debug.isPropertyDefined("jogl.debug.FixedFuncPipeline", true); } - + /** The maximum texture units which could be used, depending on {@link ShaderSelectionMode}. */ public static final int MAX_TEXTURE_UNITS = 8; public static final int MAX_LIGHTS = 8; - + public FixedFuncPipeline(GL2ES2 gl, ShaderSelectionMode mode, PMVMatrix pmvMatrix) { shaderRootClass = FixedFuncPipeline.class; shaderSrcRoot = shaderSrcRootDef; @@ -88,8 +88,8 @@ public class FixedFuncPipeline { fragmentColorTextureFile = fragmentColorTextureFileDef; init(gl, mode, pmvMatrix); } - public FixedFuncPipeline(GL2ES2 gl, ShaderSelectionMode mode, PMVMatrix pmvMatrix, - Class<?> shaderRootClass, String shaderSrcRoot, + public FixedFuncPipeline(GL2ES2 gl, ShaderSelectionMode mode, PMVMatrix pmvMatrix, + Class<?> shaderRootClass, String shaderSrcRoot, String shaderBinRoot, String vertexColorFile, String vertexColorLightFile, String fragmentColorFile, String fragmentColorTextureFile) { @@ -100,9 +100,9 @@ public class FixedFuncPipeline { this.vertexColorLightFile = vertexColorLightFile; this.fragmentColorFile = fragmentColorFile; this.fragmentColorTextureFile = fragmentColorTextureFile; - init(gl, mode, pmvMatrix); + init(gl, mode, pmvMatrix); } - + public ShaderSelectionMode getShaderSelectionMode() { return requestedShaderSelectionMode; } public void setShaderSelectionMode(ShaderSelectionMode mode) { requestedShaderSelectionMode=mode; } public ShaderSelectionMode getCurrentShaderSelectionMode() { return currentShaderSelectionMode; } @@ -153,21 +153,21 @@ public class FixedFuncPipeline { colorStatic.put(1, green); colorStatic.put(2, blue); colorStatic.put(3, alpha); - + shaderState.useProgram(gl, true); - final GLUniformData ud = shaderState.getUniform(mgl_ColorStatic); + final GLUniformData ud = shaderState.getUniform(mgl_ColorStatic); if(null!=ud) { // same data object .. shaderState.uniform(gl, ud); } else { throw new GLException("Failed to update: mgl_ColorStatic"); - } + } } - + // // Arrays / States // - + public void glEnableClientState(GL2ES2 gl, int glArrayIndex) { glToggleClientState(gl, glArrayIndex, true); } @@ -202,7 +202,7 @@ public class FixedFuncPipeline { break; } } - + public void glVertexPointer(GL2ES2 gl, GLArrayData data) { shaderState.useProgram(gl, true); shaderState.vertexAttribPointer(gl, data); @@ -217,14 +217,14 @@ public class FixedFuncPipeline { shaderState.useProgram(gl, true); shaderState.vertexAttribPointer(gl, data); } - + // // MULTI-TEXTURE // /** Enables/Disables the named texture unit (if changed), returns previous state */ private boolean glEnableTexture(boolean enable, int unit) { - final boolean isEnabled = 0 != ( textureEnabledBits & ( 1 << activeTextureUnit ) ); + final boolean isEnabled = 0 != ( textureEnabledBits & ( 1 << activeTextureUnit ) ); if( isEnabled != enable ) { if(enable) { textureEnabledBits |= ( 1 << unit ); @@ -237,7 +237,7 @@ public class FixedFuncPipeline { } return isEnabled; } - + public void glClientActiveTexture(int textureUnit) { textureUnit -= GL.GL_TEXTURE0; if(0 <= textureUnit && textureUnit<MAX_TEXTURE_UNITS) { @@ -246,7 +246,7 @@ public class FixedFuncPipeline { throw new GLException("glClientActiveTexture textureUnit not within GL_TEXTURE0 + [0.."+MAX_TEXTURE_UNITS+"]: "+textureUnit); } } - + public void glActiveTexture(int textureUnit) { textureUnit -= GL.GL_TEXTURE0; if(0 <= textureUnit && textureUnit<MAX_TEXTURE_UNITS) { @@ -264,7 +264,7 @@ public class FixedFuncPipeline { data.setName( GLPointerFuncUtil.getPredefinedArrayIndexName(data.getIndex(), clientActiveTextureUnit) ) ; shaderState.vertexAttribPointer(gl, data); } - + public void glBindTexture(int target, int texture) { if(GL.GL_TEXTURE_2D == target) { if( texture != boundTextureObject[activeTextureUnit] ) { @@ -272,15 +272,15 @@ public class FixedFuncPipeline { textureFormatDirty = true; } } else { - System.err.println("FixedFuncPipeline: Unimplemented glBindTexture for target "+toHexString(target)+". Texture name "+toHexString(texture)); + System.err.println("FixedFuncPipeline: Unimplemented glBindTexture for target "+toHexString(target)+". Texture name "+toHexString(texture)); } } - + public void glTexImage2D(int target, /* int level, */ int internalformat, /*, int width, int height, int border, */ int format /*, int type, Buffer pixels */) { final int ifmt; if(GL.GL_TEXTURE_2D == target) { - switch(internalformat) { + switch(internalformat) { case 3: case GL.GL_RGB: case GL.GL_RGB565: @@ -306,16 +306,16 @@ public class FixedFuncPipeline { // System.err.println("glTexImage2D TEXTURE_2D: internalformat ifmt "+toHexString(internalformat)+" fmt "+toHexString(format)+" -> "+toHexString(ifmt)); } } else { - System.err.println("FixedFuncPipeline: Unimplemented glTexImage2D: target "+toHexString(target)+", internalformat "+toHexString(internalformat)); + System.err.println("FixedFuncPipeline: Unimplemented glTexImage2D: target "+toHexString(target)+", internalformat "+toHexString(internalformat)); } } /* public void glTexImage2D(int target, int level, int internalformat, int width, int height, int border, - int format, int type, long pixels_buffer_offset) { + int format, int type, long pixels_buffer_offset) { textureFormat.put(activeTextureUnit, internalformat); textureFormatDirty = true; }*/ - + public void glTexEnvi(int target, int pname, int value) { if(GL2ES1.GL_TEXTURE_ENV == target && GL2ES1.GL_TEXTURE_ENV_MODE == pname) { final int mode; @@ -351,7 +351,7 @@ public class FixedFuncPipeline { if( value != textureEnvMode.get(activeTextureUnit) ) { textureEnvMode.put(activeTextureUnit, value); textureEnvModeDirty = true; - } + } } public void glGetTexEnviv(int target, int pname, IntBuffer params) { // FIXME System.err.println("FixedFuncPipeline: Unimplemented glGetTexEnviv: target "+toHexString(target)+", pname "+toHexString(pname)); @@ -359,13 +359,13 @@ public class FixedFuncPipeline { public void glGetTexEnviv(int target, int pname, int[] params, int params_offset) { // FIXME System.err.println("FixedFuncPipeline: Unimplemented glGetTexEnviv: target "+toHexString(target)+", pname "+toHexString(pname)); } - + // // Point Sprites // public void glPointSize(float size) { pointParams.put(0, size); - pointParamsDirty = true; + pointParamsDirty = true; } public void glPointParameterf(int pname, float param) { switch(pname) { @@ -379,7 +379,7 @@ public class FixedFuncPipeline { pointParams.put(4+3, param); break; } - pointParamsDirty = true; + pointParamsDirty = true; } public void glPointParameterfv(int pname, float[] params, int params_offset) { switch(pname) { @@ -389,7 +389,7 @@ public class FixedFuncPipeline { pointParams.put(4+2, params[params_offset + 2]); break; } - pointParamsDirty = true; + pointParamsDirty = true; } public void glPointParameterfv(int pname, java.nio.FloatBuffer params) { final int o = params.position(); @@ -400,24 +400,24 @@ public class FixedFuncPipeline { pointParams.put(4+2, params.get(o + 2)); break; } - pointParamsDirty = true; + pointParamsDirty = true; } // private int[] pointTexObj = new int[] { 0 }; - + private void glDrawPoints(GL2ES2 gl, GLRunnable2<Object,Object> glDrawAction, Object args) { if(gl.isGL2GL3()) { gl.glEnable(GL2GL3.GL_VERTEX_PROGRAM_POINT_SIZE); } if(gl.isGL2ES1()) { gl.glEnable(GL2ES1.GL_POINT_SPRITE); - } + } loadShaderPoints(gl); shaderState.attachShaderProgram(gl, shaderProgramPoints, true); validate(gl, false); // sync uniforms glDrawAction.run(gl, args); - + if(gl.isGL2ES1()) { gl.glDisable(GL2ES1.GL_POINT_SPRITE); } @@ -432,17 +432,17 @@ public class FixedFuncPipeline { int[] _args = (int[])args; gl.glDrawArrays(GL.GL_POINTS, _args[0], _args[1]); return null; - } - }; + } + }; private final void glDrawPointArrays(GL2ES2 gl, int first, int count) { - glDrawPoints(gl, glDrawArraysAction, new int[] { first, count }); + glDrawPoints(gl, glDrawArraysAction, new int[] { first, count }); } - + // // Lighting - // + // - public void glLightfv(GL2ES2 gl, int light, int pname, java.nio.FloatBuffer params) { + public void glLightfv(GL2ES2 gl, int light, int pname, java.nio.FloatBuffer params) { shaderState.useProgram(gl, true); light -=GLLightingFunc.GL_LIGHT0; if(0 <= light && light < MAX_LIGHTS) { @@ -536,14 +536,14 @@ public class FixedFuncPipeline { ud.setData(params); shaderState.uniform(gl, ud); } else if(verbose) { - + } } // // Misc States // - + public void glShadeModel(GL2ES2 gl, int mode) { shaderState.useProgram(gl, true); GLUniformData ud = shaderState.getUniform(mgl_ShadeModel); @@ -608,7 +608,7 @@ public class FixedFuncPipeline { _func = 8; break; default: - throw new GLException("glAlphaFunc invalid func: "+toHexString(func)); + throw new GLException("glAlphaFunc invalid func: "+toHexString(func)); } if(0 < _func) { if(0>alphaTestFunc) { @@ -623,7 +623,7 @@ public class FixedFuncPipeline { } /** - * @return false if digested in regard to GL2ES2 spec, + * @return false if digested in regard to GL2ES2 spec, * eg this call must not be passed to an underlying ES2 implementation. * true if this call shall be passed to an underlying GL2ES2/ES2 implementation as well. */ @@ -631,16 +631,16 @@ public class FixedFuncPipeline { switch(cap) { case GL.GL_BLEND: case GL.GL_DEPTH_TEST: - case GL.GL_DITHER: + case GL.GL_DITHER: case GL.GL_POLYGON_OFFSET_FILL: case GL.GL_SAMPLE_ALPHA_TO_COVERAGE: case GL.GL_SAMPLE_COVERAGE: case GL.GL_SCISSOR_TEST: case GL.GL_STENCIL_TEST: return true; - + case GL.GL_CULL_FACE: - /** ES2 supports CullFace implicit + /** ES2 supports CullFace implicit final int _cullFace; if(0>cullFace && enable || 0<cullFace && !enable) { _cullFace = cullFace * -1; @@ -652,15 +652,15 @@ public class FixedFuncPipeline { cullFace=_cullFace; } */ return true; - + case GL.GL_TEXTURE_2D: glEnableTexture(enable, activeTextureUnit); return false; - + case GLLightingFunc.GL_LIGHTING: lightingEnabled=enable; return false; - + case GL2ES1.GL_ALPHA_TEST: final int _alphaTestFunc; if(0>alphaTestFunc && enable || 0<alphaTestFunc && !enable) { @@ -673,12 +673,12 @@ public class FixedFuncPipeline { alphaTestFunc=_alphaTestFunc; } return false; - + case GL2ES1.GL_POINT_SMOOTH: pointParams.put(1, enable ? 1.0f : 0.0f); pointParamsDirty = true; return false; - + case GL2ES1.GL_POINT_SPRITE: // gl_PointCoord always enabled return false; @@ -699,7 +699,7 @@ public class FixedFuncPipeline { // // Draw // - + public void glDrawArrays(GL2ES2 gl, int mode, int first, int count) { switch(mode) { case GL2.GL_QUAD_STRIP: @@ -717,34 +717,34 @@ public class FixedFuncPipeline { for (int j = first; j < count - 3; j += 4) { gl.glDrawArrays(GL.GL_TRIANGLE_FAN, j, 4); } - } else { + } else { gl.glDrawArrays(mode, first, count); } } public void glDrawElements(GL2ES2 gl, int mode, int count, int type, java.nio.Buffer indices) { - validate(gl, true); + validate(gl, true); if ( GL2.GL_QUADS == mode && !gl.isGL2() ) { final int idx0 = indices.position(); - + if( GL.GL_UNSIGNED_BYTE == type ) { final ByteBuffer b = (ByteBuffer) indices; for (int j = 0; j < count; j++) { gl.glDrawArrays(GL.GL_TRIANGLE_FAN, (int)(0x000000ff & b.get(idx0+j)), 4); - } + } } else if( GL.GL_UNSIGNED_SHORT == type ){ final ShortBuffer b = (ShortBuffer) indices; for (int j = 0; j < count; j++) { gl.glDrawArrays(GL.GL_TRIANGLE_FAN, (int)(0x0000ffff & b.get(idx0+j)), 4); - } + } } else { final IntBuffer b = (IntBuffer) indices; for (int j = 0; j < count; j++) { gl.glDrawArrays(GL.GL_TRIANGLE_FAN, (int)(0xffffffff & b.get(idx0+j)), 4); - } + } } } else { // FIXME: Impl. VBO usage .. or unroll (see above)! - if( !gl.getContext().isCPUDataSourcingAvail() ) { + if( !gl.getContext().isCPUDataSourcingAvail() ) { throw new GLException("CPU data sourcing n/a w/ "+gl.getContext()); } if( GL2ES1.GL_POINTS != mode ) { @@ -756,17 +756,17 @@ public class FixedFuncPipeline { } } public void glDrawElements(GL2ES2 gl, int mode, int count, int type, long indices_buffer_offset) { - validate(gl, true); + validate(gl, true); if ( GL2.GL_QUADS == mode && !gl.isGL2() ) { throw new GLException("Cannot handle indexed QUADS on !GL2 w/ VBO due to lack of CPU index access"); - } else if( GL2ES1.GL_POINTS != mode ) { + } else if( GL2ES1.GL_POINTS != mode ) { // FIXME GL_POINTS ! gl.glDrawElements(mode, count, type, indices_buffer_offset); } else { gl.glDrawElements(mode, count, type, indices_buffer_offset); } } - + private final int textureEnabledCount() { int n=0; for(int i=MAX_TEXTURE_UNITS-1; i>=0; i--) { @@ -776,12 +776,12 @@ public class FixedFuncPipeline { } return n; } - + public void validate(GL2ES2 gl, boolean selectShader) { if( selectShader ) { if( ShaderSelectionMode.AUTO == requestedShaderSelectionMode) { final ShaderSelectionMode newMode; - + // pre-validate shader switch if( 0 != textureEnabledBits ) { if(lightingEnabled) { @@ -808,9 +808,9 @@ public class FixedFuncPipeline { shaderState.useProgram(gl, true); } } - + GLUniformData ud; - if( pmvMatrix.update() ) { + if( pmvMatrix.update() ) { ud = shaderState.getUniform(mgl_PMVMatrix); if(null!=ud) { final FloatBuffer m; @@ -818,7 +818,7 @@ public class FixedFuncPipeline { ShaderSelectionMode.COLOR_LIGHT_PER_VERTEX== currentShaderSelectionMode ) { m = pmvMatrix.glGetPMvMvitMatrixf(); } else { - m = pmvMatrix.glGetPMvMatrixf(); + m = pmvMatrix.glGetPMvMatrixf(); } if(m != ud.getBuffer()) { ud.setData(m); @@ -829,7 +829,7 @@ public class FixedFuncPipeline { throw new GLException("Failed to update: mgl_PMVMatrix"); } } - if(colorVAEnabledDirty) { + if(colorVAEnabledDirty) { ud = shaderState.getUniform(mgl_ColorEnabled); if(null!=ud) { int ca = true == shaderState.isVertexAttribArrayEnabled(GLPointerFuncUtil.mgl_Color) ? 1 : 0 ; @@ -838,7 +838,7 @@ public class FixedFuncPipeline { shaderState.uniform(gl, ud); } } else { - throw new GLException("Failed to update: mgl_ColorEnabled"); + throw new GLException("Failed to update: mgl_ColorEnabled"); } colorVAEnabledDirty = false; } @@ -868,16 +868,16 @@ public class FixedFuncPipeline { if(pointParamsDirty) { ud = shaderState.getUniform(mgl_PointParams); if(null!=ud) { - // same data object + // same data object shaderState.uniform(gl, ud); } pointParamsDirty = false; } - + if(lightsEnabledDirty) { ud = shaderState.getUniform(mgl_LightsEnabled); if(null!=ud) { - // same data object + // same data object shaderState.uniform(gl, ud); } lightsEnabledDirty=false; @@ -886,41 +886,41 @@ public class FixedFuncPipeline { if(textureCoordEnabledDirty) { ud = shaderState.getUniform(mgl_TexCoordEnabled); if(null!=ud) { - // same data object + // same data object shaderState.uniform(gl, ud); } textureCoordEnabledDirty=false; - } + } if(textureEnvModeDirty) { ud = shaderState.getUniform(mgl_TexEnvMode); if(null!=ud) { - // same data object + // same data object shaderState.uniform(gl, ud); } textureEnvModeDirty = false; } - + if(textureFormatDirty) { for(int i = 0; i<MAX_TEXTURE_UNITS; i++) { textureFormat.put(i, texID2Format.get(boundTextureObject[i])); } ud = shaderState.getUniform(mgl_TexFormat); if(null!=ud) { - // same data object + // same data object shaderState.uniform(gl, ud); - } + } textureFormatDirty = false; - } + } if(textureEnabledDirty) { ud = shaderState.getUniform(mgl_TextureEnabled); if(null!=ud) { - // same data object + // same data object shaderState.uniform(gl, ud); } textureEnabledDirty=false; } - + if(verbose) { System.err.println("validate: "+toString(null, DEBUG).toString()); } @@ -944,7 +944,7 @@ public class FixedFuncPipeline { sb.append("\n\t, ShaderState: "); shaderState.toString(sb, alsoUnlocated); sb.append("]"); - return sb; + return sb; } public String toString() { return toString(null, DEBUG).toString(); @@ -954,19 +954,19 @@ public class FixedFuncPipeline { private static final String constMaxTextures2 = "#define MAX_TEXTURE_UNITS 2\n"; private static final String constMaxTextures4 = "#define MAX_TEXTURE_UNITS 4\n"; private static final String constMaxTextures8 = "#define MAX_TEXTURE_UNITS 8\n"; - + private final void customizeShader(GL2ES2 gl, ShaderCode vp, ShaderCode fp, String maxTextureDefine) { int rsVpPos = vp.defaultShaderCustomization(gl, true, true); - int rsFpPos = fp.defaultShaderCustomization(gl, true, true); + int rsFpPos = fp.defaultShaderCustomization(gl, true, true); vp.insertShaderSource(0, rsVpPos, maxTextureDefine); - fp.insertShaderSource(0, rsFpPos, maxTextureDefine); + fp.insertShaderSource(0, rsFpPos, maxTextureDefine); } private final void loadShaderPoints(GL2ES2 gl) { if( null != shaderProgramPoints ) { return; } - + final ShaderCode vp = ShaderCode.create( gl, GL2ES2.GL_VERTEX_SHADER, shaderRootClass, shaderSrcRoot, shaderBinRoot, shaderPointFileDef, true); final ShaderCode fp = ShaderCode.create( gl, GL2ES2.GL_FRAGMENT_SHADER, shaderRootClass, shaderSrcRoot, @@ -977,18 +977,18 @@ public class FixedFuncPipeline { shaderProgramPoints.add(fp); if(!shaderProgramPoints.link(gl, System.err)) { throw new GLException("Couldn't link VertexColor program: "+shaderProgramPoints); - } + } } - + private final void loadShader(GL2ES2 gl, ShaderSelectionMode mode) { final boolean loadColor = ShaderSelectionMode.COLOR == mode; final boolean loadColorTexture2 = ShaderSelectionMode.COLOR_TEXTURE2 == mode; final boolean loadColorTexture4 = ShaderSelectionMode.COLOR_TEXTURE4 == mode; final boolean loadColorTexture8 = ShaderSelectionMode.COLOR_TEXTURE8 == mode; - final boolean loadColorTexture = loadColorTexture2 || loadColorTexture4 || loadColorTexture8 ; + final boolean loadColorTexture = loadColorTexture2 || loadColorTexture4 || loadColorTexture8 ; final boolean loadColorLightPerVertex = ShaderSelectionMode.COLOR_LIGHT_PER_VERTEX == mode; final boolean loadColorTexture8LightPerVertex = ShaderSelectionMode.COLOR_TEXTURE8_LIGHT_PER_VERTEX == mode; - + if( null != shaderProgramColor && loadColor || null != shaderProgramColorTexture2 && loadColorTexture2 || null != shaderProgramColorTexture4 && loadColorTexture4 || @@ -997,7 +997,7 @@ public class FixedFuncPipeline { null != shaderProgramColorTexture8Light && loadColorTexture8LightPerVertex ) { return; } - + if( loadColor ) { final ShaderCode vp = ShaderCode.create( gl, GL2ES2.GL_VERTEX_SHADER, shaderRootClass, shaderSrcRoot, shaderBinRoot, vertexColorFile, true); @@ -1014,7 +1014,7 @@ public class FixedFuncPipeline { final ShaderCode vp = ShaderCode.create( gl, GL2ES2.GL_VERTEX_SHADER, shaderRootClass, shaderSrcRoot, shaderBinRoot, vertexColorFile, true); final ShaderCode fp = ShaderCode.create( gl, GL2ES2.GL_FRAGMENT_SHADER, shaderRootClass, shaderSrcRoot, shaderBinRoot, fragmentColorTextureFile, true); - + if( loadColorTexture2 ) { customizeShader(gl, vp, fp, constMaxTextures2); shaderProgramColorTexture2 = new ShaderProgram(); @@ -1066,7 +1066,7 @@ public class FixedFuncPipeline { } } } - + private ShaderProgram selectShaderProgram(GL2ES2 gl, ShaderSelectionMode newMode) { if(ShaderSelectionMode.AUTO == newMode) { newMode = ShaderSelectionMode.COLOR; @@ -1096,13 +1096,13 @@ public class FixedFuncPipeline { currentShaderSelectionMode = newMode; return sp; } - - private void init(GL2ES2 gl, ShaderSelectionMode mode, PMVMatrix pmvMatrix) { + + private void init(GL2ES2 gl, ShaderSelectionMode mode, PMVMatrix pmvMatrix) { if(null==pmvMatrix) { throw new GLException("PMVMatrix is null"); } this.pmvMatrix=pmvMatrix; - this.requestedShaderSelectionMode = mode; + this.requestedShaderSelectionMode = mode; this.shaderState=new ShaderState(); this.shaderState.setVerbose(verbose); @@ -1115,11 +1115,11 @@ public class FixedFuncPipeline { shaderState.uniform(gl, new GLUniformData(mgl_ColorEnabled, 0)); shaderState.uniform(gl, new GLUniformData(mgl_ColorStatic, 4, colorStatic)); - - texID2Format.setKeyNotFoundValue(0); + + texID2Format.setKeyNotFoundValue(0); shaderState.uniform(gl, new GLUniformData(mgl_TexCoordEnabled, 1, textureCoordEnabled)); shaderState.uniform(gl, new GLUniformData(mgl_TexEnvMode, 1, textureEnvMode)); - shaderState.uniform(gl, new GLUniformData(mgl_TexFormat, 1, textureFormat)); + shaderState.uniform(gl, new GLUniformData(mgl_TexFormat, 1, textureFormat)); shaderState.uniform(gl, new GLUniformData(mgl_TextureEnabled, 1, textureEnabled)); for(int i=0; i<MAX_TEXTURE_UNITS; i++) { shaderState.uniform(gl, new GLUniformData(mgl_Texture+i, i)); @@ -1128,7 +1128,7 @@ public class FixedFuncPipeline { /** ES2 supports CullFace implicit shaderState.uniform(gl, new GLUniformData(mgl_CullFace, cullFace)); */ shaderState.uniform(gl, new GLUniformData(mgl_AlphaTestFunc, alphaTestFunc)); - shaderState.uniform(gl, new GLUniformData(mgl_AlphaTestRef, alphaTestRef)); + shaderState.uniform(gl, new GLUniformData(mgl_AlphaTestRef, alphaTestRef)); shaderState.uniform(gl, new GLUniformData(mgl_PointParams, 4, pointParams)); for(int i=0; i<MAX_LIGHTS; i++) { shaderState.uniform(gl, new GLUniformData(mgl_LightSource+"["+i+"].ambient", 4, defAmbient)); @@ -1141,7 +1141,7 @@ public class FixedFuncPipeline { shaderState.uniform(gl, new GLUniformData(mgl_LightSource+"["+i+"].constantAttenuation", defConstantAtten)); shaderState.uniform(gl, new GLUniformData(mgl_LightSource+"["+i+"].linearAttenuation", defLinearAtten)); shaderState.uniform(gl, new GLUniformData(mgl_LightSource+"["+i+"].quadraticAttenuation", defQuadraticAtten)); - } + } shaderState.uniform(gl, new GLUniformData(mgl_LightModel+".ambient", 4, defLightModelAmbient)); shaderState.uniform(gl, new GLUniformData(mgl_LightsEnabled, 1, lightsEnabled)); shaderState.uniform(gl, new GLUniformData(mgl_FrontMaterial+".ambient", 4, defMatAmbient)); @@ -1159,11 +1159,11 @@ public class FixedFuncPipeline { private String toHexString(int i) { return "0x"+Integer.toHexString(i); } - + protected boolean verbose = DEBUG; private final FloatBuffer colorStatic = Buffers.copyFloatBuffer(one4f); - + private int activeTextureUnit=0; private int clientActiveTextureUnit=0; private final IntIntHashMap texID2Format = new IntIntHashMap(); @@ -1172,9 +1172,9 @@ public class FixedFuncPipeline { private final IntBuffer textureEnabled = Buffers.newDirectIntBuffer(new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }); // per unit private boolean textureEnabledDirty = false; private final IntBuffer textureCoordEnabled = Buffers.newDirectIntBuffer(new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }); // per unit - private boolean textureCoordEnabledDirty = false; + private boolean textureCoordEnabledDirty = false; // textureEnvMode: 1 GL_ADD, 2 GL_MODULATE (default), 3 GL_DECAL, 4 GL_BLEND, 5 GL_REPLACE, 6 GL_COMBINE - private final IntBuffer textureEnvMode = Buffers.newDirectIntBuffer(new int[] { 2, 2, 2, 2, 2, 2, 2, 2 }); + private final IntBuffer textureEnvMode = Buffers.newDirectIntBuffer(new int[] { 2, 2, 2, 2, 2, 2, 2, 2 }); private boolean textureEnvModeDirty = false; private final IntBuffer textureFormat = Buffers.newDirectIntBuffer(new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }); // per unit private boolean textureFormatDirty = false; @@ -1192,11 +1192,11 @@ public class FixedFuncPipeline { private boolean alphaTestDirty=false; private int alphaTestFunc=-8; // <=0 disabled; 1 GL_NEVER, 2 GL_LESS, 3 GL_EQUAL, 4 GL_LEQUAL, 5 GL_GREATER, 6 GL_NOTEQUAL, 7 GL_GEQUAL, and 8 GL_ALWAYS (default) private float alphaTestRef=0f; - + private boolean pointParamsDirty = false; /** ( pointSize, pointSmooth, attn. pointMinSize, attn. pointMaxSize ) , ( attenuation coefficients 1f 0f 0f, attenuation fade theshold 1f ) */ - private final FloatBuffer pointParams = Buffers.newDirectFloatBuffer(new float[] { 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f }); - + private final FloatBuffer pointParams = Buffers.newDirectFloatBuffer(new float[] { 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f }); + private PMVMatrix pmvMatrix; private ShaderState shaderState; private ShaderProgram shaderProgramColor; @@ -1204,7 +1204,7 @@ public class FixedFuncPipeline { private ShaderProgram shaderProgramColorLight; private ShaderProgram shaderProgramColorTexture8Light; private ShaderProgram shaderProgramPoints; - + private ShaderSelectionMode requestedShaderSelectionMode = ShaderSelectionMode.AUTO; private ShaderSelectionMode currentShaderSelectionMode = requestedShaderSelectionMode; @@ -1219,7 +1219,7 @@ public class FixedFuncPipeline { private static final String mgl_LightsEnabled = "mgl_LightsEnabled"; // int mgl_LightsEnabled[MAX_LIGHTS]; private static final String mgl_AlphaTestFunc = "mgl_AlphaTestFunc"; // 1i (lowp int) - private static final String mgl_AlphaTestRef = "mgl_AlphaTestRef"; // 1f + private static final String mgl_AlphaTestRef = "mgl_AlphaTestRef"; // 1f private static final String mgl_ShadeModel = "mgl_ShadeModel"; // 1i private static final String mgl_PointParams = "mgl_PointParams"; // vec4[2]: { (sz, smooth, attnMinSz, attnMaxSz), (attnCoeff(3), attnFadeTs) } @@ -1231,7 +1231,7 @@ public class FixedFuncPipeline { // private static final FloatBuffer zero4f = Buffers.newDirectFloatBuffer(new float[] { 0.0f, 0.0f, 0.0f, 0.0f }); private static final FloatBuffer neut4f = Buffers.newDirectFloatBuffer(new float[] { 0.0f, 0.0f, 0.0f, 1.0f }); - private static final FloatBuffer one4f = Buffers.newDirectFloatBuffer(new float[] { 1.0f, 1.0f, 1.0f, 1.0f }); + private static final FloatBuffer one4f = Buffers.newDirectFloatBuffer(new float[] { 1.0f, 1.0f, 1.0f, 1.0f }); public static final FloatBuffer defAmbient = neut4f; public static final FloatBuffer defDiffuseN = neut4f; @@ -1245,7 +1245,7 @@ public class FixedFuncPipeline { public static final float defQuadraticAtten = 0f; public static final FloatBuffer defLightModelAmbient = Buffers.newDirectFloatBuffer(new float[] { 0.2f, 0.2f, 0.2f, 1.0f }); - + public static final FloatBuffer defMatAmbient = Buffers.newDirectFloatBuffer(new float[] { 0.2f, 0.2f, 0.2f, 1.0f }); public static final FloatBuffer defMatDiffuse = Buffers.newDirectFloatBuffer(new float[] { 0.8f, 0.8f, 0.8f, 1.0f }); public static final FloatBuffer defMatSpecular = neut4f; @@ -1259,13 +1259,13 @@ public class FixedFuncPipeline { private static final String shaderPointFileDef = "FixedFuncPoints"; private static final String shaderSrcRootDef = "shaders" ; private static final String shaderBinRootDef = "shaders/bin" ; - + private final Class<?> shaderRootClass; - private final String shaderSrcRoot; + private final String shaderSrcRoot; private final String shaderBinRoot; private final String vertexColorFile; private final String vertexColorLightFile; private final String fragmentColorFile; - private final String fragmentColorTextureFile; + private final String fragmentColorTextureFile; } |