diff options
author | Billy Biggs <bbiggs> | 2005-09-21 18:54:30 +0000 |
---|---|---|
committer | Billy Biggs <bbiggs> | 2005-09-21 18:54:30 +0000 |
commit | 1ac75d88696998fae3200d49cded9b84dc837b50 (patch) | |
tree | 5bcb20173bb6df279f6f95052de9c6fa3ac16329 /bundles | |
parent | dfa24e6125855b843925fa744767b981b8f8ae60 (diff) | |
download | eclipse.platform.swt-1ac75d88696998fae3200d49cded9b84dc837b50.tar.gz eclipse.platform.swt-1ac75d88696998fae3200d49cded9b84dc837b50.tar.xz eclipse.platform.swt-1ac75d88696998fae3200d49cded9b84dc837b50.zip |
Bugfixes for alpha size and clipping
Diffstat (limited to 'bundles')
-rwxr-xr-x | bundles/org.eclipse.swt.opengl/carbon/org/eclipse/swt/opengl/GLCanvas.java | 90 |
1 files changed, 67 insertions, 23 deletions
diff --git a/bundles/org.eclipse.swt.opengl/carbon/org/eclipse/swt/opengl/GLCanvas.java b/bundles/org.eclipse.swt.opengl/carbon/org/eclipse/swt/opengl/GLCanvas.java index 5fc3576ac2..04ea0a9462 100755 --- a/bundles/org.eclipse.swt.opengl/carbon/org/eclipse/swt/opengl/GLCanvas.java +++ b/bundles/org.eclipse.swt.opengl/carbon/org/eclipse/swt/opengl/GLCanvas.java @@ -17,7 +17,8 @@ import org.eclipse.swt.internal.carbon.*; import org.eclipse.swt.internal.opengl.carbon.*; public class GLCanvas extends Canvas { - int glContext; + int context; + int pixelFormat; static final int MAX_ATTRIBUTES = 32; public GLCanvas (Composite parent, int style, GLFormatData data) { @@ -40,6 +41,10 @@ public GLCanvas (Composite parent, int style, GLFormatData data) { aglAttrib [pos++] = AGL.AGL_BLUE_SIZE; aglAttrib [pos++] = data.blueSize; } + if (data.alphaSize > 0) { + aglAttrib [pos++] = AGL.AGL_ALPHA_SIZE; + aglAttrib [pos++] = data.alphaSize; + } if (data.depthSize > 0) { aglAttrib [pos++] = AGL.AGL_DEPTH_SIZE; aglAttrib [pos++] = data.depthSize; @@ -73,44 +78,83 @@ public GLCanvas (Composite parent, int style, GLFormatData data) { aglAttrib [pos++] = data.samples; } aglAttrib [pos++] = AGL.AGL_NONE; - int pixelFormat = AGL.aglChoosePixelFormat (0, 0, aglAttrib); - glContext = AGL.aglCreateContext (pixelFormat, 0); + pixelFormat = AGL.aglChoosePixelFormat (0, 0, aglAttrib); +// context = AGL.aglCreateContext (pixelFormat, share == null ? 0 : share.context); + context = AGL.aglCreateContext (pixelFormat, 0); int window = OS.GetControlOwner (handle); int port = OS.GetWindowPort (window); - AGL.aglSetDrawable (glContext, port); + AGL.aglSetDrawable (context, port); Listener listener = new Listener () { public void handleEvent (Event event) { switch (event.type) { - case SWT.Resize: handleResize (event); break; + case SWT.Dispose: + AGL.aglDestroyContext (context); + break; + case SWT.Resize: + case SWT.Hide: + case SWT.Show: + getDisplay().asyncExec(new Runnable() { + public void run() { + fixBounds(); + } + }); + break; } } - }; + }; addListener (SWT.Resize, listener); + Shell shell = getShell(); + shell.addListener(SWT.Resize, listener); + shell.addListener(SWT.Show, listener); + shell.addListener(SWT.Hide, listener); + Control c = this; + do { + c.addListener(SWT.Show, listener); + c.addListener(SWT.Hide, listener); + c = c.getParent(); + } while (c != shell); + addListener (SWT.Dispose, listener); } -void handleResize (Event event) { - Rectangle bounds = getBounds (); - AGL.aglUpdateContext (glContext); - int[] glbounds = new int[4]; - glbounds[0] = bounds.x; - glbounds[1] = bounds.y; - glbounds[2] = bounds.width; - glbounds[3] = bounds.height; - AGL.aglSetInteger (glContext, AGL.AGL_BUFFER_RECT, glbounds); - AGL.aglEnable (glContext, AGL.AGL_BUFFER_RECT); +void fixBounds () { + GCData data = new GCData(); + int gc = internal_new_GC(data); + Rect bounds = new Rect(); + OS.GetRegionBounds (data.visibleRgn, bounds); + int width = bounds.right - bounds.left; + int height = bounds.bottom - bounds.top; + Rect rect = new Rect (); + int window = OS.GetControlOwner (handle); + int port = OS.GetWindowPort (window); + OS.GetPortBounds (port, rect); + int [] glbounds = new int [4]; + glbounds[0] = bounds.left; + glbounds[1] = rect.bottom - rect.top - bounds.top - height; + glbounds[2] = width; + glbounds[3] = height; + AGL.aglSetInteger (context, AGL.AGL_BUFFER_RECT, glbounds); + AGL.aglEnable (context, AGL.AGL_BUFFER_RECT); + AGL.aglSetInteger (context, AGL.AGL_CLIP_REGION, data.visibleRgn); + AGL.aglUpdateContext (context); + + internal_dispose_GC(gc, data); } -public boolean isCurrent () { - return AGL.aglGetCurrentContext () == glContext; +public void swapBuffers () { + checkWidget (); + AGL.aglSwapBuffers (context); } -public void setCurrent () { - if (AGL.aglGetCurrentContext () == glContext) return; - AGL.aglSetCurrentContext (glContext); +public boolean isCurrent () { + checkWidget (); + return AGL.aglGetCurrentContext () == context; } -public void swapBuffers () { - AGL.aglSwapBuffers (glContext); +public void setCurrent () { + checkWidget (); + if (AGL.aglGetCurrentContext () != context) { + AGL.aglSetCurrentContext (context); + } } } |