aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/com/sun/opengl/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/classes/com/sun/opengl/util')
-rwxr-xr-xsrc/classes/com/sun/opengl/util/awt/TextRenderer.java6
-rw-r--r--src/classes/com/sun/opengl/util/glsl/ShaderCode.java14
-rw-r--r--src/classes/com/sun/opengl/util/glsl/ShaderProgram.java21
-rw-r--r--src/classes/com/sun/opengl/util/glsl/ShaderState.java21
-rwxr-xr-xsrc/classes/com/sun/opengl/util/glsl/fixed/FixedFuncHook.java4
-rwxr-xr-xsrc/classes/com/sun/opengl/util/texture/Texture.java13
-rwxr-xr-xsrc/classes/com/sun/opengl/util/texture/TextureData.java7
7 files changed, 77 insertions, 9 deletions
diff --git a/src/classes/com/sun/opengl/util/awt/TextRenderer.java b/src/classes/com/sun/opengl/util/awt/TextRenderer.java
index 4e80dfaa4..b7616d879 100755
--- a/src/classes/com/sun/opengl/util/awt/TextRenderer.java
+++ b/src/classes/com/sun/opengl/util/awt/TextRenderer.java
@@ -1882,6 +1882,12 @@ public class TextRenderer {
}
}
+ public void dispose(GLAutoDrawable drawable) {
+ glu.destroy();
+ glu=null;
+ frame=null;
+ }
+
// Unused methods
public void init(GLAutoDrawable drawable) {
}
diff --git a/src/classes/com/sun/opengl/util/glsl/ShaderCode.java b/src/classes/com/sun/opengl/util/glsl/ShaderCode.java
index 288ef760b..f5ed88ff0 100644
--- a/src/classes/com/sun/opengl/util/glsl/ShaderCode.java
+++ b/src/classes/com/sun/opengl/util/glsl/ShaderCode.java
@@ -244,11 +244,21 @@ public class ShaderCode {
return valid;
}
- public void release(GL2ES2 gl) {
+ public void destroy(GL2ES2 gl) {
if(isValid()) {
- gl.glDeleteShader(shader());
+ if(null!=gl) {
+ gl.glDeleteShader(shader());
+ }
valid=false;
}
+ if(null!=shaderBinary) {
+ shaderBinary.clear();
+ shaderBinary=null;
+ }
+ shaderSource=null;
+ shaderBinaryFormat=-1;
+ shaderType=-1;
+ id=null;
}
public boolean equals(Object obj) {
diff --git a/src/classes/com/sun/opengl/util/glsl/ShaderProgram.java b/src/classes/com/sun/opengl/util/glsl/ShaderProgram.java
index 066244fa6..7973c471f 100644
--- a/src/classes/com/sun/opengl/util/glsl/ShaderProgram.java
+++ b/src/classes/com/sun/opengl/util/glsl/ShaderProgram.java
@@ -37,14 +37,29 @@ public class ShaderProgram {
public Integer key() { return id; }
/**
- * @see #glReleaseAllVertexAttributes
+ * Detaches all shader codes and deletes the program.
+ * Destroys the shader codes as well.
+ * Calls release(gl, true)
+ *
+ * @see #release(GL2ES2, boolean)
+ */
+ public synchronized void destroy(GL2ES2 gl) {
+ release(gl, true);
+ }
+
+ /**
+ * Detaches all shader codes and deletes the program.
+ * Calls release(gl, false)
+ *
+ * @see #release(GL2ES2, boolean)
*/
public synchronized void release(GL2ES2 gl) {
release(gl, false);
}
/**
- * @see #glReleaseAllVertexAttributes
+ * Detaches all shader codes and deletes the program.
+ * If releaseShaderToo is true, destroys the shader codes as well.
*/
public synchronized void release(GL2ES2 gl, boolean releaseShaderToo) {
glUseProgram(gl, false);
@@ -52,7 +67,7 @@ public class ShaderProgram {
ShaderCode shaderCode = (ShaderCode) iter.next();
gl.glDetachShader(shaderProgram, shaderCode.shader());
if(releaseShaderToo) {
- shaderCode.release(gl);
+ shaderCode.destroy(gl);
}
}
shaderMap.clear();
diff --git a/src/classes/com/sun/opengl/util/glsl/ShaderState.java b/src/classes/com/sun/opengl/util/glsl/ShaderState.java
index 6320f9c6a..52ae35d2d 100644
--- a/src/classes/com/sun/opengl/util/glsl/ShaderState.java
+++ b/src/classes/com/sun/opengl/util/glsl/ShaderState.java
@@ -105,13 +105,32 @@ public class ShaderState {
public ShaderProgram shaderProgram() { return shaderProgram; }
/**
+ * Calls release(gl, true, true)
+ *
+ * @see #glReleaseAllVertexAttributes
+ * @see #glReleaseAllUniforms
+ * @see #release(GL2ES2, boolean, boolean)
+ */
+ public synchronized void destroy(GL2ES2 gl) {
+ release(gl, true, true);
+ }
+
+ /**
+ * Calls release(gl, false, false)
+ *
* @see #glReleaseAllVertexAttributes
* @see #glReleaseAllUniforms
+ * @see #release(GL2ES2, boolean, boolean)
*/
- public synchronized void release(GL2ES2 gl) {
+ public synchronized void releaseAllData(GL2ES2 gl) {
release(gl, false, false);
}
+ /**
+ * @see #glReleaseAllVertexAttributes
+ * @see #glReleaseAllUniforms
+ * @see ShaderProgram#release(GL2ES2, boolean)
+ */
public synchronized void release(GL2ES2 gl, boolean releaseProgramToo, boolean releaseShaderToo) {
boolean prgInUse = false;
if(null!=shaderProgram) {
diff --git a/src/classes/com/sun/opengl/util/glsl/fixed/FixedFuncHook.java b/src/classes/com/sun/opengl/util/glsl/fixed/FixedFuncHook.java
index d4b3be046..8c4b539d5 100755
--- a/src/classes/com/sun/opengl/util/glsl/fixed/FixedFuncHook.java
+++ b/src/classes/com/sun/opengl/util/glsl/fixed/FixedFuncHook.java
@@ -46,8 +46,8 @@ public class FixedFuncHook implements GLFixedFuncHookIf {
vertexColorFile, vertexColorLightFile, fragmentColorFile, fragmentColorTextureFile);
}
- public void dispose() {
- fixedFunction.release(gl);
+ public void destroy() {
+ fixedFunction.destroy(gl);
fixedFunction = null;
}
diff --git a/src/classes/com/sun/opengl/util/texture/Texture.java b/src/classes/com/sun/opengl/util/texture/Texture.java
index 29f22e57a..e16b840fa 100755
--- a/src/classes/com/sun/opengl/util/texture/Texture.java
+++ b/src/classes/com/sun/opengl/util/texture/Texture.java
@@ -264,17 +264,28 @@ public class Texture {
*
* @throws GLException if no OpenGL context was current or if any
* OpenGL-related errors occurred
+ * @deprecated use destroy(GL)
*/
public void dispose() throws GLException {
- dispose(GLU.getCurrentGL());
+ destroy(GLU.getCurrentGL());
}
/**
* Disposes the native resources used by this texture object.
*
* @throws GLException if any OpenGL-related errors occurred
+ * @deprecated use destroy(GL)
*/
public void dispose(GL gl) throws GLException {
+ destroy(gl);
+ }
+
+ /**
+ * Destroys the native resources used by this texture object.
+ *
+ * @throws GLException if any OpenGL-related errors occurred
+ */
+ public void destroy(GL gl) throws GLException {
gl.glDeleteTextures(1, new int[] {texID}, 0);
texID = 0;
}
diff --git a/src/classes/com/sun/opengl/util/texture/TextureData.java b/src/classes/com/sun/opengl/util/texture/TextureData.java
index dcaee52f2..8dbd124af 100755
--- a/src/classes/com/sun/opengl/util/texture/TextureData.java
+++ b/src/classes/com/sun/opengl/util/texture/TextureData.java
@@ -310,6 +310,13 @@ public class TextureData {
}
}
+ /** Calls flush()
+ * @see #flush()
+ */
+ public void destroy() {
+ flush();
+ }
+
/** Defines a callback mechanism to allow the user to explicitly
deallocate native resources (memory-mapped files, etc.)
associated with a particular TextureData. */