| 1295 | |
| 1296 | |
| 1297 | GLXFBConfig getFBConfigFromVisual(Display *dpy, XVisualInfo *vis) |
| 1298 | { |
| 1299 | GLXContext ctx = 0; int temp, fbcid = 0, n = 0; |
| 1300 | GLXFBConfig *configs = NULL, config = 0; |
| 1301 | try |
| 1302 | { |
| 1303 | if(!(ctx = glXCreateContext(dpy, vis, NULL, True))) |
| 1304 | THROWNL("glXCreateNewContext"); |
| 1305 | glXQueryContext(dpy, ctx, GLX_FBCONFIG_ID, &fbcid); |
| 1306 | glXDestroyContext(dpy, ctx); ctx = 0; |
| 1307 | if(!(configs = glXGetFBConfigs(dpy, DefaultScreen(dpy), &n)) || n == 0) |
| 1308 | THROWNL("Cannot map visual to FB config"); |
| 1309 | for(int i = 0; i < n; i++) |
| 1310 | { |
| 1311 | temp = cfgid(dpy, configs[i]); |
| 1312 | if(temp == fbcid) { config = configs[i]; break; } |
| 1313 | } |
| 1314 | XFree(configs); configs = NULL; |
| 1315 | if(!config) THROWNL("Cannot map visual to FB config"); |
| 1316 | return config; |
| 1317 | } |
| 1318 | catch(...) |
| 1319 | { |
| 1320 | if(ctx) glXDestroyContext(dpy, ctx); |
| 1321 | if(configs) XFree(configs); |
| 1322 | throw; |
| 1323 | } |
| 1324 | } |
| 1325 | |
| 1326 | |
| 1327 | #define TEST_ATTRIB(vattribs, cattribs, desc) \ |
no test coverage detected