summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt.opengl
diff options
context:
space:
mode:
authorBilly Biggs <bbiggs>2005-09-21 18:55:37 +0000
committerBilly Biggs <bbiggs>2005-09-21 18:55:37 +0000
commit8bb5e530c3690c8043832507e873b6f20419203a (patch)
treef4aa1f8eeb0d296ec867bf9b74138fa8dfe301c8 /bundles/org.eclipse.swt.opengl
parent1ac75d88696998fae3200d49cded9b84dc837b50 (diff)
downloadeclipse.platform.swt-8bb5e530c3690c8043832507e873b6f20419203a.tar.gz
eclipse.platform.swt-8bb5e530c3690c8043832507e873b6f20419203a.tar.xz
eclipse.platform.swt-8bb5e530c3690c8043832507e873b6f20419203a.zip
Dispose fixes, try renaming GLFormatData to the shorter GLData
Diffstat (limited to 'bundles/org.eclipse.swt.opengl')
-rw-r--r--bundles/org.eclipse.swt.opengl/common/org/eclipse/swt/opengl/GLData.java (renamed from bundles/org.eclipse.swt.opengl/common/org/eclipse/swt/opengl/GLFormatData.java)2
-rw-r--r--bundles/org.eclipse.swt.opengl/win32/org/eclipse/swt/opengl/GLCanvas.java33
2 files changed, 25 insertions, 10 deletions
diff --git a/bundles/org.eclipse.swt.opengl/common/org/eclipse/swt/opengl/GLFormatData.java b/bundles/org.eclipse.swt.opengl/common/org/eclipse/swt/opengl/GLData.java
index d0aa927c57..b57872ac34 100644
--- a/bundles/org.eclipse.swt.opengl/common/org/eclipse/swt/opengl/GLFormatData.java
+++ b/bundles/org.eclipse.swt.opengl/common/org/eclipse/swt/opengl/GLData.java
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.swt.opengl;
-public class GLFormatData {
+public class GLData {
public int bufferSize;
public boolean doubleBuffer;
public boolean stereo;
diff --git a/bundles/org.eclipse.swt.opengl/win32/org/eclipse/swt/opengl/GLCanvas.java b/bundles/org.eclipse.swt.opengl/win32/org/eclipse/swt/opengl/GLCanvas.java
index e5fb2941eb..29e2109fc7 100644
--- a/bundles/org.eclipse.swt.opengl/win32/org/eclipse/swt/opengl/GLCanvas.java
+++ b/bundles/org.eclipse.swt.opengl/win32/org/eclipse/swt/opengl/GLCanvas.java
@@ -16,10 +16,10 @@ import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.widgets.*;
public class GLCanvas extends Canvas {
- int glHandle;
+ int context;
-public GLCanvas (Composite parent, int style, GLFormatData data) {
- super (parent, style);
+public GLCanvas (Composite parent, int style, GLData data) {
+ super (parent, style);
if (data == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
PIXELFORMATDESCRIPTOR pfd = new PIXELFORMATDESCRIPTOR ();
@@ -34,7 +34,8 @@ public GLCanvas (Composite parent, int style, GLFormatData data) {
pfd.cRedBits = (byte) data.redSize;
pfd.cGreenBits = (byte) data.greenSize;
pfd.cBlueBits = (byte) data.blueSize;
- pfd.cAlphaBits = (byte) data.depthSize;
+ pfd.cAlphaBits = (byte) data.alphaSize;
+ pfd.cDepthBits = (byte) data.depthSize;
pfd.cStencilBits = (byte) data.stencilSize;
pfd.cAccumRedBits = (byte) data.accumRedSize;
pfd.cAccumGreenBits = (byte) data.accumGreenSize;
@@ -53,7 +54,7 @@ public GLCanvas (Composite parent, int style, GLFormatData data) {
int hDC = OS.GetDC (handle);
int pixelFormat = WGL.ChoosePixelFormat (hDC, pfd);
- if (pixelFormat == 0) {
+ if (pixelFormat == 0) {
OS.ReleaseDC (handle, hDC);
SWT.error (SWT.ERROR_UNSUPPORTED_DEPTH);
}
@@ -61,12 +62,26 @@ public GLCanvas (Composite parent, int style, GLFormatData data) {
OS.ReleaseDC (handle, hDC);
SWT.error (SWT.ERROR_UNSUPPORTED_DEPTH);
}
- glHandle = WGL.wglCreateContext (hDC);
- if (glHandle == 0) {
+ context = WGL.wglCreateContext (hDC);
+ if (context == 0) {
OS.ReleaseDC (handle, hDC);
SWT.error (SWT.ERROR_NO_HANDLES);
}
OS.ReleaseDC (handle, hDC);
+// if (share != null) {
+// WGL.wglShareLists (context, share.context);
+// }
+
+ Listener listener = new Listener () {
+ public void handleEvent (Event event) {
+ switch (event.type) {
+ case SWT.Dispose:
+ WGL.wglDeleteContext (context);
+ break;
+ }
+ }
+ };
+ addListener (SWT.Dispose, listener);
}
public boolean isCurrent () {
@@ -78,13 +93,13 @@ public void setCurrent () {
checkWidget ();
if (WGL.wglGetCurrentContext () == handle) return;
int hDC = OS.GetDC (handle);
- WGL.wglMakeCurrent (hDC, glHandle);
+ WGL.wglMakeCurrent (hDC, context);
OS.ReleaseDC (handle, hDC);
}
public void swapBuffers () {
checkWidget ();
- int hDC = OS.GetDC(handle);
+ int hDC = OS.GetDC (handle);
WGL.SwapBuffers (hDC);
OS.ReleaseDC (handle, hDC);
}