aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/com/sun/opengl/impl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2009-03-14 05:20:29 +0000
committerSven Gothel <[email protected]>2009-03-14 05:20:29 +0000
commit9517d52c18bfa93d78e03f4c212757eda421afb6 (patch)
tree8c1bc95802461520f3477c3c224d285debff4e2c /src/classes/com/sun/opengl/impl
parent78ff34edd75db5cd7f3055466d992ca7be3a70a6 (diff)
NEWT window closing:
- New WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY and WindowListener.windowDestroyNotify() method. - Removed windowClosed() method for JNI hook - Added windowDestroyNotify() windowDestroyed(), where windowDestroyNotify() shall be called by the native implementation _before_ the window gets shutdown. The Window.java then sends a WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY event, and either Window.java or it's owner GLWindow.java issues the destroy() procedure. - Added GLEventListener.dispose(GLAutoDrawable), to allow user application to release GL ressources. Issued by GLWindow (-> see windowDestroyNotify()) - X11 impl intercepts WM_DELETE_WINDOW, using Atom, MacosX impl already uses the _before_ method (VERIFY), and Windows impl uses the WM_CLOSE event (VERIFY). JOGL2 dispose/destroy .. - Added GLEventListener.dispose() to GLCanvas and GLJpanel - GL* toString() rearrangement, assumes it is issued by GLContext(), which indeed is the core information node. - Added proper destroy() methods and calls, to achieve a proper resource release at destruction. Instrumentizing almost all classes with a destroy() method, so no release function lookup is necessary. - misc changes .. JOGL2 Demos - Fixed in regards to the above changes git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1867 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/com/sun/opengl/impl')
-rw-r--r--src/classes/com/sun/opengl/impl/GLContextImpl.java3
-rw-r--r--src/classes/com/sun/opengl/impl/GLDrawableHelper.java33
-rw-r--r--src/classes/com/sun/opengl/impl/GLDrawableImpl.java2
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/ProjectFloat.java24
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/gl2/ProjectDouble.java24
-rw-r--r--src/classes/com/sun/opengl/impl/glsl/fixed/FixedFuncPipeline.java4
-rw-r--r--src/classes/com/sun/opengl/impl/jawt/JAWTWindow.java17
7 files changed, 74 insertions, 33 deletions
diff --git a/src/classes/com/sun/opengl/impl/GLContextImpl.java b/src/classes/com/sun/opengl/impl/GLContextImpl.java
index d00afde4d..1d51ca9d6 100644
--- a/src/classes/com/sun/opengl/impl/GLContextImpl.java
+++ b/src/classes/com/sun/opengl/impl/GLContextImpl.java
@@ -165,7 +165,8 @@ public abstract class GLContextImpl extends GLContext {
public void destroy() {
if (lock.isHeld()) {
- throw new GLException("Can not destroy context while it is current");
+ // release current context
+ release();
}
/* FIXME: refactor dependence on Java 2D / JOGL bridge
diff --git a/src/classes/com/sun/opengl/impl/GLDrawableHelper.java b/src/classes/com/sun/opengl/impl/GLDrawableHelper.java
index 8c9568381..e7fea1cee 100644
--- a/src/classes/com/sun/opengl/impl/GLDrawableHelper.java
+++ b/src/classes/com/sun/opengl/impl/GLDrawableHelper.java
@@ -55,6 +55,16 @@ public class GLDrawableHelper {
public GLDrawableHelper() {
}
+ public synchronized String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("GLEventListeners num "+listeners.size()+" [");
+ for (Iterator iter = listeners.iterator(); iter.hasNext(); ) {
+ sb.append(iter.next()+", ");
+ }
+ sb.append("]");
+ return sb.toString();
+ }
+
public synchronized void addGLEventListener(GLEventListener listener) {
List newListeners = (List) ((ArrayList) listeners).clone();
newListeners.add(listener);
@@ -67,6 +77,15 @@ public class GLDrawableHelper {
listeners = newListeners;
}
+ public synchronized void dispose(GLAutoDrawable drawable) {
+ List newListeners = (List) ((ArrayList) listeners).clone();
+ for (Iterator iter = newListeners.iterator(); iter.hasNext(); ) {
+ ((GLEventListener) iter.next()).dispose(drawable);
+ iter.remove();
+ }
+ listeners = newListeners;
+ }
+
public void init(GLAutoDrawable drawable) {
for (Iterator iter = listeners.iterator(); iter.hasNext(); ) {
((GLEventListener) iter.next()).init(drawable);
@@ -117,12 +136,14 @@ public class GLDrawableHelper {
try {
res = context.makeCurrent();
if (res != GLContext.CONTEXT_NOT_CURRENT) {
- perThreadInitAction.set(initAction);
- if (res == GLContext.CONTEXT_CURRENT_NEW) {
- if (DEBUG) {
- System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running initAction");
- }
- initAction.run();
+ if(null!=initAction) {
+ perThreadInitAction.set(initAction);
+ if (res == GLContext.CONTEXT_CURRENT_NEW) {
+ if (DEBUG) {
+ System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running initAction");
+ }
+ initAction.run();
+ }
}
if (DEBUG && VERBOSE) {
System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running runnable");
diff --git a/src/classes/com/sun/opengl/impl/GLDrawableImpl.java b/src/classes/com/sun/opengl/impl/GLDrawableImpl.java
index 46c79cf2b..f01f8eeda 100644
--- a/src/classes/com/sun/opengl/impl/GLDrawableImpl.java
+++ b/src/classes/com/sun/opengl/impl/GLDrawableImpl.java
@@ -134,7 +134,7 @@ public abstract class GLDrawableImpl implements GLDrawable {
}
public String toString() {
- return "GLDrawable[realized "+getRealized()+
+ return getClass().getName()+"[realized "+getRealized()+
", window "+getNativeWindow()+
", factory "+getFactory()+"]";
}
diff --git a/src/classes/com/sun/opengl/impl/ProjectFloat.java b/src/classes/com/sun/opengl/impl/ProjectFloat.java
index 61c1bd8a1..fbeccc61f 100755
--- a/src/classes/com/sun/opengl/impl/ProjectFloat.java
+++ b/src/classes/com/sun/opengl/impl/ProjectFloat.java
@@ -164,6 +164,7 @@ public class ProjectFloat {
private final float[] up = new float[3];
// Buffer-based implementation
+ private FloatBuffer locbuf;
private final FloatBuffer matrixBuf;
private final FloatBuffer tempInvertMatrixBuf;
@@ -180,24 +181,31 @@ public class ProjectFloat {
// Slice up one big buffer because some NIO implementations
// allocate a huge amount of memory to back even the smallest of
// buffers.
- FloatBuffer buf = BufferUtil.newFloatBuffer(2*16+2*4+3*3);
+ locbuf = BufferUtil.newFloatBuffer(2*16+2*4+3*3);
int pos = 0;
int sz = 16;
- matrixBuf = slice(buf, pos, sz);
+ matrixBuf = slice(locbuf, pos, sz);
pos += sz;
- tempInvertMatrixBuf = slice(buf, pos, sz);
+ tempInvertMatrixBuf = slice(locbuf, pos, sz);
pos += sz;
sz = 4;
- inBuf = slice(buf, pos, sz);
+ inBuf = slice(locbuf, pos, sz);
pos += sz;
- outBuf = slice(buf, pos, sz);
+ outBuf = slice(locbuf, pos, sz);
pos += sz;
sz = 3;
- forwardBuf = slice(buf, pos, sz);
+ forwardBuf = slice(locbuf, pos, sz);
pos += sz;
- sideBuf = slice(buf, pos, sz);
+ sideBuf = slice(locbuf, pos, sz);
pos += sz;
- upBuf = slice(buf, pos, sz);
+ upBuf = slice(locbuf, pos, sz);
+ }
+
+ public void destroy() {
+ if(locbuf!=null) {
+ locbuf.clear();
+ locbuf=null;
+ }
}
private static FloatBuffer slice(FloatBuffer buf, int pos, int len) {
diff --git a/src/classes/com/sun/opengl/impl/gl2/ProjectDouble.java b/src/classes/com/sun/opengl/impl/gl2/ProjectDouble.java
index 760aba15d..4efbcfb1e 100755
--- a/src/classes/com/sun/opengl/impl/gl2/ProjectDouble.java
+++ b/src/classes/com/sun/opengl/impl/gl2/ProjectDouble.java
@@ -157,6 +157,7 @@ public class ProjectDouble {
private final double[] up = new double[3];
// Buffer-based implementation
+ private DoubleBuffer locbuf;
private final DoubleBuffer matrixBuf;
private final DoubleBuffer tempMatrixBuf;
@@ -173,24 +174,31 @@ public class ProjectDouble {
// Slice up one big buffer because some NIO implementations
// allocate a huge amount of memory to back even the smallest of
// buffers.
- DoubleBuffer buf = BufferUtil.newDoubleBuffer(128);
+ DoubleBuffer locbuf = BufferUtil.newDoubleBuffer(128);
int pos = 0;
int sz = 16;
- matrixBuf = slice(buf, pos, sz);
+ matrixBuf = slice(locbuf, pos, sz);
pos += sz;
- tempMatrixBuf = slice(buf, pos, sz);
+ tempMatrixBuf = slice(locbuf, pos, sz);
pos += sz;
sz = 4;
- inBuf = slice(buf, pos, sz);
+ inBuf = slice(locbuf, pos, sz);
pos += sz;
- outBuf = slice(buf, pos, sz);
+ outBuf = slice(locbuf, pos, sz);
pos += sz;
sz = 3;
- forwardBuf = slice(buf, pos, sz);
+ forwardBuf = slice(locbuf, pos, sz);
pos += sz;
- sideBuf = slice(buf, pos, sz);
+ sideBuf = slice(locbuf, pos, sz);
pos += sz;
- upBuf = slice(buf, pos, sz);
+ upBuf = slice(locbuf, pos, sz);
+ }
+
+ public void destroy() {
+ if(locbuf!=null) {
+ locbuf.clear();
+ locbuf=null;
+ }
}
private static DoubleBuffer slice(DoubleBuffer buf, int pos, int len) {
diff --git a/src/classes/com/sun/opengl/impl/glsl/fixed/FixedFuncPipeline.java b/src/classes/com/sun/opengl/impl/glsl/fixed/FixedFuncPipeline.java
index c5b85924d..1d33254c0 100644
--- a/src/classes/com/sun/opengl/impl/glsl/fixed/FixedFuncPipeline.java
+++ b/src/classes/com/sun/opengl/impl/glsl/fixed/FixedFuncPipeline.java
@@ -53,12 +53,12 @@ public class FixedFuncPipeline {
return name;
}
- public void release(GL2ES2 gl) {
- shaderState.release(gl);
+ public void destroy(GL2ES2 gl) {
shaderProgramColor.release(gl, true);
shaderProgramColorLight.release(gl, true);
shaderProgramColorTexture.release(gl, true);
shaderProgramColorTextureLight.release(gl, true);
+ shaderState.destroy(gl);
}
public void glEnableClientState(GL2ES2 gl, int glArrayIndex) {
diff --git a/src/classes/com/sun/opengl/impl/jawt/JAWTWindow.java b/src/classes/com/sun/opengl/impl/jawt/JAWTWindow.java
index ebbb7f666..b38df14ec 100644
--- a/src/classes/com/sun/opengl/impl/jawt/JAWTWindow.java
+++ b/src/classes/com/sun/opengl/impl/jawt/JAWTWindow.java
@@ -128,10 +128,6 @@ public abstract class JAWTWindow implements NativeWindow {
return component;
}
- public final boolean isTerminalObject() {
- return true;
- }
-
public void setSize(int width, int height) {
component.setSize(width, height);
}
@@ -145,10 +141,17 @@ public abstract class JAWTWindow implements NativeWindow {
}
public String toString() {
- return "JAWT-Window[windowHandle "+getWindowHandle()+
+ StringBuffer sb = new StringBuffer();
+
+ sb.append("JAWT-Window[windowHandle "+getWindowHandle()+
", surfaceHandle "+getSurfaceHandle()+
- ", size "+getWidth()+"x"+getHeight()+
+ ", pos "+component.getX()+"/"+component.getY()+", size "+getWidth()+"x"+getHeight()+
+ ", visible "+component.isVisible()+
", wrappedWindow "+getWrappedWindow()+
- ", terminalObject "+isTerminalObject()+"]";
+ ", visualID "+visualID+
+ ", screen handle/index "+getScreenHandle()+"/"+getScreenIndex() +
+ ", display handle "+getDisplayHandle()+"]");
+
+ return sb.toString();
}
}