Gamp v0.0.7-54-gccdc599
Gamp: Graphics, Audio, Multimedia and Processing
Loading...
Searching...
No Matches
TextureSequence.hpp
Go to the documentation of this file.
1/*
2 * Author: Sven Gothel <sgothel@jausoft.com>
3 * Copyright Gothel Software e.K.
4 *
5 * SPDX-License-Identifier: MIT
6 *
7 * This Source Code Form is subject to the terms of the MIT License
8 * If a copy of the MIT was not distributed with this file,
9 * you can obtain one at https://opensource.org/license/mit/.
10 */
11#ifndef GAMP_RENDER_GL_TEXTURE_TEXTURESEQUENCE_HPP_
12#define GAMP_RENDER_GL_TEXTURE_TEXTURESEQUENCE_HPP_
13
14#include <jau/string_util.hpp>
16#include <gamp/GampTypes.hpp>
19
21
23 /** \addtogroup Gamp_GL
24 *
25 * @{
26 */
27
28 /**
29 * Protocol for texture sequences, like animations, movies, etc.
30 * <p>
31 * Ensure to respect the texture coordinates provided by
32 * {@link TextureFrame}.{@link TextureFrame#getTexture() getTexture()}.{@link Texture#getImageTexCoords() getImageTexCoords()}.
33 * </p>
34 * The user's shader shall be fitted for this implementation.
35 * Assuming we use a base shader code w/o headers using </code>ShaderCode</code>.
36 * (Code copied from unit test / demo <code>TexCubeES2</code>)
37 * <pre>
38 *
39 static final String[] es2_prelude = { "#version 100\n", "precision mediump float;\n" };
40 static final String gl2_prelude = "#version 110\n";
41 static final String shaderBasename = "texsequence_xxx"; // the base shader code w/o headers
42 static final String myTextureLookupName = "myTexture2D"; // the desired texture lookup function
43
44 private void initShader(GL2ES2 gl, TextureSequence texSeq) {
45 // Create & Compile the shader objects
46 ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, TexCubeES2.class,
47 "shader", "shader/bin", shaderBasename, true);
48 ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, TexCubeES2.class,
49 "shader", "shader/bin", shaderBasename, true);
50
51 // Prelude shader code w/ GLSL profile specifics [ 1. pre-proc, 2. other ]
52 int rsFpPos;
53 if(gl.isGLES2()) {
54 // insert ES2 version string in beginning
55 rsVp.insertShaderSource(0, 0, es2_prelude[0]);
56 rsFpPos = rsFp.insertShaderSource(0, 0, es2_prelude[0]);
57 } else {
58 // insert GL2 version string in beginning
59 rsVp.insertShaderSource(0, 0, gl2_prelude);
60 rsFpPos = rsFp.insertShaderSource(0, 0, gl2_prelude);
61 }
62 // insert required extensions as determined by TextureSequence implementation.
63 rsFpPos = rsFp.insertShaderSource(0, rsFpPos, texSeq.getRequiredExtensionsShaderStub());
64 if(gl.isGLES2()) {
65 // insert ES2 default precision declaration
66 rsFpPos = rsFp.insertShaderSource(0, rsFpPos, es2_prelude[1]);
67 }
68 // negotiate the texture lookup function name
69 final String texLookupFuncName = texSeq.getTextureLookupFunctionName(myTextureLookupName);
70
71 // in case a fixed lookup function is being chosen, replace the name in our code
72 rsFp.replaceInShaderSource(myTextureLookupName, texLookupFuncName);
73
74 // Cache the TextureSequence shader details in StringBuilder:
75 final StringBuilder sFpIns = new StringBuilder();
76
77 // .. declaration of the texture sampler using the implementation specific type
78 sFpIns.append("uniform ").append(texSeq.getTextureSampler2DType()).append(" mgl_ActiveTexture;\n");
79
80 // .. the actual texture lookup function, maybe null in case a built-in function is being used
81 sFpIns.append(texSeq.getTextureLookupFragmentShaderImpl());
82
83 // Now insert the TextureShader details in our shader after the given tag:
84 rsFp.insertShaderSource(0, "TEXTURE-SEQUENCE-CODE-BEGIN", 0, sFpIns);
85
86 // Create & Link the shader program
87 ShaderProgram sp = new ShaderProgram();
88 sp.add(rsVp);
89 sp.add(rsFp);
90 if(!sp.link(gl, System.err)) {
91 throw new GLException("Couldn't link program: "+sp);
92 }
93 ...
94 * </pre>
95 * The above procedure might look complicated, however, it allows most flexibility and
96 * workarounds to also deal with GLSL bugs.
97 *
98 */
100 public:
101 constexpr static std::string_view samplerExternalOES = "samplerExternalOES";
102 constexpr static std::string_view sampler2D = "sampler2D";
103
104 /**
105 * Texture holder interface, maybe specialized by implementation
106 * to associated related data.
107 */
109 public:
110 TextureFrame(final Texture t, final int pts, final int duration) {
111 super(pts, duration);
112 texture = t;
113 }
114 public TextureFrame(final Texture t) {
115 texture = t;
116 }
117
118 public final Texture getTexture() { return texture; }
119
120 @Override
121 public String toString() {
122 return "TextureFrame[pts " + pts + " ms, l " + duration + " ms, texID "+ (null != texture ? texture.getTextureObject() : 0) + "]";
123 }
124 protected final Texture texture;
125 }
126
127 /**
128 * Event listener to notify users of updates regarding the {@link TextureSequence}.
129 * <p>
130 * Implementations sending events down to all listeners,
131 * while not necessarily making the user's OpenGL context current.
132 * </p>
133 * <p>
134 * Events may be sent from a 3rd-party thread, possibly holding another, maybe shared, OpenGL context current.<br/>
135 * Hence a user shall not issue <i>any</i> OpenGL, time consuming
136 * or {@link TextureSequence} operations directly.<br>
137 * Instead, the user shall:
138 * <ul>
139 * <li>off-load complex or {@link TextureSequence} commands on another thread, or</li>
140 * <li>injecting {@link GLRunnable} objects via {@link GLAutoDrawable#invoke(boolean, GLRunnable)}, or</li>
141 * <li>simply changing a volatile state of their {@link GLEventListener} implementation.</li>
142 * </ul>
143 * </p>
144 * */
145 public interface TexSeqEventListener<T extends TextureSequence> {
146 /**
147 * Signaling listeners that a new {@link TextureFrame} is available.
148 * <p>
149 * User shall utilize {@link TextureSequence#getNextTexture(GL)} to dequeue it to maintain
150 * a consistent queue.
151 * </p>
152 * @param ts the event source
153 * @param newFrame the newly enqueued frame
154 * @param when system time in msec.
155 **/
156 public void newFrameAvailable(T ts, TextureFrame newFrame, long when);
157 }
158
159 /** Returns the texture target used by implementation. */
160 public int getTextureTarget();
161
162 /** Return the texture unit used to render the current frame. */
163 public int getTextureUnit();
164
166
167 public int[] getTextureWrapST();
168
169 /**
170 * Returning {@code true} indicates texture correction for aspect-ratio in the shader.
171 * Graph's {@link Region} shader will utilize {@link #setTexCoordBBox(Texture, AABBox, boolean, float[], boolean)}
172 * for texture-coordinate bounding-box calculation.
173 * <p>
174 * Returning {@code false} indicates no correction for aspect-ratio in the shader.
175 * Graph's {@link Region} shader will utilize {@link #setTexCoordBBoxSimple(Texture, AABBox, float[], boolean)}
176 * for texture-coordinate bounding-box calculation.
177 * </p>
178 * <p>
179 * Default value is implementation specific
180 * and toggling is optional.
181 * </p>
182 * @see #setTexCoordBBox(Texture, AABBox, boolean, float[], boolean)
183 * @see #setTexCoordBBoxSimple(Texture, AABBox, float[], boolean)
184 * @see #useARatioLetterbox()
185 */
186 public boolean useARatioAdjustment();
187
188 /**
189 * Toggles {@link #useARatioLetterbox()}.
190 * <p>
191 * Default value is implementation specific
192 * and toggling is optional.
193 * </p>
194 * @see #useARatioLetterbox()
195 * @see #useARatioAdjustment()
196 */
197 public void setARatioAdjustment(final boolean v);
198
199 /**
200 * Returns whether {@link #useARatioAdjustment()} shall add letter-box space to match aspect-ratio, otherwise it will be zoomed in.
201 * <p>
202 * Default value is implementation specific
203 * and toggling is optional.
204 * </p>
205 * @see #useARatioAdjustment()
206 * @see #setARatioLetterbox(boolean, Vec4f)
207 */
208 public boolean useARatioLetterbox();
209
210 /** Returns {@link #useARatioLetterbox()} background color for added letter-box space, defaults to transparent zero. */
212
213 /**
214 * Toggles {@link #useARatioLetterbox()}.
215 * <p>
216 * Default value is implementation specific
217 * and toggling is optional.
218 * </p>
219 * <p>
220 * Impacts only if {@link #useARatioAdjustment()} returns {@code true}.
221 * </p>
222 * @param v new value for {@link #useARatioLetterbox()}
223 * @param backColor optional background color for added letter-box space, defaults to transparent zero
224 * @see #useARatioLetterbox()
225 * @see #useARatioAdjustment()
226 */
227 public void setARatioLetterbox(final boolean v, Vec4f backColor);
228
229 /**
230 * Returns true if texture source is ready <i>and</i> a texture is available
231 * via {@link #getNextTexture(GL)} and {@link #getLastTexture()}.
232 */
233 public boolean isTextureAvailable();
234
235 /**
236 * Returns the last updated texture.
237 * <p>
238 * In case the instance is just initialized, it shall return a <code>TextureFrame</code>
239 * object with valid attributes. The texture content may be undefined
240 * until the first call of {@link #getNextTexture(GL)}.<br>
241 * </p>
242 * Not blocking.
243 *
244 * @throws IllegalStateException if instance is not initialized
245 */
246 public TextureFrame getLastTexture() throws IllegalStateException ;
247
248 /**
249 * Returns the next texture to be rendered.
250 * <p>
251 * Implementation shall return the next frame if available, may block if a next frame may arrive <i>soon</i>.
252 * Otherwise implementation shall return the last frame.
253 * </p>
254 * <p>
255 * Shall return <code>null</code> in case <i>no</i> next or last frame is available.
256 * </p>
257 *
258 * @throws IllegalStateException if instance is not initialized
259 */
260 public TextureFrame getNextTexture(GL gl) throws IllegalStateException ;
261
262 /**
263 * In case a shader extension is required, based on the implementation
264 * and the runtime GL profile, this method returns the preprocessor macros, e.g.:
265 * <pre>
266 * #extension GL_OES_EGL_image_external : enable
267 * </pre>
268 *
269 * @throws IllegalStateException if instance is not initialized
270 */
271 public String getRequiredExtensionsShaderStub() throws IllegalStateException ;
272
273 /**
274 * Returns either <code>sampler2D</code> or <code>samplerExternalOES</code>
275 * depending on {@link #getLastTexture()}.{@link TextureFrame#getTexture() getTexture()}.{@link Texture#getTarget() getTarget()}.
276 *
277 * @throws IllegalStateException if instance is not initialized
278 **/
279 public String getTextureSampler2DType() throws IllegalStateException ;
280
281 /**
282 * Set the desired shader code's texture lookup function name.
283 *
284 * @param texLookupFuncName desired lookup function name. If <code>null</code> or ignored by the implementation,
285 * a build-in name is returned.
286 * @return the chosen lookup function name
287 *
288 * @throws IllegalStateException if instance is not initialized
289 * @see #getTextureLookupFunctionName()
290 * @see #getTextureFragmentShaderHashCode()
291 * @see #getTextureLookupFragmentShaderImpl()
292 */
293 public String setTextureLookupFunctionName(String texLookupFuncName) throws IllegalStateException ;
294
295 /**
296 * Returns the chosen lookup function name, which can be set via {@link #setTextureLookupFunctionName(String)}.
297 *
298 * @throws IllegalStateException if instance is not initialized
299 * @see #setTextureLookupFunctionName(String)
300 * @see #getTextureFragmentShaderHashCode()
301 * @see #getTextureLookupFragmentShaderImpl()
302 */
303 public String getTextureLookupFunctionName() throws IllegalStateException ;
304
305 /**
306 * Returns the complete texture2D lookup function code of type
307 * <pre>
308 * vec4 <i>funcName</i>(in <i>getTextureSampler2DType()</i> image, in vec2 texCoord) {
309 * vec4 texColor = do_something_with(image, texCoord);
310 * return texColor;
311 * }
312 * </pre>
313 * <p>
314 * <i>funcName</i> is set via {@link #setTextureLookupFunctionName(String)}
315 * and queried via {@link #getTextureLookupFunctionName()}.
316 * </p>
317 * <p>
318 * User shall call {@link #setTextureLookupFunctionName(String)} first if intended.
319 * </p>
320 * <p>
321 * Note: This function may return an empty string in case a build-in lookup
322 * function is being chosen. If the implementation desires so,
323 * {@link #getTextureLookupFunctionName()} will ignore the desired function name
324 * and returns the build-in lookup function name.
325 * </p>
326 * @throws IllegalStateException if instance is not initialized
327 * @see #getTextureLookupFunctionName()
328 * @see #setTextureLookupFunctionName(String)
329 * @see #getTextureFragmentShaderHashID()
330 * @see #getTextureFragmentShaderHashCode()
331 * @see #getTextureSampler2DType()
332 */
333 public String getTextureLookupFragmentShaderImpl() throws IllegalStateException;
334
335 /**
336 * Returns the concatenated string representing the following values
337 * utilized for {@link #getTextureFragmentShaderHashCode()}.
338 * <ul>
339 * <li>{@link #getTextureSampler2DType()}</li>
340 * <li>{@link #getTextureLookupFunctionName()}</li>
341 * <li>{@link #getTextureLookupFragmentShaderImpl()}</li>
342 * </ul>
343 * <p>
344 * To reduce string concatenating, implementation may simply return {@link #getTextureLookupFragmentShaderImpl()},
345 * if it covers {@link #getTextureSampler2DType()} and {@link #getTextureLookupFunctionName()}.
346 * </p>
347 * @see #getTextureFragmentShaderHashCode()
348 */
350
351 /**
352 * Returns the hash code of the string {@link #getTextureFragmentShaderHashID()}.
353 * <p>
354 * User shall call {@link #setTextureLookupFunctionName(String)} first if intended.
355 * </p>
356 * <p>
357 * Returns zero if {@link #isTextureAvailable() texture is not available}.
358 * </p>
359 * The returned hash code allows selection of a matching shader program for this {@link TextureSequence} instance.
360 * <p>
361 * </p>
362 * <p>
363 * Implementation caches the resulting hash code, which is reset by {@link #setTextureLookupFunctionName(String)}
364 * and this method if {@link #isTextureAvailable() texture is not available}.
365 * </p>
366 * @see #setTextureLookupFunctionName(String)
367 * @see #getTextureLookupFunctionName()
368 * @see #getTextureLookupFragmentShaderImpl()
369 * @see #getTextureFragmentShaderHashID()
370 */
372
373 /**
374 * Calculates the texture coordinates bounding box w/o correcting aspect-ratio.
375 * @param tex the {@link Texture}
376 * @param box the {@Link AABBox} of the destination
377 * @param colorTexBBox destination float[6] array for the following three texture-coordinate tuples: minX/minY, maxX/maxY, texW/texH
378 * @param verbose TODO
379 * @see #useARatioAdjustment()
380 */
381 public static void setTexCoordBBoxSimple(final Texture tex, final AABBox box, final float[] colorTexBBox, final boolean verbose) {
382 final TextureCoords tc = tex.getImageTexCoords();
383 final float tcW = tc.right() - tc.left();
384 final float tcH;
385 colorTexBBox[0] = box.getMinX() / tcW;
386 colorTexBBox[2] = box.getMaxX() / tcW;
387 if( tex.getMustFlipVertically() ) {
388 tcH = tc.bottom() - tc.top();
389 colorTexBBox[1] = box.getMaxY() / tcH;
390 colorTexBBox[3] = box.getMinY() / tcH;
391 } else {
392 tcH = tc.top() - tc.bottom();
393 colorTexBBox[1] = box.getMinY() / tcH;
394 colorTexBBox[3] = box.getMaxY() / tcH;
395 }
396 colorTexBBox[4] = tcW;
397 colorTexBBox[5] = tcH;
398 if( verbose ) {
399 final float colorTexBBoxW = colorTexBBox[2] - colorTexBBox[0];
400 final float colorTexBBoxH = colorTexBBox[3] - colorTexBBox[1];
401 System.err.println("XXX setTexCoordBBoxSimple:");
402 System.err.println("XXX ColorTex "+tex);
403 System.err.println("XXX ColorTexBBox min "+colorTexBBox[0]+"/"+colorTexBBox[1]+", max "+colorTexBBox[2]+"/"+colorTexBBox[3]+
404 ", dim "+colorTexBBoxW+" x "+colorTexBBoxH+
405 ", tc-dim "+tcW+" x "+tcH+", tc "+tc);
406 }
407
408 }
409
410 /**
411 * Calculates the texture coordinates bounding box while correcting for aspect-ratio.
412 * @param tex the {@link Texture}
413 * @param box the {@Link AABBox} of the destination
414 * @param letterBox true to produce letter-box space to match aspect-ratio, otherwise will zoom in
415 * @param colorTexBBox destination float[6] array for the following three texture-coordinate tuples: minX/minY, maxX/maxY, texW/texH
416 * @param verbose TODO
417 * @see #useARatioAdjustment()
418 */
419 public static void setTexCoordBBox(final Texture tex, final AABBox box, final boolean letterBox, final float[] colorTexBBox, final boolean verbose) {
420 final TextureCoords tc = tex.getImageTexCoords();
421 final float boxRatio = box.getWidth() / box.getHeight();
422 final float imgRatio = tex.getAspectRatio();
423 final float box2ImgRatio = boxRatio / imgRatio;
424 final float tcW = tc.right() - tc.left();
425 final float tcH;
426 float boxWidthCut=0, boxHeightCut=0, boxWidthExt=0, boxHeightExt=0;
427
428 if( box2ImgRatio >= 1.0f ) {
429 if( letterBox ) {
430 boxWidthCut = box.getWidth() * ( 1f - 1f / box2ImgRatio );
431 final float tcWH = tcW * 0.5f;
432 final float boxWidthCutL = boxWidthCut * tcWH;
433 final float boxWidthCutR = boxWidthCut * ( 1f - tcWH );
434 colorTexBBox[0] = ( box.getMinX() + boxWidthCutL ) / tcW;
435 colorTexBBox[2] = ( box.getMaxX() - boxWidthCutR ) / tcW;
436 if( tex.getMustFlipVertically() ) {
437 tcH = tc.bottom() - tc.top();
438 colorTexBBox[1] = box.getMaxY() / tcH;
439 colorTexBBox[3] = box.getMinY() / tcH;
440 } else {
441 tcH = tc.top() - tc.bottom();
442 colorTexBBox[1] = box.getMinY() / tcH;
443 colorTexBBox[3] = box.getMaxY() / tcH;
444 }
445 } else {
446 colorTexBBox[0] = box.getMinX() / tcW;
447 colorTexBBox[2] = box.getMaxX() / tcW;
448 boxHeightExt = box.getHeight() * ( box2ImgRatio - 1f );
449 if( tex.getMustFlipVertically() ) {
450 tcH = tc.bottom() - tc.top();
451 final float tcHH = tcH * 0.5f;
452 final float boxHeightExtB = boxHeightExt * tcHH;
453 final float boxHeightExtT = boxHeightExt * ( 1f - tcHH );
454 colorTexBBox[1] = ( box.getMaxY() + boxHeightExtT ) / tcH;
455 colorTexBBox[3] = ( box.getMinY() - boxHeightExtB ) / tcH;
456 } else {
457 tcH = tc.top() - tc.bottom();
458 final float tcHH = tcH * 0.5f;
459 final float boxHeightExtB = boxHeightExt * tcHH;
460 final float boxHeightExtT = boxHeightExt * ( 1f - tcHH );
461 colorTexBBox[1] = ( box.getMinY() - boxHeightExtB ) / tcH;
462 colorTexBBox[3] = ( box.getMaxY() + boxHeightExtT ) / tcH;
463 }
464 }
465 } else {
466 if( letterBox ) {
467 colorTexBBox[0] = box.getMinX() / tcW;
468 colorTexBBox[2] = box.getMaxX() / tcW;
469 boxHeightCut = box.getHeight() * ( 1f - box2ImgRatio );
470 if( tex.getMustFlipVertically() ) {
471 tcH = tc.bottom() - tc.top();
472 final float tcHH = tcH * 0.5f;
473 final float boxHeightCutB = boxHeightCut * tcHH;
474 final float boxHeightCutT = boxHeightCut * ( 1f - tcHH );
475 colorTexBBox[1] = ( box.getMaxY() - boxHeightCutT ) / tcH;
476 colorTexBBox[3] = ( box.getMinY() + boxHeightCutB ) / tcH;
477 } else {
478 tcH = tc.top() - tc.bottom();
479 final float tcHH = tcH * 0.5f;
480 final float boxHeightCutB = boxHeightCut * tcHH;
481 final float boxHeightCutT = boxHeightCut * ( 1f - tcHH );
482 colorTexBBox[1] = ( box.getMinY() + boxHeightCutB ) / tcH;
483 colorTexBBox[3] = ( box.getMaxY() - boxHeightCutT ) / tcH;
484 }
485 } else {
486 boxWidthExt = box.getWidth() * ( 1f / box2ImgRatio - 1f );
487 final float tcWH = tcW * 0.5f;
488 final float boxWidthExtL = boxWidthExt * tcWH;
489 final float boxWidthExtR = boxWidthExt * ( 1f - tcWH );
490 colorTexBBox[0] = ( box.getMinX() - boxWidthExtL ) / tcW;
491 colorTexBBox[2] = ( box.getMaxX() + boxWidthExtR ) / tcW;
492 if( tex.getMustFlipVertically() ) {
493 tcH = tc.bottom() - tc.top();
494 colorTexBBox[1] = box.getMaxY() / tcH;
495 colorTexBBox[3] = box.getMinY() / tcH;
496 } else {
497 tcH = tc.top() - tc.bottom();
498 colorTexBBox[1] = box.getMinY() / tcH;
499 colorTexBBox[3] = box.getMaxY() / tcH;
500 }
501 }
502 }
503 colorTexBBox[4] = tcW;
504 colorTexBBox[5] = tcH;
505 if( verbose ) {
506 final float texWidthRatio = (float)tex.getImageWidth() / (float)tex.getWidth();
507 final float texHeightRatio = (float)tex.getImageHeight() / (float)tex.getHeight();
508 final float texRatio = ( tc.right() - tc.left() ) / ( tc.bottom() - tc.top() );
509 final float box2TexRatio = boxRatio / texRatio;
510 final float colorTexBBoxW = colorTexBBox[2] - colorTexBBox[0];
511 final float colorTexBBoxH = colorTexBBox[3] - colorTexBBox[1];
512 System.err.println("XXX setTexCoordBBox:");
513 System.err.println("XXX ColorTex imgRatio "+imgRatio+", texRatio "+texRatio+", texPixelRatio[w "+texWidthRatio+", h "+texHeightRatio+"], "+tex);
514 System.err.println("XXX ColorTexBBox lbox "+letterBox+", cut "+boxWidthCut+"/"+boxHeightCut+", ext "+boxWidthExt+"/"+boxHeightExt);
515 System.err.println("XXX ColorTexBBox min "+colorTexBBox[0]+"/"+colorTexBBox[1]+", max "+colorTexBBox[2]+"/"+colorTexBBox[3]+
516 ", dim "+colorTexBBoxW+" x "+colorTexBBoxH+
517 ", tc-dim "+tcW+" x "+tcH+", tc "+tc+", box2ImgRatio "+box2ImgRatio+", box2TexRatio "+box2TexRatio);
518 System.err.println("XXX Box ratio "+boxRatio+", "+box);
519 }
520 }
521 };
522
523 /**@}*/
524
525} // namespace gamp::render::gl
526
527#endif /* GAMP_RENDER_GL_TEXTURE_TEXTURESEQUENCE_HPP_ */
528
Integer time frame in milliseconds, maybe specialized for texture/video, audio, .
constexpr uint32_t pts() const noexcept
Returns this frame's presentation timestamp (PTS) in milliseconds.
constexpr uint32_t duration() const noexcept
Get this frame's duration in milliseconds.
Rectangular texture coordinates.
Texture holder interface, maybe specialized by implementation to associated related data.
TextureFrame(final Texture t, final int pts, final int duration)
Protocol for texture sequences, like animations, movies, etc.
gamp::render::gl::texture::TextureSequence::TextureFrame gamp::av::TimeFrameI newFrameAvailable(T ts, TextureFrame newFrame, long when)
Event listener to notify users of updates regarding the TextureSequence.
String getRequiredExtensionsShaderStub()
In case a shader extension is required, based on the implementation and the runtime GL profile,...
String getTextureLookupFragmentShaderImpl()
Returns the complete texture2D lookup function code of type.
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.
static constexpr std::string_view 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.
String getTextureSampler2DType()
Returns either sampler2D or samplerExternalOES depending on getLastTexture().
void setARatioLetterbox(final boolean v, Vec4f backColor)
Toggles useARatioLetterbox().
int getTextureFragmentShaderHashCode()
Returns the hash code of the string getTextureFragmentShaderHashID().
boolean useARatioAdjustment()
Returning true indicates texture correction for aspect-ratio in the shader.
boolean useARatioLetterbox()
Returns whether useARatioAdjustment() shall add letter-box space to match aspect-ratio,...
String setTextureLookupFunctionName(String texLookupFuncName)
Set the desired shader code's texture lookup function name.
void setARatioAdjustment(final boolean v)
Toggles useARatioLetterbox().
String getTextureLookupFunctionName()
Returns the chosen lookup function name, which can be set via setTextureLookupFunctionName(String).
String getTextureFragmentShaderHashID()
Returns the concatenated string representing the following values utilized for getTextureFragmentShad...
TextureFrame getNextTexture(GL gl)
Returns the next texture to be rendered.
static constexpr std::string_view sampler2D
boolean isTextureAvailable()
Returns true if texture source is ready and a texture is available via getNextTexture(GL) and getLast...
TextureFrame getLastTexture()
Returns the last updated texture.
int getTextureUnit()
Return the texture unit used to render the current frame.
int getTextureTarget()
Returns the texture target used by implementation.
Represents an OpenGL texture object.
Definition Texture.hpp:151
@ verbose
Verbose operations (debugging).
Vector4F< float > Vec4f
Definition vec4f.hpp:360
static std::string f(uint32_t v)