JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
MovieSBSStereo.java
Go to the documentation of this file.
1/**
2 * Copyright 2012 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 */
28
29package com.jogamp.opengl.demos.av;
30
31import java.net.URISyntaxException;
32import java.nio.FloatBuffer;
33
34import com.jogamp.opengl.GL;
35import com.jogamp.opengl.GL2ES2;
36import com.jogamp.opengl.GLAnimatorControl;
37import com.jogamp.opengl.GLAutoDrawable;
38import com.jogamp.opengl.GLES2;
39import com.jogamp.opengl.GLException;
40import com.jogamp.opengl.GLUniformData;
41import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
42
43import com.jogamp.common.net.Uri;
44import com.jogamp.common.os.Clock;
45import com.jogamp.common.os.Platform;
46import com.jogamp.common.util.InterruptSource;
47import com.jogamp.graph.curve.Region;
48import com.jogamp.graph.curve.opengl.GLRegion;
49import com.jogamp.graph.curve.opengl.RegionRenderer;
50import com.jogamp.graph.font.Font;
51import com.jogamp.graph.font.FontScale;
52import com.jogamp.math.FloatUtil;
53import com.jogamp.math.Matrix4f;
54import com.jogamp.math.Quaternion;
55import com.jogamp.math.Recti;
56import com.jogamp.math.Vec3f;
57import com.jogamp.newt.Window;
58import com.jogamp.newt.event.KeyAdapter;
59import com.jogamp.newt.event.KeyEvent;
60import com.jogamp.newt.event.KeyListener;
61import com.jogamp.newt.event.MouseAdapter;
62import com.jogamp.newt.event.MouseEvent;
63import com.jogamp.newt.event.MouseListener;
64import com.jogamp.newt.opengl.GLWindow;
65import com.jogamp.opengl.GLExtensions;
66import com.jogamp.opengl.GLProfile;
67import com.jogamp.opengl.JoglVersion;
68import com.jogamp.opengl.demos.graph.TextRendererGLELBase;
69import com.jogamp.opengl.demos.util.MiscUtils;
70import com.jogamp.opengl.util.CustomGLEventListener;
71import com.jogamp.opengl.util.GLArrayDataServer;
72import com.jogamp.opengl.util.PMVMatrix;
73import com.jogamp.opengl.util.av.GLMediaPlayer;
74import com.jogamp.opengl.util.av.GLMediaPlayer.GLMediaEventListener;
75import com.jogamp.opengl.util.av.GLMediaPlayerFactory;
76import com.jogamp.opengl.util.glsl.ShaderCode;
77import com.jogamp.opengl.util.glsl.ShaderProgram;
78import com.jogamp.opengl.util.glsl.ShaderState;
79import com.jogamp.opengl.util.stereo.EyeParameter;
80import com.jogamp.opengl.util.stereo.ViewerPose;
81import com.jogamp.opengl.util.stereo.StereoClientRenderer;
82import com.jogamp.opengl.util.stereo.StereoGLEventListener;
83import com.jogamp.opengl.util.texture.Texture;
84import com.jogamp.opengl.util.texture.TextureCoords;
85import com.jogamp.opengl.util.texture.TextureSequence;
86import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame;
87
88/**
89 * Side-By-Side (SBS) 3D Movie Player for {@link StereoClientRenderer}
90 * <p>
91 * The movie is assumed to be symmetrical SBS,
92 * the left-eye receives the left-part of the texture
93 * and the right-eye the right-part.
94 * </p>
95 */
96public class MovieSBSStereo implements StereoGLEventListener {
97 public static final String WINDOW_KEY = "window";
98 public static final String STEREO_RENDERER_KEY = "stereo";
99 public static final String PLAYER = "player";
100
101 private static boolean waitForKey = false;
102 private int surfWidth, surfHeight;
103 private int prevMouseX; // , prevMouseY;
104 private int rotate = 0;
105 private float zoom0;
106 private float zoom1;
107 private float zoom;
108 private long startTime;
109 private final float alpha = 1.0f;
110
111 private GLMediaPlayer mPlayer;
112 private boolean mPlayerScaleOrig;
113 private float[] verts = null;
114 private GLArrayDataServer interleavedVBOLeft;
115 private GLArrayDataServer interleavedVBORight;
116 private volatile boolean resetGLState = false;
117 private StereoClientRenderer stereoClientRenderer;
118
119 private ShaderState st;
120 private PMVMatrix pmvMatrix;
121 private GLUniformData pmvMatrixUniform;
122 private static final String shaderBasename = "texsequence_xxx";
123 private static final String myTextureLookupName = "myTexture2D";
124
125 /** Blender's Big Buck Bunny: 24f 416p H.264, AAC 48000 Hz, 2 ch, mpeg stream. */
126 public static final Uri defURI;
127 static {
128 Uri _defURI = null;
129 try {
130 // Blender's Big Buck Bunny Trailer: 24f 640p VP8, Vorbis 44100Hz mono, WebM/Matroska Stream.
131 // _defURI = new URI("http://video.webmfiles.org/big-buck-bunny_trailer.webm");
132 _defURI = Uri.cast("http://archive.org/download/BigBuckBunny_328/BigBuckBunny_512kb.mp4");
133 } catch (final URISyntaxException e) {
134 e.printStackTrace();
135 }
136 defURI = _defURI;
137 }
138
139 private final class InfoTextRendererGLELBase extends TextRendererGLELBase {
140 private final Font font = getFont(0, 0, 0);
141 private final float fontSize = 1f; // 0.01f;
142 private final GLRegion regionFPS;
143
144 InfoTextRendererGLELBase(final GLProfile glp, final int rmode) {
145 // FIXME: Graph TextRenderer does not AA well w/o MSAA and FBO
146 super(rmode, Region.DEFAULT_AA_SAMPLE_COUNT);
148 regionFPS = GLRegion.create(glp, renderModes, null, 0, 0);
149 System.err.println("RegionFPS "+Region.getRenderModeString(renderModes)+", sampleCount "+Region.DEFAULT_AA_SAMPLE_COUNT+", class "+regionFPS.getClass().getName());
150 staticRGBAColor[0] = 0.9f;
151 staticRGBAColor[1] = 0.9f;
152 staticRGBAColor[2] = 0.9f;
153 staticRGBAColor[3] = 1.0f;
154 }
155
156 @Override
157 public void init(final GLAutoDrawable drawable) {
158 super.init(drawable);
159 }
160
161 @Override
162 public void dispose(final GLAutoDrawable drawable) {
163 if( null != regionFPS ) {
164 regionFPS.destroy(drawable.getGL().getGL2ES2());
165 }
166 super.dispose(drawable);
167 }
168
169 @Override
170 public void display(final GLAutoDrawable drawable) {
171 final GLAnimatorControl anim = drawable.getAnimator();
172 final float lfps = null != anim ? anim.getLastFPS() : 0f;
173 final float tfps = null != anim ? anim.getTotalFPS() : 0f;
174 final float pts = mPlayer.getPTS().getCurrent() / 1000f;
175
176 // Note: MODELVIEW is from [ 0 .. height ]
177
178 final int height = 0; // drawable.getSurfaceHeight();
179
180 final float aspect = (float)mPlayer.getWidth() / (float)mPlayer.getHeight();
181
182 final String ptsPrec = null != regionFPS ? "3.1" : "3.0";
183 final String text1 = String.format("%0"+ptsPrec+"f/%0"+ptsPrec+"f s, %s (%01.2fx, vol %01.2f), a %01.2f, fps %02.1f -> %02.1f / %02.1f",
184 pts, mPlayer.getDuration() / 1000f,
185 mPlayer.getState().toString().toLowerCase(), mPlayer.getPlaySpeed(), mPlayer.getAudioVolume(),
186 aspect, mPlayer.getFramerate(), lfps, tfps);
187 final String text2 = String.format("audio: id %d, kbps %d, codec %s",
188 mPlayer.getAID(), mPlayer.getAudioBitrate()/1000, mPlayer.getAudioCodec());
189 final String text3 = String.format("video: id %d, kbps %d, codec %s",
190 mPlayer.getVID(), mPlayer.getVideoBitrate()/1000, mPlayer.getVideoCodec());
191 final String text4 = mPlayer.getUri().path.decode();
192 if( displayOSD && null != renderer ) {
193 // We share ClearColor w/ MovieSimple's init !
194 final float pixelSize = FontScale.toPixels(fontSize, dpiH);
195 if( null != regionFPS ) {
196 final GL2ES2 gl = drawable.getGL().getGL2ES2();
197 renderString(drawable, font, pixelSize, text1, 1 /* col */, 1 /* row */, 0, 0, -1, regionFPS.clear(gl)); // no-cache
198 } else {
199 renderString(drawable, font, pixelSize, text1, 1 /* col */, 1 /* row */, 0, 0, -1, true);
200 }
201 renderString(drawable, font, pixelSize, text2, 1 /* col */, -4 /* row */, 0, height, -1, true);
202 renderString(drawable, font, pixelSize, text3, 1 /* col */, -3 /* row */, 0, height, 0, true);
203 renderString(drawable, font, pixelSize, text4, 1 /* col */, -2 /* row */, 0, height, 1, true);
204 }
205 } };
206 private final boolean enableTextRendererGLEL = false;
207 private InfoTextRendererGLELBase textRendererGLEL = null;
208 private boolean displayOSD = false;
209
210 private final MouseListener mouseAction = new MouseAdapter() {
211 @Override
212 public void mousePressed(final MouseEvent e) {
213 if(e.getY()<=surfHeight/2 && null!=mPlayer && 1 == e.getClickCount()) {
214 if(GLMediaPlayer.State.Playing == mPlayer.getState()) {
215 mPlayer.pause(false);
216 } else {
217 mPlayer.resume();
218 }
219 }
220 }
221 @Override
222 public void mouseReleased(final MouseEvent e) {
223 if(e.getY()<=surfHeight/2) {
224 rotate = -1;
225 zoom = zoom0;
226 System.err.println("zoom: "+zoom);
227 }
228 }
229 @Override
230 public void mouseMoved(final MouseEvent e) {
231 prevMouseX = e.getX();
232 // prevMouseY = e.getY();
233 }
234 @Override
235 public void mouseDragged(final MouseEvent e) {
236 final int x = e.getX();
237 final int y = e.getY();
238
239 if(y>surfHeight/2) {
240 final float dp = (float)(x-prevMouseX)/(float)surfWidth;
241 final int pts0 = mPlayer.getPTS().getCurrent();
242 mPlayer.seek(pts0 + (int) (mPlayer.getDuration() * dp));
243 } else {
244 mPlayer.resume();
245 rotate = 1;
246 zoom = zoom1;
247 }
248
249 prevMouseX = x;
250 // prevMouseY = y;
251 }
252 @Override
253 public void mouseWheelMoved(final MouseEvent e) {
254 if( !e.isShiftDown() ) {
255 zoom += e.getRotation()[1]/10f; // vertical: wheel
256 System.err.println("zoom: "+zoom);
257 }
258 } };
259
260 private final KeyListener keyAction = new KeyAdapter() {
261 @Override
262 public void keyReleased(final KeyEvent e) {
263 if( e.isAutoRepeat() ) {
264 return;
265 }
266 System.err.println("MC "+e);
267 final int pts0 = mPlayer.getPTS().getCurrent();
268 int pts1 = 0;
269 switch(e.getKeySymbol()) {
270 case KeyEvent.VK_O: displayOSD = !displayOSD; break;
271 case KeyEvent.VK_RIGHT: pts1 = pts0 + 1000; break;
272 case KeyEvent.VK_UP: pts1 = pts0 + 10000; break;
273 case KeyEvent.VK_PAGE_UP: pts1 = pts0 + 30000; break;
274 case KeyEvent.VK_LEFT: pts1 = pts0 - 1000; break;
275 case KeyEvent.VK_DOWN: pts1 = pts0 - 10000; break;
276 case KeyEvent.VK_PAGE_DOWN: pts1 = pts0 - 30000; break;
277 case KeyEvent.VK_ESCAPE:
278 case KeyEvent.VK_HOME:
279 case KeyEvent.VK_BACK_SPACE: {
280 mPlayer.seek(0);
281 break;
282 }
283 case KeyEvent.VK_SPACE: {
284 if(GLMediaPlayer.State.Paused == mPlayer.getState()) {
285 mPlayer.resume();
286 } else {
287 mPlayer.pause(false);
288 }
289 break;
290 }
291 case KeyEvent.VK_MULTIPLY:
292 mPlayer.setPlaySpeed(1.0f);
293 break;
294 case KeyEvent.VK_SUBTRACT: {
295 float playSpeed = mPlayer.getPlaySpeed();
296 if( e.isShiftDown() ) {
297 playSpeed /= 2.0f;
298 } else {
299 playSpeed -= 0.1f;
300 }
301 mPlayer.setPlaySpeed(playSpeed);
302 } break;
303 case KeyEvent.VK_ADD: {
304 float playSpeed = mPlayer.getPlaySpeed();
305 if( e.isShiftDown() ) {
306 playSpeed *= 2.0f;
307 } else {
308 playSpeed += 0.1f;
309 }
310 mPlayer.setPlaySpeed(playSpeed);
311 } break;
312 case KeyEvent.VK_M: {
313 float audioVolume = mPlayer.getAudioVolume();
314 if( audioVolume > 0.5f ) {
315 audioVolume = 0f;
316 } else {
317 audioVolume = 1f;
318 }
319 mPlayer.setAudioVolume(audioVolume);
320 } break;
321 }
322
323 if( 0 != pts1 ) {
324 mPlayer.seek(pts1);
325 }
326 } };
327
328 /** user needs to issue {@link #playStream(URI, int, int, int, int)} afterwards. */
329 public MovieSBSStereo() throws IllegalStateException {
330 mPlayerScaleOrig = false;
332 mPlayer.attachObject(PLAYER, this);
333 System.out.println("pC.1a "+mPlayer);
334 }
335
336 public void initStream(final Uri streamLoc, final int vid, final int aid, final int textureCount) {
337 mPlayer.playStream(streamLoc, vid, aid, GLMediaPlayer.STREAM_ID_NONE, textureCount);
338 System.out.println("pC.1b "+mPlayer);
339 }
340
341 public GLMediaPlayer getGLMediaPlayer() { return mPlayer; }
342
343 public void setScaleOrig(final boolean v) {
344 mPlayerScaleOrig = v;
345 }
346
348 stereoClientRenderer = scr;
349 }
350 public StereoClientRenderer getStereoClientRenderer() { return stereoClientRenderer; }
351
352 public void resetGLState() {
353 resetGLState = true;
354 }
355
356 private void initShader(final GL2ES2 gl) {
357 // Create & Compile the shader objects
359 "../shader", "../shader/bin", shaderBasename, true);
361 "../shader", "../shader/bin", shaderBasename, true);
362
363 boolean preludeGLSLVersion = true;
366 throw new GLException(GLExtensions.OES_EGL_image_external+" requested but not available");
367 }
368 if( Platform.OSType.ANDROID == Platform.getOSType() && gl.isGLES3() ) {
369 // Bug on Nexus 10, ES3 - Android 4.3, where
370 // GL_OES_EGL_image_external extension directive leads to a failure _with_ '#version 300 es' !
371 // P0003: Extension 'GL_OES_EGL_image_external' not supported
372 preludeGLSLVersion = false;
373 }
374 }
375 rsVp.defaultShaderCustomization(gl, preludeGLSLVersion, true);
376
377 int rsFpPos = preludeGLSLVersion ? rsFp.addGLSLVersion(gl) : 0;
378 rsFpPos = rsFp.insertShaderSource(0, rsFpPos, mPlayer.getRequiredExtensionsShaderStub());
379 rsFp.addDefaultShaderPrecision(gl, rsFpPos);
380
381 final String texLookupFuncName = mPlayer.setTextureLookupFunctionName(myTextureLookupName);
382 rsFp.replaceInShaderSource(myTextureLookupName, texLookupFuncName);
383
384 // Inject TextureSequence shader details
385 final StringBuilder sFpIns = new StringBuilder();
386 sFpIns.append("uniform ").append(mPlayer.getTextureSampler2DType()).append(" mgl_ActiveTexture;\n");
387 sFpIns.append(mPlayer.getTextureLookupFragmentShaderImpl());
388 rsFp.insertShaderSource(0, "TEXTURE-SEQUENCE-CODE-BEGIN", 0, sFpIns);
389
390 // Create & Link the shader program
391 final ShaderProgram sp = new ShaderProgram();
392 sp.add(rsVp);
393 sp.add(rsFp);
394 if(!sp.link(gl, System.err)) {
395 throw new GLException("Couldn't link program: "+sp);
396 }
397
398 // Let's manage all our states using ShaderState.
399 st = new ShaderState();
400 st.attachShaderProgram(gl, sp, false);
401 }
402
403 @Override
404 public void init(final GLAutoDrawable drawable) {
405 if(null == mPlayer) {
406 throw new InternalError("mPlayer null");
407 }
408 if( GLMediaPlayer.State.Uninitialized == mPlayer.getState() ) {
409 throw new IllegalStateException("mPlayer in uninitialized state: "+mPlayer);
410 }
411 final boolean hasVideo = GLMediaPlayer.STREAM_ID_NONE != mPlayer.getVID();
412 resetGLState = false;
413
414 zoom0 = -2.1f;
415 zoom1 = -5f;
416 zoom = 0f;
417
418 final GL2ES2 gl = drawable.getGL().getGL2ES2();
419 System.err.println(JoglVersion.getGLInfo(gl, null));
420 System.err.println("Alpha: "+alpha+", opaque "+drawable.getChosenGLCapabilities().isBackgroundOpaque()+
421 ", "+drawable.getClass().getName()+", "+drawable);
422
423 if(waitForKey) {
424 MiscUtils.waitForKey("Init>");
425 }
426 final Texture tex;
427 try {
428 System.out.println("p0 "+mPlayer);
429 mPlayer.setTextureMinMagFilter( new int[] { GL.GL_NEAREST, GL.GL_NEAREST } );
430 if(GLMediaPlayer.State.Initialized == mPlayer.getState() ) {
431 mPlayer.initGL(gl);
432 }
433 System.out.println("p1 "+mPlayer);
434 final TextureFrame frame = mPlayer.getLastTexture();
435 if( null != frame ) {
436 if( !hasVideo ) {
437 throw new InternalError("XXX: "+mPlayer);
438 }
439 tex = frame.getTexture();
440 if( null == tex ) {
441 throw new InternalError("XXX: "+mPlayer);
442 }
443 } else {
444 tex = null;
445 if( hasVideo ) {
446 throw new InternalError("XXX: "+mPlayer);
447 }
448 }
449 } catch (final Exception glex) {
450 glex.printStackTrace();
451 if(null != mPlayer) {
452 mPlayer.destroy(gl);
453 mPlayer = null;
454 }
455 throw new GLException(glex);
456 }
457
458 if( hasVideo ) {
459 initShader(gl);
460
461 // Push the 1st uniform down the path
462 st.useProgram(gl, true);
463
464 final Recti viewPort = new Recti(0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
465 pmvMatrix = new PMVMatrix();
466 reshapePMV(viewPort.width(), viewPort.height());
467 pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.getSyncPMv());
468 if(!st.uniform(gl, pmvMatrixUniform)) {
469 throw new GLException("Error setting PMVMatrix in shader: "+st);
470 }
471 if(!st.uniform(gl, new GLUniformData("mgl_ActiveTexture", mPlayer.getTextureUnit()))) {
472 throw new GLException("Error setting mgl_ActiveTexture in shader: "+st);
473 }
474
475 final float dWidth = drawable.getSurfaceWidth();
476 final float dHeight = drawable.getSurfaceHeight();
477 final float mWidth = mPlayer.getWidth();
478 final float mHeight = mPlayer.getHeight();
479 final float mAspect = mWidth/mHeight;
480 System.err.println("XXX0: mov aspect: "+mAspect);
481 float xs, ys;
482 if(mPlayerScaleOrig && mWidth < dWidth && mHeight < dHeight) {
483 xs = mAspect * ( mWidth / dWidth ) ; ys = xs / mAspect ;
484 } else {
485 xs = mAspect; ys = 1f; // b>h
486 }
487 verts = new float[] { -1f*xs, -1f*ys, 0f, // LB
488 1f*xs, 1f*ys, 0f // RT
489 };
490 {
491 System.err.println("XXX0: pixel LB: "+verts[0]+", "+verts[1]+", "+verts[2]);
492 System.err.println("XXX0: pixel RT: "+verts[3]+", "+verts[4]+", "+verts[5]);
493 final Vec3f winLB = new Vec3f();
494 final Vec3f winRT = new Vec3f();
495 pmvMatrix.mapObjToWin(new Vec3f(verts[0], verts[1], verts[2]), viewPort, winLB);
496 pmvMatrix.mapObjToWin(new Vec3f(verts[3], verts[4], verts[5]), viewPort, winRT);
497 System.err.println("XXX0: win LB: "+winLB);
498 System.err.println("XXX0: win RT: "+winRT);
499 }
500
501 interleavedVBOLeft = GLArrayDataServer.createGLSLInterleaved(3+4+2, GL.GL_FLOAT, false, 3*4, GL.GL_STATIC_DRAW);
502 {
503 interleavedVBOLeft.addGLSLSubArray("mgl_Vertex", 3, GL.GL_ARRAY_BUFFER);
504 interleavedVBOLeft.addGLSLSubArray("mgl_Color", 4, GL.GL_ARRAY_BUFFER);
505 interleavedVBOLeft.addGLSLSubArray("mgl_MultiTexCoord", 2, GL.GL_ARRAY_BUFFER);
506 }
507 interleavedVBORight = GLArrayDataServer.createGLSLInterleaved(3+4+2, GL.GL_FLOAT, false, 3*4, GL.GL_STATIC_DRAW);
508 {
509 interleavedVBORight.addGLSLSubArray("mgl_Vertex", 3, GL.GL_ARRAY_BUFFER);
510 interleavedVBORight.addGLSLSubArray("mgl_Color", 4, GL.GL_ARRAY_BUFFER);
511 interleavedVBORight.addGLSLSubArray("mgl_MultiTexCoord", 2, GL.GL_ARRAY_BUFFER);
512 }
513 updateInterleavedVBO(gl, interleavedVBOLeft, tex, 0);
514 updateInterleavedVBO(gl, interleavedVBORight, tex, 1);
515
516 st.ownAttribute(interleavedVBOLeft, true);
517 st.ownAttribute(interleavedVBORight, true);
518 gl.glClearColor(0.3f, 0.3f, 0.3f, 0.3f);
519
521
522 st.useProgram(gl, false);
523
524 // Let's show the completed shader state ..
525 System.out.println("iVBOLeft : "+interleavedVBOLeft);
526 System.out.println("iVBORight: "+interleavedVBORight);
527 System.out.println(st);
528 }
529
530 mPlayer.resume();
531 System.out.println("play.0 "+mPlayer);
532 startTime = System.currentTimeMillis();
533
534 final Object upstreamWidget = drawable.getUpstreamWidget();
535 if (upstreamWidget instanceof Window) {
536 final Window window = (Window) upstreamWidget;
537 window.addMouseListener(mouseAction);
538 window.addKeyListener(keyAction);
539 surfWidth = window.getSurfaceWidth();
540 surfHeight = window.getSurfaceHeight();
541 }
542 final int rmode = drawable.getChosenGLCapabilities().getSampleBuffers() ? 0 : Region.VBAA_RENDERING_BIT;
543 if( enableTextRendererGLEL ) {
544 textRendererGLEL = new InfoTextRendererGLELBase(gl.getGLProfile(), rmode);
545 textRendererGLEL.init(drawable);
546 } else {
547 textRendererGLEL = null;
548 }
549 }
550
551 protected void updateInterleavedVBO(final GL gl, final GLArrayDataServer iVBO, final Texture tex, final int eyeNum) {
552 final boolean wasEnabled = iVBO.enabled();
553 iVBO.seal(gl, false);
554 iVBO.rewind();
555 {
556 final FloatBuffer ib = (FloatBuffer)iVBO.getBuffer();
557 final TextureCoords tc = tex.getImageTexCoords();
558 final float texHalfWidth = tc.right()/2f;
559 System.err.println("XXX0: "+tc+", texHalfWidth "+texHalfWidth);
560 System.err.println("XXX0: tex aspect: "+tex.getAspectRatio());
561 System.err.println("XXX0: tex y-flip: "+tex.getMustFlipVertically());
562
563 // left-bottom
564 ib.put(verts[0]); ib.put(verts[1]); ib.put(verts[2]);
565 ib.put( 1); ib.put( 1); ib.put( 1); ib.put(alpha);
566 if( 0 == eyeNum ) {
567 ib.put( tc.left() ); ib.put( tc.bottom() );
568 } else {
569 ib.put( tc.left() + texHalfWidth ); ib.put( tc.bottom() );
570 }
571
572 // right-bottom
573 ib.put(verts[3]); ib.put(verts[1]); ib.put(verts[2]);
574 ib.put( 1); ib.put( 1); ib.put( 1); ib.put(alpha);
575 if( 0 == eyeNum ) {
576 ib.put( texHalfWidth ); ib.put( tc.bottom() );
577 } else {
578 ib.put( tc.right() ); ib.put( tc.bottom() );
579 }
580
581 // left-top
582 ib.put(verts[0]); ib.put(verts[4]); ib.put(verts[2]);
583 ib.put( 1); ib.put( 1); ib.put( 1); ib.put(alpha);
584 if( 0 == eyeNum ) {
585 ib.put( tc.left() ); ib.put( tc.top() );
586 } else {
587 ib.put( tc.left() + texHalfWidth ); ib.put( tc.top() );
588 }
589
590 // right-top
591 ib.put(verts[3]); ib.put(verts[4]); ib.put(verts[2]);
592 ib.put( 1); ib.put( 1); ib.put( 1); ib.put(alpha);
593 if( 0 == eyeNum ) {
594 ib.put( texHalfWidth ); ib.put( tc.top() );
595 } else {
596 ib.put( tc.right() ); ib.put( tc.top() );
597 }
598 }
599 iVBO.seal(gl, true);
600 if( !wasEnabled ) {
601 iVBO.enableBuffer(gl, false);
602 }
603 }
604
605 @Override
606 public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
607 final GL2ES2 gl = drawable.getGL().getGL2ES2();
608 surfWidth = width;
609 surfHeight = height;
610
611 if(null == mPlayer) { return; }
612
613 if(null != st) {
614 reshapePMV(width, height);
615 st.useProgram(gl, true);
616 st.uniform(gl, pmvMatrixUniform);
617 st.useProgram(gl, false);
618 }
619
620 System.out.println("pR "+mPlayer);
621 if( null != textRendererGLEL ) {
622 textRendererGLEL.reshape(drawable, 0, 0, width, height);
623 }
624 }
625
626 private final float zNear = 0.1f;
627 private final float zFar = 10000f;
628
629 private void reshapePMV(final int width, final int height) {
631 pmvMatrix.glLoadIdentity();
632 pmvMatrix.gluPerspective(FloatUtil.QUARTER_PI, (float)width / (float)height, zNear, zFar);
633
635 pmvMatrix.glLoadIdentity();
636 pmvMatrix.glTranslatef(0, 0, zoom0);
637 }
638
639 private final Matrix4f mat4Tmp1 = new Matrix4f();
640 private final Matrix4f mat4Tmp2 = new Matrix4f();
641 private final Vec3f vec3Tmp1 = new Vec3f();
642 private final Vec3f vec3Tmp2 = new Vec3f();
643 private final Vec3f vec3Tmp3 = new Vec3f();
644
645 GLArrayDataServer interleavedVBOCurrent = null;
646
647 private static final float scalePos = 4f;
648
649 @Override
650 public void reshapeForEye(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height,
651 final EyeParameter eyeParam, final ViewerPose viewerPose) {
652 final GL2ES2 gl = drawable.getGL().getGL2ES2();
653 interleavedVBOCurrent = 0 == eyeParam.number ? interleavedVBOLeft : interleavedVBORight;
654
655 surfWidth = drawable.getSurfaceWidth();
656 surfHeight = drawable.getSurfaceHeight();
657
658 if(null == mPlayer) { return; }
659 if(null == st) { return; }
660
661 {
662 //
663 // Projection
664 //
665 final Matrix4f mat4 = new Matrix4f();
667 mat4.setToPerspective(eyeParam.fovhv, zNear, zFar);
668 pmvMatrix.glLoadMatrixf(mat4);
669
670 //
671 // Modelview
672 //
674 final Quaternion rollPitchYaw = new Quaternion();
675 // private final float eyeYaw = FloatUtil.PI; // 180 degrees in radians
676 // rollPitchYaw.rotateByAngleY(eyeYaw);
677 final Vec3f shiftedEyePos = rollPitchYaw.rotateVector(viewerPose.position, vec3Tmp1);
678 shiftedEyePos.scale(scalePos); // amplify viewerPose position
679 shiftedEyePos.add(eyeParam.positionOffset);
680
681 rollPitchYaw.mult(viewerPose.orientation);
682 final Vec3f up = rollPitchYaw.rotateVector(Vec3f.UNIT_Y, vec3Tmp2);
683 final Vec3f forward = rollPitchYaw.rotateVector(Vec3f.UNIT_Z_NEG, vec3Tmp3); // -> center
684 final Vec3f center = forward.add(shiftedEyePos);
685
686 final Matrix4f mLookAt = mat4Tmp2.setToLookAt(shiftedEyePos, center, up, mat4Tmp1);
687 mat4.mul( mat4Tmp1.setToTranslation( eyeParam.distNoseToPupilX,
688 eyeParam.distMiddleToPupilY,
689 eyeParam.eyeReliefZ ), mLookAt);
690 mat4.translate(0, 0, zoom0, mat4Tmp1);
691 pmvMatrix.glLoadMatrixf(mat4);
692 }
693 st.useProgram(gl, true);
694 st.uniform(gl, pmvMatrixUniform);
695 st.useProgram(gl, false);
696 if( null != textRendererGLEL ) {
697 textRendererGLEL.reshape(drawable, 0, 0, width, height);
698 }
699 }
700
701 @Override
702 public void dispose(final GLAutoDrawable drawable) {
703 if( null != textRendererGLEL ) {
704 textRendererGLEL.dispose(drawable);
705 textRendererGLEL = null;
706 }
707 disposeImpl(drawable, true);
708 }
709
710 private void disposeImpl(final GLAutoDrawable drawable, final boolean disposePlayer) {
711 if(null == mPlayer) { return; }
712
713 final Object upstreamWidget = drawable.getUpstreamWidget();
714 if (upstreamWidget instanceof Window) {
715 final Window window = (Window) upstreamWidget;
716 window.removeMouseListener(mouseAction);
717 window.removeKeyListener(keyAction);
718 }
719
720 System.out.println("pD.1 "+mPlayer+", disposePlayer "+disposePlayer);
721 final GL2ES2 gl = drawable.getGL().getGL2ES2();
722 if( disposePlayer ) {
723 mPlayer.destroy(gl);
724 System.out.println("pD.X "+mPlayer);
725 mPlayer=null;
726 }
727 pmvMatrixUniform = null;
728 if(null != pmvMatrix) {
729 pmvMatrix=null;
730 }
731 if(null != st) {
732 st.destroy(gl);
733 st=null;
734 }
735 }
736
737 long lastPerfPos = 0;
738
739 @Override
740 public void display(final GLAutoDrawable drawable) {
741 display(drawable, 0);
742 }
743
744 @Override
745 public void display(final GLAutoDrawable drawable, final int flags) {
746 // TODO Auto-generated method stub
747 final boolean repeatedFrame = 0 != ( CustomGLEventListener.DISPLAY_REPEAT & flags );
748 final boolean dontClear = 0 != ( CustomGLEventListener.DISPLAY_DONTCLEAR & flags );
749 final GLArrayDataServer iVBO = null != interleavedVBOCurrent ? interleavedVBOCurrent : interleavedVBOLeft;
750
751 final GL2ES2 gl = drawable.getGL().getGL2ES2();
752 if(null == mPlayer) { return; }
753
754 if( resetGLState ) {
755 resetGLState = false;
756 System.err.println("XXX resetGLState");
757 disposeImpl(drawable, false);
758 init(drawable);
759 reshape(drawable, 0, 0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
760 }
761
762 final long currentPos = System.currentTimeMillis();
763 if( currentPos - lastPerfPos > 2000 ) {
764 System.err.println( mPlayer.getPerfString() );
765 lastPerfPos = currentPos;
766 }
767
768 if( !dontClear ) {
770 }
771
772 if(null == st) {
773 return;
774 }
775
776 st.useProgram(gl, true);
777
779 pmvMatrix.glPushMatrix();
780 pmvMatrix.glTranslatef(0, 0, zoom);
781 if( rotate > 0) {
782 final float ang = ((System.currentTimeMillis() - startTime) * 360.0f) / 8000.0f;
783 pmvMatrix.glRotatef(ang, 0, 0, 1);
784 } else {
785 rotate = 0;
786 }
787 st.uniform(gl, pmvMatrixUniform);
788 iVBO.enableBuffer(gl, true);
789 Texture tex = null;
790 if(null!=mPlayer) {
791 final TextureSequence.TextureFrame texFrame;
792 if( repeatedFrame ) {
793 texFrame=mPlayer.getLastTexture();
794 } else {
795 texFrame=mPlayer.getNextTexture(gl);
796 }
797 if(null != texFrame) {
798 tex = texFrame.getTexture();
800 tex.enable(gl);
801 tex.bind(gl);
802 }
803 }
805 if(null != tex) {
806 tex.disable(gl);
807 }
808 iVBO.enableBuffer(gl, false);
809 st.useProgram(gl, false);
810 pmvMatrix.glPopMatrix();
811
812 if( null != textRendererGLEL ) {
813 textRendererGLEL.display(drawable);
814 }
815 }
816
817 static class StereoGLMediaEventListener implements GLMediaEventListener {
818 void destroyWindow(final Window window) {
819 new InterruptSource.Thread( () -> { window.destroy(); } ).start();
820 }
821 @Override
822 public void attributesChanged(final GLMediaPlayer mp, final GLMediaPlayer.EventMask eventMask, final long when) {
823 System.err.println("MovieSimple AttributesChanges: "+eventMask+", when "+when);
824 System.err.println("MovieSimple State: "+mp);
825 final GLWindow window = (GLWindow) mp.getAttachedObject(WINDOW_KEY);
826 final MovieSBSStereo ms = (MovieSBSStereo)mp.getAttachedObject(PLAYER);
827 final StereoClientRenderer stereoClientRenderer = (StereoClientRenderer) mp.getAttachedObject(STEREO_RENDERER_KEY);
828
829 if( eventMask.isSet(GLMediaPlayer.EventMask.Bit.Size) ) {
830 // window.disposeGLEventListener(ms, false /* remove */ );
831 ms.resetGLState();
832 }
833 if( eventMask.isSet(GLMediaPlayer.EventMask.Bit.Init) ) {
834 // Use GLEventListener in all cases [A+V, V, A]
835 stereoClientRenderer.addGLEventListener(ms);
836 final GLAnimatorControl anim = window.getAnimator();
837 anim.setUpdateFPSFrames(60, null);
838 anim.resetFPSCounter();
839 ms.setStereoClientRenderer(stereoClientRenderer);
840 } else if( eventMask.isSet(GLMediaPlayer.EventMask.Bit.Play) ) {
841 window.getAnimator().resetFPSCounter();
842 }
843
844 boolean destroy = false;
845 Throwable err = null;
846
847 if( eventMask.isSet(GLMediaPlayer.EventMask.Bit.EOS) ) {
848 err = ms.mPlayer.getStreamException();
849 if( null != err ) {
850 System.err.println("MovieSimple State: Exception");
851 destroy = true;
852 } else {
853 new InterruptSource.Thread() {
854 @Override
855 public void run() {
856 mp.setPlaySpeed(1f);
857 mp.seek(0);
858 mp.resume();
859 }
860 }.start();
861 }
862 }
863 if( eventMask.isSet(GLMediaPlayer.EventMask.Bit.Error) ) {
864 err = ms.mPlayer.getStreamException();
865 if( null != err ) {
866 System.err.println("MovieSimple State: Exception");
867 }
868 destroy = true;
869 }
870 if( destroy ) {
871 if( null != err ) {
872 err.printStackTrace();
873 }
874 destroyWindow(window);
875 }
876 }
877 };
878 public final static StereoGLMediaEventListener stereoGLMediaEventListener = new StereoGLMediaEventListener();
879}
Abstract Outline shape representation define the method an OutlineShape(s) is bound and rendered.
Definition: Region.java:62
static String getRenderModeString(final int renderModes)
Returns a unique technical description string for renderModes as follows:
Definition: Region.java:251
static final int DEFAULT_AA_SAMPLE_COUNT
Default pass2 AA sample count {@value} for Graph Region AA render-modes: VBAA_RENDERING_BIT or Region...
Definition: Region.java:177
static final int VBAA_RENDERING_BIT
Rendering-Mode bit for Region.
Definition: Region.java:115
A GLRegion is the OGL binding of one or more OutlineShapes Defined by its vertices and generated tria...
Definition: GLRegion.java:70
final GLRegion clear(final GL2ES2 gl)
Clears all buffers, i.e.
Definition: GLRegion.java:436
final void destroy(final GL2ES2 gl)
Delete and clear the associated OGL objects.
Definition: GLRegion.java:460
static GLRegion create(final GLProfile glp, int renderModes, final TextureSequence colorTexSeq, final int pass2TexUnit, final int initialVerticesCount, final int initialIndicesCount)
Create a GLRegion using the passed render mode.
Definition: GLRegion.java:109
static final GLCallback defaultBlendDisable
Default GL#GL_BLEND disable GLCallback, simply turning-off the GL#GL_BLEND state and turning-on depth...
static final GLCallback defaultBlendEnable
Default GL#GL_BLEND enable GLCallback, turning-off depth writing via GL#glDepthMask(boolean) if Rende...
Basic Float math utility functions.
Definition: FloatUtil.java:83
static final float QUARTER_PI
The value PI/4, i.e.
Basic 4x4 float matrix implementation using fields for intensive use-cases (host operations).
Definition: Matrix4f.java:89
final Matrix4f mul(final Matrix4f b)
Multiply matrix: [this] = [this] x [b].
Definition: Matrix4f.java:726
final Matrix4f translate(final float x, final float y, final float z, final Matrix4f tmp)
Translate this matrix, i.e.
Definition: Matrix4f.java:1558
Matrix4f setToPerspective(final float fovy_rad, final float aspect, final float zNear, final float zFar)
Set this matrix to perspective frustum projection.
Definition: Matrix4f.java:1303
Matrix4f setToLookAt(final Vec3f eye, final Vec3f center, final Vec3f up, final Matrix4f tmp)
Set this matrix to the look-at matrix based on given parameters.
Definition: Matrix4f.java:1432
Quaternion implementation supporting Gimbal-Lock free rotations.
Definition: Quaternion.java:45
final Vec3f rotateVector(final Vec3f vecIn, final Vec3f vecOut)
final Quaternion mult(final Quaternion q)
Multiply this quaternion by the param quaternion.
Rectangle with x, y, width and height integer components.
Definition: Recti.java:34
3D Vector based upon three float components.
Definition: Vec3f.java:37
Vec3f scale(final float s)
this = this * s, returns this.
Definition: Vec3f.java:218
static final Vec3f UNIT_Z_NEG
Definition: Vec3f.java:44
static final Vec3f UNIT_Y
Definition: Vec3f.java:41
Vec3f add(final float dx, final float dy, final float dz)
this = this + { dx, dy, dz }, returns this.
Definition: Vec3f.java:239
final SyncMatrices4f getSyncPMv()
Returns SyncMatrices4f of 2 matrices within one FloatBuffer: P and Mv.
final boolean mapObjToWin(final Vec3f objPos, final Recti viewport, final Vec3f winPos)
Map object coordinates to window coordinates.
A generic exception for OpenGL errors used throughout the binding as a substitute for RuntimeExceptio...
Class holding OpenGL extension strings, commonly used by JOGL's implementation.
static final String OES_EGL_image_external
Specifies the the OpenGL profile.
Definition: GLProfile.java:77
GLSL uniform data wrapper encapsulating data to be uploaded to the GPU as a uniform.
static StringBuilder getGLInfo(final GL gl, final StringBuilder sb)
Side-By-Side (SBS) 3D Movie Player for StereoClientRenderer.
void init(final GLAutoDrawable drawable)
Called by the drawable immediately after the OpenGL context is initialized.
static final StereoGLMediaEventListener stereoGLMediaEventListener
void display(final GLAutoDrawable drawable, final int flags)
Extended display method, allowing to pass a display flag, e.g.
void updateInterleavedVBO(final GL gl, final GLArrayDataServer iVBO, final Texture tex, final int eyeNum)
void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height)
Called by the drawable during the first repaint after the component has been resized.
static final Uri defURI
Blender's Big Buck Bunny: 24f 416p H.264, AAC 48000 Hz, 2 ch, mpeg stream.
void initStream(final Uri streamLoc, final int vid, final int aid, final int textureCount)
void reshapeForEye(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height, final EyeParameter eyeParam, final ViewerPose viewerPose)
Stereo capable specialization of reshape(GLAutoDrawable, int, int, int, int) for one StereoDeviceRend...
MovieSBSStereo()
user needs to issue playStream(URI, int, int, int, int) afterwards.
void setStereoClientRenderer(final StereoClientRenderer scr)
void dispose(final GLAutoDrawable drawable)
Notifies the listener to perform the release of all OpenGL resources per GLContext,...
void display(final GLAutoDrawable drawable)
Called by the drawable to initiate OpenGL rendering by the client.
void renderString(final GLAutoDrawable drawable, final Font font, final float pixelSize, final CharSequence text, final int column, final float tx, final float ty, final float tz, final boolean cacheRegion)
static void waitForKey(final String preMessage)
Definition: MiscUtils.java:167
void seal(final GL gl, final boolean seal)
Convenience method calling seal(boolean) and enableBuffer(GL, boolean).
void enableBuffer(final GL gl, final boolean enable)
Enables the buffer if enable is true, and transfers the data if required.
static GLArrayDataServer createGLSLInterleaved(final int compsPerElement, final int dataType, final boolean normalized, final int initialElementCount, final int vboUsage)
Create a VBO for GLSL interleaved array data starting with a new created Buffer object with initialEl...
GLArrayDataWrapper addGLSLSubArray(final String name, final int comps, final int vboTarget)
Configure a segment of this GLSL interleaved array (see createGLSLInterleaved(int,...
Buffer getBuffer()
The Buffer holding the data, may be null if a GPU buffer without client bound data.
PMVMatrix implements a subset of the fixed function pipeline GLMatrixFunc using PMVMatrix4f.
Definition: PMVMatrix.java:62
final void glTranslatef(final float x, final float y, final float z)
Translate the current matrix.
Definition: PMVMatrix.java:379
final void glMatrixMode(final int matrixName)
Sets the current matrix mode.
Definition: PMVMatrix.java:218
final void gluPerspective(final float fovy_rad, final float aspect, final float zNear, final float zFar)
Multiply the current matrix with the perspective/frustum matrix.
Definition: PMVMatrix.java:499
final void glPushMatrix()
Push the current matrix to it's stack, while preserving it's values.
Definition: PMVMatrix.java:458
final void glRotatef(final float ang_deg, final float x, final float y, final float z)
Rotate the current matrix.
Definition: PMVMatrix.java:413
final void glPopMatrix()
Pop the current matrix from it's stack.
Definition: PMVMatrix.java:447
final void glLoadIdentity()
Load the current matrix with the identity matrix.
Definition: PMVMatrix.java:325
final void glLoadMatrixf(final float[] values, final int offset)
Load the current matrix w/ the provided one.
Definition: PMVMatrix.java:271
Convenient shader code class to use and instantiate vertex or fragment programs.
Definition: ShaderCode.java:75
final int defaultShaderCustomization(final GL2ES2 gl, final boolean preludeVersion, final boolean addDefaultPrecision)
Default customization of this shader source code.
final int addGLSLVersion(final GL2ES2 gl)
Add GLSL version at the head of this shader source code.
static ShaderCode create(final GL2ES2 gl, final int type, final int count, final Class<?> context, final String[] sourceFiles, final boolean mutableStringBuilder)
Creates a complete ShaderCode object while reading all shader source of sourceFiles,...
int replaceInShaderSource(final String oldName, final String newName)
Replaces oldName with newName in all shader sources.
final int addDefaultShaderPrecision(final GL2ES2 gl, int pos)
Adds default precision to source code at given position if required, i.e.
int insertShaderSource(final int shaderIdx, final String tag, final int fromIndex, final CharSequence data)
Adds data after the line containing tag.
ShaderState allows to sharing data between shader programs, while updating the attribute and uniform ...
void ownAttribute(final GLArrayData attribute, final boolean own)
Binds or unbinds the GLArrayData lifecycle to this ShaderState.
synchronized void useProgram(final GL2ES2 gl, final boolean on)
Turns the shader program on or off.
synchronized boolean attachShaderProgram(final GL2ES2 gl, final ShaderProgram prog, final boolean enable)
Attach or switch a shader program.
synchronized void destroy(final GL2ES2 gl)
Calls release(gl, true, true, true).
boolean uniform(final GL2ES2 gl, final GLUniformData data)
Set the uniform data, if it's location is valid, i.e.
Constant single eye parameter of the viewer, relative to its ViewerPose.
final float distNoseToPupilX
IPD related horizontal distance from nose to pupil in meter.
final FovHVHalves fovhv
Field of view in both directions, may not be centered, either FovHVHalves#inTangents or radians.
final float distMiddleToPupilY
Vertical distance from middle-line to pupil in meter.
final Vec3f positionOffset
eye position vector used to define eye height in meter relative to actor.
final float eyeReliefZ
Z-axis eye relief in meter.
StereoClientRenderer utilizing StereoDeviceRenderer implementing GLEventListener for convenience.
final void addGLEventListener(final StereoGLEventListener l)
position and orientation of viewer.
Definition: ViewerPose.java:36
final Quaternion orientation
Orientation of viewer.
Definition: ViewerPose.java:50
final Vec3f position
position of viewer in meter.
Definition: ViewerPose.java:47
Specifies texture coordinates for a rectangular area of a texture.
Texture holder interface, maybe specialized by implementation to associated related data.
Represents an OpenGL texture object.
Definition: Texture.java:173
TextureCoords getImageTexCoords()
Returns the set of texture coordinates corresponding to the entire image.
Definition: Texture.java:480
void bind(final GL gl)
Binds this texture to the given GL context.
Definition: Texture.java:377
boolean getMustFlipVertically()
Indicates whether this texture's texture coordinates must be flipped vertically in order to properly ...
Definition: Texture.java:536
void disable(final GL gl)
Disables this texture's target (e.g., GL_TEXTURE_2D) in the given GL state.
Definition: Texture.java:357
float getAspectRatio()
Returns the original aspect ratio of the image, defined as (image width) / (image height),...
Definition: Texture.java:468
void enable(final GL gl)
Enables this texture's target (e.g., GL_TEXTURE_2D) in the given GL context's state.
Definition: Texture.java:330
Uninitialized
Uninitialized player, no resources shall be hold.
Initialized
Stream has been initialized, user may play or call initGL(GL).
Interface wrapper for font implementation.
Definition: Font.java:60
boolean isBackgroundOpaque()
Returns whether an opaque or translucent surface is requested, supported or chosen.
int getSurfaceWidth()
Returns the width of the client area excluding insets (window decorations) in pixel units.
int getSurfaceHeight()
Returns the height of the client area excluding insets (window decorations) in pixel units.
Specifying NEWT's Window functionality:
Definition: Window.java:115
void addKeyListener(KeyListener l)
Appends the given com.jogamp.newt.event.KeyListener to the end of the list.
void addMouseListener(MouseListener l)
Appends the given MouseListener to the end of the list.
void destroy()
Destroys this window incl.releasing all related resources.
static final int GL_VERTEX_SHADER
GL_ES_VERSION_2_0, GL_VERSION_2_0, GL_EXT_vertex_shader, GL_ARB_vertex_shader Alias for: GL_VERTEX_SH...
Definition: GL2ES2.java:39
static final int GL_FRAGMENT_SHADER
GL_ES_VERSION_2_0, GL_VERSION_2_0, GL_ATI_fragment_shader, GL_ARB_fragment_shader Alias for: GL_FRAGM...
Definition: GL2ES2.java:541
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
Object getUpstreamWidget()
Method may return the upstream UI toolkit object holding this GLAutoDrawable instance,...
GL2ES2 getGL2ES2()
Casts this object to the GL2ES2 interface.
GLProfile getGLProfile()
Returns the GLProfile associated with this GL object.
boolean isExtensionAvailable(String glExtensionName)
Returns true if the specified OpenGL extension can be used successfully through this GL instance give...
boolean isGLES3()
Indicates whether this GL object conforms to the OpenGL ES ≥ 3.0 profile.
boolean getSampleBuffers()
Returns whether sample buffers for full-scene antialiasing (FSAA) should be allocated for this drawab...
GLCapabilitiesImmutable getChosenGLCapabilities()
Fetches the GLCapabilitiesImmutable corresponding to the chosen OpenGL capabilities (pixel format / v...
int getSurfaceWidth()
Returns the width of this GLDrawable's surface client area in pixel units.
int getSurfaceHeight()
Returns the height of this GLDrawable's surface client area in pixel units.
static final int GL_TEXTURE_EXTERNAL_OES
GL_OES_EGL_image_external Define "GL_TEXTURE_EXTERNAL_OES" with expression '0x8D65',...
Definition: GLES2.java:57
void glDrawArrays(int mode, int first, int count)
Entry point to C language function: void {@native glDrawArrays}(GLenum mode, GLint first,...
static final int GL_STATIC_DRAW
GL_VERSION_1_5, GL_ES_VERSION_2_0, GL_VERSION_ES_1_0, GL_ARB_vertex_buffer_object Alias for: GL_STATI...
Definition: GL.java:673
static final int GL_FLOAT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_FLOAT" with expressio...
Definition: GL.java:786
static final int GL_COLOR_BUFFER_BIT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_COLOR_BUFFER_BIT" wit...
Definition: GL.java:390
void glClearColor(float red, float green, float blue, float alpha)
Entry point to C language function: void {@native glClearColor}(GLfloat red, GLfloat green,...
void glEnable(int cap)
Entry point to C language function: void {@native glEnable}(GLenum cap) Part of GL_ES_VERSION_2_0,...
static final int GL_DEPTH_TEST
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_DEPTH_TEST" with expr...
Definition: GL.java:43
void glActiveTexture(int texture)
Entry point to C language function: void {@native glActiveTexture}(GLenum texture) Part of GL_ES_V...
void glClear(int mask)
Entry point to C language function: void {@native glClear}(GLbitfield mask) Part of GL_ES_VERSION_...
static final int GL_TRIANGLE_STRIP
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_TRIANGLE_STRIP" with ...
Definition: GL.java:760
static final int GL_NEAREST
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_NEAREST" with express...
Definition: GL.java:715
static final int GL_TEXTURE0
GL_ES_VERSION_2_0, GL_VERSION_1_3, GL_VERSION_ES_1_0, GL_ARB_multitexture Alias for: GL_TEXTURE0_ARB ...
Definition: GL.java:71
static final int GL_DEPTH_BUFFER_BIT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_DEPTH_BUFFER_BIT" wit...
Definition: GL.java:738
static final int GL_ARRAY_BUFFER
GL_VERSION_1_5, GL_ES_VERSION_2_0, GL_VERSION_ES_1_0, GL_ARB_vertex_buffer_object Alias for: GL_ARRAY...
Definition: GL.java:633
Subset of OpenGL fixed function pipeline's matrix operations.
static final int GL_PROJECTION
Matrix mode projection.
static final int GL_MODELVIEW
Matrix mode modelview.
As the contract of GLMediaFrameListener and TexSeqEventListener requests, implementations of GLMediaE...
GLMediaPlayer interface specifies a TextureSequence state machine using a multiplexed audio/video str...
State pause(boolean flush)
Pauses the StreamWorker decoding thread.
int getVID()
Return the video stream id, see audio and video Stream IDs.
float getAudioVolume()
Returns the audio volume.
int getDuration()
Return total duration of stream in msec.
int getWidth()
Returns the width of the video.
State destroy(GL gl)
Releases the GL, stream and other resources, including attached user objects.
boolean setAudioVolume(float v)
Sets the audio volume, [0f..1f].
static final int STREAM_ID_NONE
Constant {@value} for mute or not available.
TextureSequence.TextureFrame getLastTexture()
Returns the last updated texture.In case the instance is just initialized, it shall return a TextureF...
void initGL(GL gl)
Initializes OpenGL related resources.
float getPlaySpeed()
Returns the playback speed.
Uri getUri()
Return the stream location, as set by playStream(Uri, int, int, int, int).
void setTextureMinMagFilter(int[] minMagFilter)
Sets the texture min-mag filter, defaults to GL#GL_NEAREST.
boolean setPlaySpeed(float rate)
Sets the playback speed.
void playStream(Uri streamLoc, int vid, int aid, int sid, int textureCount)
Issues asynchronous stream initialization.
int getHeight()
Returns the height of the video.
int getAID()
Return the audio stream id, see audio and video Stream IDs.
TextureSequence.TextureFrame getNextTexture(GL gl)
Returns the next texture to be rendered.Implementation shall return the next frame if available,...
int getAudioBitrate()
Warning: Optional information, may not be supported by implementation.
float getFramerate()
Warning: Optional information, may not be supported by implementation.
int seek(int msec)
Seeks to the new absolute position.
String getVideoCodec()
Warning: Optional information, may not be supported by implementation.
Object attachObject(String name, Object obj)
Attaches the user object for the given name.
State resume()
Starts or resumes the StreamWorker decoding thread.
int getVideoBitrate()
Warning: Optional information, may not be supported by implementation.
PTS getPTS()
Returns current System Clock Reference (SCR) presentation timestamp (PTS).
String getAudioCodec()
Warning: Optional information, may not be supported by implementation.
String getPerfString()
Returns a string representation of this player's performance values.
Extended GLEventListener and CustomGLEventListener interface supporting stereoscopic client rendering...
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().
String setTextureLookupFunctionName(String texLookupFuncName)
Set the desired shader code's texture lookup function name.
int getTextureUnit()
Return the texture unit used to render the current frame.
String getRequiredExtensionsShaderStub()
In case a shader extension is required, based on the implementation and the runtime GL profile,...