diff options
Diffstat (limited to 'src/jogl/classes/javax')
-rw-r--r-- | src/jogl/classes/javax/media/opengl/GLArrayData.java | 57 | ||||
-rw-r--r-- | src/jogl/classes/javax/media/opengl/GLUniformData.java | 20 |
2 files changed, 68 insertions, 9 deletions
diff --git a/src/jogl/classes/javax/media/opengl/GLArrayData.java b/src/jogl/classes/javax/media/opengl/GLArrayData.java index 5d17f6874..8e1383031 100644 --- a/src/jogl/classes/javax/media/opengl/GLArrayData.java +++ b/src/jogl/classes/javax/media/opengl/GLArrayData.java @@ -30,6 +30,8 @@ package javax.media.opengl; import java.nio.Buffer; +import javax.media.opengl.fixedfunc.GLPointerFunc; + /** * * The total number of bytes hold by the referenced buffer is: @@ -38,6 +40,19 @@ import java.nio.Buffer; */ public interface GLArrayData { /** + * Implementation and type dependent object association. + * <p> + * One currently known use case is to associate a {@link com.jogamp.opengl.util.glsl.ShaderState ShaderState} + * to an GLSL aware vertex attribute object, allowing to use the ShaderState to handle it's + * data persistence, location and state change.<br/> + * This is implicitly done via {@link com.jogamp.opengl.util.glsl.ShaderState#ownAttribute(GLArrayData, boolean) shaderState.ownAttribute(GLArrayData, boolean)}. + * </p> + * @param obj implementation and type dependent association + * @param enable pass true to enable the association and false to disable it. + */ + public void associate(Object obj, boolean enable); + + /** * Returns true if this data set is intended for a GLSL vertex shader attribute, * otherwise false, ie intended for fixed function vertex pointer */ @@ -47,10 +62,10 @@ public interface GLArrayData { * The index of the predefined array index, see list below, * or -1 in case of a shader attribute array. * - * @see javax.media.opengl.GL2#GL_VERTEX_ARRAY - * @see javax.media.opengl.GL2#GL_NORMAL_ARRAY - * @see javax.media.opengl.GL2#GL_COLOR_ARRAY - * @see javax.media.opengl.GL2#GL_TEXTURE_COORD_ARRAY + * @see GLPointerFunc#GL_VERTEX_ARRAY + * @see GLPointerFunc#GL_NORMAL_ARRAY + * @see GLPointerFunc#GL_COLOR_ARRAY + * @see GLPointerFunc#GL_TEXTURE_COORD_ARRAY */ public int getIndex(); @@ -61,6 +76,11 @@ public interface GLArrayData { /** * Set a new name for this array. + * <p> + * This clears the location, i.e. sets it to -1. + * </p> + * @see #setLocation(int) + * @see #setLocation(GL2ES2, int) */ public void setName(String newName); @@ -72,14 +92,37 @@ public interface GLArrayData { public int getLocation(); /** - * Sets the determined location of the shader attribute - * This is usually done within ShaderState. + * Sets the given location of the shader attribute * + * @return the given location * @see com.jogamp.opengl.util.glsl.ShaderState#vertexAttribPointer(GL2ES2, GLArrayData) */ - public void setLocation(int v); + public int setLocation(int v); /** + * Retrieves the location of the shader attribute from the linked shader program. + * <p> + * No validation is performed within the implementation. + * </p> + * @param gl + * @param program + * @return ≥0 denotes a valid attribute location as found and used in the given shader program. + * <0 denotes an invalid location, i.e. not found or used in the given shader program. + */ + public int setLocation(GL2ES2 gl, int program); + + /** + * Binds the location of the shader attribute to the given location for the unlinked shader program. + * <p> + * No validation is performed within the implementation. + * </p> + * @param gl + * @param program + * @return the given location + */ + public int setLocation(GL2ES2 gl, int program, int location); + + /** * Determines whether the data is server side (VBO) and enabled, * or a client side array (false). */ diff --git a/src/jogl/classes/javax/media/opengl/GLUniformData.java b/src/jogl/classes/javax/media/opengl/GLUniformData.java index 18a422670..60d0c58bf 100644 --- a/src/jogl/classes/javax/media/opengl/GLUniformData.java +++ b/src/jogl/classes/javax/media/opengl/GLUniformData.java @@ -147,10 +147,26 @@ public class GLUniformData { public int getLocation() { return location; } /** - * Sets the determined location of the shader uniform. + * Sets the given location of the shader uniform. + * @return the given location */ - public GLUniformData setLocation(int location) { this.location=location; return this; } + public int setLocation(int location) { this.location=location; return location; } + /** + * Retrieves the location of the shader uniform from the linked shader program. + * <p> + * No validation is performed within the implementation. + * </p> + * @param gl + * @param program + * @return ≥0 denotes a valid uniform location as found and used in the given shader program. + * <0 denotes an invalid location, i.e. not found or used in the given shader program. + */ + public int setLocation(GL2ES2 gl, int program) { + location = gl.glGetUniformLocation(program, name); + return location; + } + public Object getObject() { return data; } |