|
15 | 15 | #include <string.h>
|
16 | 16 | #endif
|
17 | 17 |
|
18 |
| -#if defined(IS_MACOSX) |
19 |
| - |
20 |
| -/* Helper functions (documented below). */ |
21 |
| -static CGLContextObj createFullScreenCGLContext(CGOpenGLDisplayMask displayMask); |
22 |
| -static void destroyFullScreenCGLContext(CGLContextObj glContext); |
23 |
| - |
24 |
| -static uint8_t *createBufferFromCurrentCGLContext(GLint x, |
25 |
| - GLint y, |
26 |
| - GLsizei width, |
27 |
| - GLsizei height, |
28 |
| - size_t bytewidth); |
29 |
| - |
30 |
| -#endif |
31 |
| - |
32 | 18 | MMBitmapRef copyMMBitmapFromDisplayInRect(MMRect rect)
|
33 | 19 | {
|
34 | 20 | #if defined(IS_MACOSX)
|
35 | 21 |
|
36 | 22 | size_t bytewidth;
|
37 | 23 | uint8_t bitsPerPixel, bytesPerPixel;
|
38 |
| - uint8_t *buffer; |
| 24 | + //uint8_t *buffer; |
39 | 25 |
|
40 | 26 | CGDirectDisplayID displayID = CGMainDisplayID();
|
41 | 27 |
|
@@ -165,92 +151,3 @@ MMBitmapRef copyMMBitmapFromDisplayInRect(MMRect rect)
|
165 | 151 | return bitmap;
|
166 | 152 | #endif
|
167 | 153 | }
|
168 |
| - |
169 |
| -#if defined(IS_MACOSX) |
170 |
| - |
171 |
| -/* Creates and returns a full-screen OpenGL graphics context (to be |
172 |
| - * released/destroyed by caller). |
173 |
| - * |
174 |
| - * To clean up the returned context use destroyFullScreenCGLContext(); */ |
175 |
| -static CGLContextObj createFullScreenCGLContext(CGOpenGLDisplayMask displayMask) |
176 |
| -{ |
177 |
| - CGLContextObj glContext = NULL; |
178 |
| - CGLPixelFormatObj pix; |
179 |
| - GLint npix; |
180 |
| - CGLPixelFormatAttribute attribs[4]; |
181 |
| - |
182 |
| - attribs[0] = kCGLPFAFullScreen; |
183 |
| - attribs[1] = kCGLPFADisplayMask; |
184 |
| - attribs[2] = displayMask; |
185 |
| - attribs[3] = (CGLPixelFormatAttribute)0; |
186 |
| - |
187 |
| - CGLChoosePixelFormat(attribs, &pix, &npix); |
188 |
| - CGLCreateContext(pix, NULL, &glContext); |
189 |
| - |
190 |
| - /* The pixel format is no longer needed, so destroy it. */ |
191 |
| - CGLDestroyPixelFormat(pix); |
192 |
| - |
193 |
| - if (glContext == NULL) return NULL; |
194 |
| - |
195 |
| - /* Set our context as the current OpenGL context. */ |
196 |
| - CGLSetCurrentContext(glContext); |
197 |
| - |
198 |
| - /* Set full-screen mode. */ |
199 |
| - CGLSetFullScreen(glContext); |
200 |
| - //CGLSetFullScreenOnDisplay(glContext, displayMask); |
201 |
| - |
202 |
| - /* Select front buffer as our source for pixel data. */ |
203 |
| - glReadBuffer(GL_FRONT); |
204 |
| - |
205 |
| - /* Finish previous OpenGL commands before continuing. */ |
206 |
| - glFinish(); |
207 |
| - |
208 |
| - if (glGetError() != GL_NO_ERROR) return NULL; |
209 |
| - |
210 |
| - return glContext; |
211 |
| -} |
212 |
| - |
213 |
| -/* Cleans up CGLContext created by createFullScreenCGLContext(); */ |
214 |
| -static void destroyFullScreenCGLContext(CGLContextObj glContext) |
215 |
| -{ |
216 |
| - glPopClientAttrib(); /* Clear attributes previously set. */ |
217 |
| - CGLSetCurrentContext(NULL); /* Reset context. */ |
218 |
| - CGLClearDrawable(glContext); /* Disassociate from full-screen. */ |
219 |
| - CGLDestroyContext(glContext); /* Release memory. */ |
220 |
| -} |
221 |
| - |
222 |
| -/* Returns newly malloc'd bitmap (to be freed by caller). */ |
223 |
| -static uint8_t *createBufferFromCurrentCGLContext(GLint x, |
224 |
| - GLint y, |
225 |
| - GLsizei width, |
226 |
| - GLsizei height, |
227 |
| - size_t bytewidth) |
228 |
| -{ |
229 |
| - uint8_t *data = NULL; |
230 |
| - |
231 |
| - /* For extra safety, save & restore OpenGL states that are changed. */ |
232 |
| - glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT); |
233 |
| - |
234 |
| - glPixelStorei(GL_PACK_ALIGNMENT, BYTE_ALIGN); /* Force alignment. */ |
235 |
| - glPixelStorei(GL_PACK_ROW_LENGTH, 0); |
236 |
| - glPixelStorei(GL_PACK_SKIP_ROWS, 0); |
237 |
| - glPixelStorei(GL_PACK_SKIP_PIXELS, 0); |
238 |
| - |
239 |
| - /* Allocate size for bitmap */ |
240 |
| - data = malloc(bytewidth * height); |
241 |
| - if (data == NULL) return NULL; |
242 |
| - |
243 |
| - /* Read the OpenGL frame into our buffer */ |
244 |
| - glReadPixels(x, y, width, height, |
245 |
| - MMRGB_IS_BGR ? GL_BGRA : GL_RGBA, |
246 |
| -#if __BYTE_ORDER == __BIG_ENDIAN |
247 |
| - GL_UNSIGNED_INT_8_8_8_8, /* Non-native format (little-endian) */ |
248 |
| -#elif __BYTE_ORDER == __LITTLE_ENDIAN |
249 |
| - GL_UNSIGNED_INT_8_8_8_8_REV, /* Native format */ |
250 |
| -#endif |
251 |
| - data); |
252 |
| - |
253 |
| - return data; |
254 |
| -} |
255 |
| - |
256 |
| -#endif |
0 commit comments