28package com.jogamp.opengl.demos.av;
31import java.net.URISyntaxException;
32import java.util.Arrays;
34import com.jogamp.nativewindow.util.DimensionImmutable;
35import com.jogamp.nativewindow.util.PointImmutable;
36import com.jogamp.opengl.GL;
37import com.jogamp.opengl.GLAutoDrawable;
38import com.jogamp.opengl.GLCapabilities;
39import com.jogamp.opengl.GLProfile;
40import com.jogamp.opengl.GLRunnable;
41import com.jogamp.opengl.demos.es2.GearsES2;
42import com.jogamp.opengl.demos.util.MiscUtils;
43import com.jogamp.opengl.demos.util.QuitAdapter;
45import jogamp.opengl.util.stereo.GenericStereoDevice;
47import com.jogamp.common.net.Uri;
48import com.jogamp.math.FovHVHalves;
49import com.jogamp.math.Vec3f;
50import com.jogamp.newt.MonitorDevice;
51import com.jogamp.newt.Screen;
52import com.jogamp.newt.event.KeyAdapter;
53import com.jogamp.newt.event.KeyEvent;
54import com.jogamp.newt.opengl.GLWindow;
55import com.jogamp.newt.opengl.util.stereo.StereoDeviceUtil;
56import com.jogamp.opengl.util.Animator;
57import com.jogamp.opengl.util.AnimatorBase;
58import com.jogamp.opengl.util.av.GLMediaPlayer;
59import com.jogamp.opengl.util.stereo.StereoDevice;
60import com.jogamp.opengl.util.stereo.StereoDeviceRenderer;
61import com.jogamp.opengl.util.stereo.StereoDeviceFactory;
62import com.jogamp.opengl.util.stereo.StereoClientRenderer;
63import com.jogamp.opengl.util.stereo.StereoGLEventListener;
64import com.jogamp.opengl.util.stereo.StereoUtil;
108 static long duration = 10000;
110 static boolean useStereoScreen =
true;
112 static int numSamples = 0;
113 static boolean biLinear =
true;
114 static boolean useSingleFBO =
false;
115 static boolean useVignette =
true;
116 static boolean useChromatic =
true;
117 static boolean useTimewarp =
true;
118 static boolean useAutoSwap =
false;
119 static String useFilmFile =
null;
120 static String useFilmURI =
null;
122 static int deviceIndex = 0;
124 public static void main(
final String args[])
throws InterruptedException, URISyntaxException {
125 boolean useRecommendedDistortionBits =
true;
129 for(
int i=0; i<args.length; i++) {
130 if(args[i].equals(
"-time")) {
133 }
else if(args[i].equals(
"-samples")) {
136 }
else if(args[i].equals(
"-biLinear")) {
139 }
else if(args[i].equals(
"-singleFBO")) {
142 }
else if(args[i].equals(
"-vignette")) {
145 useRecommendedDistortionBits =
false;
146 }
else if(args[i].equals(
"-chromatic")) {
149 useRecommendedDistortionBits =
false;
150 }
else if(args[i].equals(
"-timewarp")) {
153 useRecommendedDistortionBits =
false;
154 }
else if(args[i].equals(
"-vignette")) {
157 useRecommendedDistortionBits =
false;
158 }
else if(args[i].equals(
"-mainScreen")) {
161 }
else if(args[i].equals(
"-device")) {
164 }
else if(args[i].equals(
"-deviceIndex")) {
167 }
else if(args[i].equals(
"-posx")) {
170 }
else if(args[i].equals(
"-posy")) {
173 }
else if(args[i].equals(
"-autoSwap")) {
176 }
else if(args[i].equals(
"-filmFile")) {
178 useFilmFile = args[i];
179 }
else if(args[i].equals(
"-filmURI")) {
181 useFilmURI = args[i];
187 if(
null != useFilmFile ) {
189 movieURI = Uri.valueOf(
new File(useFilmFile));
190 upstream = movieSimple;
191 }
else if(
null != useFilmURI ) {
193 movieURI = Uri.cast(useFilmURI);
194 upstream = movieSimple;
197 demo.
setZ(2f, 10000f, 20f);
204 demo01.
doIt(deviceType, deviceIndex, posx, posy,
205 upstream, movieSimple, movieURI, biLinear, numSamples, useSingleFBO,
206 useRecommendedDistortionBits, useVignette, useChromatic, useTimewarp,
207 useAutoSwap,
true ,
false );
212 final boolean biLinear,
final int numSamples,
final boolean useSingleFBO,
213 final boolean useRecommendedDistortionBits,
final boolean useVignette,
final boolean useChromatic,
final boolean useTimewarp,
214 final boolean useAutoSwap,
final boolean useAnimator,
final boolean exclusiveContext)
throws InterruptedException {
216 System.err.println(
"glob duration "+duration);
217 System.err.println(
"glob useStereoScreen "+useStereoScreen);
218 System.err.println(
"deviceType "+deviceType);
219 System.err.println(
"deviceIndex "+deviceIndex);
220 System.err.println(
"biLinear "+biLinear);
221 System.err.println(
"numSamples "+numSamples);
222 System.err.println(
"useSingleFBO "+useSingleFBO);
223 System.err.println(
"useRecommendedDistortionBits "+useRecommendedDistortionBits);
224 System.err.println(
"useVignette "+useVignette);
225 System.err.println(
"useChromatic "+useChromatic);
226 System.err.println(
"useTimewarp "+useTimewarp);
227 System.err.println(
"useAutoSwap "+useAutoSwap);
230 if(
null == stereoDeviceFactory ) {
231 System.err.println(
"No StereoDeviceFactory available");
236 if(
null == stereoDevice ) {
237 System.err.println(
"No StereoDevice.Context available for index "+deviceIndex);
241 final boolean isGenericDevice = stereoDevice instanceof GenericStereoDevice;
243 if( 0 <= posx && 0 <= posy && isGenericDevice ) {
244 ((GenericStereoDevice)stereoDevice).setSurfacePosition(posx, posy);
246 System.err.println(
"StereoDevice "+stereoDevice);
253 System.err.println(
"Device Res "+deviceRes+
", reqRotation "+stereoDevice.
getRequiredRotation());
254 System.err.println(
"Device Pos "+devicePos);
261 System.err.println(
"Could not start sensors on device "+deviceIndex);
267 if( useStereoScreen ) {
284 System.err.println(
"Default Fov[0]: "+defaultEyeFov[0]);
285 System.err.println(
"Default Fov[0]: "+defaultEyeFov[0].toStringInDegrees());
286 if( defaultEyeFov.length > 1 ) {
287 System.err.println(
"Default Fov[1]: "+defaultEyeFov[1]);
288 System.err.println(
"Default Fov[1]: "+defaultEyeFov[1].toStringInDegrees());
291 final boolean usesLenses = 0 != ( StereoDeviceRenderer.DISTORTION_BARREL & stereoDevice.
getMinimumDistortionBits() );
292 final Vec3f eyePositionOffset =
null != movieSimple && usesLenses ?
new Vec3f( 0f, 0.3f, 0f )
294 System.err.println(
"Eye Position Offset: "+eyePositionOffset);
296 final int textureUnit = 0;
297 final int reqDistortionBits;
298 if( useRecommendedDistortionBits ) {
301 reqDistortionBits = ( useVignette ? StereoDeviceRenderer.DISTORTION_VIGNETTE : 0 ) |
303 ( useTimewarp ? StereoDeviceRenderer.DISTORTION_TIMEWARP : 0 );
307 final float pixelsPerDisplayPixel = 1f;
309 stereoDevice.
createRenderer(reqDistortionBits, useSingleFBO ? 1 : 2, eyePositionOffset,
310 defaultEyeFov, pixelsPerDisplayPixel, textureUnit);
311 System.err.println(
"StereoDeviceRenderer: "+stereoDeviceRenderer);
313 final int texFilter = biLinear ? GL.GL_LINEAR :
GL.
GL_NEAREST;
315 if(
null != movieSimple &&
null != movieURI) {
316 movieSimple.setScaleOrig(
true);
333 public void keyReleased(
final KeyEvent e) {
368 animator.
add(window);
375 System.err.println(
"Window.0.windowSize : "+window.
getWidth()+
" x "+window.
getHeight());
378 if( useStereoScreen ) {
381 System.err.println(
"Window.1.windowSize : "+window.
getWidth()+
" x "+window.
getHeight());
388 final long t0 = System.currentTimeMillis();
390 while(!quitAdapter.shouldQuit() && t1-t0<duration) {
392 t1 = System.currentTimeMillis();
Horizontal and vertical field of view (FOV) halves, allowing a non-centered projection.
3D Vector based upon three float components.
Visual output device, i.e.
final Screen getScreen()
Returns the Screen owning this monitor.
A screen may span multiple MonitorDevices representing their combined virtual size.
abstract int removeReference()
See Display#removeReference().
final short getKeySymbol()
Returns the virtual key symbol reflecting the current keyboard layout.
static final short VK_P
See VK_A.
static final short VK_R
See VK_A.
static final short VK_O
See VK_A.
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
final int getSurfaceHeight()
Returns the height of this GLDrawable's surface client area in pixel units.
final void setPosition(final int x, final int y)
Sets the location of the window's client area excluding insets (window decorations) in window units.
final void addKeyListener(final KeyListener l)
Appends the given com.jogamp.newt.event.KeyListener to the end of the list.
final int getSurfaceWidth()
Returns the width of this GLDrawable's surface client area in pixel units.
final void setVisible(final boolean visible)
Calls setVisible(true, visible), i.e.
final void setSurfaceSize(final int pixelWidth, final int pixelHeight)
Sets the size of the window's surface in pixel units which claims the window's client area excluding ...
final void addWindowListener(final WindowListener l)
Appends the given com.jogamp.newt.event.WindowListener to the end of the list.
final int getHeight()
Returns the height of the client area excluding insets (window decorations) in window units.
final void setUndecorated(final boolean value)
final void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
final int getWidth()
Returns the width of the client area excluding insets (window decorations) in window units.
static GLWindow create(final GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing a new default Screen and default Display wi...
StereoDevice NEWT related utilities.
static MonitorDevice getMonitorDevice(final StereoDevice stereoDevice, final boolean adjustRotation)
Returns the StereoDevice's associated MonitorDevice or null, if none is attached.
Specifies a set of OpenGL capabilities.
Specifies the the OpenGL profile.
static GLProfile getMaxProgrammable(final AbstractGraphicsDevice device, final boolean favorHardwareRasterizer)
Returns the highest profile, implementing the programmable shader pipeline.
Side-By-Side (SBS) 3D Movie Player for StereoClientRenderer.
static final StereoGLMediaEventListener stereoGLMediaEventListener
static final String STEREO_RENDERER_KEY
Simple planar movie player w/ orthogonal 1:1 projection.
static final String WINDOW_KEY
All distortions, no multisampling, bilinear filtering, manual-swap and using two FBOs (default,...
static void main(final String args[])
void doIt(final StereoDeviceFactory.DeviceType deviceType, final int deviceIndex, final int posx, final int posy, final StereoGLEventListener upstream, final MovieSBSStereo movieSimple, final Uri movieURI, final boolean biLinear, final int numSamples, final boolean useSingleFBO, final boolean useRecommendedDistortionBits, final boolean useVignette, final boolean useChromatic, final boolean useTimewarp, final boolean useAutoSwap, final boolean useAnimator, final boolean exclusiveContext)
void setVerbose(final boolean v)
void setZ(final float zNear, final float zFar, final float zViewDist)
static int atoi(final String str, final int def)
static boolean atob(final String str, final boolean def)
static long atol(final String str, final long def)
final synchronized void add(final GLAutoDrawable drawable)
Adds a drawable to this animator's list of rendering drawables.
final synchronized Thread setExclusiveContext(final Thread t)
Dedicate all GLAutoDrawable's context to the given exclusive context thread.
final void setUpdateFPSFrames(final int frames, final PrintStream out)
final synchronized boolean start()
Starts this animator, if not running.
final synchronized boolean stop()
Stops this animator.
StereoClientRenderer utilizing StereoDeviceRenderer implementing GLEventListener for convenience.
final void addGLEventListener(final StereoGLEventListener l)
Platform agnostic StereoDevice factory.
abstract void shutdown()
Shutdown factory if valid.
static StereoDeviceFactory createFactory(final DeviceType type)
final StereoDevice createDevice(final int deviceIndex, final StereoDeviceConfig config, final boolean verbose)
static String distortionBitsToString(final int distortionBits)
See StereoDeviceRenderer#getDistortionBits().
StereoDevice type used for createFactory(type).
Default
Auto selection of device in the following order:
Immutable Dimension Interface, consisting of it's read only components:
Immutable Point interface.
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
boolean invoke(boolean wait, GLRunnable glRunnable)
Enqueues a one-shot GLRunnable, which will be executed within the next display() call after all regis...
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
void setAutoSwapBufferMode(boolean enable)
Enables or disables automatic buffer swapping for this drawable.
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...
Stereoscopic device rendering interface.
static final int DISTORTION_CHROMATIC
Distortion Bit: Chromatic distortion compensating lens chromatic aberration.
ViewerPose getLastViewerPose()
Returns the last ViewerPose.
Interface describing a native stereoscopic device.
DimensionImmutable getSurfaceSize()
Returns the required surface size in pixel in target space.
Vec3f getDefaultEyePositionOffset()
Return the device default eye position offset for createRenderer(int, int, Vec3f, FovHVHalves[],...
int getMinimumDistortionBits()
Returns the minimum distortion compensation bits as required by the StereoDeviceRenderer,...
boolean startSensors(int desiredSensorBits, int requiredSensorBits)
Start desired and required sensors.
boolean stopSensors()
Stop sensors.
PointImmutable getPosition()
If operation within a device spanning virtual desktop, returns the device position.
int getRecommendedDistortionBits()
Returns the recommended distortion compensation bits for the StereoDeviceRenderer,...
boolean getSensorsStarted()
Return true if sensors have been started, false otherwise.
StereoDeviceRenderer createRenderer(final int distortionBits, final int textureCount, final Vec3f eyePositionOffset, final FovHVHalves[] eyeFov, final float pixelsPerDisplayPixel, final int textureUnit)
Create a new StereoDeviceRenderer instance.
FovHVHalves[] getDefaultFOV()
Returns the device default FovHVHalves for all supported eyes in natural order, i....
void resetLocationSensorOrigin()
Sets the location sensor's origin of this device to the current position.
int getSupportedSensorBits()
Returns the supported sensor capability bits, e.g.
void dispose()
Disposes this StereoDevice, if valid.
int getRequiredRotation()
Returns the CCW rotation as required by this display device.
Extended GLEventListener and CustomGLEventListener interface supporting stereoscopic client rendering...