com.jogamp.opengl.util.texture

## Class ImageSequence

- java.lang.Object
- - com.jogamp.opengl.util.texture.ImageSequence

- All Implemented Interfaces:
    TextureSequence

      public class ImageSequence
      extends Object
      implements TextureSequence

  Simple `TextureSequence` implementation allowing `existing textures` or `image streams` to be used and replayed as `frames`.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface com.jogamp.opengl.util.texture.TextureSequence

      `TextureSequence.TexSeqEventListener<T extends TextureSequence>, TextureSequence.TextureFrame`

  - ### Field Summary

    - ### Fields inherited from interface com.jogamp.opengl.util.texture.TextureSequence

      `sampler2D, samplerExternalOES`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ImageSequence(int textureUnit, boolean useBuildInTexLookup)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addFrame(GL gl, Class<?> context, String imageResourcePath, String imageSuffix)`
    `void` | `addFrame(GL gl, Texture tex)`
    `void` | `destroy(GL gl)`
    `int` | `getCurrentIdx()`
    `TextureSequence.TextureFrame` | `getFrame(int idx)`
    `int` | `getFrameCount()`
    `TextureSequence.TextureFrame` | `getLastTexture()` Returns the last updated texture.
    `boolean` | `getManualStepping()`
    `TextureSequence.TextureFrame` | `getNextTexture(GL gl)` Returns the next texture to be rendered.
    `String` | `getRequiredExtensionsShaderStub()` In case a shader extension is required, based on the implementation and the runtime GL profile, this method returns the preprocessor macros, e.g.:
    `int` | `getTextureFragmentShaderHashCode()` Returns the hash code of the strings: `TextureSequence.getTextureLookupFragmentShaderImpl()` `TextureSequence.getTextureSampler2DType()`
    `String` | `getTextureLookupFragmentShaderImpl()` Returns the complete texture2D lookup function code of type
    `String` | `getTextureLookupFunctionName(String desiredFuncName)`
    `int[]` | `getTextureMinMagFilter()`
    `String` | `getTextureSampler2DType()` Returns either `sampler2D` or `samplerExternalOES` depending on `TextureSequence.getLastTexture()`.`getTexture()`.`getTarget()`.
    `int` | `getTextureTarget()` Returns the texture target used by implementation.
    `int` | `getTextureUnit()` Return the texture unit used to render the current frame.
    `int[]` | `getTextureWrapST()`
    `boolean` | `isTextureAvailable()` Returns true if texture source is ready and a texture is available via `TextureSequence.getNextTexture(GL)` and `TextureSequence.getLastTexture()`.
    `void` | `setCurrentIdx(int idx)`
    `void` | `setManualStepping(boolean v)`
    `void` | `setParams(int magFilter, int minFilter, int wrapS, int wrapT)`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ImageSequence

          public ImageSequence(int textureUnit,
                       boolean useBuildInTexLookup)

  - ### Method Detail

    - #### setParams

          public void setParams(int magFilter,
                       int minFilter,
                       int wrapS,
                       int wrapT)

    - #### addFrame

          public final void addFrame(GL gl,
                      Texture tex)

    - #### addFrame

          public final void addFrame(GL gl,
                      Class<?> context,
                      String imageResourcePath,
                      String imageSuffix)
                              throws IOException

      Throws:
        `IOException`

    - #### getFrameCount

          public final int getFrameCount()

    - #### getCurrentIdx

          public final int getCurrentIdx()

    - #### setCurrentIdx

          public final void setCurrentIdx(int idx)
                                   throws IndexOutOfBoundsException

      Throws:
        `IndexOutOfBoundsException`

    - #### setManualStepping

          public final void setManualStepping(boolean v)

    - #### getManualStepping

          public final boolean getManualStepping()

    - #### getFrame

          public final TextureSequence.TextureFrame getFrame(int idx)

    - #### destroy

          public void destroy(GL gl)
                       throws GLException

      Throws:
        `GLException`

    - #### getTextureTarget

          public int getTextureTarget()

      Description copied from interface: `TextureSequence`
      Returns the texture target used by implementation.
      Specified by:
        `getTextureTarget` in interface `TextureSequence`

    - #### getTextureUnit

          public int getTextureUnit()

      Description copied from interface: `TextureSequence`
      Return the texture unit used to render the current frame.
      Specified by:
        `getTextureUnit` in interface `TextureSequence`

    - #### getTextureMinMagFilter

          public int[] getTextureMinMagFilter()

      Specified by:
        `getTextureMinMagFilter` in interface `TextureSequence`

    - #### getTextureWrapST

          public int[] getTextureWrapST()

      Specified by:
        `getTextureWrapST` in interface `TextureSequence`

    - #### isTextureAvailable

          public boolean isTextureAvailable()

      Description copied from interface: `TextureSequence`
      Returns true if texture source is ready and a texture is available via `TextureSequence.getNextTexture(GL)` and `TextureSequence.getLastTexture()`.
      Specified by:
        `isTextureAvailable` in interface `TextureSequence`

    - #### getLastTexture

          public TextureSequence.TextureFrame getLastTexture()
                                                      throws IllegalStateException

      Description copied from interface: `TextureSequence`
      Returns the last updated texture.

      In case the instance is just initialized, it shall return a `TextureFrame` object with valid attributes. The texture content may be undefined until the first call of `TextureSequence.getNextTexture(GL)`.

      Not blocking.
      Specified by:
        `getLastTexture` in interface `TextureSequence`
      Throws:
        `IllegalStateException` - if instance is not initialized

    - #### getNextTexture

          public TextureSequence.TextureFrame getNextTexture(GL gl)
                                                      throws IllegalStateException

      Description copied from interface: `TextureSequence`
      Returns the next texture to be rendered.

      Implementation shall return the next frame if available, may block if a next frame may arrive soon. Otherwise implementation shall return the last frame.

      Shall return `null` in case no next or last frame is available.

      Specified by:
        `getNextTexture` in interface `TextureSequence`
      Throws:
        `IllegalStateException` - if instance is not initialized

    - #### getRequiredExtensionsShaderStub

          public String getRequiredExtensionsShaderStub()
                                                 throws IllegalStateException

      Description copied from interface: `TextureSequence`
      In case a shader extension is required, based on the implementation and the runtime GL profile, this method returns the preprocessor macros, e.g.:

           #extension GL_OES_EGL_image_external : enable

      Specified by:
        `getRequiredExtensionsShaderStub` in interface `TextureSequence`
      Throws:
        `IllegalStateException` - if instance is not initialized

    - #### getTextureSampler2DType

          public String getTextureSampler2DType()
                                         throws IllegalStateException

      Description copied from interface: `TextureSequence`
      Returns either `sampler2D` or `samplerExternalOES` depending on `TextureSequence.getLastTexture()`.`getTexture()`.`getTarget()`.
      Specified by:
        `getTextureSampler2DType` in interface `TextureSequence`
      Throws:
        `IllegalStateException` - if instance is not initialized

    - #### getTextureLookupFunctionName

          public String getTextureLookupFunctionName(String desiredFuncName)
                                              throws IllegalStateException

      Specified by:
        `getTextureLookupFunctionName` in interface `TextureSequence`
      Parameters:
        `desiredFuncName` - desired lookup function name. If `null` or ignored by the implementation, a build-in name is returned.
      Returns:
        the final lookup function name
      Throws:
        `IllegalStateException` - if instance is not initialized
      See Also:
        `#getTextureLookupFragmentShaderImpl()}`

    - #### getTextureLookupFragmentShaderImpl

          public String getTextureLookupFragmentShaderImpl()
                                                    throws IllegalStateException

      Description copied from interface: `TextureSequence`
      Returns the complete texture2D lookup function code of type

             vec4 funcName(in getTextureSampler2DType() image, in vec2 texCoord) {
                vec4 texColor = do_something_with(image, texCoord);
                return texColor;
             }

      funcName can be negotiated and queried via `TextureSequence.getTextureLookupFunctionName(String)`.

      Note: This function may return an empty string in case a build-in lookup function is being chosen. If the implementation desires so, `TextureSequence.getTextureLookupFunctionName(String)` will ignore the desired function name and returns the build-in lookup function name.
      Specified by:
        `getTextureLookupFragmentShaderImpl` in interface `TextureSequence`
      Throws:
        `IllegalStateException` - if instance is not initialized
      See Also:
        `TextureSequence.getTextureLookupFunctionName(String)`, `TextureSequence.getTextureSampler2DType()`

    - #### getTextureFragmentShaderHashCode

          public int getTextureFragmentShaderHashCode()

      Description copied from interface: `TextureSequence`
      Returns the hash code of the strings:
      - `TextureSequence.getTextureLookupFragmentShaderImpl()`
      - `TextureSequence.getTextureSampler2DType()`

      Returns zero if `texture is not available`.

      The returned hash code allows selection of a matching shader program for this `TextureSequence` instance.

      Implementation shall cache the resulting hash code, which must be reset to zero if `texture is not available`.

      Specified by:
        `getTextureFragmentShaderHashCode` in interface `TextureSequence`

Copyright 2010 JogAmp Community.