Commit 74174dd5d650ee82250724ff0d96d44c7647ff38

  • avatar
  • Chia-I Wu <olvaffe @gm…l.com>
  • Tue Sep 29 12:19:50 CEST 2009
egl: Better report of driver loading error.
  
116116 suffix = "dll";
117117#else /* _EGL_PLATFORM_NO_OS */
118118 if (path) {
119 /* force the use of the default driver */
120 _eglLog(_EGL_DEBUG, "ignore EGL_DRIVER");
119121 free(path);
120122 path = NULL;
121123 }
156156static _EGLMain_t
157157_eglOpenLibrary(const char *driverPath, lib_handle *handle)
158158{
159 _EGLMain_t mainFunc;
160159 lib_handle lib;
160 _EGLMain_t mainFunc = NULL;
161 const char *error = "unknown error";
161162
162163 assert(driverPath);
163164
164#if defined(_EGL_PLATFORM_WINDOWS)
165 /* XXX untested */
166165 _eglLog(_EGL_DEBUG, "dlopen(%s)", driverPath);
167166 lib = open_library(driverPath);
168 if (!lib) {
169 _eglLog(_EGL_WARNING, "Could not open %s",
170 driverPath);
171 return NULL;
172 }
173 mainFunc = (_EGLMain_t) GetProcAddress(lib, "_eglMain");
167
168#if defined(_EGL_PLATFORM_WINDOWS)
169 /* XXX untested */
170 if (lib)
171 mainFunc = (_EGLMain_t) GetProcAddress(lib, "_eglMain");
174172#elif defined(_EGL_PLATFORM_X)
175 _eglLog(_EGL_DEBUG, "dlopen(%s)", driverPath);
176 lib = open_library(driverPath);
177 if (!lib) {
178 _eglLog(_EGL_WARNING, "Could not open %s (%s)",
179 driverPath, dlerror());
180 if (!getenv("EGL_DRIVER"))
181 _eglLog(_EGL_WARNING,
182 "The driver can be overridden by setting EGL_DRIVER");
183 return NULL;
173 if (lib) {
174 mainFunc = (_EGLMain_t) dlsym(lib, "_eglMain");
175 if (!mainFunc)
176 error = dlerror();
184177 }
185 mainFunc = (_EGLMain_t) dlsym(lib, "_eglMain");
178 else {
179 error = dlerror();
180 }
186181#else /* _EGL_PLATFORM_NO_OS */
187 lib = 0;
188 /* must be default driver name */
182 /* must be the default driver name */
189183 if (strcmp(driverPath, DefaultDriverName) == 0)
190184 mainFunc = (_EGLMain_t) _eglMain;
191185 else
192 mainFunc = NULL;
186 error = "not builtin driver";
193187#endif
194188
189 if (!lib) {
190 _eglLog(_EGL_WARNING, "Could not open driver %s (%s)",
191 driverPath, error);
192 if (!getenv("EGL_DRIVER"))
193 _eglLog(_EGL_WARNING,
194 "The driver can be overridden by setting EGL_DRIVER");
195 return NULL;
196 }
197
195198 if (!mainFunc) {
196 _eglLog(_EGL_WARNING, "_eglMain not found in %s", driverPath);
199 _eglLog(_EGL_WARNING, "_eglMain not found in %s (%s)",
200 driverPath, error);
197201 if (lib)
198202 close_library(lib);
199203 return NULL;