comparison libvo/gl_common.c @ 16111:5683110fce0a

Use dlsym to get glXGetProcAddress, only way to (hopefully) make it compile everywhere since the gl/glx headers are such a mess...
author reimar
date Tue, 26 Jul 2005 18:28:51 +0000
parents 519a307e3ccf
children d280ec2b9e63
comparison
equal deleted inserted replaced
16110:82990d1dce53 16111:5683110fce0a
199 199
200 static void *setNull(const GLubyte *s) { 200 static void *setNull(const GLubyte *s) {
201 return NULL; 201 return NULL;
202 } 202 }
203 203
204 static void *(*getProcAddress)(const GLubyte *procName); 204 static void *(*getProcAddress)(const GLubyte *procName) = NULL;
205 205
206 static void getFunctions() { 206 static void getFunctions() {
207 if (!getProcAddress) 207 if (!getProcAddress)
208 getProcAddress = setNull; 208 getProcAddress = setNull;
209 BindBuffer = getProcAddress("glBindBuffer"); 209 BindBuffer = getProcAddress("glBindBuffer");
324 wglDeleteContext(*context); 324 wglDeleteContext(*context);
325 } 325 }
326 *context = 0; 326 *context = 0;
327 } 327 }
328 #else 328 #else
329 #if defined(__sun) || defined(__sgi)
330 extern void *dlopen(const char *, int);
331 #endif
332 extern void *dlsym(void *, const char *);
333 /**
334 * \brief find address of a linked function
335 * \param s name of function to find
336 * \return address of function or NULL if not found
337 *
338 * Copied from xine
339 */
340 static void *getdladdr(const GLubyte *s) {
341 #if defined(__sun) || defined(__sgi)
342 static void *handle = dlopen(NULL, RTLD_LAZY);
343 return dlsym(handle, s);
344 #else
345 return dlsym(0, s);
346 #endif
347 }
348
329 /** 349 /**
330 * \brief Returns the XVisualInfo associated with Window win. 350 * \brief Returns the XVisualInfo associated with Window win.
331 * \param win Window whose XVisualInfo is returne. 351 * \param win Window whose XVisualInfo is returne.
332 * \return XVisualInfo of the window. Caller must use XFree to free it. 352 * \return XVisualInfo of the window. Caller must use XFree to free it.
333 */ 353 */
401 glXDestroyContext(mDisplay, *context); 421 glXDestroyContext(mDisplay, *context);
402 *context = new_context; 422 *context = new_context;
403 if (*vinfo) 423 if (*vinfo)
404 XFree(*vinfo); 424 XFree(*vinfo);
405 *vinfo = new_vinfo; 425 *vinfo = new_vinfo;
406 #ifdef GLX_ARB_get_proc_address 426 if (!getProcAddress)
407 getProcAddress = (void *)glXGetProcAddressARB; 427 getProcAddress = getdladdr("glXGetProcAddress");
408 #else 428 if (!getProcAddress)
409 getProcAddress = NULL; 429 getProcAddress = getdladdr("glXGetProcAddressARB");
410 #endif 430 if (!getProcAddress)
431 getProcAddress = getdladdr;
411 getFunctions(); 432 getFunctions();
412 433
413 // and inform that reinit is neccessary 434 // and inform that reinit is neccessary
414 return SET_WINDOW_REINIT; 435 return SET_WINDOW_REINIT;
415 } 436 }