| 54 | |
| 55 | |
| 56 | void GLFrame::init(void) |
| 57 | { |
| 58 | XVisualInfo *v = NULL; |
| 59 | |
| 60 | try |
| 61 | { |
| 62 | pf = pf_get(PF_RGB); |
| 63 | XWindowAttributes xwa; |
| 64 | memset(&xwa, 0, sizeof(xwa)); |
| 65 | XGetWindowAttributes(dpy, win, &xwa); |
| 66 | XVisualInfo vtemp; int n = 0; |
| 67 | if(!xwa.visual) THROW("Could not get window attributes"); |
| 68 | vtemp.visualid = xwa.visual->visualid; |
| 69 | int maj_opcode = -1, first_event = -1, first_error = -1; |
| 70 | if(!XQueryExtension(dpy, "GLX", &maj_opcode, &first_event, &first_error) |
| 71 | || maj_opcode < 0 || first_event < 0 || first_error < 0) |
| 72 | THROW("GLX extension not available"); |
| 73 | if(!(v = XGetVisualInfo(dpy, VisualIDMask, &vtemp, &n)) || n == 0) |
| 74 | THROW("Could not obtain visual"); |
| 75 | if(!(ctx = glXCreateContext(dpy, v, NULL, True))) |
| 76 | THROW("Could not create GLX context"); |
| 77 | XFree(v); v = NULL; |
| 78 | } |
| 79 | catch(...) |
| 80 | { |
| 81 | if(dpy && ctx) |
| 82 | { |
| 83 | glXMakeCurrent(dpy, 0, 0); glXDestroyContext(dpy, ctx); ctx = 0; |
| 84 | } |
| 85 | if(v) XFree(v); |
| 86 | if(dpy) |
| 87 | { |
| 88 | XCloseDisplay(dpy); dpy = NULL; |
| 89 | } |
| 90 | throw; |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | |
| 95 | GLFrame::~GLFrame(void) |
no test coverage detected