aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphil <[email protected]>2016-10-17 09:59:33 +1300
committerphil <[email protected]>2016-10-17 09:59:33 +1300
commitb0baf72761a6a517cc7916905051524d23c2a28d (patch)
treec5fbd60c7c78850766a532772663e5d24f65443f
parent4cb354edc89e379a3fe02cecc7d64171e951b24e (diff)
gl2es2pipeline tiny code tidy by moving things around for offscfeen
buffers, whole methods only, should not break anything gl2es2deppipeline has validity message improved
-rw-r--r--src/main/java/org/jogamp/java3d/Jogl2es2DEPPipeline.java17
-rw-r--r--src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java298
2 files changed, 158 insertions, 157 deletions
diff --git a/src/main/java/org/jogamp/java3d/Jogl2es2DEPPipeline.java b/src/main/java/org/jogamp/java3d/Jogl2es2DEPPipeline.java
index 1e8422a..97794bb 100644
--- a/src/main/java/org/jogamp/java3d/Jogl2es2DEPPipeline.java
+++ b/src/main/java/org/jogamp/java3d/Jogl2es2DEPPipeline.java
@@ -14,9 +14,10 @@ abstract class Jogl2es2DEPPipeline extends Pipeline
+ "Each Geomtry must have a format of GeometryArray.BY_REFERENCE = true and GeometryArray.INTERLEAVED = false. \n"//
+ "Texture Coordinate generation is not supported, Texture Filter, Sharpen and combine are not supported. \n"//
+ "Texture3D, TextureCubeMap are not supported. \n"//
- + "Off screen buffers and decals are also not supported. \n"//
- + "Coordinates must be defind and float type, colors if defined must be float type. \n"//
- + "It is strongly recomended that you use the format GeometryArray.USE_NIO_BUFFER = true.";//
+ + "Accum style anti-aliasing, rasters and decals are also not supported. \n"//
+ + "Coordinates must be defind and float type, colors must be float type, if defined. \n"//
+ + "It is strongly recomended that you use the format GeometryArray.USE_NIO_BUFFER = true. \n"//
+ + "Note LineArray and LineStripArray will not render as nicely as the fixed function pipeline.";//
/**
* Constructor for singleton JoglPipeline instance
@@ -40,11 +41,10 @@ abstract class Jogl2es2DEPPipeline extends Pipeline
int texCoordSetMapLen, int[] texUnitOffset, int numActiveTexUnitState, int vertexAttrCount, int[] vertexAttrSizes,
float[] varray, float[] carray, int cDirty)
{
- throw new UnsupportedOperationException("Use of GeometryArrays (un-indexed) by Copy or interleaved not allowed.\n" + VALID_FORMAT_MESSAGE);
+ throw new UnsupportedOperationException(
+ "Use of GeometryArrays (un-indexed) by Copy or interleaved not allowed.\n" + VALID_FORMAT_MESSAGE);
}
-
-
// used by GeometryArray by Reference in interleaved format with NIO buffer
@Override
@Deprecated
@@ -166,7 +166,8 @@ abstract class Jogl2es2DEPPipeline extends Pipeline
float planeSw, float planeTx, float planeTy, float planeTz, float planeTw, float planeRx, float planeRy, float planeRz,
float planeRw, float planeQx, float planeQy, float planeQz, float planeQw, double[] vworldToEc)
{
- throw new UnsupportedOperationException("Texture Coordinate generation is not supported in the GL2ES2 pipeline.\n" + VALID_FORMAT_MESSAGE);
+ throw new UnsupportedOperationException(
+ "Texture Coordinate generation is not supported in the GL2ES2 pipeline.\n" + VALID_FORMAT_MESSAGE);
}
// ---------------------------------------------------------------------
@@ -337,8 +338,6 @@ abstract class Jogl2es2DEPPipeline extends Pipeline
// Canvas3D methods - native wrappers
//
-
-
// This is the native method for doing accumulation.
@Override
@Deprecated
diff --git a/src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java b/src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java
index 718fc22..8034317 100644
--- a/src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java
+++ b/src/main/java/org/jogamp/java3d/Jogl2es2Pipeline.java
@@ -6175,151 +6175,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
private Object mainThreadContext; // Fix for Bug 983
- static boolean isOffscreenLayerSurfaceEnabled(Canvas3D cv)
- {
- if (cv.drawable == null || cv.offScreen)
- return false;
-
- JoglDrawable joglDrawble = (JoglDrawable) cv.drawable;
- JAWTWindow jawtwindow = (JAWTWindow) joglDrawble.getNativeWindow();
- if (jawtwindow == null)
- return false;
-
- return jawtwindow.isOffscreenLayerSurfaceEnabled();
- }
-
- static boolean hasFBObjectSizeChanged(JoglDrawable jdraw, int width, int height)
- {
- if (!(jdraw.getGLDrawable() instanceof GLFBODrawable))
- return false;
-
- FBObject fboBack = ((GLFBODrawable) jdraw.getGLDrawable()).getFBObject(GL.GL_BACK);
- if (fboBack == null)
- return false;
-
- return (width != fboBack.getWidth() || height != fboBack.getHeight());
- }
-
- // Mac/JRE 7; called from Renderer when resizing is detected
- // Implementation follows the approach in
- // jogamp.opengl.GLDrawableHelper.resizeOffscreenDrawable(..)
- @Override
- void resizeOffscreenLayer(Canvas3D cv, int cvWidth, int cvHeight)
- {
- if (!isOffscreenLayerSurfaceEnabled(cv))
- return;
-
- JoglDrawable joglDrawable = (JoglDrawable) cv.drawable;
- if (!hasFBObjectSizeChanged(joglDrawable, cvWidth, cvHeight))
- return;
-
- int newWidth = Math.max(1, cvWidth);
- int newHeight = Math.max(1, cvHeight);
-
- GLDrawable glDrawble = joglDrawable.getGLDrawable();
- GLContext glContext = context(cv.ctx);
-
- // Assuming glContext != null
-
- final NativeSurface surface = glDrawble.getNativeSurface();
- final ProxySurface proxySurface = (surface instanceof ProxySurface) ? (ProxySurface) surface : null;
-
- final int lockRes = surface.lockSurface();
-
- try
- {
- // propagate new size - seems not relevant here
- if (proxySurface != null)
- {
- final UpstreamSurfaceHook ush = proxySurface.getUpstreamSurfaceHook();
- if (ush instanceof UpstreamSurfaceHook.MutableSize)
- {
- ((UpstreamSurfaceHook.MutableSize) ush).setSurfaceSize(newWidth, newHeight);
- }
- }
- /*
- else if(DEBUG) {
- // we have to assume surface contains the new size already, hence size check @ bottom
- System.err.println("GLDrawableHelper.resizeOffscreenDrawable: Drawable's offscreen surface n.a. ProxySurface, but "
- +ns.getClass().getName()+": "+ns); }
- */
-
- GL2ES2 gl = glContext.getGL().getGL2ES2();
-
- // FBO : should be the default case on Mac OS X
- if (glDrawble instanceof GLFBODrawable)
- {
-
- // Resize GLFBODrawable
- // TODO msaa gets lost
- // ((GLFBODrawable)glDrawble).resetSize(gl);
-
- // Alternative: resize GL_BACK FBObject directly,
- // if multisampled the FBO sink (GL_FRONT) will be resized
- // before the swap is executed
- int numSamples = ((GLFBODrawable) glDrawble).getChosenGLCapabilities().getNumSamples();
- FBObject fboObjectBack = ((GLFBODrawable) glDrawble).getFBObject(GL.GL_BACK);
- fboObjectBack.reset(gl, newWidth, newHeight, numSamples/* , false */); // false = don't reset
- // SamplingSinkFBO
- // immediately
- fboObjectBack.bind(gl);
-
- // If double buffered without antialiasing the GL_FRONT FBObject
- // will be resized by glDrawble after the next swap-call
- }
- // pbuffer - not tested because Mac OS X 10.7+ supports FBO
- else
- {
- // Create new GLDrawable (pbuffer) and update the coresponding
- // GLContext
-
- final GLContext currentContext = GLContext.getCurrent();
- final GLDrawableFactory factory = glDrawble.getFactory();
-
- // Ensure to sync GL command stream
- if (currentContext != glContext)
- {
- glContext.makeCurrent();
- }
- gl.glFinish();
- glContext.release();
-
- if (proxySurface != null)
- {
- proxySurface.enableUpstreamSurfaceHookLifecycle(false);
- }
-
- try
- {
- glDrawble.setRealized(false);
- // New GLDrawable
- glDrawble = factory.createGLDrawable(surface);
- glDrawble.setRealized(true);
-
- joglDrawable.setGLDrawable(glDrawble);
- }
- finally
- {
- if (proxySurface != null)
- {
- proxySurface.enableUpstreamSurfaceHookLifecycle(true);
- }
- }
-
- glContext.setGLDrawable(glDrawble, true); // re-association
-
- // make current last current context
- if (currentContext != null)
- {
- currentContext.makeCurrent();
- }
- }
- }
- finally
- {
- surface.unlockSurface();
- }
- }
+
// Fix for Bug 983
private void checkAppContext()
@@ -6467,7 +6323,7 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
// Issue 417: JOGL: Mip-mapped NPOT textures rendered incorrectly
// J3D images are aligned to 1 byte
- gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1);
+ //gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1);
// Workaround for issue 400: Enable separate specular by default
// gl.glLightModeli(GL2.GL_LIGHT_MODEL_COLOR_CONTROL,
@@ -6602,6 +6458,152 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
}
+ //Offscreen rendering methods below -----------------------
+ static boolean isOffscreenLayerSurfaceEnabled(Canvas3D cv)
+ {
+ if (cv.drawable == null || cv.offScreen)
+ return false;
+
+ JoglDrawable joglDrawble = (JoglDrawable) cv.drawable;
+ JAWTWindow jawtwindow = (JAWTWindow) joglDrawble.getNativeWindow();
+ if (jawtwindow == null)
+ return false;
+
+ return jawtwindow.isOffscreenLayerSurfaceEnabled();
+ }
+
+ static boolean hasFBObjectSizeChanged(JoglDrawable jdraw, int width, int height)
+ {
+ if (!(jdraw.getGLDrawable() instanceof GLFBODrawable))
+ return false;
+
+ FBObject fboBack = ((GLFBODrawable) jdraw.getGLDrawable()).getFBObject(GL.GL_BACK);
+ if (fboBack == null)
+ return false;
+
+ return (width != fboBack.getWidth() || height != fboBack.getHeight());
+ }
+
+ // Mac/JRE 7; called from Renderer when resizing is detected
+ // Implementation follows the approach in
+ // jogamp.opengl.GLDrawableHelper.resizeOffscreenDrawable(..)
+ @Override
+ void resizeOffscreenLayer(Canvas3D cv, int cvWidth, int cvHeight)
+ {
+ if (!isOffscreenLayerSurfaceEnabled(cv))
+ return;
+
+ JoglDrawable joglDrawable = (JoglDrawable) cv.drawable;
+ if (!hasFBObjectSizeChanged(joglDrawable, cvWidth, cvHeight))
+ return;
+
+ int newWidth = Math.max(1, cvWidth);
+ int newHeight = Math.max(1, cvHeight);
+
+ GLDrawable glDrawble = joglDrawable.getGLDrawable();
+ GLContext glContext = context(cv.ctx);
+
+ // Assuming glContext != null
+
+ final NativeSurface surface = glDrawble.getNativeSurface();
+ final ProxySurface proxySurface = (surface instanceof ProxySurface) ? (ProxySurface) surface : null;
+
+ final int lockRes = surface.lockSurface();
+
+ try
+ {
+ // propagate new size - seems not relevant here
+ if (proxySurface != null)
+ {
+ final UpstreamSurfaceHook ush = proxySurface.getUpstreamSurfaceHook();
+ if (ush instanceof UpstreamSurfaceHook.MutableSize)
+ {
+ ((UpstreamSurfaceHook.MutableSize) ush).setSurfaceSize(newWidth, newHeight);
+ }
+ }
+ /*
+ else if(DEBUG) {
+ // we have to assume surface contains the new size already, hence size check @ bottom
+ System.err.println("GLDrawableHelper.resizeOffscreenDrawable: Drawable's offscreen surface n.a. ProxySurface, but "
+ +ns.getClass().getName()+": "+ns); }
+ */
+
+ GL2ES2 gl = glContext.getGL().getGL2ES2();
+
+ // FBO : should be the default case on Mac OS X
+ if (glDrawble instanceof GLFBODrawable)
+ {
+
+ // Resize GLFBODrawable
+ // TODO msaa gets lost
+ // ((GLFBODrawable)glDrawble).resetSize(gl);
+
+ // Alternative: resize GL_BACK FBObject directly,
+ // if multisampled the FBO sink (GL_FRONT) will be resized
+ // before the swap is executed
+ int numSamples = ((GLFBODrawable) glDrawble).getChosenGLCapabilities().getNumSamples();
+ FBObject fboObjectBack = ((GLFBODrawable) glDrawble).getFBObject(GL.GL_BACK);
+ fboObjectBack.reset(gl, newWidth, newHeight, numSamples/* , false */); // false = don't reset
+ // SamplingSinkFBO
+ // immediately
+ fboObjectBack.bind(gl);
+
+ // If double buffered without antialiasing the GL_FRONT FBObject
+ // will be resized by glDrawble after the next swap-call
+ }
+ // pbuffer - not tested because Mac OS X 10.7+ supports FBO
+ else
+ {
+ // Create new GLDrawable (pbuffer) and update the coresponding
+ // GLContext
+
+ final GLContext currentContext = GLContext.getCurrent();
+ final GLDrawableFactory factory = glDrawble.getFactory();
+
+ // Ensure to sync GL command stream
+ if (currentContext != glContext)
+ {
+ glContext.makeCurrent();
+ }
+ gl.glFinish();
+ glContext.release();
+
+ if (proxySurface != null)
+ {
+ proxySurface.enableUpstreamSurfaceHookLifecycle(false);
+ }
+
+ try
+ {
+ glDrawble.setRealized(false);
+ // New GLDrawable
+ glDrawble = factory.createGLDrawable(surface);
+ glDrawble.setRealized(true);
+
+ joglDrawable.setGLDrawable(glDrawble);
+ }
+ finally
+ {
+ if (proxySurface != null)
+ {
+ proxySurface.enableUpstreamSurfaceHookLifecycle(true);
+ }
+ }
+
+ glContext.setGLDrawable(glDrawble, true); // re-association
+
+ // make current last current context
+ if (currentContext != null)
+ {
+ currentContext.makeCurrent();
+ }
+ }
+ }
+ finally
+ {
+ surface.unlockSurface();
+ }
+ }
// This is the native for creating an offscreen buffer
@Override
Drawable createOffScreenBuffer(Canvas3D cv, Context ctx, int width, int height)
@@ -6719,8 +6721,8 @@ class Jogl2es2Pipeline extends Jogl2es2DEPPipeline
}
// else pbuffer
- gl.glPixelStorei(GL2.GL_PACK_ROW_LENGTH, width);
- gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, 1);
+ //gl.glPixelStorei(GL2.GL_PACK_ROW_LENGTH, width);
+ //gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, 1);
int type = 0;