summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-03-13 21:38:29 +0100
committerSven Gothel <[email protected]>2023-03-13 21:38:29 +0100
commit67a723477ecd818fbc5859fe20ee536a3b4efae5 (patch)
treeca9ad9fa7b45c1fb99ce153667af64d13f73bc0c /src/jogl/classes/com
parent6feb3738231210b03edefa7a60cf11e644fb7a5d (diff)
GLRegion + RegionRenderer: Add clearShader(..) to delete all ShaderPrograms and is references.
Diffstat (limited to 'src/jogl/classes/com')
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java8
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java23
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java3
3 files changed, 27 insertions, 7 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java
index 57f9a69d8..a86060fab 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java
@@ -39,6 +39,7 @@ import jogamp.graph.curve.opengl.VBORegion2PVBAAES2;
import jogamp.graph.curve.opengl.VBORegionSPES2;
import com.jogamp.opengl.util.PMVMatrix;
+import com.jogamp.opengl.util.glsl.ShaderProgram;
import com.jogamp.opengl.util.texture.TextureSequence;
import com.jogamp.graph.curve.Region;
import com.jogamp.graph.font.Font;
@@ -178,6 +179,7 @@ public abstract class GLRegion extends Region {
*/
protected abstract void updateImpl(final GL2ES2 gl);
+ protected abstract void clearShaderImpl(final GL2ES2 gl);
protected abstract void destroyImpl(final GL2ES2 gl);
protected abstract void clearImpl(final GL2ES2 gl);
@@ -210,10 +212,16 @@ public abstract class GLRegion extends Region {
return this;
}
+ /** Deletes all {@link ShaderProgram}s and nullifies its references. */
+ public final void clearShader(final GL2ES2 gl) {
+ clearShaderImpl(gl);
+ }
+
/**
* Delete and clear the associated OGL objects.
*/
public final void destroy(final GL2ES2 gl) {
+ clearShaderImpl(gl);
clear(gl);
destroyImpl(gl);
}
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 6f419704b..6b661fd7b 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
@@ -223,11 +223,9 @@ public class RegionRenderer {
initialized = true;
}
- public final void destroy(final GL2ES2 gl) {
+ /** Deletes all {@link ShaderProgram}s and nullifies its references. */
+ public final void clearShader(final GL2ES2 gl) {
if(!initialized){
- if(DEBUG_INSTANCE) {
- System.err.println("TextRenderer: Not initialized!");
- }
return;
}
for(final Iterator<IntObjectHashMap.Entry> i = shaderPrograms.iterator(); i.hasNext(); ) {
@@ -236,6 +234,16 @@ public class RegionRenderer {
}
shaderPrograms.clear();
rs.destroy(gl);
+ }
+
+ public final void destroy(final GL2ES2 gl) {
+ if(!initialized){
+ if(DEBUG_INSTANCE) {
+ System.err.println("TextRenderer: Not initialized!");
+ }
+ return;
+ }
+ clearShader(gl);
initialized = false;
}
@@ -445,7 +453,7 @@ public class RegionRenderer {
ShaderProgram sp = (ShaderProgram) shaderPrograms.get( shaderKey );
if( null != sp ) {
final boolean spChanged = getRenderState().setShaderProgram(gl, sp);
- if(DEBUG) {
+ if( DEBUG ) {
if( spChanged ) {
System.err.printf("RegionRendererImpl01.useShaderProgram.X1: GOT renderModes %s, sel1 %s, key 0x%X -> sp %d / %d (changed)%n", Region.getRenderModeString(renderModes), sel1, shaderKey, sp.program(), sp.id());
} else {
@@ -570,9 +578,10 @@ public class RegionRenderer {
getRenderState().setShaderProgram(gl, sp);
shaderPrograms.put(shaderKey, sp);
- if(DEBUG) {
- System.err.printf("RegionRendererImpl01.useShaderProgram.X1: PUT renderModes %s, sel1 %s, key 0x%X -> sp %d / %d (changed)%n",
+ if( DEBUG ) {
+ System.err.printf("RegionRendererImpl01.useShaderProgram.X1: PUT renderModes %s, sel1 %s, key 0x%X -> sp %d / %d (changed, new)%n",
Region.getRenderModeString(renderModes), sel1, shaderKey, sp.program(), sp.id());
+ // rsFp.dumpShaderSource(System.err);
}
return true;
}
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 2b243e6cf..407f40b68 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java
@@ -325,6 +325,9 @@ public class RenderState {
hintBitfield &= ~mask;
}
+ /**
+ * Issues {@link ShaderProgram#destroy(GL2ES2)} and nullifies reference.
+ */
public void destroy(final GL2ES2 gl) {
if( null != sp ) {
sp.destroy(gl);