this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Initial work on CGS Apple private APIs

+88 -6
+2
src/frameworks/OpenGL/CMakeLists.txt
··· 23 23 GL 24 24 GLU 25 25 EGL 26 + CoreFoundation 27 + CoreGraphics 26 28 ) 27 29 28 30 set_property(TARGET OpenGL APPEND_STRING PROPERTY LINK_FLAGS
+82 -5
src/frameworks/OpenGL/OpenGL.c
··· 5 5 6 6 #include <OpenGL/OpenGL.h> 7 7 #include <OpenGL/CGLInternal.h> 8 + #include <CoreFoundation/CFDictionary.h> 8 9 9 10 // Try to get the right (generic) type definitions. 10 11 // In particular, we really want EGLNativeDisplayType to be void *, ··· 32 33 EGL_NONE 33 34 }; 34 35 36 + struct _CGLDisplay 37 + { 38 + EGLDisplay display; 39 + EGLConfig config; 40 + int num_config; 41 + }; 42 + 43 + static CFMutableDictionaryRef g_displays; 44 + 35 45 struct _CGLContextObj { 36 46 GLuint retain_count; 37 47 pthread_mutex_t lock; ··· 63 73 } 64 74 } 65 75 76 + __attribute__((constructor)) 77 + static void _CGLInitialize(void) 78 + { 79 + g_displays = CFDictionaryCreateMutable(NULL, 0, NULL, NULL); 80 + } 81 + 66 82 static int attributes_count(const CGLPixelFormatAttribute *attrs) { 67 83 int result; 68 84 for (result = 0; attrs[result] != 0; result++) { ··· 89 105 return kCGLNoError; 90 106 } 91 107 108 + static struct _CGLDisplay* getCGLDisplay(CGSConnectionID cid) 109 + { 110 + struct _CGLDisplay* rv = (struct _CGLDisplay*) CFDictionaryGetValue(g_displays, (const void*)(unsigned long) cid); 111 + 112 + if (!rv) 113 + { 114 + EGLDisplay disp = eglGetDisplay(_CGSNativeDisplay(cid)); 115 + if (disp == EGL_NO_DISPLAY) 116 + return NULL; 117 + 118 + rv = (struct _CGLDisplay*) malloc(sizeof(*rv)); 119 + rv->display = disp; 120 + 121 + eglInitialize(rv->display, NULL, NULL); 122 + eglChooseConfig(rv->display, attribute_list, &rv->config, 1, &rv->num_config); 123 + 124 + eglBindAPI(EGL_OPENGL_API); 125 + 126 + CFDictionaryAddValue(g_displays, (const void*)(unsigned long) cid, rv); 127 + } 128 + 129 + return rv; 130 + } 131 + 132 + CGLError CGLSetSurface(CGLContextObj gl, CGSConnectionID cid, CGSWindowID wid, CGSSurfaceID sid) 133 + { 134 + struct _CGLDisplay* disp = getCGLDisplay(cid); 135 + if (!disp) 136 + return kCGLBadConnection; 137 + 138 + EGLNativeWindowType window = (EGLNativeWindowType) _CGSNativeWindowForSurfaceID(cid, wid, sid); 139 + if (!window) 140 + return kCGLBadWindow; 141 + 142 + gl->egl_surface = eglCreateWindowSurface(disp->display, disp->config, window, NULL); 143 + if (gl->egl_surface == EGL_NO_SURFACE) 144 + return kCGLBadState; 145 + return kCGLNoError; 146 + } 147 + 148 + CGLContextObj CGWindowContextCreate(CGSConnectionID cid, CGSWindowID wid, CFDictionaryRef options) 149 + { 150 + struct _CGLDisplay* disp = getCGLDisplay(cid); 151 + if (!disp) 152 + return NULL; 153 + 154 + EGLNativeWindowType window = (EGLNativeWindowType) _CGSNativeWindowForID(cid, wid); 155 + if (!window) 156 + return NULL; 157 + 158 + CGLContextObj context; 159 + CGLError err = CGLCreateContext(NULL, NULL, &context); 160 + 161 + if (err != kCGLNoError) 162 + return NULL; 163 + 164 + context->egl_surface = eglCreateWindowSurface(disp->display, disp->config, window, NULL); 165 + if (context->egl_surface == EGL_NO_SURFACE) 166 + { 167 + CGLReleaseContext(context); 168 + return NULL; 169 + } 170 + 171 + return context; 172 + } 173 + 92 174 CGLWindowRef CGLGetWindow(void *native_window) { 93 175 94 176 EGLNativeWindowType window = (EGLNativeWindowType) native_window; ··· 243 325 244 326 *resultp = context; 245 327 246 - return kCGLNoError; 247 - } 248 - 249 - CGLError CGLSwapBuffers(CGLWindowRef window) { 250 - eglSwapBuffers(display, window); 251 328 return kCGLNoError; 252 329 } 253 330
+4 -1
src/frameworks/OpenGL/include/OpenGL/CGLInternal.h
··· 2 2 #define _CGL_INTERNAL_H_ 3 3 4 4 #include <OpenGL/OpenGL.h> 5 + #include <CoreGraphics/CoreGraphicsPrivate.h> 6 + #include <CoreFoundation/CFDictionary.h> 5 7 6 8 #ifdef __cplusplus 7 9 extern "C" { ··· 15 17 CGL_EXPORT void CGLDestroyWindow(CGLWindowRef window); 16 18 17 19 CGL_EXPORT CGLError CGLContextMakeCurrentAndAttachToWindow(CGLContextObj context, CGLWindowRef window); 18 - CGL_EXPORT CGLError CGLSwapBuffers(CGLWindowRef window); 20 + CGLError CGLSetSurface(CGLContextObj gl, CGSConnectionID cid, CGSWindowID wid, CGSSurfaceID sid); 21 + CGLContextObj CGWindowContextCreate(CGSConnectionID cid, CGSWindowID wid, CFDictionaryRef options); 19 22 20 23 #ifdef __cplusplus 21 24 }