aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl/FBObject.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2019-06-23 08:03:04 +0200
committerSven Gothel <[email protected]>2019-06-23 08:03:04 +0200
commitbba73bc096250a3c7fc036d84b1ea054d1b70b06 (patch)
treeed02575eac2a46bd49627444dcce972946ae8d2e /src/jogl/classes/com/jogamp/opengl/FBObject.java
parent154e91978498d8b6db9ce34a1f06b298bcf4c361 (diff)
iOS: Initial working commit supporting iOS (ipad pro 11)
using our OpenJFK 9 x86_64 and arm64 build. Test demo class is 'com.jogamp.opengl.demos.ios.Hello', residing in the new demo folder 'src/demos/com/jogamp/opengl/demos/ios/Hello.java'. This commit does not yet include a working NEWT specialization for iOS, but it shall followup soon. Instead this commit demonstrates JOGL operating on native UIWindow, UIView and CAEAGLLayer as provided by Nativewindow's IOSUtil. Test Video https://www.youtube.com/watch?v=Z4lUQNFTGMI +++ Notable bug: The FBO used and sharing the COLORBUFFER RENDERBUFFER memory resources with CAEAGLLayer to be displayed in the UIView seemingly cannot handle GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT24 or GL_DEPTH_COMPONENT32 depth buffer - none at all (Device + Simulation). Therefor the default demo GLEventListener chosen here don't require a depth buffer ;-) This issue can hopefully be mitigated with other means than using a flat FBO sink similar to FBO multisampling.
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/FBObject.java')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/FBObject.java48
1 files changed, 45 insertions, 3 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/FBObject.java b/src/jogl/classes/com/jogamp/opengl/FBObject.java
index c36727fe4..00a560fc7 100644
--- a/src/jogl/classes/com/jogamp/opengl/FBObject.java
+++ b/src/jogl/classes/com/jogamp/opengl/FBObject.java
@@ -34,7 +34,6 @@ import com.jogamp.opengl.GL;
import com.jogamp.opengl.GL2ES2;
import com.jogamp.opengl.GL2ES3;
import com.jogamp.opengl.GL2GL3;
-import com.jogamp.opengl.GL3;
import com.jogamp.opengl.GLBase;
import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.GLCapabilitiesImmutable;
@@ -43,6 +42,7 @@ import com.jogamp.opengl.GLException;
import com.jogamp.opengl.GLProfile;
import jogamp.opengl.Debug;
+import jogamp.opengl.ios.eagl.EAGL;
import com.jogamp.common.ExceptionUtils;
import com.jogamp.common.util.PropertyAccess;
@@ -483,6 +483,48 @@ public class FBObject {
@Override
public final ColorAttachment getColorAttachment() { return this; }
+ @Override
+ public boolean initialize(final GL gl) throws GLException {
+ final boolean init = 0 == getName();
+ if( init ) {
+ final boolean checkError = DEBUG || GLContext.DEBUG_GL;
+ if( checkError ) {
+ checkPreGLError(gl);
+ }
+ final int[] name = new int[] { -1 };
+ gl.glGenRenderbuffers(1, name, 0);
+ setName(name[0]);
+
+ gl.glBindRenderbuffer(GL.GL_RENDERBUFFER, getName());
+ if( getSamples() > 0 ) {
+ ((GL2ES3)gl).glRenderbufferStorageMultisample(GL.GL_RENDERBUFFER, getSamples(), format, getWidth(), getHeight());
+ } else {
+ // FIXME: Need better way to inject the IOS EAGL Layer into FBObject
+ // FIXME: May want to implement optional injection of a BufferStorage SPI?
+ final GLContext ctx = gl.getContext();
+ final Long iosEAGLLayer = (Long) ctx.getAttachedObject("IOS_EAGL_LAYER");
+ if( null != iosEAGLLayer ) {
+ EAGL.eaglBindDrawableStorageToRenderbuffer(gl.getContext().contextHandle, GL.GL_RENDERBUFFER, iosEAGLLayer.longValue());
+ } else {
+ gl.glRenderbufferStorage(GL.GL_RENDERBUFFER, format, getWidth(), getHeight());
+ }
+ }
+ if( checkError ) {
+ final int glerr = gl.glGetError();
+ if(GL.GL_NO_ERROR != glerr) {
+ gl.glDeleteRenderbuffers(1, name, 0);
+ setName(0);
+ throw new GLException("GL Error "+toHexString(glerr)+" while creating "+this);
+ }
+ }
+ if(DEBUG) {
+ System.err.println("Attachment.init.X: "+this);
+ }
+ }
+ return init;
+ }
+
+
}
/** Texture FBO attachment */
@@ -1250,7 +1292,7 @@ public class FBObject {
return("FBO missing read buffer");
case GL.GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
return("FBO missing multisample buffer");
- case GL3.GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS:
+ case GL3ES3.GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS:
return("FBO missing layer targets");
case GL.GL_FRAMEBUFFER_UNSUPPORTED:
@@ -1281,7 +1323,7 @@ public class FBObject {
case GL2GL3.GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:
case GL2GL3.GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER:
case GL.GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
- case GL3.GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS:
+ case GL3ES3.GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS:
if(0 == colorbufferCount || null == depth) {
// we are in transition
return true;