summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt.opengl
diff options
context:
space:
mode:
authorBilly Biggs <bbiggs>2005-09-22 03:54:42 +0000
committerBilly Biggs <bbiggs>2005-09-22 03:54:42 +0000
commitbc2685c30248fd053c7881991106e2bd19720496 (patch)
treeb7b9aec87f9b1485de234463c4df19b735392125 /bundles/org.eclipse.swt.opengl
parent2be67445ac6f806ce6e0d476174e974cb38f9780 (diff)
downloadeclipse.platform.swt-bc2685c30248fd053c7881991106e2bd19720496.tar.gz
eclipse.platform.swt-bc2685c30248fd053c7881991106e2bd19720496.tar.xz
eclipse.platform.swt-bc2685c30248fd053c7881991106e2bd19720496.zip
Add getGLData().
Diffstat (limited to 'bundles/org.eclipse.swt.opengl')
-rw-r--r--bundles/org.eclipse.swt.opengl/win32/org/eclipse/swt/opengl/GLCanvas.java35
1 files changed, 34 insertions, 1 deletions
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 2502c56aa5..32b1a1a092 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
@@ -21,6 +21,7 @@ import org.eclipse.swt.widgets.*;
public class GLCanvas extends Canvas {
int context;
+ int pixelFormat;
/**
* Create a GLCanvas widget using the attributes described in the GLData
@@ -75,7 +76,7 @@ public GLCanvas (Composite parent, int style, GLData data) {
// }
int hDC = OS.GetDC (handle);
- int pixelFormat = WGL.ChoosePixelFormat (hDC, pfd);
+ pixelFormat = WGL.ChoosePixelFormat (hDC, pfd);
if (pixelFormat == 0) {
OS.ReleaseDC (handle, hDC);
SWT.error (SWT.ERROR_UNSUPPORTED_DEPTH);
@@ -107,6 +108,38 @@ public GLCanvas (Composite parent, int style, GLData data) {
}
/**
+ * Returns a GLData object describing the created context.
+ *
+ * @return GLData description of the OpenGL context attributes
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public GLData getGLData () {
+ checkWidget ();
+ GLData data = new GLData ();
+ PIXELFORMATDESCRIPTOR pfd = new PIXELFORMATDESCRIPTOR ();
+ pfd.nSize = (short) PIXELFORMATDESCRIPTOR.sizeof;
+ int hDC = OS.GetDC (handle);
+ WGL.DescribePixelFormat(hDC, pixelFormat, PIXELFORMATDESCRIPTOR.sizeof, pfd);
+ OS.ReleaseDC (handle, hDC);
+ data.doubleBuffer = (pfd.dwFlags & WGL.PFD_DOUBLEBUFFER) != 0;
+ data.stereo = (pfd.dwFlags & WGL.PFD_STEREO) != 0;
+ data.redSize = pfd.cRedBits;
+ data.greenSize = pfd.cGreenBits;
+ data.blueSize = pfd.cBlueBits;
+ data.alphaSize = pfd.cAlphaBits;
+ data.depthSize = pfd.cDepthBits;
+ data.stencilSize = pfd.cStencilBits;
+ data.accumRedSize = pfd.cAccumRedBits;
+ data.accumGreenSize = pfd.cAccumGreenBits;
+ data.accumBlueSize = pfd.cAccumBlueBits;
+ data.accumAlphaSize = pfd.cAccumAlphaBits;
+ return data;
+}
+
+/**
* Returns a boolean indicating whether the receiver's OpenGL context
* is the current context.
*