aboutsummaryrefslogtreecommitdiffstats
path: root/src/demos/com/jogamp/opengl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2019-06-24 14:57:55 +0200
committerSven Gothel <[email protected]>2019-06-24 14:57:55 +0200
commit203f795cd3332d6d61c210c8b7901de069d9166a (patch)
treee35b5ff354eadbf917162fa83469e420a55b8b9f /src/demos/com/jogamp/opengl
parentbba73bc096250a3c7fc036d84b1ea054d1b70b06 (diff)
iOS: Clean up promotion of EAGLLayer use down to FBObject
Initial commit bba73bc096250a3c7fc036d84b1ea054d1b70b06 hacked its path using a context global EGLLayer instance attachement. The hack was good for the first demo, however, it forbid using other FBObjects etc on the way. Properly specifying FBObject.Attachment.StorageDefinition, allowing the user to inject code for selected FBO attachements to define their storage. This might be useful for different platforms as well - however, it is OS agnostic and instance specific now. In this sense, GLFBODrawableImpl, hosting FBObject, has a more specific instance of FBObject.Attachment.StorageDefinition for color-renderbuffer. It is passed along newly created color renderbuffer. GLDrawableFactoryImpl.createGLDrawable uses a derived interface, OnscreenFBOColorbufferStorageDefinition which is defined in IOSEAGLDrawableFactory and return by its getter. GLDrawableFactoryImpl.createGLDrawable is therefor platform agnostic again. Bottom line is, as more platforms will be added, these semi-public interfaces have to adapt to suit them all .. All this due to iOS architecture for 'onscreen rendering' using a FBO which shares its color renderbuffer storage with the EAGLLayer, associated with the UIView. A bit weird maybe in first sight, but efficient for creating cheap hardware design ;-) Only criticism here is that Apple didn't bother using EGL and an extension.
Diffstat (limited to 'src/demos/com/jogamp/opengl')
-rw-r--r--src/demos/com/jogamp/opengl/demos/ios/Hello.java24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/demos/com/jogamp/opengl/demos/ios/Hello.java b/src/demos/com/jogamp/opengl/demos/ios/Hello.java
index d593dd3bc..9982d7d1f 100644
--- a/src/demos/com/jogamp/opengl/demos/ios/Hello.java
+++ b/src/demos/com/jogamp/opengl/demos/ios/Hello.java
@@ -37,6 +37,8 @@ import com.jogamp.nativewindow.UpstreamWindowHookMutableSizePos;
import com.jogamp.common.GlueGenVersion;
import com.jogamp.opengl.JoglVersion;
import com.jogamp.opengl.demos.es2.RedSquareES2;
+import com.jogamp.opengl.util.Animator;
+import com.jogamp.opengl.util.AnimatorBase;
import jogamp.nativewindow.WrappedWindow;
import jogamp.nativewindow.ios.IOSUtil;
@@ -61,9 +63,9 @@ public class Hello {
public static void main(final String[] args) {
int width = 832, height = 480; // ipad pro 11: 2388x1668 px (scale: 2)
- int fboDepthBits = 0; // CAEAGLLayer fails with depth 16 + 24 in Simulation
+ int fboDepthBits = -1; // CAEAGLLayer fails with depth 16 + 24 in Simulation; -1 means don't change
boolean exitJVM = false;
- String demoName = "com.jogamp.opengl.demos.es2.LandscapeES2";
+ String demoName = "com.jogamp.opengl.demos.es2.GearsES2";
for(int i=0; i<args.length; i++) {
if(args[i].equals("-exit")) {
exitJVM = true;
@@ -119,9 +121,9 @@ public class Hello {
// 1) Config ..
final GLProfile glp = GLProfile.getGL2ES2();
final GLCapabilities reqCaps = new GLCapabilities(glp);
- reqCaps.setOnscreen(true);
- reqCaps.setDoubleBuffered(false);
- reqCaps.setDepthBits(fboDepthBits);
+ if( 0 <= fboDepthBits) {
+ reqCaps.setDepthBits(fboDepthBits);
+ }
System.out.println("Requested GL Caps: "+reqCaps);
final GLDrawableFactoryImpl factory = (GLDrawableFactoryImpl) GLDrawableFactory.getFactory(glp);
@@ -170,14 +172,20 @@ public class Hello {
System.out.println("Choosen demo "+demo.getClass().getName());
glad.addGLEventListener(demo);
- for(int i=0; i<60*10; i++) { // 10s w/ 60fps
- glad.display(); // force native context creation
+ final Animator animator = new Animator();
+ // animator.setExclusiveContext(exclusiveContext);
+ animator.setUpdateFPSFrames(60, System.err);
+ animator.add(glad);
+ animator.start();
+
+ for(int i=0; i<10; i++) { // 10s
try {
- Thread.sleep(16);
+ Thread.sleep(1000);
} catch (final InterruptedException e) {
e.printStackTrace();
}
}
+ animator.stop();
} finally {
if( null != glad ) {