aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-08-01 17:46:27 +0200
committerSven Gothel <[email protected]>2023-08-01 17:46:27 +0200
commit285459363469e60df9db51a4c0485ec21d4e04ae (patch)
tree6c39bd4c3db123a43907e9722a208aff82d579cb
parenta973324a75b55b722caa755a7a573be849d997e4 (diff)
Graph RegionRendered.init(..): Disable renderer (and shader programs etc) to avoid side-effects. Usually called @ GLEventListener.init(..)
-rw-r--r--src/demos/com/jogamp/opengl/demos/graph/TextRendererGLELBase.java7
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java3
3 files changed, 7 insertions, 11 deletions
diff --git a/src/demos/com/jogamp/opengl/demos/graph/TextRendererGLELBase.java b/src/demos/com/jogamp/opengl/demos/graph/TextRendererGLELBase.java
index 22f2d096a..3e6cec83e 100644
--- a/src/demos/com/jogamp/opengl/demos/graph/TextRendererGLELBase.java
+++ b/src/demos/com/jogamp/opengl/demos/graph/TextRendererGLELBase.java
@@ -131,13 +131,12 @@ public abstract class TextRendererGLELBase implements GLEventListener {
@Override
public void init(final GLAutoDrawable drawable) {
exclusivePMVMatrix = null == sharedPMVMatrix;
- this.renderer = RegionRenderer.create(sharedPMVMatrix, enableCallback, disableCallback);
- this.getRenderer().getRenderState().setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED);
+ renderer = RegionRenderer.create(sharedPMVMatrix, enableCallback, disableCallback);
+ renderer.getRenderState().setHintMask(RenderState.BITHINT_GLOBAL_DEPTH_TEST_ENABLED);
this.textRenderUtil = new TextRegionUtil(renderModes);
final GL2ES2 gl = drawable.getGL().getGL2ES2();
renderer.init(gl);
- this.getRenderer().getRenderState().setColorStatic(staticRGBAColor[0], staticRGBAColor[1], staticRGBAColor[2], staticRGBAColor[3]);
- renderer.enable(gl, false);
+ renderer.getRenderState().setColorStatic(staticRGBAColor[0], staticRGBAColor[1], staticRGBAColor[2], staticRGBAColor[3]);
final Object upObj = drawable.getUpstreamWidget();
if( upObj instanceof Window ) {
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
index 147edaee9..6e5cd1487 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
@@ -238,8 +238,8 @@ public final class RegionRenderer {
/**
* Initialize shader and bindings for GPU based rendering bound to the given GL object's GLContext
* if not initialized yet.
- * <p>Leaves the renderer enabled, ie ShaderState.</p>
- * <p>Shall be called by a {@code draw()} method, e.g. {@link RegionRenderer#draw(GL2ES2, Region, int)}</p>
+ * <p>Disables the renderer via {@link #enable(GL2ES2, boolean)} to remove any side-effects, ie ShaderState incl. shader program.</p>
+ * <p>Shall be called once before at initialization before a {@code draw()} method, e.g. {@link RegionRenderer#draw(GL2ES2, Region, int)}</p>
*
* @param gl referencing the current GLContext to which the ShaderState is bound to
* @throws GLException if initialization failed
@@ -265,10 +265,8 @@ public final class RegionRenderer {
rs.attachTo(gl);
- if( null != enableCallback ) {
- enableCallback.run(gl, this);
- }
initialized = true;
+ enable(gl, false);
}
/** Deletes all {@link ShaderProgram}s and nullifies its references including {@link RenderState#destroy(GL2ES2)}. */
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java b/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java
index f7a7e4c09..f66d58d3c 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java
@@ -132,8 +132,7 @@ public abstract class TextRendererGLELBase implements GLEventListener {
this.textRenderUtil = new TextRegionUtil(renderModes);
final GL2ES2 gl = drawable.getGL().getGL2ES2();
renderer.init(gl);
- this.getRenderer().getRenderState().setColorStatic(staticRGBAColor[0], staticRGBAColor[1], staticRGBAColor[2], staticRGBAColor[3]);
- renderer.enable(gl, false);
+ renderer.getRenderState().setColorStatic(staticRGBAColor[0], staticRGBAColor[1], staticRGBAColor[2], staticRGBAColor[3]);
final Object upObj = drawable.getUpstreamWidget();
if( upObj instanceof Window ) {