JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
TextureSequence.java
Go to the documentation of this file.
1/**
2 * Copyright 2012-2024 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28package com.jogamp.opengl.util.texture;
29
30import com.jogamp.opengl.GL;
31import com.jogamp.opengl.GLAutoDrawable;
32import com.jogamp.opengl.GLRunnable;
33import com.jogamp.opengl.GLEventListener;
34
35import com.jogamp.common.av.TimeFrameI;
36import com.jogamp.graph.curve.Region;
37import com.jogamp.math.Vec4f;
38import com.jogamp.math.geom.AABBox;
39
40/**
41 * Protocol for texture sequences, like animations, movies, etc.
42 * <p>
43 * Ensure to respect the texture coordinates provided by
44 * {@link TextureFrame}.{@link TextureFrame#getTexture() getTexture()}.{@link Texture#getImageTexCoords() getImageTexCoords()}.
45 * </p>
46 * The user's shader shall be fitted for this implementation.
47 * Assuming we use a base shader code w/o headers using </code>ShaderCode</code>.
48 * (Code copied from unit test / demo <code>TexCubeES2</code>)
49 * <pre>
50 *
51 static final String[] es2_prelude = { "#version 100\n", "precision mediump float;\n" };
52 static final String gl2_prelude = "#version 110\n";
53 static final String shaderBasename = "texsequence_xxx"; // the base shader code w/o headers
54 static final String myTextureLookupName = "myTexture2D"; // the desired texture lookup function
55
56 private void initShader(GL2ES2 gl, TextureSequence texSeq) {
57 // Create & Compile the shader objects
58 ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, TexCubeES2.class,
59 "shader", "shader/bin", shaderBasename, true);
60 ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, TexCubeES2.class,
61 "shader", "shader/bin", shaderBasename, true);
62
63 // Prelude shader code w/ GLSL profile specifics [ 1. pre-proc, 2. other ]
64 int rsFpPos;
65 if(gl.isGLES2()) {
66 // insert ES2 version string in beginning
67 rsVp.insertShaderSource(0, 0, es2_prelude[0]);
68 rsFpPos = rsFp.insertShaderSource(0, 0, es2_prelude[0]);
69 } else {
70 // insert GL2 version string in beginning
71 rsVp.insertShaderSource(0, 0, gl2_prelude);
72 rsFpPos = rsFp.insertShaderSource(0, 0, gl2_prelude);
73 }
74 // insert required extensions as determined by TextureSequence implementation.
75 rsFpPos = rsFp.insertShaderSource(0, rsFpPos, texSeq.getRequiredExtensionsShaderStub());
76 if(gl.isGLES2()) {
77 // insert ES2 default precision declaration
78 rsFpPos = rsFp.insertShaderSource(0, rsFpPos, es2_prelude[1]);
79 }
80 // negotiate the texture lookup function name
81 final String texLookupFuncName = texSeq.getTextureLookupFunctionName(myTextureLookupName);
82
83 // in case a fixed lookup function is being chosen, replace the name in our code
84 rsFp.replaceInShaderSource(myTextureLookupName, texLookupFuncName);
85
86 // Cache the TextureSequence shader details in StringBuilder:
87 final StringBuilder sFpIns = new StringBuilder();
88
89 // .. declaration of the texture sampler using the implementation specific type
90 sFpIns.append("uniform ").append(texSeq.getTextureSampler2DType()).append(" mgl_ActiveTexture;\n");
91
92 // .. the actual texture lookup function, maybe null in case a built-in function is being used
93 sFpIns.append(texSeq.getTextureLookupFragmentShaderImpl());
94
95 // Now insert the TextureShader details in our shader after the given tag:
96 rsFp.insertShaderSource(0, "TEXTURE-SEQUENCE-CODE-BEGIN", 0, sFpIns);
97
98 // Create & Link the shader program
99 ShaderProgram sp = new ShaderProgram();
100 sp.add(rsVp);
101 sp.add(rsFp);
102 if(!sp.link(gl, System.err)) {
103 throw new GLException("Couldn't link program: "+sp);
104 }
105 ...
106 * </pre>
107 * The above procedure might look complicated, however, it allows most flexibility and
108 * workarounds to also deal with GLSL bugs.
109 *
110 */
111public interface TextureSequence {
112 public static final String samplerExternalOES = "samplerExternalOES";
113 public static final String sampler2D = "sampler2D";
114
115 /**
116 * Texture holder interface, maybe specialized by implementation
117 * to associated related data.
118 */
119 public static class TextureFrame extends TimeFrameI {
120 public TextureFrame(final Texture t, final int pts, final int duration) {
121 super(pts, duration);
122 texture = t;
123 }
124 public TextureFrame(final Texture t) {
125 texture = t;
126 }
127
128 public final Texture getTexture() { return texture; }
129
130 @Override
131 public String toString() {
132 return "TextureFrame[pts " + pts + " ms, l " + duration + " ms, texID "+ (null != texture ? texture.getTextureObject() : 0) + "]";
133 }
134 protected final Texture texture;
135 }
136
137 /**
138 * Event listener to notify users of updates regarding the {@link TextureSequence}.
139 * <p>
140 * Implementations sending events down to all listeners,
141 * while not necessarily making the user's OpenGL context current.
142 * </p>
143 * <p>
144 * Events may be sent from a 3rd-party thread, possibly holding another, maybe shared, OpenGL context current.<br/>
145 * Hence a user shall not issue <i>any</i> OpenGL, time consuming
146 * or {@link TextureSequence} operations directly.<br>
147 * Instead, the user shall:
148 * <ul>
149 * <li>off-load complex or {@link TextureSequence} commands on another thread, or</li>
150 * <li>injecting {@link GLRunnable} objects via {@link GLAutoDrawable#invoke(boolean, GLRunnable)}, or</li>
151 * <li>simply changing a volatile state of their {@link GLEventListener} implementation.</li>
152 * </ul>
153 * </p>
154 * */
155 public interface TexSeqEventListener<T extends TextureSequence> {
156 /**
157 * Signaling listeners that a new {@link TextureFrame} is available.
158 * <p>
159 * User shall utilize {@link TextureSequence#getNextTexture(GL)} to dequeue it to maintain
160 * a consistent queue.
161 * </p>
162 * @param ts the event source
163 * @param newFrame the newly enqueued frame
164 * @param when system time in msec.
165 **/
166 public void newFrameAvailable(T ts, TextureFrame newFrame, long when);
167 }
168
169 /** Returns the texture target used by implementation. */
170 public int getTextureTarget();
171
172 /** Return the texture unit used to render the current frame. */
173 public int getTextureUnit();
174
176
177 public int[] getTextureWrapST();
178
179 /**
180 * Returning {@code true} indicates texture correction for aspect-ratio in the shader.
181 * Graph's {@link Region} shader will utilize {@link #setTexCoordBBox(Texture, AABBox, boolean, float[], boolean)}
182 * for texture-coordinate bounding-box calculation.
183 * <p>
184 * Returning {@code false} indicates no correction for aspect-ratio in the shader.
185 * Graph's {@link Region} shader will utilize {@link #setTexCoordBBoxSimple(Texture, AABBox, float[], boolean)}
186 * for texture-coordinate bounding-box calculation.
187 * </p>
188 * <p>
189 * Default value is implementation specific
190 * and toggling is optional.
191 * </p>
192 * @see #setTexCoordBBox(Texture, AABBox, boolean, float[], boolean)
193 * @see #setTexCoordBBoxSimple(Texture, AABBox, float[], boolean)
194 * @see #useARatioLetterbox()
195 */
196 public boolean useARatioAdjustment();
197
198 /**
199 * Toggles {@link #useARatioLetterbox()}.
200 * <p>
201 * Default value is implementation specific
202 * and toggling is optional.
203 * </p>
204 * @see #useARatioLetterbox()
205 * @see #useARatioAdjustment()
206 */
207 public void setARatioAdjustment(final boolean v);
208
209 /**
210 * Returns whether {@link #useARatioAdjustment()} shall add letter-box space to match aspect-ratio, otherwise it will be zoomed in.
211 * <p>
212 * Default value is implementation specific
213 * and toggling is optional.
214 * </p>
215 * @see #useARatioAdjustment()
216 * @see #setARatioLetterbox(boolean, Vec4f)
217 */
218 public boolean useARatioLetterbox();
219
220 /** Returns {@link #useARatioLetterbox()} background color for added letter-box space, defaults to transparent zero. */
222
223 /**
224 * Toggles {@link #useARatioLetterbox()}.
225 * <p>
226 * Default value is implementation specific
227 * and toggling is optional.
228 * </p>
229 * <p>
230 * Impacts only if {@link #useARatioAdjustment()} returns {@code true}.
231 * </p>
232 * @param v new value for {@link #useARatioLetterbox()}
233 * @param backColor optional background color for added letter-box space, defaults to transparent zero
234 * @see #useARatioLetterbox()
235 * @see #useARatioAdjustment()
236 */
237 public void setARatioLetterbox(final boolean v, Vec4f backColor);
238
239 /**
240 * Returns true if texture source is ready <i>and</i> a texture is available
241 * via {@link #getNextTexture(GL)} and {@link #getLastTexture()}.
242 */
243 public boolean isTextureAvailable();
244
245 /**
246 * Returns the last updated texture.
247 * <p>
248 * In case the instance is just initialized, it shall return a <code>TextureFrame</code>
249 * object with valid attributes. The texture content may be undefined
250 * until the first call of {@link #getNextTexture(GL)}.<br>
251 * </p>
252 * Not blocking.
253 *
254 * @throws IllegalStateException if instance is not initialized
255 */
256 public TextureFrame getLastTexture() throws IllegalStateException ;
257
258 /**
259 * Returns the next texture to be rendered.
260 * <p>
261 * Implementation shall return the next frame if available, may block if a next frame may arrive <i>soon</i>.
262 * Otherwise implementation shall return the last frame.
263 * </p>
264 * <p>
265 * Shall return <code>null</code> in case <i>no</i> next or last frame is available.
266 * </p>
267 *
268 * @throws IllegalStateException if instance is not initialized
269 */
270 public TextureFrame getNextTexture(GL gl) throws IllegalStateException ;
271
272 /**
273 * In case a shader extension is required, based on the implementation
274 * and the runtime GL profile, this method returns the preprocessor macros, e.g.:
275 * <pre>
276 * #extension GL_OES_EGL_image_external : enable
277 * </pre>
278 *
279 * @throws IllegalStateException if instance is not initialized
280 */
281 public String getRequiredExtensionsShaderStub() throws IllegalStateException ;
282
283 /**
284 * Returns either <code>sampler2D</code> or <code>samplerExternalOES</code>
285 * depending on {@link #getLastTexture()}.{@link TextureFrame#getTexture() getTexture()}.{@link Texture#getTarget() getTarget()}.
286 *
287 * @throws IllegalStateException if instance is not initialized
288 **/
289 public String getTextureSampler2DType() throws IllegalStateException ;
290
291 /**
292 * Set the desired shader code's texture lookup function name.
293 *
294 * @param texLookupFuncName desired lookup function name. If <code>null</code> or ignored by the implementation,
295 * a build-in name is returned.
296 * @return the chosen lookup function name
297 *
298 * @throws IllegalStateException if instance is not initialized
299 * @see #getTextureLookupFunctionName()
300 * @see #getTextureFragmentShaderHashCode()
301 * @see #getTextureLookupFragmentShaderImpl()
302 */
303 public String setTextureLookupFunctionName(String texLookupFuncName) throws IllegalStateException ;
304
305 /**
306 * Returns the chosen lookup function name, which can be set via {@link #setTextureLookupFunctionName(String)}.
307 *
308 * @throws IllegalStateException if instance is not initialized
309 * @see #setTextureLookupFunctionName(String)
310 * @see #getTextureFragmentShaderHashCode()
311 * @see #getTextureLookupFragmentShaderImpl()
312 */
313 public String getTextureLookupFunctionName() throws IllegalStateException ;
314
315 /**
316 * Returns the complete texture2D lookup function code of type
317 * <pre>
318 * vec4 <i>funcName</i>(in <i>getTextureSampler2DType()</i> image, in vec2 texCoord) {
319 * vec4 texColor = do_something_with(image, texCoord);
320 * return texColor;
321 * }
322 * </pre>
323 * <p>
324 * <i>funcName</i> is set via {@link #setTextureLookupFunctionName(String)}
325 * and queried via {@link #getTextureLookupFunctionName()}.
326 * </p>
327 * <p>
328 * User shall call {@link #setTextureLookupFunctionName(String)} first if intended.
329 * </p>
330 * <p>
331 * Note: This function may return an empty string in case a build-in lookup
332 * function is being chosen. If the implementation desires so,
333 * {@link #getTextureLookupFunctionName()} will ignore the desired function name
334 * and returns the build-in lookup function name.
335 * </p>
336 * @throws IllegalStateException if instance is not initialized
337 * @see #getTextureLookupFunctionName()
338 * @see #setTextureLookupFunctionName(String)
339 * @see #getTextureFragmentShaderHashID()
340 * @see #getTextureFragmentShaderHashCode()
341 * @see #getTextureSampler2DType()
342 */
343 public String getTextureLookupFragmentShaderImpl() throws IllegalStateException;
344
345 /**
346 * Returns the concatenated string representing the following values
347 * utilized for {@link #getTextureFragmentShaderHashCode()}.
348 * <ul>
349 * <li>{@link #getTextureSampler2DType()}</li>
350 * <li>{@link #getTextureLookupFunctionName()}</li>
351 * <li>{@link #getTextureLookupFragmentShaderImpl()}</li>
352 * </ul>
353 * <p>
354 * To reduce string concatenating, implementation may simply return {@link #getTextureLookupFragmentShaderImpl()},
355 * if it covers {@link #getTextureSampler2DType()} and {@link #getTextureLookupFunctionName()}.
356 * </p>
357 * @see #getTextureFragmentShaderHashCode()
358 */
360
361 /**
362 * Returns the hash code of the string {@link #getTextureFragmentShaderHashID()}.
363 * <p>
364 * User shall call {@link #setTextureLookupFunctionName(String)} first if intended.
365 * </p>
366 * <p>
367 * Returns zero if {@link #isTextureAvailable() texture is not available}.
368 * </p>
369 * The returned hash code allows selection of a matching shader program for this {@link TextureSequence} instance.
370 * <p>
371 * </p>
372 * <p>
373 * Implementation caches the resulting hash code, which is reset by {@link #setTextureLookupFunctionName(String)}
374 * and this method if {@link #isTextureAvailable() texture is not available}.
375 * </p>
376 * @see #setTextureLookupFunctionName(String)
377 * @see #getTextureLookupFunctionName()
378 * @see #getTextureLookupFragmentShaderImpl()
379 * @see #getTextureFragmentShaderHashID()
380 */
382
383 /**
384 * Calculates the texture coordinates bounding box w/o correcting aspect-ratio.
385 * @param tex the {@link Texture}
386 * @param box the {@Link AABBox} of the destination
387 * @param colorTexBBox destination float[6] array for the following three texture-coordinate tuples: minX/minY, maxX/maxY, texW/texH
388 * @param verbose TODO
389 * @see #useARatioAdjustment()
390 */
391 public static void setTexCoordBBoxSimple(final Texture tex, final AABBox box, final float[] colorTexBBox, final boolean verbose) {
392 final TextureCoords tc = tex.getImageTexCoords();
393 final float tcW = tc.right() - tc.left();
394 final float tcH;
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;
401 } else {
402 tcH = tc.top() - tc.bottom();
403 colorTexBBox[1] = box.getMinY() / tcH;
404 colorTexBBox[3] = box.getMaxY() / tcH;
405 }
406 colorTexBBox[4] = tcW;
407 colorTexBBox[5] = tcH;
408 if( verbose ) {
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);
416 }
417
418 }
419
420 /**
421 * Calculates the texture coordinates bounding box while correcting for aspect-ratio.
422 * @param tex the {@link Texture}
423 * @param box the {@Link AABBox} of the destination
424 * @param letterBox true to produce letter-box space to match aspect-ratio, otherwise will zoom in
425 * @param colorTexBBox destination float[6] array for the following three texture-coordinate tuples: minX/minY, maxX/maxY, texW/texH
426 * @param verbose TODO
427 * @see #useARatioAdjustment()
428 */
429 public static void setTexCoordBBox(final Texture tex, final AABBox box, final boolean letterBox, final float[] colorTexBBox, final boolean verbose) {
430 final TextureCoords tc = tex.getImageTexCoords();
431 final float boxRatio = box.getWidth() / box.getHeight();
432 final float imgRatio = tex.getAspectRatio();
433 final float box2ImgRatio = boxRatio / imgRatio;
434 final float tcW = tc.right() - tc.left();
435 final float tcH;
436 float boxWidthCut=0, boxHeightCut=0, boxWidthExt=0, boxHeightExt=0;
437
438 if( box2ImgRatio >= 1.0f ) {
439 if( letterBox ) {
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;
446 if( tex.getMustFlipVertically() ) {
447 tcH = tc.bottom() - tc.top();
448 colorTexBBox[1] = box.getMaxY() / tcH;
449 colorTexBBox[3] = box.getMinY() / tcH;
450 } else {
451 tcH = tc.top() - tc.bottom();
452 colorTexBBox[1] = box.getMinY() / tcH;
453 colorTexBBox[3] = box.getMaxY() / tcH;
454 }
455 } else {
456 colorTexBBox[0] = box.getMinX() / tcW;
457 colorTexBBox[2] = box.getMaxX() / tcW;
458 boxHeightExt = box.getHeight() * ( box2ImgRatio - 1f );
459 if( tex.getMustFlipVertically() ) {
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;
466 } else {
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;
473 }
474 }
475 } else {
476 if( letterBox ) {
477 colorTexBBox[0] = box.getMinX() / tcW;
478 colorTexBBox[2] = box.getMaxX() / tcW;
479 boxHeightCut = box.getHeight() * ( 1f - box2ImgRatio );
480 if( tex.getMustFlipVertically() ) {
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;
487 } else {
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;
494 }
495 } else {
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;
502 if( tex.getMustFlipVertically() ) {
503 tcH = tc.bottom() - tc.top();
504 colorTexBBox[1] = box.getMaxY() / tcH;
505 colorTexBBox[3] = box.getMinY() / tcH;
506 } else {
507 tcH = tc.top() - tc.bottom();
508 colorTexBBox[1] = box.getMinY() / tcH;
509 colorTexBBox[3] = box.getMaxY() / tcH;
510 }
511 }
512 }
513 colorTexBBox[4] = tcW;
514 colorTexBBox[5] = tcH;
515 if( verbose ) {
516 final float texWidthRatio = (float)tex.getImageWidth() / (float)tex.getWidth();
517 final float texHeightRatio = (float)tex.getImageHeight() / (float)tex.getHeight();
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);
529 }
530 }
531}
4D Vector based upon four float components.
Definition: Vec4f.java:37
Axis Aligned Bounding Box.
Definition: AABBox.java:54
final float getWidth()
Definition: AABBox.java:879
final float getHeight()
Definition: AABBox.java:883
Specifies texture coordinates for a rectangular area of a texture.
Texture holder interface, maybe specialized by implementation to associated related data.
TextureFrame(final Texture t, final int pts, final int duration)
Represents an OpenGL texture object.
Definition: Texture.java:173
int getImageHeight()
Returns the height of the image contained within this texture.
Definition: Texture.java:459
TextureCoords getImageTexCoords()
Returns the set of texture coordinates corresponding to the entire image.
Definition: Texture.java:480
int getHeight()
Returns the height of the allocated OpenGL texture in pixels.
Definition: Texture.java:431
boolean getMustFlipVertically()
Indicates whether this texture's texture coordinates must be flipped vertically in order to properly ...
Definition: Texture.java:536
float getAspectRatio()
Returns the original aspect ratio of the image, defined as (image width) / (image height),...
Definition: Texture.java:468
int getWidth()
Returns the width of the allocated OpenGL texture in pixels.
Definition: Texture.java:420
int getTextureObject(final GL gl)
Returns the underlying OpenGL texture object for this texture and generates it if not done yet.
Definition: Texture.java:968
int getImageWidth()
Returns the width of the image contained within this texture.
Definition: Texture.java:445
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().
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.
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,...
void setARatioAdjustment(final boolean v)
Toggles useARatioLetterbox().