diff options
author | Sven Gothel <[email protected]> | 2010-03-30 02:01:28 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2010-03-30 02:01:28 +0200 |
commit | 62dcd1a3fe345c4d2c0e42472d2c7646fe224e8f (patch) | |
tree | 9841146ffc54d1bd8a675e38a123bf82d019db96 /src/jogl/classes/com/jogamp/opengl/util/glsl | |
parent | 1a2a54a83a9adb95b4bfe9c337751acbef0cb0d3 (diff) | |
parent | 476d1d755b6d9c5650779aedda1265917a6dec6e (diff) |
Merge branch 'master' of github.com:mbien/jogl
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/util/glsl')
7 files changed, 71 insertions, 69 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 01b94d0d9..94b329cd5 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java @@ -1,6 +1,7 @@ package com.jogamp.opengl.util.glsl; +import com.jogamp.gluegen.runtime.Buffers; import javax.media.opengl.*; import com.jogamp.opengl.util.*; import com.jogamp.opengl.impl.Debug; @@ -34,7 +35,7 @@ public class ShaderCode { shaderBinaryFormat = -1; shaderBinary = null; shaderType = type; - shader = BufferUtil.newIntBuffer(number); + shader = Buffers.newDirectIntBuffer(number); id = getNextID(); if(DEBUG_CODE) { @@ -55,7 +56,7 @@ public class ShaderCode { shaderBinaryFormat = binFormat; shaderBinary = binary; shaderType = type; - shader = BufferUtil.newIntBuffer(number); + shader = Buffers.newDirectIntBuffer(number); id = getNextID(); } 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 49a341cc6..430ed08ce 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderProgram.java @@ -5,7 +5,6 @@ import javax.media.opengl.*; import java.util.HashMap; import java.util.Iterator; -import java.nio.*; import java.io.PrintStream; public class ShaderProgram { @@ -104,16 +103,20 @@ public class ShaderProgram { * Refetches all previously bin/get attribute names * and resets all attribute data as well * - * @see getAttribLocation * @param gl * @param oldShaderID the to be replace Shader * @param newShader the new ShaderCode * @param verboseOut the optional verbose outputstream * @throws GLException is the program is not linked * - * @see #glRefetchAttribLocations - * @see #glResetAllVertexAttributes - * @see #glReplaceShader + * @see ShaderState#glEnableVertexAttribArray + * @see ShaderState#glDisableVertexAttribArray + * @see ShaderState#glVertexAttribPointer + * @see ShaderState#getVertexAttribPointer + * @see ShaderState#glReleaseAllVertexAttributes + * @see ShaderState#glResetAllVertexAttributes + * @see ShaderState#glResetAllVertexAttributes + * @see ShaderState#glResetAllVertexAttributes */ public synchronized boolean glReplaceShader(GL2ES2 gl, int oldShaderID, ShaderCode newShader, PrintStream verboseOut) { if(!programLinked) throw new GLException("Program is not linked"); 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 33f6e210b..86f9251b7 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java @@ -2,14 +2,11 @@ package com.jogamp.opengl.util.glsl; import javax.media.opengl.*; -import com.jogamp.opengl.util.*; import com.jogamp.opengl.impl.Debug; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import java.nio.*; -import java.io.PrintStream; import java.security.*; public class ShaderState { @@ -25,8 +22,8 @@ public class ShaderState { /** * Fetches the current shader state from the thread local storage (TLS) * - * @see javax.media.opengl.glsl.ShaderState#glUseProgram(GL2ES2, boolean) - * @see javax.media.opengl.glsl.ShaderState#getCurrent() + * @see com.jogamp.opengl.util.glsl.ShaderState#glUseProgram(GL2ES2, boolean) + * @see com.jogamp.opengl.util.glsl.ShaderState#getCurrent() */ public static synchronized ShaderState getCurrent() { GLContext current = GLContext.getCurrent(); @@ -41,8 +38,8 @@ public class ShaderState { * Puts this ShaderState to to the thread local storage (TLS), * if <code>on</code> is <code>true</code>. * - * @see javax.media.opengl.glsl.ShaderState#glUseProgram(GL2ES2, boolean) - * @see javax.media.opengl.glsl.ShaderState#getCurrent() + * @see com.jogamp.opengl.util.glsl.ShaderState#glUseProgram(GL2ES2, boolean) + * @see com.jogamp.opengl.util.glsl.ShaderState#getCurrent() */ public synchronized void glUseProgram(GL2ES2 gl, boolean on) { if(on) { @@ -178,7 +175,7 @@ public class ShaderState { * @see #glGetAttribLocation * @see javax.media.opengl.GL2ES2#glGetAttribLocation * @see #getAttribLocation - * @see #glReplaceShader + * @see ShaderProgram#glReplaceShader */ public void glBindAttribLocation(GL2ES2 gl, int index, String name) { if(null==shaderProgram) throw new GLException("No program is attached"); @@ -203,7 +200,7 @@ public class ShaderState { * @see #glGetAttribLocation * @see javax.media.opengl.GL2ES2#glGetAttribLocation * @see #getAttribLocation - * @see #glReplaceShader + * @see ShaderProgram#glReplaceShader */ public int glGetAttribLocation(GL2ES2 gl, String name) { if(!shaderProgram.linked()) throw new GLException("Program is not linked"); @@ -240,17 +237,17 @@ public class ShaderState { * Even if the attribute is not found in the current shader, * it is stored in this state. * - * @returns false, if the name is not found, otherwise true + * @return false, if the name is not found, otherwise true * * @throws GLException if the program is not in use * * @see #glEnableVertexAttribArray * @see #glDisableVertexAttribArray * @see #glVertexAttribPointer - * @see #getVertexAttributePointer + * @see #getVertexAttribPointer * @see #glReleaseAllVertexAttributes * @see #glResetAllVertexAttributes - * @see #glReplaceShader + * @see ShaderProgram#glReplaceShader */ public boolean glEnableVertexAttribArray(GL2ES2 gl, String name) { if(!shaderProgram.inUse()) throw new GLException("Program is not in use"); @@ -281,17 +278,17 @@ public class ShaderState { * Even if the attribute is not found in the current shader, * it is removed from this state. * - * @returns false, if the name is not found, otherwise true + * @return false, if the name is not found, otherwise true * * @throws GLException if the program is not in use * * @see #glEnableVertexAttribArray * @see #glDisableVertexAttribArray * @see #glVertexAttribPointer - * @see #getVertexAttributePointer + * @see #getVertexAttribPointer * @see #glReleaseAllVertexAttributes * @see #glResetAllVertexAttributes - * @see #glReplaceShader + * @see ShaderProgram#glReplaceShader */ public boolean glDisableVertexAttribArray(GL2ES2 gl, String name) { if(!shaderProgram.inUse()) throw new GLException("Program is not in use"); @@ -322,17 +319,17 @@ public class ShaderState { * it's index will be set with the attribute's location, * if found. * - * @returns false, if the name is not found, otherwise true + * @return false, if the name is not found, otherwise true * * @throws GLException if the program is not in use * * @see #glEnableVertexAttribArray * @see #glDisableVertexAttribArray * @see #glVertexAttribPointer - * @see #getVertexAttributePointer + * @see #getVertexAttribPointer * @see #glReleaseAllVertexAttributes * @see #glResetAllVertexAttributes - * @see #glReplaceShader + * @see ShaderProgram#glReplaceShader */ public boolean glVertexAttribPointer(GL2ES2 gl, GLArrayData data) { if(!shaderProgram.inUse()) throw new GLException("Program is not in use"); @@ -367,15 +364,15 @@ public class ShaderState { /** * Get the vertex attribute data, previously set. * - * @returns the GLArrayData object, null if not previously set. + * @return the GLArrayData object, null if not previously set. * * @see #glEnableVertexAttribArray * @see #glDisableVertexAttribArray * @see #glVertexAttribPointer - * @see #getVertexAttributePointer + * @see #getVertexAttribPointer * @see #glReleaseAllVertexAttributes * @see #glResetAllVertexAttributes - * @see #glReplaceShader + * @see ShaderProgram#glReplaceShader */ public GLArrayData getVertexAttribPointer(String name) { return (GLArrayData) vertexAttribMap2Data.get(name); @@ -390,11 +387,11 @@ public class ShaderState { * @see #glEnableVertexAttribArray * @see #glDisableVertexAttribArray * @see #glVertexAttribPointer - * @see #getVertexAttributePointer + * @see #getVertexAttribPointer * @see #glReleaseAllVertexAttributes * @see #glResetAllVertexAttributes * @see #glResetAllVertexAttributes - * @see #glReplaceShader + * @see ShaderProgram#glReplaceShader */ public void glReleaseAllVertexAttributes(GL2ES2 gl) { if(null!=shaderProgram) { @@ -428,11 +425,11 @@ public class ShaderState { * @see #glEnableVertexAttribArray * @see #glDisableVertexAttribArray * @see #glVertexAttribPointer - * @see #getVertexAttributePointer + * @see #getVertexAttribPointer * @see #glReleaseAllVertexAttributes * @see #glResetAllVertexAttributes * @see #glResetAllVertexAttributes - * @see #glReplaceShader + * @see ShaderProgram#glReplaceShader */ public void glDisableAllVertexAttributeArrays(GL2ES2 gl, boolean removeFromState) { if(!shaderProgram.inUse()) throw new GLException("Program is not in use"); @@ -458,10 +455,10 @@ public class ShaderState { * @see #glEnableVertexAttribArray * @see #glDisableVertexAttribArray * @see #glVertexAttribPointer - * @see #getVertexAttributePointer + * @see #getVertexAttribPointer * @see #glReleaseAllVertexAttributes * @see #glResetAllVertexAttributes - * @see #glReplaceShader + * @see ShaderProgram#glReplaceShader */ public void glResetAllVertexAttributes(GL2ES2 gl) { if(!shaderProgram.inUse()) throw new GLException("Program is not in use"); @@ -520,7 +517,7 @@ public class ShaderState { * @see #glGetUniformLocation * @see javax.media.opengl.GL2ES2#glGetUniformLocation * @see #getUniformLocation - * @see #glReplaceShader + * @see ShaderProgram#glReplaceShader */ protected int glGetUniformLocation(GL2ES2 gl, String name) { if(!shaderProgram.inUse()) throw new GLException("Program is not in use"); @@ -554,14 +551,14 @@ public class ShaderState { * if found. * * - * @returns false, if the name is not found, otherwise true + * @return false, if the name is not found, otherwise true * * @throws GLException if the program is not in use * * @see #glGetUniformLocation * @see javax.media.opengl.GL2ES2#glGetUniformLocation * @see #getUniformLocation - * @see #glReplaceShader + * @see ShaderProgram#glReplaceShader */ public boolean glUniform(GL2ES2 gl, GLUniformData data) { if(!shaderProgram.inUse()) throw new GLException("Program is not in use"); @@ -581,7 +578,7 @@ public class ShaderState { /** * Get the uniform data, previously set. * - * @returns the GLUniformData object, null if not previously set. + * @return the GLUniformData object, null if not previously set. */ public GLUniformData getUniform(String name) { return (GLUniformData) uniformMap2Data.get(name); 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 a7042c47a..f00357bfb 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 @@ -66,25 +66,25 @@ public class FixedFuncUtil { /** * String name for - * @see javax.media.opengl.GL#GL_VERTEX_ARRAY + * @see javax.media.opengl.GL2#GL_VERTEX_ARRAY */ public static final String mgl_Vertex = FixedFuncPipeline.mgl_Vertex; /** * String name for - * @see javax.media.opengl.GL#GL_NORMAL_ARRAY + * @see javax.media.opengl.GL2#GL_NORMAL_ARRAY */ public static final String mgl_Normal = FixedFuncPipeline.mgl_Normal; /** * String name for - * @see javax.media.opengl.GL#GL_COLOR_ARRAY + * @see javax.media.opengl.GL2#GL_COLOR_ARRAY */ public static final String mgl_Color = FixedFuncPipeline.mgl_Color; /** * String name for - * @see javax.media.opengl.GL#GL_TEXTURE_COORD_ARRAY + * @see javax.media.opengl.GL2#GL_TEXTURE_COORD_ARRAY */ public static final String mgl_MultiTexCoord = FixedFuncPipeline.mgl_MultiTexCoord; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/impl/FixedFuncHook.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/impl/FixedFuncHook.java index 6e5bd2eb2..2276cc835 100755 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/impl/FixedFuncHook.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/impl/FixedFuncHook.java @@ -128,7 +128,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun pmvMatrix.glLoadMatrixf(m); } public void glLoadMatrixf(float[] m, int m_offset) { - glLoadMatrixf(BufferUtil.newFloatBuffer(m, m_offset)); + glLoadMatrixf(GLBuffers.newDirectFloatBuffer(m, m_offset)); } public void glPopMatrix() { pmvMatrix.glPopMatrix(); @@ -143,7 +143,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun pmvMatrix.glMultMatrixf(m); } public void glMultMatrixf(float[] m, int m_offset) { - glMultMatrixf(BufferUtil.newFloatBuffer(m, m_offset)); + glMultMatrixf(GLBuffers.newDirectFloatBuffer(m, m_offset)); } public void glTranslatef(float x, float y, float z) { pmvMatrix.glTranslatef(x, y, z); @@ -165,23 +165,23 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun // LightingIf // public void glColor4f(float red, float green, float blue, float alpha) { - fixedFunction.glColor4fv(gl, BufferUtil.newFloatBuffer(new float[] { red, green, blue, alpha })); + fixedFunction.glColor4fv(gl, GLBuffers.newDirectFloatBuffer(new float[] { red, green, blue, alpha })); } public void glLightfv(int light, int pname, java.nio.FloatBuffer params) { fixedFunction.glLightfv(gl, light, pname, params); } public void glLightfv(int light, int pname, float[] params, int params_offset) { - glLightfv(light, pname, BufferUtil.newFloatBuffer(params, params_offset)); + glLightfv(light, pname, GLBuffers.newDirectFloatBuffer(params, params_offset)); } public void glMaterialfv(int face, int pname, java.nio.FloatBuffer params) { fixedFunction.glMaterialfv(gl, face, pname, params); } public void glMaterialfv(int face, int pname, float[] params, int params_offset) { - glMaterialfv(face, pname, BufferUtil.newFloatBuffer(params, params_offset)); + glMaterialfv(face, pname, GLBuffers.newDirectFloatBuffer(params, params_offset)); } public void glMaterialf(int face, int pname, float param) { - glMaterialfv(face, pname, BufferUtil.newFloatBuffer(new float[] { param })); + glMaterialfv(face, pname, GLBuffers.newDirectFloatBuffer(new float[] { param })); } public void glShadeModel(int mode) { fixedFunction.glShadeModel(gl, mode); diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/impl/FixedFuncPipeline.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/impl/FixedFuncPipeline.java index 1a60ab21e..9ead6c4eb 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/impl/FixedFuncPipeline.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/fixedfunc/impl/FixedFuncPipeline.java @@ -1,11 +1,11 @@ package com.jogamp.opengl.util.glsl.fixedfunc.impl; +import com.jogamp.gluegen.runtime.Buffers; import javax.media.opengl.*; import javax.media.opengl.fixedfunc.*; import com.jogamp.opengl.util.*; import com.jogamp.opengl.util.glsl.*; -import com.jogamp.opengl.util.glsl.fixedfunc.*; import java.nio.*; public class FixedFuncPipeline { @@ -490,14 +490,14 @@ public class FixedFuncPipeline { protected boolean verbose=false; protected boolean textureEnabled=false; - protected IntBuffer textureCoordsEnabled = BufferUtil.newIntBuffer(new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }); + protected IntBuffer textureCoordsEnabled = Buffers.newDirectIntBuffer(new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }); protected boolean textureCoordsEnabledDirty = false; protected int activeTextureUnit=0; protected int cullFace=-2; // <=0 disabled, 1: front, 2: back (default, but disabled), 3: front & back protected boolean lightingEnabled=false; - protected IntBuffer lightsEnabled = BufferUtil.newIntBuffer(new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }); + protected IntBuffer lightsEnabled = Buffers.newDirectIntBuffer(new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }); protected boolean lightsEnabledDirty = false; protected PMVMatrix pmvMatrix; @@ -525,23 +525,23 @@ public class FixedFuncPipeline { protected static final String mgl_CullFace = "mgl_CullFace"; // 1i - protected static final FloatBuffer zero4f = BufferUtil.newFloatBuffer(new float[] { 0.0f, 0.0f, 0.0f, 0.0f }); + protected static final FloatBuffer zero4f = Buffers.newDirectFloatBuffer(new float[] { 0.0f, 0.0f, 0.0f, 0.0f }); - public static final FloatBuffer defAmbient = BufferUtil.newFloatBuffer(new float[] { 0f, 0f, 0f, 1f }); + public static final FloatBuffer defAmbient = Buffers.newDirectFloatBuffer(new float[] { 0f, 0f, 0f, 1f }); public static final FloatBuffer defDiffuse = zero4f; public static final FloatBuffer defSpecular= zero4f; - public static final FloatBuffer defPosition= BufferUtil.newFloatBuffer(new float[] { 0f, 0f, 1f, 0f }); - public static final FloatBuffer defSpotDir = BufferUtil.newFloatBuffer(new float[] { 0f, 0f, -1f }); + public static final FloatBuffer defPosition= Buffers.newDirectFloatBuffer(new float[] { 0f, 0f, 1f, 0f }); + public static final FloatBuffer defSpotDir = Buffers.newDirectFloatBuffer(new float[] { 0f, 0f, -1f }); public static final float defSpotExponent = 0f; public static final float defSpotCutoff = 180f; public static final float defConstantAtten = 1f; public static final float defLinearAtten = 0f; public static final float defQuadraticAtten= 0f; - public static final FloatBuffer defMatAmbient = BufferUtil.newFloatBuffer(new float[] { 0.2f, 0.2f, 0.2f, 1.0f }); - public static final FloatBuffer defMatDiffuse = BufferUtil.newFloatBuffer(new float[] { 0.8f, 0.8f, 0.8f, 1.0f }); - public static final FloatBuffer defMatSpecular= BufferUtil.newFloatBuffer(new float[] { 0f, 0f, 0f, 1f}); - public static final FloatBuffer defMatEmission= BufferUtil.newFloatBuffer(new float[] { 0f, 0f, 0f, 1f}); + 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= Buffers.newDirectFloatBuffer(new float[] { 0f, 0f, 0f, 1f}); + public static final FloatBuffer defMatEmission= Buffers.newDirectFloatBuffer(new float[] { 0f, 0f, 0f, 1f}); public static final float defMatShininess = 0f; protected static final String vertexColorFileDef = "FixedFuncColor"; 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 9741da737..a0eed50ea 100755 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShader.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShader.java @@ -7,16 +7,17 @@ import com.jogamp.opengl.util.glsl.*; import java.io.*; import java.net.*; -/** Precompiles a shader into a vendor binary format. Input is the - resource name of the shader, such as - "com/jogamp/opengl/impl/glsl/fixed/shader/a.fp". - Output is "com/jogamp/opengl/impl/glsl/fixed/shader/bin/nvidia/a.bfp". - - All path and suffixes are determined by the ShaderCode class, - which ensures runtime compatibility. - - @see javax.media.opengl.glsl.ShaderCode - */ +/** + * Precompiles a shader into a vendor binary format. Input is the + * resource name of the shader, such as + * "com/jogamp/opengl/impl/glsl/fixed/shader/a.fp". + * Output is "com/jogamp/opengl/impl/glsl/fixed/shader/bin/nvidia/a.bfp". + * + * All path and suffixes are determined by the ShaderCode class, + * which ensures runtime compatibility. + * + * @see com.jogamp.opengl.util.glsl.ShaderCode + */ public abstract class CompileShader { |