gl_common: don't use GL4 feature

glGetIntegerv(GL_NUM_EXTENSIONS) is only available since GL4.

(However glGetStringi(GL_EXTENSIONS) is available since GL3)

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2019-05-16 02:19:48 +01:00
parent 2d50d32bf7
commit 3cabba6161
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
1 changed files with 11 additions and 9 deletions

View File

@ -175,24 +175,26 @@ static inline void gl_check_err_(const char *func, int line) {
}
}
static inline void gl_clear_err(void) {
while (glGetError() != GL_NO_ERROR);
}
#define gl_check_err() gl_check_err_(__func__, __LINE__)
/**
* Check if a GLX extension exists.
*/
static inline bool gl_has_extension(const char *ext) {
GLint nexts = 0;
glGetIntegerv(GL_NUM_EXTENSIONS, &nexts);
if (!nexts) {
log_error("Failed to get GL extension list.");
return false;
}
for (int i = 0; i < nexts; i++) {
for (int i = 0; ; i++) {
const char *exti = (const char *)glGetStringi(GL_EXTENSIONS, (GLuint)i);
if (strcmp(ext, exti) == 0)
if (exti == 0) {
break;
}
if (strcmp(ext, exti) == 0) {
return true;
}
}
gl_clear_err();
log_info("Missing GL extension %s.", ext);
return false;
}