28package com.jogamp.opengl.util.texture;
30import com.jogamp.opengl.GL;
31import com.jogamp.opengl.GLAutoDrawable;
32import com.jogamp.opengl.GLRunnable;
33import com.jogamp.opengl.GLEventListener;
35import com.jogamp.common.av.TimeFrameI;
36import com.jogamp.graph.curve.Region;
37import com.jogamp.math.Vec4f;
38import com.jogamp.math.geom.AABBox;
121 super(pts, duration);
393 final float tcW = tc.right() - tc.left();
395 colorTexBBox[0] = box.getMinX() / tcW;
396 colorTexBBox[2] = box.getMaxX() / tcW;
397 if( tex.getMustFlipVertically() ) {
398 tcH = tc.bottom() - tc.top();
399 colorTexBBox[1] = box.getMaxY() / tcH;
400 colorTexBBox[3] = box.getMinY() / tcH;
402 tcH = tc.top() - tc.bottom();
403 colorTexBBox[1] = box.getMinY() / tcH;
404 colorTexBBox[3] = box.getMaxY() / tcH;
406 colorTexBBox[4] = tcW;
407 colorTexBBox[5] = tcH;
409 final float colorTexBBoxW = colorTexBBox[2] - colorTexBBox[0];
410 final float colorTexBBoxH = colorTexBBox[3] - colorTexBBox[1];
411 System.err.println(
"XXX setTexCoordBBoxSimple:");
412 System.err.println(
"XXX ColorTex "+tex);
413 System.err.println(
"XXX ColorTexBBox min "+colorTexBBox[0]+
"/"+colorTexBBox[1]+
", max "+colorTexBBox[2]+
"/"+colorTexBBox[3]+
414 ", dim "+colorTexBBoxW+
" x "+colorTexBBoxH+
415 ", tc-dim "+tcW+
" x "+tcH+
", tc "+tc);
433 final float box2ImgRatio = boxRatio / imgRatio;
434 final float tcW = tc.right() - tc.left();
436 float boxWidthCut=0, boxHeightCut=0, boxWidthExt=0, boxHeightExt=0;
438 if( box2ImgRatio >= 1.0f ) {
440 boxWidthCut = box.
getWidth() * ( 1f - 1f / box2ImgRatio );
441 final float tcWH = tcW * 0.5f;
442 final float boxWidthCutL = boxWidthCut * tcWH;
443 final float boxWidthCutR = boxWidthCut * ( 1f - tcWH );
444 colorTexBBox[0] = ( box.
getMinX() + boxWidthCutL ) / tcW;
445 colorTexBBox[2] = ( box.
getMaxX() - boxWidthCutR ) / tcW;
447 tcH = tc.bottom() - tc.top();
448 colorTexBBox[1] = box.
getMaxY() / tcH;
449 colorTexBBox[3] = box.
getMinY() / tcH;
451 tcH = tc.top() - tc.bottom();
452 colorTexBBox[1] = box.
getMinY() / tcH;
453 colorTexBBox[3] = box.
getMaxY() / tcH;
456 colorTexBBox[0] = box.
getMinX() / tcW;
457 colorTexBBox[2] = box.
getMaxX() / tcW;
458 boxHeightExt = box.
getHeight() * ( box2ImgRatio - 1f );
460 tcH = tc.bottom() - tc.top();
461 final float tcHH = tcH * 0.5f;
462 final float boxHeightExtB = boxHeightExt * tcHH;
463 final float boxHeightExtT = boxHeightExt * ( 1f - tcHH );
464 colorTexBBox[1] = ( box.
getMaxY() + boxHeightExtT ) / tcH;
465 colorTexBBox[3] = ( box.
getMinY() - boxHeightExtB ) / tcH;
467 tcH = tc.top() - tc.bottom();
468 final float tcHH = tcH * 0.5f;
469 final float boxHeightExtB = boxHeightExt * tcHH;
470 final float boxHeightExtT = boxHeightExt * ( 1f - tcHH );
471 colorTexBBox[1] = ( box.
getMinY() - boxHeightExtB ) / tcH;
472 colorTexBBox[3] = ( box.
getMaxY() + boxHeightExtT ) / tcH;
477 colorTexBBox[0] = box.
getMinX() / tcW;
478 colorTexBBox[2] = box.
getMaxX() / tcW;
479 boxHeightCut = box.
getHeight() * ( 1f - box2ImgRatio );
481 tcH = tc.bottom() - tc.top();
482 final float tcHH = tcH * 0.5f;
483 final float boxHeightCutB = boxHeightCut * tcHH;
484 final float boxHeightCutT = boxHeightCut * ( 1f - tcHH );
485 colorTexBBox[1] = ( box.
getMaxY() - boxHeightCutT ) / tcH;
486 colorTexBBox[3] = ( box.
getMinY() + boxHeightCutB ) / tcH;
488 tcH = tc.top() - tc.bottom();
489 final float tcHH = tcH * 0.5f;
490 final float boxHeightCutB = boxHeightCut * tcHH;
491 final float boxHeightCutT = boxHeightCut * ( 1f - tcHH );
492 colorTexBBox[1] = ( box.
getMinY() + boxHeightCutB ) / tcH;
493 colorTexBBox[3] = ( box.
getMaxY() - boxHeightCutT ) / tcH;
496 boxWidthExt = box.
getWidth() * ( 1f / box2ImgRatio - 1f );
497 final float tcWH = tcW * 0.5f;
498 final float boxWidthExtL = boxWidthExt * tcWH;
499 final float boxWidthExtR = boxWidthExt * ( 1f - tcWH );
500 colorTexBBox[0] = ( box.
getMinX() - boxWidthExtL ) / tcW;
501 colorTexBBox[2] = ( box.
getMaxX() + boxWidthExtR ) / tcW;
503 tcH = tc.bottom() - tc.top();
504 colorTexBBox[1] = box.
getMaxY() / tcH;
505 colorTexBBox[3] = box.
getMinY() / tcH;
507 tcH = tc.top() - tc.bottom();
508 colorTexBBox[1] = box.
getMinY() / tcH;
509 colorTexBBox[3] = box.
getMaxY() / tcH;
513 colorTexBBox[4] = tcW;
514 colorTexBBox[5] = tcH;
518 final float texRatio = ( tc.right() - tc.left() ) / ( tc.bottom() - tc.top() );
519 final float box2TexRatio = boxRatio / texRatio;
520 final float colorTexBBoxW = colorTexBBox[2] - colorTexBBox[0];
521 final float colorTexBBoxH = colorTexBBox[3] - colorTexBBox[1];
522 System.err.println(
"XXX setTexCoordBBox:");
523 System.err.println(
"XXX ColorTex imgRatio "+imgRatio+
", texRatio "+texRatio+
", texPixelRatio[w "+texWidthRatio+
", h "+texHeightRatio+
"], "+tex);
524 System.err.println(
"XXX ColorTexBBox lbox "+letterBox+
", cut "+boxWidthCut+
"/"+boxHeightCut+
", ext "+boxWidthExt+
"/"+boxHeightExt);
525 System.err.println(
"XXX ColorTexBBox min "+colorTexBBox[0]+
"/"+colorTexBBox[1]+
", max "+colorTexBBox[2]+
"/"+colorTexBBox[3]+
526 ", dim "+colorTexBBoxW+
" x "+colorTexBBoxH+
527 ", tc-dim "+tcW+
" x "+tcH+
", tc "+tc+
", box2ImgRatio "+box2ImgRatio+
", box2TexRatio "+box2TexRatio);
528 System.err.println(
"XXX Box ratio "+boxRatio+
", "+box);
4D Vector based upon four float components.
Axis Aligned Bounding Box.
Specifies texture coordinates for a rectangular area of a texture.
Texture holder interface, maybe specialized by implementation to associated related data.
final Texture getTexture()
TextureFrame(final Texture t)
TextureFrame(final Texture t, final int pts, final int duration)
Represents an OpenGL texture object.
int getImageHeight()
Returns the height of the image contained within this texture.
TextureCoords getImageTexCoords()
Returns the set of texture coordinates corresponding to the entire image.
int getHeight()
Returns the height of the allocated OpenGL texture in pixels.
boolean getMustFlipVertically()
Indicates whether this texture's texture coordinates must be flipped vertically in order to properly ...
float getAspectRatio()
Returns the original aspect ratio of the image, defined as (image width) / (image height),...
int getWidth()
Returns the width of the allocated OpenGL texture in pixels.
int getTextureObject(final GL gl)
Returns the underlying OpenGL texture object for this texture and generates it if not done yet.
int getImageWidth()
Returns the width of the image contained within this texture.
Event listener to notify users of updates regarding the TextureSequence.
void newFrameAvailable(T ts, TextureFrame newFrame, long when)
Signaling listeners that a new TextureFrame is available.
Protocol for texture sequences, like animations, movies, etc.
void setARatioLetterbox(final boolean v, Vec4f backColor)
Toggles useARatioLetterbox().
static final String sampler2D
TextureFrame getLastTexture()
Returns the last updated texture.
int getTextureTarget()
Returns the texture target used by implementation.
String getTextureLookupFragmentShaderImpl()
Returns the complete texture2D lookup function code of type.
String getTextureSampler2DType()
Returns either sampler2D or samplerExternalOES depending on getLastTexture().
boolean useARatioLetterbox()
Returns whether useARatioAdjustment() shall add letter-box space to match aspect-ratio,...
int getTextureFragmentShaderHashCode()
Returns the hash code of the string getTextureFragmentShaderHashID().
String setTextureLookupFunctionName(String texLookupFuncName)
Set the desired shader code's texture lookup function name.
static void setTexCoordBBoxSimple(final Texture tex, final AABBox box, final float[] colorTexBBox, final boolean verbose)
Calculates the texture coordinates bounding box w/o correcting aspect-ratio.
String getTextureLookupFunctionName()
Returns the chosen lookup function name, which can be set via setTextureLookupFunctionName(String).
int getTextureUnit()
Return the texture unit used to render the current frame.
TextureFrame getNextTexture(GL gl)
Returns the next texture to be rendered.
static final String samplerExternalOES
Vec4f getARatioLetterboxBackColor()
Returns useARatioLetterbox() background color for added letter-box space, defaults to transparent zer...
static void setTexCoordBBox(final Texture tex, final AABBox box, final boolean letterBox, final float[] colorTexBBox, final boolean verbose)
Calculates the texture coordinates bounding box while correcting for aspect-ratio.
boolean isTextureAvailable()
Returns true if texture source is ready and a texture is available via getNextTexture(GL) and getLast...
boolean useARatioAdjustment()
Returning true indicates texture correction for aspect-ratio in the shader.
String getTextureFragmentShaderHashID()
Returns the concatenated string representing the following values utilized for getTextureFragmentShad...
String getRequiredExtensionsShaderStub()
In case a shader extension is required, based on the implementation and the runtime GL profile,...
int[] getTextureMinMagFilter()
void setARatioAdjustment(final boolean v)
Toggles useARatioLetterbox().