-
- GLint agl_attrs[] = {
- AGL_RGBA,
- AGL_DOUBLEBUFFER,
- AGL_DEPTH_SIZE, 16,
- 0 };
- AGLPixelFormat aglpixf = aglChoosePixelFormat (NULL, 0, agl_attrs);
- AGLContext ctx = aglCreateContext (aglpixf, NULL);
- aglDestroyPixelFormat (aglpixf);
- if (! ctx) {
- check_gl_error("aglCreateContext");
- abort();
- }
-
- if (! aglSetDrawable (ctx, GetWindowPort ([[view window] windowRef]))) {
- check_gl_error("aglSetDrawable");
- abort();
- }
+ NSOpenGLContext *ctx = [view oglContext];
+
+ if (!ctx) {
+
+ NSOpenGLPixelFormatAttribute attrs[40];
+ int i = 0;
+ attrs[i++] = NSOpenGLPFAColorSize; attrs[i++] = 24;
+ attrs[i++] = NSOpenGLPFAAlphaSize; attrs[i++] = 8;
+ attrs[i++] = NSOpenGLPFADepthSize; attrs[i++] = 16;
+
+ if (get_boolean_resource (mi->dpy, "doubleBuffer", "DoubleBuffer"))
+ attrs[i++] = NSOpenGLPFADoubleBuffer;
+
+ Bool ms_p = get_boolean_resource (mi->dpy, "multiSample", "MultiSample");
+
+ /* Sometimes, turning on multisampling kills performance. At one point,
+ I thought the answer was, "only run multisampling on one screen, and
+ leave it turned off on other screens". That's what this code does,
+ but it turns out, that solution is insufficient. I can't really tell
+ what causes poor performance with multisampling, but it's not
+ predictable. Without changing the code, some times a given saver will
+ perform fine with multisampling on, and other times it will perform
+ very badly. Without multisampling, they always perform fine.
+ */
+// if (ms_p && [[view window] screen] != [[NSScreen screens] objectAtIndex:0])
+// ms_p = 0;
+
+ if (ms_p) {
+ attrs[i++] = NSOpenGLPFASampleBuffers; attrs[i++] = 1;
+ attrs[i++] = NSOpenGLPFASamples; attrs[i++] = 6;
+ // Don't really understand what this means:
+ // attrs[i++] = NSOpenGLPFANoRecovery;
+ }