28package com.jogamp.opengl.demos.ios;
30import com.jogamp.common.util.ReflectionUtil;
31import com.jogamp.common.util.VersionUtil;
32import com.jogamp.nativewindow.AbstractGraphicsScreen;
33import com.jogamp.nativewindow.MutableGraphicsConfiguration;
34import com.jogamp.nativewindow.NativeWindowFactory;
35import com.jogamp.nativewindow.UpstreamWindowHookMutableSizePos;
37import com.jogamp.common.GlueGenVersion;
38import com.jogamp.opengl.JoglVersion;
39import com.jogamp.opengl.demos.es2.RedSquareES2;
40import com.jogamp.opengl.util.Animator;
41import com.jogamp.opengl.util.AnimatorBase;
43import jogamp.nativewindow.WrappedWindow;
44import jogamp.nativewindow.ios.IOSUtil;
45import jogamp.opengl.GLDrawableFactoryImpl;
47import com.jogamp.opengl.GLAutoDrawable;
48import com.jogamp.opengl.GLAutoDrawableDelegate;
49import com.jogamp.opengl.GLCapabilities;
50import com.jogamp.opengl.GLCapabilitiesImmutable;
51import com.jogamp.opengl.GLDrawable;
52import com.jogamp.opengl.GLDrawableFactory;
53import com.jogamp.opengl.GLEventListener;
54import com.jogamp.opengl.GLProfile;
58 private static int parseInt(
final String s,
final int def) {
60 return Integer.parseInt(s);
61 }
catch (
final NumberFormatException nfe) {}
65 public static void main(
final String[] args) {
66 int width = 832, height = 480;
67 int fboDepthBits = -1;
68 boolean exitJVM =
false;
69 String demoName =
"com.jogamp.opengl.demos.es2.GearsES2";
70 for(
int i=0; i<args.length; i++) {
71 if(args[i].equals(
"-exit")) {
73 }
else if(args[i].equals(
"-demo") && i+1<args.length) {
75 }
else if(args[i].equals(
"-width") && i+1<args.length) {
76 width = parseInt(args[++i], width);
77 }
else if(args[i].equals(
"-height") && i+1<args.length) {
78 height = parseInt(args[++i], height);
79 }
else if(args[i].equals(
"-fboDepthBits") && i+1<args.length) {
80 fboDepthBits = parseInt(args[++i], fboDepthBits);
82 System.err.println(
"ignoring arg["+i+
"]: "+args[i]);
85 System.out.println(
"Hello JogAmp World: exitJVM "+exitJVM+
", size "+width+
"x"+height+
", fboDepthBits "+fboDepthBits+
", demo "+demoName);
86 System.out.println(
"os.name: <"+System.getProperty(
"os.name")+
">");
87 System.out.println(
"os.version: <"+System.getProperty(
"os.version")+
">");
88 System.out.println(
"os.arch: <"+System.getProperty(
"os.arch")+
">");
89 System.out.println(
"java.vendor: <"+System.getProperty(
"java.vendor")+
">");
90 System.out.println(
"java.vendor.url: <"+System.getProperty(
"java.vendor.url")+
">");
91 System.out.println(
"java.version: <"+System.getProperty(
"java.version")+
">");
92 System.out.println(
"java.vm.name: <"+System.getProperty(
"java.vm.name")+
">");
93 System.out.println(
"java.runtime.name: <"+System.getProperty(
"java.runtime.name")+
">");
94 System.out.println(
"");
95 System.out.println(VersionUtil.getPlatformInfo());
96 System.out.println(
"");
97 System.out.println(
"Version Info:");
98 System.out.println(GlueGenVersion.getInstance());
99 System.out.println(
"");
100 System.out.println(
"Full Manifest:");
101 System.out.println(GlueGenVersion.getInstance().getFullManifestInfo(
null));
103 System.out.println(
"");
104 System.err.println(
"mark-01");
105 System.err.println(
"");
107 System.err.println(
"");
108 System.err.println(
"mark-02");
109 System.err.println(
"");
111 System.err.println(
"");
112 System.err.println(
"mark-03");
113 System.out.println(
"");
115 System.out.println(
"");
116 System.err.println(
"mark-04");
117 System.err.println(
"");
120 final long uiWindow = IOSUtil.CreateUIWindow(0, 0, width, height,
true);
125 if( 0 <= fboDepthBits) {
128 System.out.println(
"Requested GL Caps: "+reqCaps);
132 final long uiView = IOSUtil.GetUIView(uiWindow,
true);
133 final long caeaglLayer = IOSUtil.GetCAEAGLLayer(uiView);
134 System.out.println(
"EAGL: UIWindow 0x"+Long.toHexString(uiWindow));
135 System.out.println(
"EAGL: UIView 0x"+Long.toHexString(uiView));
136 System.out.println(
"EAGL: EAGLLayer 0x"+Long.toHexString(caeaglLayer));
137 System.out.println(
"isUIWindow "+IOSUtil.isUIWindow(uiWindow)+
", isUIView "+IOSUtil.isUIView(uiView)+
138 ", isCAEAGLLayer "+IOSUtil.isCAEAGLLayer(caeaglLayer));
142 final WrappedWindow nativeWindow =
new WrappedWindow(config, uiView, hook,
true, uiWindow);
145 final GLDrawable drawable = factory.createGLDrawable(nativeWindow);
150 protected void destroyImplInLock() {
152 nativeWindow.destroy();
153 IOSUtil.DestroyUIWindow(uiWindow);
157 void printInfo(
final String prefix,
final GLAutoDrawable d,
final String postfix) {
159 if(
null != postfix) {
160 System.out.println(
" - "+postfix);
162 System.out.println();
167 printInfo(
"GLEvent::Init", drawable,
null);
172 printInfo(
"GLEvent::Dispose", drawable,
null);
180 public void reshape(
final GLAutoDrawable drawable,
final int x,
final int y,
final int width,
final int height) {
181 printInfo(
"GLEvent::Reshape", drawable,
"reshape["+x+
"/"+y+
" "+width+
"x"+height+
"]");
189 System.out.println(
"Choosen GL Caps: "+chosenCaps);
195 }
catch(
final Exception e ) {
196 System.err.println(e.getMessage()+
" using: <"+demoName+
">");
202 System.out.println(
"Choosen demo "+demo.getClass().getName());
211 for(
int i=0; i<10; i++) {
214 }
catch (
final InterruptedException e) {
226 System.err.println(
"");
227 System.err.println(
"mark-05");
228 System.err.println(
"");
Provides a pluggable mechanism for arbitrary window toolkits to adapt their components to the NativeW...
static AbstractGraphicsDevice createDevice(final String displayConnection, final boolean own)
Creates a native device type, following getNativeWindowType(true).
static AbstractGraphicsScreen createScreen(final AbstractGraphicsDevice device, int screen)
Fully functional GLAutoDrawable implementation utilizing already created GLDrawable and GLContext ins...
final void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext....
Specifies a set of OpenGL capabilities.
void setDepthBits(final int depthBits)
Sets the number of bits requested for the depth buffer.
static GLDrawableFactory getFactory(final GLProfile glProfile)
Returns the sole GLDrawableFactory instance.
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.
A interface describing a graphics screen in a toolkit-independent manner.
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.
Specifies an immutable set of OpenGL capabilities.
An abstraction for an OpenGL rendering target.
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.
void setRealized(boolean realized)
Indicates to GLDrawable implementations whether the underlying surface has been created and can be dr...
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.