| 108 | |
| 109 | |
| 110 | void findVisual(int bpc) |
| 111 | { |
| 112 | int winattribs[] = { GLX_RGBA, GLX_RED_SIZE, bpc, GLX_GREEN_SIZE, bpc, |
| 113 | GLX_BLUE_SIZE, bpc, None, None, None }; |
| 114 | int winattribsdb[] = { GLX_RGBA, GLX_DOUBLEBUFFER, GLX_RED_SIZE, bpc, |
| 115 | GLX_GREEN_SIZE, bpc, GLX_BLUE_SIZE, bpc, None, None, None }; |
| 116 | |
| 117 | int pbattribs[] = { GLX_RED_SIZE, bpc, GLX_GREEN_SIZE, bpc, |
| 118 | GLX_BLUE_SIZE, bpc, GLX_RENDER_TYPE, GLX_RGBA_BIT, |
| 119 | GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT, None, None, None }; |
| 120 | int pbattribsdb[] = { GLX_DOUBLEBUFFER, 1, GLX_RED_SIZE, bpc, |
| 121 | GLX_GREEN_SIZE, bpc, GLX_BLUE_SIZE, bpc, GLX_RENDER_TYPE, GLX_RGBA_BIT, |
| 122 | GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT, None, None, None }; |
| 123 | GLXFBConfig *fbconfigs = NULL; int nelements = 0; |
| 124 | |
| 125 | // Use GLX 1.1 functions here in case we're remotely displaying to |
| 126 | // something that doesn't support GLX 1.3 |
| 127 | if(useWindow || usePixmap || useFBO) |
| 128 | { |
| 129 | try |
| 130 | { |
| 131 | if(visualID) |
| 132 | { |
| 133 | XVisualInfo vtemp; int n = 0; |
| 134 | vtemp.visualid = visualID; |
| 135 | v = XGetVisualInfo(dpy, VisualIDMask, &vtemp, &n); |
| 136 | if(!v || !n) THROW("Could not obtain visual"); |
| 137 | printf("Visual = 0x%.2x\n", (unsigned int)v->visualid); |
| 138 | return; |
| 139 | } |
| 140 | if(useAlpha) |
| 141 | { |
| 142 | winattribs[7] = GLX_ALPHA_SIZE; winattribs[8] = 32 - bpc * 3; |
| 143 | winattribsdb[8] = GLX_ALPHA_SIZE; winattribsdb[9] = 32 - bpc * 3; |
| 144 | } |
| 145 | if(!(v = glXChooseVisual(dpy, DefaultScreen(dpy), winattribs)) |
| 146 | && !(v = glXChooseVisual(dpy, DefaultScreen(dpy), winattribsdb))) |
| 147 | THROW("Could not obtain Visual"); |
| 148 | printf("Visual = 0x%.2x\n", (unsigned int)v->visualid); |
| 149 | return; |
| 150 | } |
| 151 | catch(...) |
| 152 | { |
| 153 | if(v) { XFree(v); v = NULL; } |
| 154 | throw; |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | if(useAlpha) |
| 159 | { |
| 160 | pbattribs[10] = GLX_ALPHA_SIZE; pbattribs[11] = 32 - bpc * 3; |
| 161 | pbattribsdb[12] = GLX_ALPHA_SIZE; pbattribsdb[13] = 32 - bpc * 3; |
| 162 | } |
| 163 | fbconfigs = glXChooseFBConfig(dpy, DefaultScreen(dpy), pbattribs, |
| 164 | &nelements); |
| 165 | if(!fbconfigs) fbconfigs = glXChooseFBConfig(dpy, DefaultScreen(dpy), |
| 166 | pbattribsdb, &nelements); |
| 167 | if(!nelements || !fbconfigs) |
no test coverage detected