Class GLArrayDataWrapper

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static boolean DEBUG  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void associate​(Object obj, boolean enable)
      Implementation and type dependent object association.
      static GLArrayDataWrapper createFixed​(int index, int comps, int dataType, boolean normalized, int stride, int mappedElementCount, int vboName, long vboOffset, int vboUsage, int vboTarget)
      Create a VBO, using a predefined fixed function array index, wrapping the mapped data characteristics.
      static GLArrayDataWrapper createFixed​(int index, int comps, int dataType, boolean normalized, int stride, Buffer buffer, int vboName, long vboOffset, int vboUsage, int vboTarget)
      Create a VBO, using a predefined fixed function array index, wrapping the given data.
      static GLArrayDataWrapper createGLSL​(String name, int comps, int dataType, boolean normalized, int stride, int mappedElementCount, int vboName, long vboOffset, int vboUsage, int vboTarget)
      Create a VBO, using a custom GLSL array attribute name, wrapping the mapped data characteristics.
      static GLArrayDataWrapper createGLSL​(String name, int comps, int dataType, boolean normalized, int stride, Buffer buffer, int vboName, long vboOffset, int vboUsage, int vboTarget)
      Create a VBO, using a custom GLSL array attribute name, wrapping the given data.
      void destroy​(GL gl)  
      Buffer getBuffer()
      The Buffer holding the data, may be null if a GPU buffer without client bound data
      Class<?> getBufferClass()  
      static Class<?> getBufferClass​(int dataType)  
      int getComponentCount()
      The number of components per element
      int getComponentSizeInBytes()
      The component's size in bytes
      int getComponentType()
      The component's GL data type, ie.
      int getElementCount()
      The current number of used elements.
      int getIndex()
      The index of the predefined array index, see list below, or -1 in case of a shader attribute array.
      int getLocation()
      Returns the shader attribute location for this name, -1 if not yet determined
      String getName()
      The name of the reflecting shader array attribute.
      boolean getNormalized()
      True, if GL shall normalize fixed point data while converting them into float.
      int getSizeInBytes()
      The currently used size in bytes.
      In case the buffer's position is 0 (sealed, flipped), it's based on it's limit instead of it's position.
      int getStride()  
      int getVBOName()
      The VBO name or 0 if not a VBO
      long getVBOOffset()
      The VBO buffer offset or 0 if not a VBO
      int getVBOTarget()
      The VBO target or 0 if not a VBO
      int getVBOUsage()
      The VBO usage or 0 if not a VBO
      boolean isVBO()
      Determines whether the data is server side (VBO) and enabled, or a client side array (false).
      boolean isVertexAttribute()
      Returns true if this data set is intended for a GLSL vertex shader attribute, otherwise false, ie intended for fixed function vertex pointer
      int setLocation​(int v)
      Sets the given location of the shader attribute
      int setLocation​(GL2ES2 gl, int program)
      Retrieves the location of the shader attribute from the linked shader program.
      int setLocation​(GL2ES2 gl, int program, int location)
      Binds the location of the shader attribute to the given location for the unlinked shader program.
      void setName​(String newName)
      Set a new name for this array.
      void setVBOEnabled​(boolean vboEnabled)
      Enable or disable use of VBO.
      void setVBOName​(int vboName)
      Set the VBO buffer name, if valid (!= 0) enable use of VBO, otherwise (==0) disable VBO usage.
      void setVBOTarget​(int vboTarget)  
      void setVBOUsage​(int vboUsage)  
      String toString()  
      boolean validate​(GLProfile glp, boolean throwException)
      Validates this instance's parameter.
    • Field Detail

      • DEBUG

        public static final boolean DEBUG
    • Constructor Detail

      • GLArrayDataWrapper

        public GLArrayDataWrapper​(GLArrayDataWrapper src)
        Copy Constructor

        Buffer is sliced, i.e. sharing content but using own state.

        All other values are simply copied.

    • Method Detail

      • createFixed

        public static GLArrayDataWrapper createFixed​(int index,
                                                     int comps,
                                                     int dataType,
                                                     boolean normalized,
                                                     int stride,
                                                     Buffer buffer,
                                                     int vboName,
                                                     long vboOffset,
                                                     int vboUsage,
                                                     int vboTarget)
                                              throws GLException
        Create a VBO, using a predefined fixed function array index, wrapping the given data.
        Parameters:
        index - The GL array index
        comps - The array component number
        dataType - The array index GL data type
        normalized - Whether the data shall be normalized
        stride -
        buffer - the user define data
        vboName -
        vboOffset -
        vboUsage - GL2ES2.GL_STREAM_DRAW, GL.GL_STATIC_DRAW or GL.GL_DYNAMIC_DRAW
        vboTarget - GL.GL_ARRAY_BUFFER or GL.GL_ELEMENT_ARRAY_BUFFER
        Returns:
        the new create instance
        Throws:
        GLException
      • createFixed

        public static GLArrayDataWrapper createFixed​(int index,
                                                     int comps,
                                                     int dataType,
                                                     boolean normalized,
                                                     int stride,
                                                     int mappedElementCount,
                                                     int vboName,
                                                     long vboOffset,
                                                     int vboUsage,
                                                     int vboTarget)
                                              throws GLException
        Create a VBO, using a predefined fixed function array index, wrapping the mapped data characteristics.
        Parameters:
        index - The GL array index
        comps - The array component number
        dataType - The array index GL data type
        normalized - Whether the data shall be normalized
        stride -
        mappedElementCount -
        vboName -
        vboOffset -
        vboUsage - GL2ES2.GL_STREAM_DRAW, GL.GL_STATIC_DRAW or GL.GL_DYNAMIC_DRAW
        vboTarget - GL.GL_ARRAY_BUFFER or GL.GL_ELEMENT_ARRAY_BUFFER
        Returns:
        the new create instance
        Throws:
        GLException
      • validate

        public final boolean validate​(GLProfile glp,
                                      boolean throwException)
        Validates this instance's parameter. Called automatically by GLArrayDataClient and GLArrayDataServer. GLArrayDataWrapper does not validate it's instance by itself.
        Parameters:
        glp - the GLProfile to use
        throwException - whether to throw an exception if this instance has invalid parameter or not
        Returns:
        true if this instance has invalid parameter, otherwise false
      • associate

        public void associate​(Object obj,
                              boolean enable)
        Description copied from interface: GLArrayData
        Implementation and type dependent object association.

        One currently known use case is to associate a ShaderState to an GLSL aware vertex attribute object, allowing to use the ShaderState to handle it's data persistence, location and state change.
        This is implicitly done via shaderState.ownAttribute(GLArrayData, boolean).

        Specified by:
        associate in interface GLArrayData
        Parameters:
        obj - implementation and type dependent association
        enable - pass true to enable the association and false to disable it.
      • isVertexAttribute

        public final boolean isVertexAttribute()
        Description copied from interface: GLArrayData
        Returns true if this data set is intended for a GLSL vertex shader attribute, otherwise false, ie intended for fixed function vertex pointer
        Specified by:
        isVertexAttribute in interface GLArrayData
      • getLocation

        public final int getLocation()
        Description copied from interface: GLArrayData
        Returns the shader attribute location for this name, -1 if not yet determined
        Specified by:
        getLocation in interface GLArrayData
      • setLocation

        public final int setLocation​(GL2ES2 gl,
                                     int program)
        Description copied from interface: GLArrayData
        Retrieves the location of the shader attribute from the linked shader program.

        No validation is performed within the implementation.

        Specified by:
        setLocation in interface GLArrayData
        Returns:
        ≥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.
      • setLocation

        public final int setLocation​(GL2ES2 gl,
                                     int program,
                                     int location)
        Description copied from interface: GLArrayData
        Binds the location of the shader attribute to the given location for the unlinked shader program.

        No validation is performed within the implementation.

        Specified by:
        setLocation in interface GLArrayData
        Returns:
        the given location
      • getName

        public final String getName()
        Description copied from interface: GLArrayData
        The name of the reflecting shader array attribute.
        Specified by:
        getName in interface GLArrayData
      • getVBOOffset

        public final long getVBOOffset()
        Description copied from interface: GLArrayData
        The VBO buffer offset or 0 if not a VBO
        Specified by:
        getVBOOffset in interface GLArrayData
      • getVBOName

        public final int getVBOName()
        Description copied from interface: GLArrayData
        The VBO name or 0 if not a VBO
        Specified by:
        getVBOName in interface GLArrayData
      • isVBO

        public final boolean isVBO()
        Description copied from interface: GLArrayData
        Determines whether the data is server side (VBO) and enabled, or a client side array (false).
        Specified by:
        isVBO in interface GLArrayData
      • getBuffer

        public Buffer getBuffer()
        Description copied from interface: GLArrayData
        The Buffer holding the data, may be null if a GPU buffer without client bound data
        Specified by:
        getBuffer in interface GLArrayData
      • getComponentCount

        public final int getComponentCount()
        Description copied from interface: GLArrayData
        The number of components per element
        Specified by:
        getComponentCount in interface GLArrayData
      • getComponentType

        public final int getComponentType()
        Description copied from interface: GLArrayData
        The component's GL data type, ie. GL_FLOAT
        Specified by:
        getComponentType in interface GLArrayData
      • getElementCount

        public final int getElementCount()
        Description copied from interface: GLArrayData
        The current number of used elements.

        On element consist out of GLArrayData.getComponentCount() components.

        In case the buffer's position is 0 (sealed, flipped), it's based on it's limit instead of it's position.
        Specified by:
        getElementCount in interface GLArrayData
      • getSizeInBytes

        public final int getSizeInBytes()
        Description copied from interface: GLArrayData
        The currently used size in bytes.
        In case the buffer's position is 0 (sealed, flipped), it's based on it's limit instead of it's position.
        Specified by:
        getSizeInBytes in interface GLArrayData
      • getNormalized

        public final boolean getNormalized()
        Description copied from interface: GLArrayData
        True, if GL shall normalize fixed point data while converting them into float.

        Default behavior (of the fixed function pipeline) is true for fixed point data type and false for floating point data types.

        Specified by:
        getNormalized in interface GLArrayData
      • getStride

        public final int getStride()
        Specified by:
        getStride in interface GLArrayData
        Returns:
        the byte offset between consecutive components
      • getBufferClass

        public final Class<?> getBufferClass()
      • getBufferClass

        public static final Class<?> getBufferClass​(int dataType)
      • setVBOEnabled

        public void setVBOEnabled​(boolean vboEnabled)
        Enable or disable use of VBO. Only possible if a VBO buffer name is defined.
        See Also:
        setVBOName(int)
      • setVBOName

        public void setVBOName​(int vboName)
        Set the VBO buffer name, if valid (!= 0) enable use of VBO, otherwise (==0) disable VBO usage.
        See Also:
        setVBOEnabled(boolean)