aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Göthel <[email protected]>2024-02-13 22:19:05 +0100
committerSven Göthel <[email protected]>2024-02-13 22:19:05 +0100
commit101ec44f9d6df7faa0695accccfd43f51e48e7a4 (patch)
tree77a0b4dcc3fe74c91189fffe4c41a5c81e3ce2d7
parent65b3a230a53252f7c2cacd968b7afee6d43e7327 (diff)
Bug 1501: Graph RenderState add debug-bits, i.e. DEBUG_LINESTRIP used in VBORegionSPES2 to just render lines instead of the filled area -> Used in UIShapeDemo02a
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/UIShapeDemo02a.java26
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/ui/testshapes/Glyph03FreeMonoRegular_M.java4
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java15
-rw-r--r--src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java3
4 files changed, 40 insertions, 8 deletions
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/UIShapeDemo02a.java b/src/demos/com/jogamp/opengl/demos/graph/ui/UIShapeDemo02a.java
index 69bd9b000..7d2369217 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/UIShapeDemo02a.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/UIShapeDemo02a.java
@@ -31,11 +31,16 @@ import java.io.IOException;
import com.jogamp.common.util.InterruptSource;
import com.jogamp.graph.curve.Region;
+import com.jogamp.graph.curve.opengl.GLRegion;
+import com.jogamp.graph.curve.opengl.RegionRenderer;
+import com.jogamp.graph.curve.opengl.RenderState;
import com.jogamp.graph.ui.GraphShape;
import com.jogamp.graph.ui.Scene;
+import com.jogamp.graph.ui.Shape;
import com.jogamp.graph.ui.shapes.Rectangle;
import com.jogamp.math.Recti;
import com.jogamp.math.Vec3f;
+import com.jogamp.math.Vec4f;
import com.jogamp.math.geom.AABBox;
import com.jogamp.math.util.PMVMatrix4f;
import com.jogamp.newt.event.KeyAdapter;
@@ -44,7 +49,10 @@ import com.jogamp.newt.event.WindowAdapter;
import com.jogamp.newt.event.WindowEvent;
import com.jogamp.newt.opengl.GLWindow;
import com.jogamp.opengl.GL;
+import com.jogamp.opengl.GL2ES2;
+import com.jogamp.opengl.GLAutoDrawable;
import com.jogamp.opengl.GLCapabilities;
+import com.jogamp.opengl.GLEventAdapter;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.demos.graph.ui.testshapes.Glyph03FreeMonoRegular_M;
import com.jogamp.opengl.demos.util.CommandlineOptions;
@@ -112,11 +120,23 @@ public class UIShapeDemo02a {
final Rectangle rectShape;
if( use_glyph ) {
testShape = new Glyph03FreeMonoRegular_M(options.renderModes);
+ testShape.setColor(0.8f, 0.8f, 0.8f, 1);
testShape.scale(1000, 1000, 1);
rectShape = null;
+ testShape.onDraw((final Shape s, final GL2ES2 gl, final RegionRenderer renderer) -> {
+ final GLRegion region = ((GraphShape)s).getRegion();
+ renderer.getRenderState().setDebugBits(RenderState.DEBUG_LINESTRIP);
+ renderer.setColorStatic(new Vec4f(0, 0, 1, 1));
+ region.draw(gl, renderer);
+ renderer.getRenderState().clearDebugBits(RenderState.DEBUG_LINESTRIP);
+ return false;
+ });
+ scene.addShape(testShape);
} else {
testShape = null;
rectShape = new Rectangle(options.renderModes, 1, 1, 0);
+ rectShape.setColor(0, 0, 1, 1);
+ scene.addShape(rectShape);
}
scene.attachInputListenerTo(window);
@@ -141,9 +161,6 @@ public class UIShapeDemo02a {
scene.waitUntilDisplayed();
final AABBox sbox = scene.getBounds();
System.err.println("Scene "+sbox);
- if( null != testShape ) {
- scene.addShape(testShape);;
- }
if( null != rectShape ) {
final float sw = sbox.getWidth();
final float sh = sbox.getHeight();
@@ -156,8 +173,6 @@ public class UIShapeDemo02a {
w2 = w-14*delta;
}
rectShape.setDimension(w2, h, lineWidth);
- rectShape.setColor(0, 0, 1, 1);
- scene.addShape(rectShape);
System.err.printf("R_0: w %30.30f x %30.30f%n", w2, h);
Thread.sleep(500);
if( false ) {
@@ -172,6 +187,7 @@ public class UIShapeDemo02a {
}
}
}
+ scene.screenshot(true, scene.nextScreenshotFile(null, UIShapeDemo02a.class.getSimpleName(), options.renderModes, reqCaps, null));
}
private static final class MyMatrixSetup implements Scene.PMVMatrixSetup {
diff --git a/src/demos/com/jogamp/opengl/demos/graph/ui/testshapes/Glyph03FreeMonoRegular_M.java b/src/demos/com/jogamp/opengl/demos/graph/ui/testshapes/Glyph03FreeMonoRegular_M.java
index deb53380b..665b3e82b 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/ui/testshapes/Glyph03FreeMonoRegular_M.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/ui/testshapes/Glyph03FreeMonoRegular_M.java
@@ -48,7 +48,7 @@ public class Glyph03FreeMonoRegular_M extends GraphShape {
protected void addShapeToRegion(final GLProfile glp, final GL2ES2 gl) {
final OutlineShape shape = new OutlineShape();
- if( false ) {
+ if( true ) {
// Start TTF Shape for Glyph 48
// GlyphShape<48>: offset 0 of 45/45 points
// pM[044] P[483/522, on true, end true]
@@ -622,7 +622,7 @@ public class Glyph03FreeMonoRegular_M extends GraphShape {
shape.closeLastOutline(false);
} else {
final boolean with_left_leg = true; // ERROR
- final boolean with_right_leg = false; // OK
+ final boolean with_right_leg = true; // OK
// Start TTF Shape for Glyph 48
// GlyphShape<48>: offset 0 of 45/45 points
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java
index 4913d8174..c6591d5c8 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java
@@ -88,6 +88,8 @@ public class RenderState {
*/
public static final int BITHINT_GLOBAL_DEPTH_TEST_ENABLED = 1 << 1 ;
+ public static final int DEBUG_LINESTRIP = 1 << 0 ;
+
public static final RenderState getRenderState(final GL2ES2 gl) {
return (RenderState) gl.getContext().getAttachedObject(thisKey);
}
@@ -106,6 +108,7 @@ public class RenderState {
private final Frustum clipFrustum;
private boolean useClipFrustum;
private int hintBits;
+ private int debugBits;
private ShaderProgram sp;
private static synchronized int getNextID() {
@@ -210,6 +213,7 @@ public class RenderState {
this.useClipFrustum = false;
this.hintBits = 0;
+ this.debugBits = 0;
this.sp = null;
}
@@ -307,6 +311,17 @@ public class RenderState {
hintBits &= ~mask;
}
+ public final int getDebugBits() { return this.debugBits; }
+ public final boolean debugBitsSet(final int mask) {
+ return mask == ( debugBits & mask );
+ }
+ public final void setDebugBits(final int mask) {
+ debugBits |= mask;
+ }
+ public final void clearDebugBits(final int mask) {
+ debugBits &= ~mask;
+ }
+
/**
*
* @param gl
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
index 7fcd61292..eec22973c 100644
--- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
+++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java
@@ -205,9 +205,10 @@ public final class VBORegionSPES2 extends GLRegion {
gl.glDrawElements(GL.GL_TRIANGLES, indicesBuffer.getElemCount() * indicesBuffer.getCompsPerElem(), glIdxType(), 0);
// gl.glDrawElements(GL.GL_LINE_STRIP, indicesBuffer.getElemCount() * indicesBuffer.getCompsPerElem(), glIdxType(), 0);
tex.disable(gl); // nop on core
+ } else if( rs.debugBitsSet(RenderState.DEBUG_LINESTRIP) ) {
+ gl.glDrawElements(GL.GL_LINE_STRIP, indicesBuffer.getElemCount() * indicesBuffer.getCompsPerElem(), glIdxType(), 0);
} else {
gl.glDrawElements(GL.GL_TRIANGLES, indicesBuffer.getElemCount() * indicesBuffer.getCompsPerElem(), glIdxType(), 0);
- // gl.glDrawElements(GL.GL_LINE_STRIP, indicesBuffer.getElemCount() * indicesBuffer.getCompsPerElem(), glIdxType(), 0);
}
indicesBuffer.bindBuffer(gl, false);