comparison dwt/internal/cocoa/NSOpenGLView.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
comparison
equal deleted inserted replaced
44:ca5e494f2bbf 45:d8635bb48c7c
1 /******************************************************************************* 1 /*******************************************************************************
2 * Copyright (c) 2007 IBM Corporation and others. 2 * Copyright (c) 2000, 2008 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials 3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0 4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at 5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html 6 * http://www.eclipse.org/legal/epl-v10.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * IBM Corporation - initial API and implementation 9 * IBM Corporation - initial API and implementation
10 * 10 *
11 * Port to the D programming language: 11 * Port to the D programming language:
12 * Jacob Carlborg <jacob.carlborg@gmail.com> 12 * Jacob Carlborg <doob@me.com>
13 *******************************************************************************/ 13 *******************************************************************************/
14 module dwt.internal.cocoa.NSOpenGLView; 14 module dwt.internal.cocoa.NSOpenGLView;
15 15
16 import dwt.dwthelper.utils;
17 import cocoa = dwt.internal.cocoa.id;
16 import dwt.internal.cocoa.NSOpenGLContext; 18 import dwt.internal.cocoa.NSOpenGLContext;
17 import dwt.internal.cocoa.NSOpenGLPixelFormat; 19 import dwt.internal.cocoa.NSOpenGLPixelFormat;
18 import dwt.internal.cocoa.NSRect; 20 import dwt.internal.cocoa.NSRect;
19 import dwt.internal.cocoa.NSView; 21 import dwt.internal.cocoa.NSView;
20 import dwt.internal.cocoa.OS; 22 import dwt.internal.cocoa.OS;
21 import objc = dwt.internal.objc.runtime; 23 import objc = dwt.internal.objc.runtime;
22 24
23 public class NSOpenGLView : NSView 25 public class NSOpenGLView : NSView {
24 {
25 26
26 public this () 27 public this() {
27 { 28 super();
28 super(); 29 }
29 }
30 30
31 public this (objc.id id) 31 public this(objc.id id) {
32 { 32 super(id);
33 super(id); 33 }
34 }
35 34
36 public void clearGLContext () 35 public this(cocoa.id id) {
37 { 36 super(id);
38 OS.objc_msgSend(this.id_, OS.sel_clearGLContext); 37 }
39 }
40 38
41 public static NSOpenGLPixelFormat defaultPixelFormat () 39 public void clearGLContext() {
42 { 40 OS.objc_msgSend(this.id, OS.sel_clearGLContext);
43 objc.id result = OS.objc_msgSend(OS.class_NSOpenGLView, OS.sel_defaultPixelFormat); 41 }
44 return result !is null ? new NSOpenGLPixelFormat(result) : null;
45 }
46 42
47 public NSOpenGLView initWithFrame (NSRect frameRect, NSOpenGLPixelFormat format) 43 public cocoa.id initWithFrame(NSRect frameRect, NSOpenGLPixelFormat format) {
48 { 44 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFrame_pixelFormat_, frameRect, format !is null ? format.id : null);
49 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithFrame_1pixelFormat_1, frameRect, format !is null ? format.id_ : null); 45 return result !is null ? new cocoa.id(result) : null;
50 return result !is null ? this : null; 46 }
51 }
52 47
53 public NSOpenGLContext openGLContext () 48 public NSOpenGLContext openGLContext() {
54 { 49 objc.id result = OS.objc_msgSend(this.id, OS.sel_openGLContext);
55 objc.id result = OS.objc_msgSend(this.id_, OS.sel_openGLContext); 50 return result !is null ? new NSOpenGLContext(result) : null;
56 return result !is null ? new NSOpenGLContext(result) : null; 51 }
57 }
58 52
59 public NSOpenGLPixelFormat pixelFormat () 53 public void setPixelFormat(NSOpenGLPixelFormat pixelFormat) {
60 { 54 OS.objc_msgSend(this.id, OS.sel_setPixelFormat_, pixelFormat !is null ? pixelFormat.id : null);
61 objc.id result = OS.objc_msgSend(this.id_, OS.sel_pixelFormat); 55 }
62 return result !is null ? new NSOpenGLPixelFormat(result) : null;
63 }
64
65 public void prepareOpenGL ()
66 {
67 OS.objc_msgSend(this.id_, OS.sel_prepareOpenGL);
68 }
69
70 public void reshape ()
71 {
72 OS.objc_msgSend(this.id_, OS.sel_reshape);
73 }
74
75 public void setOpenGLContext (NSOpenGLContext context)
76 {
77 OS.objc_msgSend(this.id_, OS.sel_setOpenGLContext_1, context !is null ? context.id_ : null);
78 }
79
80 public void setPixelFormat (NSOpenGLPixelFormat pixelFormat)
81 {
82 OS.objc_msgSend(this.id_, OS.sel_setPixelFormat_1, pixelFormat !is null ? pixelFormat.id_ : null);
83 }
84
85 public void update ()
86 {
87 OS.objc_msgSend(this.id_, OS.sel_update);
88 }
89 56
90 } 57 }