Mercurial > projects > dwt-mac
diff dwt/internal/cocoa/NSOpenGLContext.d @ 45:d8635bb48c7c
Merge with SWT 3.5
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 01 Dec 2008 17:07:00 +0100 |
parents | f565d3a95c0a |
children |
line wrap: on
line diff
--- a/dwt/internal/cocoa/NSOpenGLContext.d Tue Oct 21 15:20:04 2008 +0200 +++ b/dwt/internal/cocoa/NSOpenGLContext.d Mon Dec 01 17:07:00 2008 +0100 @@ -1,177 +1,53 @@ /******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. + * Copyright (c) 2000, 2008 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 + * IBM Corporation - initial API and implementation * * Port to the D programming language: - * Jacob Carlborg <jacob.carlborg@gmail.com> + * Jacob Carlborg <doob@me.com> *******************************************************************************/ module dwt.internal.cocoa.NSOpenGLContext; -import dwt.internal.cocoa.gl; +import dwt.dwthelper.utils; +import cocoa = dwt.internal.cocoa.id; 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 +public class NSOpenGLContext : NSObject { + +public this() { + super(); +} + +public this(objc.id id) { + super(id); +} + +public this(cocoa.id id) { + super(id); } -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 cast(GLint) 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 static void clearCurrentContext() { + OS.objc_msgSend(OS.class_NSOpenGLContext, OS.sel_clearCurrentContext); +} - 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 cast(GLenum) OS.objc_msgSend(this.id_, OS.sel_pixelBufferCubeMapFace); - } - - public GLint pixelBufferMipMapLevel () - { - return cast(GLint) OS.objc_msgSend(this.id_, OS.sel_pixelBufferMipMapLevel); - } - - public void setCurrentVirtualScreen (GLint screen) - { - OS.objc_msgSend(this.id_, OS.sel_setCurrentVirtualScreen_1, screen); - } +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 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 flushBuffer() { + OS.objc_msgSend(this.id, OS.sel_flushBuffer); +} - 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; - } +public void makeCurrentContext() { + OS.objc_msgSend(this.id, OS.sel_makeCurrentContext); +} }