28package com.jogamp.opengl.demos.ios;
30import com.jogamp.common.util.ReflectionUtil;
31import com.jogamp.common.util.VersionUtil;
32import com.jogamp.nativewindow.ScalableSurface;
33import com.jogamp.newt.Display;
34import com.jogamp.newt.NewtFactory;
35import com.jogamp.newt.Screen;
36import com.jogamp.newt.opengl.GLWindow;
37import com.jogamp.common.GlueGenVersion;
38import com.jogamp.opengl.JoglVersion;
39import com.jogamp.opengl.demos.es2.RedSquareES2;
40import com.jogamp.opengl.util.Animator;
42import jogamp.nativewindow.ios.IOSUtil;
44import com.jogamp.opengl.GLAutoDrawable;
45import com.jogamp.opengl.GLCapabilities;
46import com.jogamp.opengl.GLEventListener;
47import com.jogamp.opengl.GLProfile;
51 private static int parseInt(
final String s,
final int def) {
53 return Integer.parseInt(s);
54 }
catch (
final NumberFormatException nfe) {}
57 private static float parseFloat(
final String s,
final float def) {
59 return Float.parseFloat(s);
60 }
catch (
final NumberFormatException nfe) {}
64 public static void main(
final String[] args) {
67 int secondsDuration = 10;
68 int width = 832, height = 480;
69 int fboDepthBits = -1;
70 boolean translucent =
false;
71 boolean exitJVM =
false;
72 String demoName =
"com.jogamp.opengl.demos.es2.GearsES2";
73 for(
int i=0; i<args.length; i++) {
74 if(args[i].equals(
"-exit")) {
76 }
else if(args[i].equals(
"-demo") && i+1<args.length) {
78 }
else if(args[i].equals(
"-width") && i+1<args.length) {
79 width = parseInt(args[++i], width);
80 }
else if(args[i].equals(
"-height") && i+1<args.length) {
81 height = parseInt(args[++i], height);
82 }
else if(args[i].equals(
"-fboDepthBits") && i+1<args.length) {
83 fboDepthBits = parseInt(args[++i], fboDepthBits);
84 }
else if(args[i].equals(
"-pixelScale") && i+1<args.length) {
85 reqSurfacePixelScale[0] = parseFloat(args[++i], reqSurfacePixelScale[0]);
86 reqSurfacePixelScale[1] = reqSurfacePixelScale[0];
87 }
else if(args[i].equals(
"-seconds") && i+1<args.length) {
88 secondsDuration = parseInt(args[++i], secondsDuration);
89 }
else if(args[i].equals(
"-translucent")) {
92 System.err.println(
"ignoring arg["+i+
"]: "+args[i]);
95 System.out.println(
"Hello JogAmp World: exitJVM "+exitJVM+
", size "+width+
"x"+height+
", fboDepthBits "+fboDepthBits+
", demo "+demoName);
96 System.out.println(
"os.name: <"+System.getProperty(
"os.name")+
">");
97 System.out.println(
"os.version: <"+System.getProperty(
"os.version")+
">");
98 System.out.println(
"os.arch: <"+System.getProperty(
"os.arch")+
">");
99 System.out.println(
"java.vendor: <"+System.getProperty(
"java.vendor")+
">");
100 System.out.println(
"java.vendor.url: <"+System.getProperty(
"java.vendor.url")+
">");
101 System.out.println(
"java.version: <"+System.getProperty(
"java.version")+
">");
102 System.out.println(
"java.vm.name: <"+System.getProperty(
"java.vm.name")+
">");
103 System.out.println(
"java.runtime.name: <"+System.getProperty(
"java.runtime.name")+
">");
104 System.out.println(
"");
105 System.out.println(VersionUtil.getPlatformInfo());
106 System.out.println(
"");
107 System.out.println(
"Version Info:");
108 System.out.println(GlueGenVersion.getInstance());
109 System.out.println(
"");
110 System.out.println(
"Full Manifest:");
111 System.out.println(GlueGenVersion.getInstance().getFullManifestInfo(
null));
113 System.out.println(
"");
114 System.err.println(
"mark-01");
115 System.err.println(
"");
117 System.err.println(
"");
118 System.err.println(
"mark-02");
119 System.err.println(
"");
121 System.err.println(
"");
122 System.err.println(
"mark-03");
123 System.out.println(
"");
125 System.out.println(
"");
126 System.err.println(
"mark-04");
127 System.err.println(
"");
134 if( 0 <= fboDepthBits) {
138 System.out.println(
"Requested GL Caps: "+reqCaps);
146 glWindow.
setSize(width, height);
149 void printInfo(
final String prefix,
final GLAutoDrawable d,
final String postfix) {
151 if(
null != postfix) {
152 System.out.println(
" - "+postfix);
154 System.out.println();
159 printInfo(
"GLEvent::Init", drawable,
null);
164 printInfo(
"GLEvent::Dispose", drawable,
null);
172 public void reshape(
final GLAutoDrawable drawable,
final int x,
final int y,
final int width,
final int height) {
173 printInfo(
"GLEvent::Reshape", drawable,
"reshape["+x+
"/"+y+
" "+width+
"x"+height+
"]");
181 }
catch(
final Exception e ) {
182 System.err.println(e.getMessage()+
" using: <"+demoName+
">");
188 System.out.println(
"Choosen demo "+demo.getClass().getName());
198 System.err.println(
"HiDPI PixelScale: "+reqSurfacePixelScale[0]+
"x"+reqSurfacePixelScale[1]+
" (req) -> "+
199 valReqSurfacePixelScale[0]+
"x"+valReqSurfacePixelScale[1]+
" (val) -> "+
200 hasSurfacePixelScale1[0]+
"x"+hasSurfacePixelScale1[1]+
" (has)");
203 final long uiView = IOSUtil.GetUIView(uiWindow,
true);
204 final long caeaglLayer = IOSUtil.GetCAEAGLLayer(uiView);
205 System.out.println(
"EAGL: UIWindow 0x"+Long.toHexString(uiWindow));
206 System.out.println(
"EAGL: UIView 0x"+Long.toHexString(uiView));
207 System.out.println(
"EAGL: EAGLLayer 0x"+Long.toHexString(caeaglLayer));
208 System.out.println(
"isUIWindow "+IOSUtil.isUIWindow(uiWindow)+
", isUIView "+IOSUtil.isUIView(uiView)+
209 ", isCAEAGLLayer "+IOSUtil.isCAEAGLLayer(caeaglLayer));
215 animator.
add(glWindow);
218 for(
int i=0; i<secondsDuration; i++) {
221 }
catch (
final InterruptedException e) {
228 System.err.println(
"");
229 System.err.println(
"mark-05");
230 System.err.println(
"");
232 if(
null != glWindow ) {
237 System.err.println(
"");
238 System.err.println(
"mark-06");
239 System.err.println(
"");
void setBackgroundOpaque(final boolean opaque)
Sets whether the surface shall be opaque or translucent.
static Display createDisplay(final String name)
Create a Display entity.
static Screen createScreen(final Display display, final int index)
Create a Screen entity.
A screen may span multiple MonitorDevices representing their combined virtual size.
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 float[] getRequestedSurfaceScale(final float[] result)
Returns the requested pixel scale of the associated NativeSurface.
final int getX()
Returns the current x position of this window, relative to it's parent.
final int getY()
Returns the current y position of the top-left corner of the client area relative to it's parent in w...
final float[] getCurrentSurfaceScale(final float[] result)
Returns the current pixel scale of the associated NativeSurface.
final int getSurfaceWidth()
Returns the width of this GLDrawable's surface client area in pixel units.
final void setSize(final int width, final int height)
Sets the size of the window's client area in window units, excluding decorations.
final void setVisible(final boolean visible)
Calls setVisible(true, visible), i.e.
final int getHeight()
Returns the height of the client area excluding insets (window decorations) in window units.
final CapabilitiesImmutable getChosenCapabilities()
Gets an immutable set of chosen capabilities.
final InsetsImmutable getInsets()
Returns the insets defined as the width and height of the window decoration on the left,...
final boolean setSurfaceScale(final float[] pixelScale)
Request a pixel scale in x- and y-direction for the associated NativeSurface, where size_in_pixel_uni...
final long getWindowHandle()
Returns the window handle for this NativeWindow.
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.
final Window getDelegatedWindow()
If the implementation uses delegation, return the delegated Window instance, otherwise return this in...
static GLWindow create(final GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing a new default Screen and default Display wi...
Specifies a set of OpenGL capabilities.
void setDepthBits(final int depthBits)
Sets the number of bits requested for the depth buffer.
Specifies the the OpenGL profile.
static AbstractGraphicsDevice getDefaultDevice()
static GLProfile getGL2ES2(final AbstractGraphicsDevice device)
Returns the GL2ES2 profile implementation, hence compatible w/ GL2ES2.
static void initSingleton()
Static initialization of JOGL.
static JoglVersion getInstance()
static StringBuilder getDefaultOpenGLInfo(AbstractGraphicsDevice device, StringBuilder sb, final boolean withCapabilitiesInfo)
static void main(final String[] args)
final synchronized void add(final GLAutoDrawable drawable)
Adds a drawable to this animator's list of rendering drawables.
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.
Adding mutable surface pixel scale property to implementing class, usually to a NativeSurface impleme...
static final float AUTOMAX_PIXELSCALE
Setting surface-pixel-scale of {@value}, results in maximum platform dependent pixel-scale,...
CapabilitiesImmutable getChosenCapabilities()
Gets an immutable set of chosen capabilities.
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
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.
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.