Top Description Inners Fields Methods
com.jogamp.opengl.util.texture

public Interface TextureSequence

Known Direct Subinterfaces
com.jogamp.opengl.util.av.GLMediaPlayer
Known Direct Implementers
com.jogamp.opengl.util.texture.ImageSequence
Imports
com.jogamp.opengl.GL, .GLAutoDrawable, .GLRunnable, .GLEventListener, com.jogamp.opengl.util.TimeFrameI

Protocol for texture sequences, like animations, movies, etc.

Ensure to respect the texture coordinates provided by TextureFrame.getTexture().getImageTexCoords().

The user's shader shall be fitted for this implementation. Assuming we use a base shader code w/o headers using ShaderCode. (Code copied from unit test / demo TexCubeES2)

   static final String[] es2_prelude = { "#version 100\n", "precision mediump float;\n" };
   static final String gl2_prelude = "#version 110\n";
   static final String shaderBasename = "texsequence_xxx";  // the base shader code w/o headers
   static final String myTextureLookupName = "myTexture2D"; // the desired texture lookup function

   private void initShader(GL2ES2 gl, TextureSequence texSeq) {
       // Create & Compile the shader objects
       ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, TexCubeES2.class,
                                           "shader", "shader/bin", shaderBasename, true);
       ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, TexCubeES2.class,
                                           "shader", "shader/bin", shaderBasename, true);

       // Prelude shader code w/ GLSL profile specifics [ 1. pre-proc, 2. other ]
       int rsFpPos;
       if(gl.isGLES2()) {
           // insert ES2 version string in beginning
           rsVp.insertShaderSource(0, 0, es2_prelude[0]);
           rsFpPos = rsFp.insertShaderSource(0, 0, es2_prelude[0]);
       } else {
           // insert GL2 version string in beginning
           rsVp.insertShaderSource(0, 0, gl2_prelude);
           rsFpPos = rsFp.insertShaderSource(0, 0, gl2_prelude);
       }
       // insert required extensions as determined by TextureSequence implementation.
       rsFpPos = rsFp.insertShaderSource(0, rsFpPos, texSeq.getRequiredExtensionsShaderStub());
       if(gl.isGLES2()) {
           // insert ES2 default precision declaration
           rsFpPos = rsFp.insertShaderSource(0, rsFpPos, es2_prelude[1]);
       }
       // negotiate the texture lookup function name
       final String texLookupFuncName = texSeq.getTextureLookupFunctionName(myTextureLookupName);

       // in case a fixed lookup function is being chosen, replace the name in our code
       rsFp.replaceInShaderSource(myTextureLookupName, texLookupFuncName);

       // Cache the TextureSequence shader details in StringBuilder:
       final StringBuilder sFpIns = new StringBuilder();

       // .. declaration of the texture sampler using the implementation specific type
       sFpIns.append("uniform ").append(texSeq.getTextureSampler2DType()).append(" mgl_ActiveTexture;\n");

       // .. the actual texture lookup function, maybe null in case a built-in function is being used
       sFpIns.append(texSeq.getTextureLookupFragmentShaderImpl());

       // Now insert the TextureShader details in our shader after the given tag:
       rsFp.insertShaderSource(0, "TEXTURE-SEQUENCE-CODE-BEGIN", 0, sFpIns);

       // Create & Link the shader program
       ShaderProgram sp = new ShaderProgram();
       sp.add(rsVp);
       sp.add(rsFp);
       if(!sp.link(gl, System.err)) {
           throw new GLException("Couldn't link program: "+sp);
       }
       ...
The above procedure might look complicated, however, it allows most flexibility and workarounds to also deal with GLSL bugs.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
TextureSequence.TexSeqEventListener<T extends TextureSequence>

Event listener to notify users of updates regarding the TextureSequence.

public static class
TextureSequence.TextureFrame

Texture holder interface, maybe specialized by implementation to associated related data.

Field Summary

Modifier and TypeField and Description
public static final String
public static final String

Method Summary

Modifier and TypeMethod and Description
public TextureSequence.TextureFrame
getLastTexture()

Returns the last updated texture.

public TextureSequence.TextureFrame
getNextTexture(GL gl)

Returns the next texture to be rendered.

public 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.:

#extension GL_OES_EGL_image_external : enable
public int
public String
getTextureLookupFragmentShaderImpl()

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;
  }
public String

Returns:

the final lookup function name
getTextureLookupFunctionName
(String
desired lookup function name. If null or ignored by the implementation, a build-in name is returned.
desiredFuncName
)

public int[]
public String
getTextureSampler2DType()

Returns either sampler2D or samplerExternalOES depending on getLastTexture().

public int
getTextureTarget()

Returns the texture target used by implementation.

public int
getTextureUnit()

Return the texture unit used to render the current frame.

public int[]
public boolean
isTextureAvailable()

Returns true if texture source is ready and a texture is available via getNextTexture(GL) and getLastTexture().

Field Detail

sampler2Dback to summary
public static final String sampler2D
samplerExternalOESback to summary
public static final String samplerExternalOES

Method Detail

getLastTextureback to summary
public TextureSequence.TextureFrame getLastTexture() throws IllegalStateException

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 getNextTexture(GL).

Not blocking.
Exceptions
IllegalStateException:
if instance is not initialized
getNextTextureback to summary
public TextureSequence.TextureFrame getNextTexture(GL gl) throws IllegalStateException

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.

Exceptions
IllegalStateException:
if instance is not initialized
getRequiredExtensionsShaderStubback to summary
public String getRequiredExtensionsShaderStub() throws IllegalStateException

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
Exceptions
IllegalStateException:
if instance is not initialized
getTextureFragmentShaderHashCodeback to summary
public int getTextureFragmentShaderHashCode()

Returns the hash code of the strings:

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.

getTextureLookupFragmentShaderImplback to summary
public String getTextureLookupFragmentShaderImpl() throws IllegalStateException

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 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, getTextureLookupFunctionName(String) will ignore the desired function name and returns the build-in lookup function name.

Exceptions
IllegalStateException:
if instance is not initialized
See Also
getTextureLookupFunctionName(String), getTextureSampler2DType()
getTextureLookupFunctionNameback to summary
public String getTextureLookupFunctionName(String desiredFuncName) throws IllegalStateException
Parameters
desiredFuncName:String

desired lookup function name. If null or ignored by the implementation, a build-in name is returned.

Returns:String

the final lookup function name

Exceptions
IllegalStateException:
if instance is not initialized
See Also
getTextureLookupFragmentShaderImpl()
getTextureMinMagFilterback to summary
public int[] getTextureMinMagFilter()
getTextureSampler2DTypeback to summary
public String getTextureSampler2DType() throws IllegalStateException

Returns either sampler2D or samplerExternalOES depending on getLastTexture().getTexture().getTarget().

Exceptions
IllegalStateException:
if instance is not initialized
getTextureTargetback to summary
public int getTextureTarget()

Returns the texture target used by implementation.

getTextureUnitback to summary
public int getTextureUnit()

Return the texture unit used to render the current frame.

getTextureWrapSTback to summary
public int[] getTextureWrapST()
isTextureAvailableback to summary
public boolean isTextureAvailable()

Returns true if texture source is ready and a texture is available via getNextTexture(GL) and getLastTexture().

com.jogamp.opengl.util.texture back to summary

public Interface TextureSequence.TexSeqEventListener<T extends TextureSequence>

Known Direct Subinterfaces
com.jogamp.opengl.util.av.GLMediaPlayer.GLMediaEventListener

Event listener to notify users of updates regarding the TextureSequence.

Implementations sending events down to all listeners, while not necessarily making the user's OpenGL context current.

Events may be sent from a 3rd-party thread, possibly holding another, maybe shared, OpenGL context current.
Hence a user shall not issue any OpenGL, time consuming or TextureSequence operations directly.
Instead, the user shall:

Method Summary

Modifier and TypeMethod and Description
public void
newFrameAvailable(T
the event source
ts
,
TextureSequence.TextureFrame
the newly enqueued frame
newFrame
,
long
system time in msec.
when
)

Signaling listeners that a new TextureFrame is available.

Method Detail

newFrameAvailableback to summary
public void newFrameAvailable(T ts, TextureSequence.TextureFrame newFrame, long when)

Signaling listeners that a new TextureFrame is available.

User shall utilize TextureSequence#getNextTexture(GL) to dequeue it to maintain a consistent queue.

Parameters
ts:T

the event source

newFrame:TextureSequence.TextureFrame

the newly enqueued frame

when:long

system time in msec.

com.jogamp.opengl.util.texture back to summary

public Class TextureSequence.TextureFrame

extends TimeFrameI
Class Inheritance
Known Direct Subclasses
jogamp.opengl.util.av.EGLMediaPlayerImpl.EGLTextureFrame

Texture holder interface, maybe specialized by implementation to associated related data.

Field Summary

Modifier and TypeField and Description
protected final Texture
Inherited from com.jogamp.opengl.util.TimeFrameI:
durationEND_OF_STREAM_PTSINVALID_PTSpts

Constructor Summary

AccessConstructor and Description
public
TextureFrame(final Texture t, final int pts, final int duration)

public

Method Summary

Modifier and TypeMethod and Description
public final Texture
public String
toString()

Overrides com.jogamp.opengl.util.TimeFrameI.toString.

Returns a string representation of the object.
Inherited from com.jogamp.opengl.util.TimeFrameI:
getDurationgetPTSsetDurationsetPTS

Field Detail

textureback to summary
protected final Texture texture

Constructor Detail

TextureFrameback to summary
public TextureFrame(final Texture t, final int pts, final int duration)
TextureFrameback to summary
public TextureFrame(final Texture t)

Method Detail

getTextureback to summary
public final Texture getTexture()
toStringback to summary
public String toString()

Overrides com.jogamp.opengl.util.TimeFrameI.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override