Mercurial > projects > dstep
comparison dstep/appkit/NSOpenGL.d @ 16:19885b43130e
Huge update, the bridge actually works now
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 03 Jan 2010 22:06:11 +0100 |
parents | |
children | b9de51448c6b |
comparison
equal
deleted
inserted
replaced
15:7ff919f595d5 | 16:19885b43130e |
---|---|
1 /** | |
2 * Copyright: Copyright (c) 2009 Jacob Carlborg. | |
3 * Authors: Jacob Carlborg | |
4 * Version: Initial created: Sep 24, 2009 | |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
6 */ | |
7 module dstep.appkit.NSOpenGL; | |
8 | |
9 import dstep.appkit.NSScreen; | |
10 import dstep.appkit.NSView; | |
11 import dstep.foundation.NSCoder; | |
12 import dstep.foundation.NSData; | |
13 import dstep.foundation.NSObject; | |
14 import dstep.objc.bridge.Bridge; | |
15 import dstep.objc.objc; | |
16 import dstep.opengl.gl; | |
17 import dstep.opengl.CGLTypes; | |
18 | |
19 typedef uint NSOpenGLPixelFormatAttribute; | |
20 alias _CGLPixelFormatObject NSOpenGLPixelFormatAuxiliary; | |
21 alias _CGLContextObject NSOpenGLContextAuxiliary; | |
22 | |
23 enum | |
24 { | |
25 NSOpenGLGOFormatCacheSize = 501, | |
26 NSOpenGLGOClearFormatCache = 502, | |
27 NSOpenGLGORetainRenderers = 503, | |
28 NSOpenGLGOResetLibrary = 504 | |
29 } | |
30 | |
31 enum : uint | |
32 { | |
33 NSOpenGLPFAAllRenderers = 1, | |
34 NSOpenGLPFADoubleBuffer = 5, | |
35 NSOpenGLPFAStereo = 6, | |
36 NSOpenGLPFAAuxBuffers = 7, | |
37 NSOpenGLPFAColorSize = 8, | |
38 NSOpenGLPFAAlphaSize = 11, | |
39 NSOpenGLPFADepthSize = 12, | |
40 NSOpenGLPFAStencilSize = 13, | |
41 NSOpenGLPFAAccumSize = 14, | |
42 NSOpenGLPFAMinimumPolicy = 51, | |
43 NSOpenGLPFAMaximumPolicy = 52, | |
44 NSOpenGLPFAOffScreen = 53, | |
45 NSOpenGLPFAFullScreen = 54, | |
46 NSOpenGLPFASampleBuffers = 55, | |
47 NSOpenGLPFASamples = 56, | |
48 NSOpenGLPFAAuxDepthStencil = 57, | |
49 NSOpenGLPFAColorFloat = 58, | |
50 NSOpenGLPFAMultisample = 59, | |
51 NSOpenGLPFASupersample = 60, | |
52 NSOpenGLPFASampleAlpha = 61, | |
53 NSOpenGLPFARendererID = 70, | |
54 NSOpenGLPFASingleRenderer = 71, | |
55 NSOpenGLPFANoRecovery = 72, | |
56 NSOpenGLPFAAccelerated = 73, | |
57 NSOpenGLPFAClosestPolicy = 74, | |
58 NSOpenGLPFARobust = 75, | |
59 NSOpenGLPFABackingStore = 76, | |
60 NSOpenGLPFAMPSafe = 78, | |
61 NSOpenGLPFAWindow = 80, | |
62 NSOpenGLPFAMultiScreen = 81, | |
63 NSOpenGLPFACompliant = 83, | |
64 NSOpenGLPFAScreenMask = 84, | |
65 NSOpenGLPFAPixelBuffer = 90, | |
66 NSOpenGLPFAAllowOfflineRenderers = 96, | |
67 NSOpenGLPFAVirtualScreenCount = 128 | |
68 } | |
69 | |
70 enum | |
71 { | |
72 NSOpenGLCPSwapRectangle = 200, | |
73 NSOpenGLCPSwapRectangleEnable = 201, | |
74 NSOpenGLCPRasterizationEnable = 221, | |
75 NSOpenGLCPSwapInterval = 222, | |
76 NSOpenGLCPSurfaceOrder = 235, | |
77 NSOpenGLCPSurfaceOpacity = 236, | |
78 NSOpenGLCPStateValidation = 301 | |
79 } | |
80 | |
81 class NSOpenGLPixelFormat : NSObject, INSCoding | |
82 { | |
83 mixin (ObjcWrap); | |
84 | |
85 this (NSCoder aDecoder) | |
86 { | |
87 super(typeof(this).alloc.initWithCoder(aDecoder).objcObject); | |
88 } | |
89 | |
90 void encodeWithCoder (NSCoder aCoder) | |
91 { | |
92 return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); | |
93 } | |
94 | |
95 typeof(this) initWithCoder (NSCoder aDecoder) | |
96 { | |
97 return invokeObjcSelf!(typeof(this), "initWithCoder:", NSCoder)(aDecoder); | |
98 } | |
99 | |
100 NSOpenGLPixelFormat initWithAttributes (NSOpenGLPixelFormatAttribute* attribs) | |
101 { | |
102 id result = invokeObjcSelf!(id, "initWithAttributes:", NSOpenGLPixelFormatAttribute*)(attribs); | |
103 return result is this.objcObject ? this : (result !is null ? new NSOpenGLPixelFormat(result) : null); | |
104 } | |
105 | |
106 this (NSOpenGLPixelFormatAttribute* attribs) | |
107 { | |
108 super(NSOpenGLPixelFormat.alloc.initWithAttributes(attribs).objcObject); | |
109 } | |
110 | |
111 NSOpenGLPixelFormat initWithData (NSData attribs) | |
112 { | |
113 id result = invokeObjcSelf!(id, "initWithData:", NSData)(attribs); | |
114 return result is this.objcObject ? this : (result !is null ? new NSOpenGLPixelFormat(result) : null); | |
115 } | |
116 | |
117 this (NSData attribs) | |
118 { | |
119 super(NSOpenGLPixelFormat.alloc.initWithData(attribs).objcObject); | |
120 } | |
121 | |
122 NSData attributes () | |
123 { | |
124 return invokeObjcSelf!(NSData, "attributes"); | |
125 } | |
126 | |
127 void setAttributes (NSData attribs) | |
128 { | |
129 return invokeObjcSelf!(void, "setAttributes:", NSData)(attribs); | |
130 } | |
131 | |
132 void getValues (ref GLint vals, uint attrib, int screen) | |
133 { | |
134 return invokeObjcSelf!(void, "getValues:forAttribute:forVirtualScreen:", GLint*, uint, int)(&vals, attrib, screen); | |
135 } | |
136 | |
137 int numberOfVirtualScreens () | |
138 { | |
139 return invokeObjcSelf!(int, "numberOfVirtualScreens"); | |
140 } | |
141 | |
142 void* CGLPixelFormatObj () | |
143 { | |
144 return invokeObjcSelf!(void*, "CGLPixelFormatObj"); | |
145 } | |
146 | |
147 } | |
148 | |
149 class NSOpenGLContext : NSObject | |
150 { | |
151 mixin (ObjcWrap); | |
152 | |
153 NSOpenGLContext initWithFormat (NSOpenGLPixelFormat format, NSOpenGLContext share) | |
154 { | |
155 id result = invokeObjcSelf!(id, "initWithFormat:shareContext:", NSOpenGLPixelFormat, NSOpenGLContext)(format, share); | |
156 return result is this.objcObject ? this : (result !is null ? new NSOpenGLContext(result) : null); | |
157 } | |
158 | |
159 this (NSOpenGLPixelFormat format, NSOpenGLContext share) | |
160 { | |
161 super(NSOpenGLContext.alloc.initWithFormat(format, share).objcObject); | |
162 } | |
163 | |
164 void setView (NSView view) | |
165 { | |
166 return invokeObjcSelf!(void, "setView:", NSView)(view); | |
167 } | |
168 | |
169 NSView view () | |
170 { | |
171 return invokeObjcSelf!(NSView, "view"); | |
172 } | |
173 | |
174 void setFullScreen () | |
175 { | |
176 return invokeObjcSelf!(void, "setFullScreen"); | |
177 } | |
178 | |
179 void setOffScreen (void* baseaddr, int width, int height, int rowbytes) | |
180 { | |
181 return invokeObjcSelf!(void, "setOffScreen:width:height:rowbytes:", void*, int, int, int)(baseaddr, width, height, rowbytes); | |
182 } | |
183 | |
184 void clearDrawable () | |
185 { | |
186 return invokeObjcSelf!(void, "clearDrawable"); | |
187 } | |
188 | |
189 void update () | |
190 { | |
191 return invokeObjcSelf!(void, "update"); | |
192 } | |
193 | |
194 void flushBuffer () | |
195 { | |
196 return invokeObjcSelf!(void, "flushBuffer"); | |
197 } | |
198 | |
199 void makeCurrentContext () | |
200 { | |
201 return invokeObjcSelf!(void, "makeCurrentContext"); | |
202 } | |
203 | |
204 static void clearCurrentContext () | |
205 { | |
206 return invokeObjcSelfClass!(void, "clearCurrentContext"); | |
207 } | |
208 | |
209 static NSOpenGLContext currentContext () | |
210 { | |
211 return invokeObjcSelfClass!(NSOpenGLContext, "currentContext"); | |
212 } | |
213 | |
214 void copyAttributesFromContext (NSOpenGLContext context, uint mask) | |
215 { | |
216 return invokeObjcSelf!(void, "copyAttributesFromContext:withMask:", NSOpenGLContext, uint)(context, mask); | |
217 } | |
218 | |
219 void setValues (GLint* vals, int param) | |
220 { | |
221 return invokeObjcSelf!(void, "setValues:forParameter:", GLint*, int)(vals, param); | |
222 } | |
223 | |
224 void getValues (GLint* vals, int param) | |
225 { | |
226 return invokeObjcSelf!(void, "getValues:forParameter:", GLint*, int)(vals, param); | |
227 } | |
228 | |
229 void setCurrentVirtualScreen (int screen) | |
230 { | |
231 return invokeObjcSelf!(void, "setCurrentVirtualScreen:", int)(screen); | |
232 } | |
233 | |
234 int currentVirtualScreen () | |
235 { | |
236 return invokeObjcSelf!(int, "currentVirtualScreen"); | |
237 } | |
238 | |
239 void createTexture (uint target, NSView view, uint format) | |
240 { | |
241 return invokeObjcSelf!(void, "createTexture:fromView:internalFormat:", uint, NSView, uint)(target, view, format); | |
242 } | |
243 | |
244 void* CGLContextObj () | |
245 { | |
246 return invokeObjcSelf!(void*, "CGLContextObj"); | |
247 } | |
248 | |
249 void setPixelBuffer (NSOpenGLPixelBuffer pixelBuffer, uint face, int level, int screen) | |
250 { | |
251 return invokeObjcSelf!(void, "setPixelBuffer:cubeMapFace:mipMapLevel:currentVirtualScreen:", NSOpenGLPixelBuffer, uint, int, int)(pixelBuffer, face, level, screen); | |
252 } | |
253 | |
254 NSOpenGLPixelBuffer pixelBuffer () | |
255 { | |
256 return invokeObjcSelf!(NSOpenGLPixelBuffer, "pixelBuffer"); | |
257 } | |
258 | |
259 uint pixelBufferCubeMapFace () | |
260 { | |
261 return invokeObjcSelf!(uint, "pixelBufferCubeMapFace"); | |
262 } | |
263 | |
264 int pixelBufferMipMapLevel () | |
265 { | |
266 return invokeObjcSelf!(int, "pixelBufferMipMapLevel"); | |
267 } | |
268 | |
269 void setTextureImageToPixelBuffer (NSOpenGLPixelBuffer pixelBuffer, uint source) | |
270 { | |
271 return invokeObjcSelf!(void, "setTextureImageToPixelBuffer:colorBuffer:", NSOpenGLPixelBuffer, uint)(pixelBuffer, source); | |
272 } | |
273 } | |
274 | |
275 class NSOpenGLPixelBuffer : NSObject | |
276 { | |
277 mixin (ObjcWrap); | |
278 | |
279 NSOpenGLPixelBuffer initWithTextureTarget (uint target, uint format, int maxLevel, int pixelsWide, int pixelsHigh) | |
280 { | |
281 id result = invokeObjcSelf!(id, "initWithTextureTarget:textureInternalFormat:textureMaxMipMapLevel:pixelsWide:pixelsHigh:", uint, uint, int, int, int)(target, format, maxLevel, pixelsWide, pixelsHigh); | |
282 return result is this.objcObject ? this : (result !is null ? new NSOpenGLPixelBuffer(result) : null); | |
283 } | |
284 | |
285 this (uint target, uint format, int maxLevel, int pixelsWide, int pixelsHigh) | |
286 { | |
287 super(NSOpenGLPixelBuffer.alloc.initWithTextureTarget(target, format, maxLevel, pixelsWide, pixelsHigh).objcObject); | |
288 } | |
289 | |
290 int pixelsWide () | |
291 { | |
292 return invokeObjcSelf!(int, "pixelsWide"); | |
293 } | |
294 | |
295 int pixelsHigh () | |
296 { | |
297 return invokeObjcSelf!(int, "pixelsHigh"); | |
298 } | |
299 | |
300 uint textureTarget () | |
301 { | |
302 return invokeObjcSelf!(uint, "textureTarget"); | |
303 } | |
304 | |
305 uint textureInternalFormat () | |
306 { | |
307 return invokeObjcSelf!(uint, "textureInternalFormat"); | |
308 } | |
309 | |
310 int textureMaxMipMapLevel () | |
311 { | |
312 return invokeObjcSelf!(int, "textureMaxMipMapLevel"); | |
313 } | |
314 } | |
315 | |
316 extern (C) | |
317 { | |
318 void NSOpenGLSetOption (int pname, int param); | |
319 void NSOpenGLGetOption (int pname, GLint* param); | |
320 void NSOpenGLGetVersion (GLint* major, GLint* minor); | |
321 } |