From fbbdf8b82e159078274475c5013f2f1147b0a4d8 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 22 Mar 2023 11:05:19 +0100 Subject: GraphUI Scene: Add optional frustum culling (default: disabled) --- .../classes/com/jogamp/graph/ui/gl/Scene.java | 36 ++++++++++++++-------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/graphui/classes/com/jogamp/graph/ui/gl/Scene.java b/src/graphui/classes/com/jogamp/graph/ui/gl/Scene.java index 39039d83d..5e7151076 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/gl/Scene.java +++ b/src/graphui/classes/com/jogamp/graph/ui/gl/Scene.java @@ -96,6 +96,7 @@ public final class Scene implements GLEventListener { private static final boolean DEBUG = false; private final ArrayList shapes = new ArrayList(); + private boolean doFrustumCulling = false; private float[] clearColor = null; private int clearMask; @@ -164,6 +165,12 @@ public final class Scene implements GLEventListener { /** Returns the {@link GL#glClear(int) glClear(..)} mask, see {@link #setClearParams(float[], int)}. */ public final int getClearMask() { return clearMask; } + /** Enable or disable {@link PMVMatrix#glGetFrustum()} culling per {@link Shape}. Default is disabled. */ + public final void setFrustumCullingEnabled(final boolean v) { doFrustumCulling = v; } + + /** Return whether {@link #setFrustumCullingEnabled(boolean) frustum culling} is enabled. */ + public final boolean isFrustumCullingEnabled() { return doFrustumCulling; } + public void attachInputListenerTo(final GLWindow window) { if(null == sbcMouseListener) { sbcMouseListener = new SBCMouseListener(); @@ -289,7 +296,7 @@ public final class Scene implements GLEventListener { private static final int[] sampleCountGLSelect = { -1 }; - private void display(final GLAutoDrawable drawable, final Object[] shapesS, final boolean glSelect) { + private void display(final GLAutoDrawable drawable, final Object[] shapes, final boolean glSelect) { final GL2ES2 gl = drawable.getGL().getGL2ES2(); final int[] sampleCount0; @@ -315,22 +322,25 @@ public final class Scene implements GLEventListener { } //final int shapeCount = shapes.size(); - final int shapeCount = shapesS.length; + final int shapeCount = shapes.length; for(int i=0; i