aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-03-15 03:26:30 +0100
committerSven Gothel <[email protected]>2023-03-15 03:26:30 +0100
commitc01a4ad712cfa2d1f8746daf161d9052c8acfccd (patch)
tree4f8a033905d0ffc63329f44726a9ea88c0b2977f /src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java
parent00dbacc5af3531af50e77a02d534dc11e08de10f (diff)
Fix ShaderProgram ownership bug, introduced in commit 67a723477ecd818fbc5859fe20ee536a3b4efae5 (reverting and clarifying)
All Graph ShaderPrograms used are owned by RegionRenderer, not RenderState nor [GL]Region*, hence [GL]Region* shall only nullify the resources but not destroy the shader currently in use. One RegionRenderer maybe used for multuple Regions.
Diffstat (limited to 'src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java')
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java28
1 files changed, 17 insertions, 11 deletions
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 407f40b68..3f7e3f81d 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java
@@ -199,14 +199,20 @@ public class RenderState {
}
public final int id() { return id; }
+
+ /** Return the current {@link ShaderProgram} */
public final ShaderProgram getShaderProgram() { return sp; }
+
+ /** Return whether the current {@link ShaderProgram} is {@link ShaderProgram#inUse() in use}. */
public final boolean isShaderProgramInUse() { return null != sp ? sp.inUse() : false; }
/**
- * Set a {@link ShaderProgram} and enable it. If the given {@link ShaderProgram} is new,
- * method returns true, otherwise false.
+ * Sets the current {@link ShaderProgram} and enables it.
+ *
+ * If the given {@link ShaderProgram} is not {@link #getShaderProgram() the current}, method returns true, otherwise false.
+ *
* @param gl
- * @param spNext
+ * @param spNext the next current {@link ShaderProgram} to be set and enabled
* @return true if a new shader program is being used and hence external uniform-data and -location,
* as well as the attribute-location must be updated, otherwise false.
*/
@@ -263,7 +269,8 @@ public class RenderState {
if( updateLocation || 0 > data.getLocation() ) {
final boolean ok = 0 <= data.setLocation(gl, sp.program());
if( throwOnError && !ok ) {
- throw new GLException("Could not locate "+data);
+ sp.dumpSource(System.err);
+ throw new GLException("Could not locate "+data.getName()+" in "+sp+", "+data);
}
return ok;
} else {
@@ -285,7 +292,8 @@ public class RenderState {
if( updateLocation ) {
updateData = 0 <= data.setLocation(gl, sp.program());
if( throwOnError && !updateData ) {
- throw new GLException("Could not locate "+data);
+ sp.dumpSource(System.err);
+ throw new GLException("Could not locate "+data.getName()+" in "+sp+", "+data);
}
}
if( updateData ){
@@ -306,7 +314,8 @@ public class RenderState {
if( updateLocation || 0 > data.getLocation() ) {
final boolean ok = 0 <= data.setLocation(gl, sp.program());
if( throwOnError && !ok ) {
- throw new GLException("Could not locate "+data);
+ sp.dumpSource(System.err);
+ throw new GLException("Could not locate "+data.getName()+" in "+sp+", "+data);
}
return ok;
} else {
@@ -326,13 +335,10 @@ public class RenderState {
}
/**
- * Issues {@link ShaderProgram#destroy(GL2ES2)} and nullifies reference.
+ * Only nullifies {@link ShaderProgram} reference owned by {@link RegionRenderer}.
*/
public void destroy(final GL2ES2 gl) {
- if( null != sp ) {
- sp.destroy(gl);
- sp = null;
- }
+ sp = null; // owned by RegionRenderer
}
public final RenderState attachTo(final GL2ES2 gl) {