From e16e974a3e2b38c65355838eeb010954354097d2 Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Fri, 14 Mar 2014 08:13:42 +0100
Subject: Bug 801: Add Frustum support to Region; Misc ..

Region: Add Frustum support, to drop 'out of sight' shapes

RenderState: Add hints, e.g. BITHINT_BLENDING_ENABLED,
             allowing user code to toggle background color etc

Demos: Incomplete - WIP
  - Reuse mapped object to window coords computed at reshape
  - TODO: Use minimal Scenegraph for Graph-UI ..
---
 .../graph/curve/opengl/VBORegion2PMSAAES2.java     | 20 ++++++++++++++++--
 .../graph/curve/opengl/VBORegion2PVBAAES2.java     | 24 +++++++++++++++++++---
 .../jogamp/graph/curve/opengl/VBORegionSPES2.java  |  8 +++++++-
 .../jogamp/graph/font/typecast/TypecastFont.java   |  2 +-
 4 files changed, 47 insertions(+), 7 deletions(-)

(limited to 'src/jogl/classes/jogamp/graph')

diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
index 176b39c25..4aeceea7e 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java
@@ -111,7 +111,7 @@ public class VBORegion2PMSAAES2  extends GLRegion {
     }
 
     @Override
-    protected void update(final GL2ES2 gl, final RegionRenderer renderer) {
+    protected void updateImpl(final GL2ES2 gl, final RegionRenderer renderer) {
         if(null == indicesFbo) {
             final ShaderState st = renderer.getShaderState();
 
@@ -137,7 +137,7 @@ public class VBORegion2PMSAAES2  extends GLRegion {
             st.ownAttribute(texCoordTxtAttr, true);
 
             if(Region.DEBUG_INSTANCE) {
-                System.err.println("VBORegion2PES2 Create: " + this);
+                System.err.println("VBORegion2PMSAAES2 Create: " + this);
             }
         }
         // seal buffers
@@ -178,6 +178,18 @@ public class VBORegion2PMSAAES2  extends GLRegion {
 
     @Override
     protected void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int[/*1*/] sampleCount) {
+        if( 0 >= indicesTxtBuffer.getElementCount() ) {
+            if(DEBUG_INSTANCE) {
+                System.err.printf("VBORegion2PMSAAES2.drawImpl: Empty%n");
+            }
+            return; // empty!
+        }
+        if( Float.isInfinite(box.getWidth()) || Float.isInfinite(box.getHeight()) ) {
+            if(DEBUG_INSTANCE) {
+                System.err.printf("VBORegion2PMSAAES2.drawImpl: Inf %s%n", box);
+            }
+            return; // inf
+        }
         final int width = renderer.getWidth();
         final int height = renderer.getHeight();
         if(width <=0 || height <= 0 || null==sampleCount || sampleCount[0] <= 0){
@@ -209,6 +221,10 @@ public class VBORegion2PMSAAES2  extends GLRegion {
                             diffWidth, diffHeight, sampleCount[0]);
                 }
             }
+            if( 0 >= targetFboWidth || 0 >= targetFboHeight ) {
+                // Nothing ..
+                return;
+            }
             final int deltaFboWidth = Math.abs(targetFboWidth-fboWidth);
             final int deltaFboHeight = Math.abs(targetFboHeight-fboHeight);
             final int maxDeltaFbo, maxLengthFbo;
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
index 3f3709d6e..a760dcd33 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java
@@ -112,7 +112,7 @@ public class VBORegion2PVBAAES2  extends GLRegion {
     }
 
     @Override
-    protected void update(final GL2ES2 gl, final RegionRenderer renderer) {
+    protected void updateImpl(final GL2ES2 gl, final RegionRenderer renderer) {
         if(null == indicesFbo) {
             final ShaderState st = renderer.getShaderState();
 
@@ -138,7 +138,7 @@ public class VBORegion2PVBAAES2  extends GLRegion {
             st.ownAttribute(texCoordTxtAttr, true);
 
             if(Region.DEBUG_INSTANCE) {
-                System.err.println("VBORegion2PES2 Create: " + this);
+                System.err.println("VBORegion2PVBAAES2 Create: " + this);
             }
         }
         // seal buffers
@@ -179,6 +179,18 @@ public class VBORegion2PVBAAES2  extends GLRegion {
 
     @Override
     protected void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int[/*1*/] sampleCount) {
+        if( 0 >= indicesTxtBuffer.getElementCount() ) {
+            if(DEBUG_INSTANCE) {
+                System.err.printf("VBORegion2PVBAAES2.drawImpl: Empty%n");
+            }
+            return; // empty!
+        }
+        if( Float.isInfinite(box.getWidth()) || Float.isInfinite(box.getHeight()) ) {
+            if(DEBUG_INSTANCE) {
+                System.err.printf("VBORegion2PVBAAES2.drawImpl: Inf %s%n", box);
+            }
+            return; // inf
+        }
         final int width = renderer.getWidth();
         final int height = renderer.getHeight();
         if(width <=0 || height <= 0 || null==sampleCount || sampleCount[0] <= 0){
@@ -207,13 +219,19 @@ public class VBORegion2PVBAAES2  extends GLRegion {
                 targetFboWidth = (int)Math.ceil(renderFboWidth);
                 targetFboHeight = (int)Math.ceil(renderFboHeight);
                 if( DEBUG_FBO_2 ) {
-                    System.err.printf("XXX.MinMax1 view[%d, %d] -> win[%.3f, %.3f]: FBO f[%.3f, %.3f], i[%d x %d], d[%.3f, %.3f], msaa %d%n",
+                    System.err.printf("XXX.MinMax obj %s%n", box.toString());
+                    System.err.printf("XXX.MinMax win %s%n", drawWinBox.toString());
+                    System.err.printf("XXX.MinMax view[%d, %d] -> win[%.3f, %.3f]: FBO f[%.3f, %.3f], i[%d x %d], d[%.3f, %.3f], msaa %d%n",
                             drawView[2], drawView[3],
                             winWidth, winHeight,
                             renderFboWidth, renderFboHeight, targetFboWidth, targetFboHeight,
                             diffWidth, diffHeight, sampleCount[0]);
                 }
             }
+            if( 0 >= targetFboWidth || 0 >= targetFboHeight ) {
+                // Nothing ..
+                return;
+            }
             final int deltaFboWidth = Math.abs(targetFboWidth-fboWidth);
             final int deltaFboHeight = Math.abs(targetFboHeight-fboHeight);
             final int maxDeltaFbo, maxLengthFbo;
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
index bdf824b6a..e45e623ba 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
@@ -81,7 +81,7 @@ public class VBORegionSPES2 extends GLRegion {
     }
 
     @Override
-    protected void update(final GL2ES2 gl, final RegionRenderer renderer) {
+    protected void updateImpl(final GL2ES2 gl, final RegionRenderer renderer) {
         if( !buffersAttached ) {
             final ShaderState st = renderer.getShaderState();
             st.ownAttribute(verticeAttr, true);
@@ -104,6 +104,12 @@ public class VBORegionSPES2 extends GLRegion {
 
     @Override
     protected void drawImpl(final GL2ES2 gl, final RegionRenderer renderer, final int[/*1*/] sampleCount) {
+        if( 0 >= indicesBuffer.getElementCount() ) {
+            if(DEBUG_INSTANCE) {
+                System.err.printf("VBORegionSPES2.drawImpl: Empty%n");
+            }
+            return; // empty!
+        }
         verticeAttr.enableBuffer(gl, true);
         texCoordAttr.enableBuffer(gl, true);
         indicesBuffer.bindBuffer(gl, true); // keeps VBO binding
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
index 3cd9ab7c1..a75c5e02c 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
@@ -224,7 +224,7 @@ class TypecastFont implements Font {
 
     @Override
     public final float getPixelSize(float fontSize /* points per inch */, float resolution) {
-        return fontSize * resolution / ( 72 /* points per inch */ );
+        return fontSize * resolution / ( 72f /* points per inch */ );
     }
 
     @Override
-- 
cgit v1.2.3