Mercurial > projects > dwt-mac
comparison 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 |
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.NSOpenGLContext; | 14 module dwt.internal.cocoa.NSOpenGLContext; |
15 | 15 |
16 import dwt.internal.cocoa.gl; | 16 import dwt.dwthelper.utils; |
17 import cocoa = dwt.internal.cocoa.id; | |
17 import dwt.internal.cocoa.NSObject; | 18 import dwt.internal.cocoa.NSObject; |
18 import dwt.internal.cocoa.NSOpenGLPixelBuffer; | |
19 import dwt.internal.cocoa.NSOpenGLPixelFormat; | |
20 import dwt.internal.cocoa.NSView; | |
21 import dwt.internal.cocoa.OS; | 19 import dwt.internal.cocoa.OS; |
22 import objc = dwt.internal.objc.runtime; | 20 import objc = dwt.internal.objc.runtime; |
23 | 21 |
24 enum NSOpenGLContextParameter | 22 public class NSOpenGLContext : NSObject { |
25 { | 23 |
26 NSOpenGLCPSwapRectangle = 200, | 24 public this() { |
27 NSOpenGLCPSwapRectangleEnable = 201, | 25 super(); |
28 NSOpenGLCPRasterizationEnable = 221, | |
29 NSOpenGLCPSwapInterval = 222, | |
30 NSOpenGLCPSurfaceOrder = 235, | |
31 NSOpenGLCPSurfaceOpacity = 236, | |
32 NSOpenGLCPStateValidation = 301 | |
33 } | 26 } |
34 | 27 |
35 alias NSOpenGLContextParameter.NSOpenGLCPSwapRectangle NSOpenGLCPSwapRectangle; | 28 public this(objc.id id) { |
36 alias NSOpenGLContextParameter.NSOpenGLCPSwapRectangleEnable NSOpenGLCPSwapRectangleEnable; | 29 super(id); |
37 alias NSOpenGLContextParameter.NSOpenGLCPRasterizationEnable NSOpenGLCPRasterizationEnable; | 30 } |
38 alias NSOpenGLContextParameter.NSOpenGLCPSwapInterval NSOpenGLCPSwapInterval; | |
39 alias NSOpenGLContextParameter.NSOpenGLCPSurfaceOrder NSOpenGLCPSurfaceOrder; | |
40 alias NSOpenGLContextParameter.NSOpenGLCPSurfaceOpacity NSOpenGLCPSurfaceOpacity; | |
41 alias NSOpenGLContextParameter.NSOpenGLCPStateValidation NSOpenGLCPStateValidation; | |
42 | 31 |
43 public class NSOpenGLContext : NSObject | 32 public this(cocoa.id id) { |
44 { | 33 super(id); |
34 } | |
45 | 35 |
46 public this () | 36 public static void clearCurrentContext() { |
47 { | 37 OS.objc_msgSend(OS.class_NSOpenGLContext, OS.sel_clearCurrentContext); |
48 super(); | 38 } |
49 } | |
50 | 39 |
51 public this (objc.id id) | 40 public static NSOpenGLContext currentContext() { |
52 { | 41 objc.id result = OS.objc_msgSend(OS.class_NSOpenGLContext, OS.sel_currentContext); |
53 super(id); | 42 return result !is null ? new NSOpenGLContext(result) : null; |
54 } | 43 } |
55 | 44 |
56 public void* CGLContextObj () | 45 public void flushBuffer() { |
57 { | 46 OS.objc_msgSend(this.id, OS.sel_flushBuffer); |
58 return cast(void*) OS.objc_msgSend(this.id_, OS.sel_CGLContextObj); | 47 } |
59 } | |
60 | 48 |
61 public static void clearCurrentContext () | 49 public void makeCurrentContext() { |
62 { | 50 OS.objc_msgSend(this.id, OS.sel_makeCurrentContext); |
63 OS.objc_msgSend(OS.class_NSOpenGLContext, OS.sel_clearCurrentContext); | 51 } |
64 } | |
65 | |
66 public void clearDrawable () | |
67 { | |
68 OS.objc_msgSend(this.id_, OS.sel_clearDrawable); | |
69 } | |
70 | |
71 public void copyAttributesFromContext (NSOpenGLContext context, GLbitfield mask) | |
72 { | |
73 OS.objc_msgSend(this.id_, OS.sel_copyAttributesFromContext_1withMask_1, context !is null ? context.id_ : null, mask); | |
74 } | |
75 | |
76 public void createTexture (GLenum target, NSView view, GLenum format) | |
77 { | |
78 OS.objc_msgSend(this.id_, OS.sel_createTexture_1fromView_1internalFormat_1, target, view !is null ? view.id_ : null, format); | |
79 } | |
80 | |
81 public static NSOpenGLContext currentContext () | |
82 { | |
83 objc.id result = OS.objc_msgSend(OS.class_NSOpenGLContext, OS.sel_currentContext); | |
84 return result !is null ? new NSOpenGLContext(result) : null; | |
85 } | |
86 | |
87 public GLint currentVirtualScreen () | |
88 { | |
89 return cast(GLint) OS.objc_msgSend(this.id_, OS.sel_currentVirtualScreen); | |
90 } | |
91 | |
92 public void flushBuffer () | |
93 { | |
94 OS.objc_msgSend(this.id_, OS.sel_flushBuffer); | |
95 } | |
96 | |
97 public void getValues (GLint* vals, NSOpenGLContextParameter param) | |
98 { | |
99 OS.objc_msgSend(this.id_, OS.sel_getValues_1forParameter_1, vals, param); | |
100 } | |
101 | |
102 public NSOpenGLContext initWithFormat (NSOpenGLPixelFormat format, NSOpenGLContext share) | |
103 { | |
104 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithFormat_1shareContext_1, format !is null ? format.id_ : null, | |
105 share !is null ? share.id_ : null); | |
106 return result !is null ? this : null; | |
107 } | |
108 | |
109 public void makeCurrentContext () | |
110 { | |
111 OS.objc_msgSend(this.id_, OS.sel_makeCurrentContext); | |
112 } | |
113 | |
114 public NSOpenGLPixelBuffer pixelBuffer () | |
115 { | |
116 objc.id result = OS.objc_msgSend(this.id_, OS.sel_pixelBuffer); | |
117 return result !is null ? new NSOpenGLPixelBuffer(result) : null; | |
118 } | |
119 | |
120 public GLenum pixelBufferCubeMapFace () | |
121 { | |
122 return cast(GLenum) OS.objc_msgSend(this.id_, OS.sel_pixelBufferCubeMapFace); | |
123 } | |
124 | |
125 public GLint pixelBufferMipMapLevel () | |
126 { | |
127 return cast(GLint) OS.objc_msgSend(this.id_, OS.sel_pixelBufferMipMapLevel); | |
128 } | |
129 | |
130 public void setCurrentVirtualScreen (GLint screen) | |
131 { | |
132 OS.objc_msgSend(this.id_, OS.sel_setCurrentVirtualScreen_1, screen); | |
133 } | |
134 | |
135 public void setFullScreen () | |
136 { | |
137 OS.objc_msgSend(this.id_, OS.sel_setFullScreen); | |
138 } | |
139 | |
140 public void setOffScreen (void* baseaddr, GLsizei width, GLsizei height, GLint rowbytes) | |
141 { | |
142 OS.objc_msgSend(this.id_, OS.sel_setOffScreen_1width_1height_1rowbytes_1, baseaddr, width, height, rowbytes); | |
143 } | |
144 | |
145 public void setPixelBuffer (NSOpenGLPixelBuffer pixelBuffer, GLenum face, GLint level, GLint screen) | |
146 { | |
147 OS.objc_msgSend(this.id_, OS.sel_setPixelBuffer_1cubeMapFace_1mipMapLevel_1currentVirtualScreen_1, | |
148 pixelBuffer !is null ? pixelBuffer.id_ : null, face, level, screen); | |
149 } | |
150 | |
151 public void setTextureImageToPixelBuffer (NSOpenGLPixelBuffer pixelBuffer, GLenum source) | |
152 { | |
153 OS.objc_msgSend(this.id_, OS.sel_setTextureImageToPixelBuffer_1colorBuffer_1, pixelBuffer !is null ? pixelBuffer.id_ : null, source); | |
154 } | |
155 | |
156 public void setValues (/*const*/GLint* vals, NSOpenGLContextParameter param) | |
157 { | |
158 OS.objc_msgSend(this.id_, OS.sel_setValues_1forParameter_1, vals, param); | |
159 } | |
160 | |
161 public void setView (NSView view) | |
162 { | |
163 OS.objc_msgSend(this.id_, OS.sel_setView_1, view !is null ? view.id_ : null); | |
164 } | |
165 | |
166 public void update () | |
167 { | |
168 OS.objc_msgSend(this.id_, OS.sel_update); | |
169 } | |
170 | |
171 public NSView view () | |
172 { | |
173 objc.id result = OS.objc_msgSend(this.id_, OS.sel_view); | |
174 return result !is null ? new NSView(result) : null; | |
175 } | |
176 | 52 |
177 } | 53 } |