From 8a794e0ce140925ab901957d1df4546f0ce6e0ee Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sat, 13 Jul 2019 19:30:26 +0100 Subject: [PATCH] Improve the compatibility of gl_has_extension Fix infinite loop when running under RenderDoc Signed-off-by: Yuxuan Shui --- src/backend/gl/gl_common.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/backend/gl/gl_common.h b/src/backend/gl/gl_common.h index f315df1f..f7abd247 100644 --- a/src/backend/gl/gl_common.h +++ b/src/backend/gl/gl_common.h @@ -162,9 +162,11 @@ static inline void gl_clear_err(void) { * Check if a GLX extension exists. */ static inline bool gl_has_extension(const char *ext) { - for (int i = 0; ; i++) { + int nexts = 0; + glGetIntegerv(GL_NUM_EXTENSIONS, &nexts); + for (int i = 0; i < nexts || !nexts; i++) { const char *exti = (const char *)glGetStringi(GL_EXTENSIONS, (GLuint)i); - if (exti == 0) { + if (exti == NULL) { break; } if (strcmp(ext, exti) == 0) {