this repo has no description
1
fork

Configure Feed

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

Support getting/setting kCGLCPSwapInterval

+25 -2
+25 -2
src/OpenGL/OpenGL.c
··· 37 37 pthread_mutex_t lock; 38 38 EGLContext egl_context; 39 39 EGLSurface egl_surface; 40 + // EGL has no function for getting the current swap interval, 41 + // so we need to save the last set value. The default is 1. 42 + int swap_interval; 40 43 }; 41 44 42 45 struct _CGLPixelFormatObj { ··· 236 239 pthread_mutex_init(&(context->lock), NULL); 237 240 context->egl_context = egl_context; 238 241 context->egl_surface = NULL; 242 + context->swap_interval = 1; 239 243 240 244 *resultp = context; 241 245 ··· 308 312 } 309 313 310 314 CGLError CGLSetParameter(CGLContextObj context, CGLContextParameter parameter, const GLint *value) { 311 - fprintf(stderr, "CGLSetParameter unimplemented\n"); 315 + if (!value) 316 + return kCGLBadAddress; 317 + 318 + if (parameter == kCGLCPSwapInterval) 319 + { 320 + GLint v = *value; 321 + EGLBoolean success = eglSwapInterval(display, v); 322 + if (success) 323 + context->swap_interval = v; 324 + return success ? kCGLNoError : kCGLBadValue; 325 + } 326 + fprintf(stderr, "CGLSetParameter unimplemented for parameter %d\n", parameter); 312 327 return kCGLNoError; 313 328 } 314 329 315 330 CGLError CGLGetParameter(CGLContextObj context, CGLContextParameter parameter, GLint *value) { 316 - fprintf(stderr, "CGLGetParameter unimplemented\n"); 331 + if (!value) 332 + return kCGLBadAddress; 333 + 334 + if (parameter == kCGLCPSwapInterval) 335 + { 336 + *value = context->swap_interval; 337 + return kCGLNoError; 338 + } 339 + fprintf(stderr, "CGLGetParameter unimplemented for parameter %d\n", parameter); 317 340 return kCGLNoError; 318 341 }