comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:380af2bdd8e5
1 /*******************************************************************************
2 * Copyright (c) 2007 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 *
11 * Port to the D Programming language:
12 * Jacob Carlborg <jacob.carlborg@gmail.com>
13 *******************************************************************************/
14 module dwt.internal.cocoa.NSOpenGLContext;
15
16 import dwt.internal.cocoa.gl;
17 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;
22 import objc = dwt.internal.objc.runtime;
23
24 enum NSOpenGLContextParameter
25 {
26 NSOpenGLCPSwapRectangle = 200,
27 NSOpenGLCPSwapRectangleEnable = 201,
28 NSOpenGLCPRasterizationEnable = 221,
29 NSOpenGLCPSwapInterval = 222,
30 NSOpenGLCPSurfaceOrder = 235,
31 NSOpenGLCPSurfaceOpacity = 236,
32 NSOpenGLCPStateValidation = 301
33 }
34
35 alias NSOpenGLContextParameter.NSOpenGLCPSwapRectangle NSOpenGLCPSwapRectangle;
36 alias NSOpenGLContextParameter.NSOpenGLCPSwapRectangleEnable NSOpenGLCPSwapRectangleEnable;
37 alias NSOpenGLContextParameter.NSOpenGLCPRasterizationEnable NSOpenGLCPRasterizationEnable;
38 alias NSOpenGLContextParameter.NSOpenGLCPSwapInterval NSOpenGLCPSwapInterval;
39 alias NSOpenGLContextParameter.NSOpenGLCPSurfaceOrder NSOpenGLCPSurfaceOrder;
40 alias NSOpenGLContextParameter.NSOpenGLCPSurfaceOpacity NSOpenGLCPSurfaceOpacity;
41 alias NSOpenGLContextParameter.NSOpenGLCPStateValidation NSOpenGLCPStateValidation;
42
43 public class NSOpenGLContext : NSObject
44 {
45
46 public this ()
47 {
48 super();
49 }
50
51 public this (objc.id id)
52 {
53 super(id);
54 }
55
56 public void* CGLContextObj ()
57 {
58 return cast(void*) OS.objc_msgSend(this.id, OS.sel_CGLContextObj);
59 }
60
61 public static void clearCurrentContext ()
62 {
63 OS.objc_msgSend(OS.class_NSOpenGLContext, OS.sel_clearCurrentContext);
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 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 OS.objc_msgSend(this.id, OS.sel_pixelBufferCubeMapFace);
123 }
124
125 public GLint pixelBufferMipMapLevel ()
126 {
127 return 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
177 }