comparison libvo/gl_common.c @ 17019:fd178c06dc84

Also parse glX extension string, makes -vo gl:swapinterval work again on linux
author reimar
date Sat, 19 Nov 2005 14:00:35 +0000
parents 94b70ab52695
children 724353364790
comparison
equal deleted inserted replaced
17018:baf593fcf738 17019:fd178c06dc84
247 } 247 }
248 248
249 /** 249 /**
250 * \brief find the function pointers of some useful OpenGL extensions 250 * \brief find the function pointers of some useful OpenGL extensions
251 * \param getProcAddress function to resolve function names, may be NULL 251 * \param getProcAddress function to resolve function names, may be NULL
252 */ 252 * \param ext2 an extra extension string
253 static void getFunctions(void *(*getProcAddress)(const GLubyte *)) { 253 */
254 static void getFunctions(void *(*getProcAddress)(const GLubyte *),
255 const char *ext2) {
254 const char *extensions = glGetString(GL_EXTENSIONS); 256 const char *extensions = glGetString(GL_EXTENSIONS);
257 if (!extensions) extensions = "";
258 if (!ext2) ext2 = "";
255 if (!getProcAddress) 259 if (!getProcAddress)
256 getProcAddress = setNull; 260 getProcAddress = setNull;
257 GenBuffers = getProcAddress("glGenBuffers"); 261 GenBuffers = getProcAddress("glGenBuffers");
258 if (!GenBuffers) 262 if (!GenBuffers)
259 GenBuffers = getProcAddress("glGenBuffersARB"); 263 GenBuffers = getProcAddress("glGenBuffersARB");
322 ProgramEnvParameter4f = getProcAddress("glProgramEnvParameter4f"); 326 ProgramEnvParameter4f = getProcAddress("glProgramEnvParameter4f");
323 if (!ProgramEnvParameter4f) 327 if (!ProgramEnvParameter4f)
324 ProgramEnvParameter4f = getProcAddress("glProgramEnvParameter4fARB"); 328 ProgramEnvParameter4f = getProcAddress("glProgramEnvParameter4fARB");
325 if (!ProgramEnvParameter4f) 329 if (!ProgramEnvParameter4f)
326 ProgramEnvParameter4f = getProcAddress("glProgramEnvParameter4fNV"); 330 ProgramEnvParameter4f = getProcAddress("glProgramEnvParameter4fNV");
327 if (!extensions || !strstr(extensions, "_swap_control")) 331 if (!strstr(extensions, "_swap_control") && !strstr(ext2, "_swap_control"))
328 SwapInterval = NULL; 332 SwapInterval = NULL;
329 else { 333 else {
330 SwapInterval = getProcAddress("glXSwapInterval"); 334 SwapInterval = getProcAddress("glXSwapInterval");
331 if (!SwapInterval) 335 if (!SwapInterval)
332 SwapInterval = getProcAddress("glXSwapIntervalEXT"); 336 SwapInterval = getProcAddress("glXSwapIntervalEXT");
1001 if (!keep_context) { 1005 if (!keep_context) {
1002 if (*context) 1006 if (*context)
1003 wglDeleteContext(*context); 1007 wglDeleteContext(*context);
1004 *context = new_context; 1008 *context = new_context;
1005 *vinfo = new_vinfo; 1009 *vinfo = new_vinfo;
1006 getFunctions(w32gpa); 1010 getFunctions(w32gpa, NULL);
1007 1011
1008 // and inform that reinit is neccessary 1012 // and inform that reinit is neccessary
1009 return SET_WINDOW_REINIT; 1013 return SET_WINDOW_REINIT;
1010 } 1014 }
1011 return SET_WINDOW_OK; 1015 return SET_WINDOW_OK;
1115 XGetGeometry(mDisplay, vo_window, &root, &tmp, &tmp, 1119 XGetGeometry(mDisplay, vo_window, &root, &tmp, &tmp,
1116 &vo_dwidth, &vo_dheight, &tmp, &tmp); 1120 &vo_dwidth, &vo_dheight, &tmp, &tmp);
1117 } 1121 }
1118 if (!keep_context) { 1122 if (!keep_context) {
1119 void *(*getProcAddress)(const GLubyte *); 1123 void *(*getProcAddress)(const GLubyte *);
1124 const char *(*glXExtStr)(Display *, int);
1120 if (*context) 1125 if (*context)
1121 glXDestroyContext(mDisplay, *context); 1126 glXDestroyContext(mDisplay, *context);
1122 *context = new_context; 1127 *context = new_context;
1123 if (*vinfo) 1128 if (*vinfo)
1124 XFree(*vinfo); 1129 XFree(*vinfo);
1126 getProcAddress = getdladdr("glXGetProcAddress"); 1131 getProcAddress = getdladdr("glXGetProcAddress");
1127 if (!getProcAddress) 1132 if (!getProcAddress)
1128 getProcAddress = getdladdr("glXGetProcAddressARB"); 1133 getProcAddress = getdladdr("glXGetProcAddressARB");
1129 if (!getProcAddress) 1134 if (!getProcAddress)
1130 getProcAddress = getdladdr; 1135 getProcAddress = getdladdr;
1131 getFunctions(getProcAddress); 1136 glXExtStr = getdladdr("glXQueryExtensionsString");
1137 getFunctions(getProcAddress, !glXExtStr ? NULL :
1138 glXExtStr(mDisplay, DefaultScreen(mDisplay)));
1132 1139
1133 // and inform that reinit is neccessary 1140 // and inform that reinit is neccessary
1134 return SET_WINDOW_REINIT; 1141 return SET_WINDOW_REINIT;
1135 } 1142 }
1136 return SET_WINDOW_OK; 1143 return SET_WINDOW_OK;