| 184 | |
| 185 | |
| 186 | Display *init3D(void) |
| 187 | { |
| 188 | init(); |
| 189 | |
| 190 | if(!dpy3D) |
| 191 | { |
| 192 | GlobalCriticalSection::SafeLock l(globalMutex); |
| 193 | if(!dpy3D) |
| 194 | { |
| 195 | if(fconfig.egl) |
| 196 | { |
| 197 | int numDevices = 0, i, validDevices = 0; |
| 198 | const char *exts = NULL; |
| 199 | EGLDeviceEXT *devices = NULL; |
| 200 | |
| 201 | if(fconfig.verbose) |
| 202 | vglout.println("[VGL] Opening EGL device %s", |
| 203 | strlen(fconfig.localdpystring) > 0 ? |
| 204 | fconfig.localdpystring : "(default)"); |
| 205 | |
| 206 | try |
| 207 | { |
| 208 | if(!(exts = _eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS))) |
| 209 | THROW("Could not query EGL extensions"); |
| 210 | if(!strstr(exts, "EGL_EXT_platform_device")) |
| 211 | THROW("EGL_EXT_platform_device extension not available"); |
| 212 | |
| 213 | if(!_eglQueryDevicesEXT(0, NULL, &numDevices) || numDevices < 1) |
| 214 | THROW("No EGL devices found"); |
| 215 | if((devices = |
| 216 | (EGLDeviceEXT *)malloc(sizeof(EGLDeviceEXT) * numDevices)) == NULL) |
| 217 | THROW("Memory allocation failure"); |
| 218 | if(!_eglQueryDevicesEXT(numDevices, devices, &numDevices) |
| 219 | || numDevices < 1) |
| 220 | THROW("Could not query EGL devices"); |
| 221 | for(i = 0; i < numDevices; i++) |
| 222 | { |
| 223 | EGLDisplay edpy = |
| 224 | _eglGetPlatformDisplayEXT(EGL_PLATFORM_DEVICE_EXT, devices[i], |
| 225 | NULL); |
| 226 | if(!edpy || !_eglInitialize(edpy, &eglMajor, &eglMinor)) |
| 227 | continue; |
| 228 | _eglTerminate(edpy); |
| 229 | if(!strcasecmp(fconfig.localdpystring, "egl")) |
| 230 | break; |
| 231 | if(!strncasecmp(fconfig.localdpystring, "egl", 3)) |
| 232 | { |
| 233 | char temps[80]; |
| 234 | |
| 235 | snprintf(temps, 80, "egl%d", validDevices); |
| 236 | if(!strcasecmp(fconfig.localdpystring, temps)) |
| 237 | break; |
| 238 | } |
| 239 | const char *devStr = |
| 240 | _eglQueryDeviceStringEXT(devices[i], EGL_DRM_DEVICE_FILE_EXT); |
| 241 | if(devStr && !strcmp(devStr, fconfig.localdpystring)) |
| 242 | break; |
| 243 | validDevices++; |
no test coverage detected