1
0
Fork 0
mirror of https://github.com/yshui/picom.git synced 2024-11-11 13:51:02 -05:00

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

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__) #define gl_check_err() gl_check_err_(__func__, __LINE__)
/** /**
* Check if a GLX extension exists. * Check if a GLX extension exists.
*/ */
static inline bool gl_has_extension(const char *ext) { static inline bool gl_has_extension(const char *ext) {
GLint nexts = 0; for (int i = 0; ; i++) {
glGetIntegerv(GL_NUM_EXTENSIONS, &nexts);
if (!nexts) {
log_error("Failed to get GL extension list.");
return false;
}
for (int i = 0; i < nexts; i++) {
const char *exti = (const char *)glGetStringi(GL_EXTENSIONS, (GLuint)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; return true;
}
} }
gl_clear_err();
log_info("Missing GL extension %s.", ext); log_info("Missing GL extension %s.", ext);
return false; return false;
} }