summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java
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/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java
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/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java')
-rw-r--r--src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java
index 64cca7bdd..ea226b407 100644
--- a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java
@@ -76,6 +76,7 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable {
// private DoubleBufferMode doubleBufferMode; // TODO: Add or remove TEXTURE (only) DoubleBufferMode support
+ private FBObject.Attachment.StorageDefinition colorRenderbufferStorageDef;
private SwapBufferContext swapBufferContext;
public static interface SwapBufferContext {
@@ -87,7 +88,7 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable {
* @param parent
* @param surface
* @param fboCaps the requested FBO capabilities
- * @param textureUnit if valid, i.e. >= 0, signals {@link #FBOMODE_USE_TEXTURE}, otherwise a color renderbuffer is assumed
+ * @param textureUnit if valid, i.e. >= 0, signals using a color texturebuffer {@link GLFBODrawable#FBOMODE_USE_TEXTURE}, otherwise a color renderbuffer is used.
*/
protected GLFBODrawableImpl(final GLDrawableFactoryImpl factory, final GLDrawableImpl parent, final NativeSurface surface,
final GLCapabilitiesImmutable fboCaps, final int textureUnit) {
@@ -100,6 +101,7 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable {
this.texUnit = textureUnit>=0 ? textureUnit : 0;
this.samples = fboCaps.getNumSamples();
this.fboResetQuirk = false;
+ this.colorRenderbufferStorageDef = null;
this.swapBufferContext = null;
}
@@ -117,7 +119,11 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable {
throw new InternalError("Sample number mismatch: "+samples+", fbos["+idx+"] "+fbo);
}
if(samples > 0 || !useTexture) {
- fbo.attachColorbuffer(gl, 0, useAlpha);
+ final FBObject.ColorAttachment ca = fbo.createColorAttachment(useAlpha);
+ if( null != colorRenderbufferStorageDef ) {
+ ca.setStorageDefinition(colorRenderbufferStorageDef);
+ }
+ fbo.attachColorbuffer(gl, 0, ca);
} else {
fbo.attachTexture2D(gl, 0, useAlpha);
}
@@ -135,7 +141,11 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable {
{
ssink.init(gl, width, height, 0);
if( !useTexture ) {
- ssink.attachColorbuffer(gl, 0, useAlpha);
+ final FBObject.ColorAttachment ca = ssink.createColorAttachment(useAlpha);
+ if( null != colorRenderbufferStorageDef ) {
+ ca.setStorageDefinition(colorRenderbufferStorageDef);
+ }
+ ssink.attachColorbuffer(gl, 0, ca);
} else {
ssink.attachTexture2D(gl, 0, useAlpha);
}
@@ -249,6 +259,24 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable {
swapBufferContext = sbc;
}
+ /**
+ * Inject custom {@link FBObject.Attachment.StorageDefinition} specialization for the use-case of:
+ * <ul>
+ * <li>Using a special <i>color renderbuffer storage</i> instead of the default {@link FBObject} <i>internal offscreen</i> storage.</li>
+ * </ul>
+ * @see {@link FBObject.Attachment.StorageDefinition}
+ * @see {@link FBObject.Attachment#setStorageDefinition(FBObject.Attachment.StorageDefinition)}
+ */
+ public final void setColorRenderbufferStorageDef(final FBObject.Attachment.StorageDefinition sd) {
+ colorRenderbufferStorageDef = sd;
+ if(DEBUG) {
+ System.err.println("EAGL.FBODrawable: setColorRenderbufferStorageDef");
+ }
+ }
+ public final boolean hasColorRenderbufferStorageDef(final FBObject.Attachment.StorageDefinition sd) {
+ return sd == colorRenderbufferStorageDef;
+ }
+
private final void reset(final GL gl, final int idx, final int width, final int height, final int samples,
final boolean useAlpha, final int depthBits, final int stencilBits) {
if( !fboResetQuirk ) {