diff dwt/internal/cocoa/NSOpenGLContext.d @ 0:380af2bdd8e5

Upload of whole dwt tree
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Sat, 09 Aug 2008 17:00:02 +0200
parents
children 8b48be5454ce
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/cocoa/NSOpenGLContext.d	Sat Aug 09 17:00:02 2008 +0200
@@ -0,0 +1,177 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     
+ * Port to the D Programming language:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
+ *******************************************************************************/
+module dwt.internal.cocoa.NSOpenGLContext;
+
+import dwt.internal.cocoa.gl;
+import dwt.internal.cocoa.NSObject;
+import dwt.internal.cocoa.NSOpenGLPixelBuffer;
+import dwt.internal.cocoa.NSOpenGLPixelFormat;
+import dwt.internal.cocoa.NSView;
+import dwt.internal.cocoa.OS;
+import objc = dwt.internal.objc.runtime;
+
+enum NSOpenGLContextParameter
+{
+    NSOpenGLCPSwapRectangle = 200,
+    NSOpenGLCPSwapRectangleEnable = 201,
+    NSOpenGLCPRasterizationEnable = 221,
+    NSOpenGLCPSwapInterval = 222,
+    NSOpenGLCPSurfaceOrder = 235,
+    NSOpenGLCPSurfaceOpacity = 236,
+    NSOpenGLCPStateValidation = 301
+}
+
+alias NSOpenGLContextParameter.NSOpenGLCPSwapRectangle NSOpenGLCPSwapRectangle;
+alias NSOpenGLContextParameter.NSOpenGLCPSwapRectangleEnable NSOpenGLCPSwapRectangleEnable;
+alias NSOpenGLContextParameter.NSOpenGLCPRasterizationEnable NSOpenGLCPRasterizationEnable;
+alias NSOpenGLContextParameter.NSOpenGLCPSwapInterval NSOpenGLCPSwapInterval;
+alias NSOpenGLContextParameter.NSOpenGLCPSurfaceOrder NSOpenGLCPSurfaceOrder;
+alias NSOpenGLContextParameter.NSOpenGLCPSurfaceOpacity NSOpenGLCPSurfaceOpacity;
+alias NSOpenGLContextParameter.NSOpenGLCPStateValidation NSOpenGLCPStateValidation;
+
+public class NSOpenGLContext : NSObject
+{
+
+    public this ()
+    {
+        super();
+    }
+
+    public this (objc.id id)
+    {
+        super(id);
+    }
+
+    public void* CGLContextObj ()
+    {
+        return cast(void*) OS.objc_msgSend(this.id, OS.sel_CGLContextObj);
+    }
+
+    public static void clearCurrentContext ()
+    {
+        OS.objc_msgSend(OS.class_NSOpenGLContext, OS.sel_clearCurrentContext);
+    }
+
+    public void clearDrawable ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_clearDrawable);
+    }
+
+    public void copyAttributesFromContext (NSOpenGLContext context, GLbitfield mask)
+    {
+        OS.objc_msgSend(this.id, OS.sel_copyAttributesFromContext_1withMask_1, context !is null ? context.id : null, mask);
+    }
+
+    public void createTexture (GLenum target, NSView view, GLenum format)
+    {
+        OS.objc_msgSend(this.id, OS.sel_createTexture_1fromView_1internalFormat_1, target, view !is null ? view.id : null, format);
+    }
+
+    public static NSOpenGLContext currentContext ()
+    {
+        objc.id result = OS.objc_msgSend(OS.class_NSOpenGLContext, OS.sel_currentContext);
+        return result !is null ? new NSOpenGLContext(result) : null;
+    }
+
+    public GLint currentVirtualScreen ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_currentVirtualScreen);
+    }
+
+    public void flushBuffer ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_flushBuffer);
+    }
+
+    public void getValues (GLint* vals, NSOpenGLContextParameter param)
+    {
+        OS.objc_msgSend(this.id, OS.sel_getValues_1forParameter_1, vals, param);
+    }
+
+    public NSOpenGLContext initWithFormat (NSOpenGLPixelFormat format, NSOpenGLContext share)
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFormat_1shareContext_1, format !is null ? format.id : null,
+                share !is null ? share.id : null);
+        return result !is null ? this : null;
+    }
+
+    public void makeCurrentContext ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_makeCurrentContext);
+    }
+
+    public NSOpenGLPixelBuffer pixelBuffer ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_pixelBuffer);
+        return result !is null ? new NSOpenGLPixelBuffer(result) : null;
+    }
+
+    public GLenum pixelBufferCubeMapFace ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_pixelBufferCubeMapFace);
+    }
+
+    public GLint pixelBufferMipMapLevel ()
+    {
+        return OS.objc_msgSend(this.id, OS.sel_pixelBufferMipMapLevel);
+    }
+
+    public void setCurrentVirtualScreen (GLint screen)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setCurrentVirtualScreen_1, screen);
+    }
+
+    public void setFullScreen ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_setFullScreen);
+    }
+
+    public void setOffScreen (void* baseaddr, GLsizei width, GLsizei height, GLint rowbytes)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setOffScreen_1width_1height_1rowbytes_1, baseaddr, width, height, rowbytes);
+    }
+
+    public void setPixelBuffer (NSOpenGLPixelBuffer pixelBuffer, GLenum face, GLint level, GLint screen)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setPixelBuffer_1cubeMapFace_1mipMapLevel_1currentVirtualScreen_1,
+                pixelBuffer !is null ? pixelBuffer.id : null, face, level, screen);
+    }
+
+    public void setTextureImageToPixelBuffer (NSOpenGLPixelBuffer pixelBuffer, GLenum source)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setTextureImageToPixelBuffer_1colorBuffer_1, pixelBuffer !is null ? pixelBuffer.id : null, source);
+    }
+
+    public void setValues (/*const*/GLint* vals, NSOpenGLContextParameter param)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setValues_1forParameter_1, vals, param);
+    }
+
+    public void setView (NSView view)
+    {
+        OS.objc_msgSend(this.id, OS.sel_setView_1, view !is null ? view.id : null);
+    }
+
+    public void update ()
+    {
+        OS.objc_msgSend(this.id, OS.sel_update);
+    }
+
+    public NSView view ()
+    {
+        objc.id result = OS.objc_msgSend(this.id, OS.sel_view);
+        return result !is null ? new NSView(result) : null;
+    }
+
+}