15 {
16 CGLPixelFormatAttribute attributes[] = {
17
18 kCGLPFAOpenGLProfile,
19 (CGLPixelFormatAttribute) kCGLOGLPVersion_3_2_Core,
20 kCGLPFADoubleBuffer,
21 (CGLPixelFormatAttribute)NULL
22 };
23
24 CGLPixelFormatObj pixFormat;
25 GLint npix;
26 CGLChoosePixelFormat(attributes, &pixFormat, &npix);
27 if (nullptr == pixFormat) {
28 printf(
"CGLChoosePixelFormat failed.");
29 return false;
30 }
31
32 CGLContextObj context;
33 CGLCreateContext(pixFormat, nullptr, &context);
34 CGLReleasePixelFormat(pixFormat);
35
36 if (!context) {
37 printf(
"CGLCreateContext failed.");
38 return false;
39 }
40
41 CGLSetCurrentContext(context);
42 return true;
43}
std::string printf(const char *fmt,...) SK_PRINTF_LIKE(1