From 9bd6cb9cc8ee5a3cea4a80c82910ae64563d5aa9 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Wed, 24 Jul 2024 08:05:03 +0200 Subject: [PATCH] retry wglMakeCurrent up to 5 times on failure --- src/render_ogl.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/render_ogl.c b/src/render_ogl.c index 84ec194..9dc8770 100644 --- a/src/render_ogl.c +++ b/src/render_ogl.c @@ -54,12 +54,14 @@ DWORD WINAPI ogl_render_main(void) Sleep(250); g_ogl.got_error = g_ogl.use_opengl = FALSE; - BOOL made_current = xwglMakeCurrent(g_ogl.hdc, g_ogl.context); - if (!made_current) + BOOL made_current = FALSE; + + for (int i = 0; i < 5; i++) { - /* make sure we retry at least once */ + if ((made_current = xwglMakeCurrent(g_ogl.hdc, g_ogl.context))) + break; + Sleep(50); - made_current = xwglMakeCurrent(g_ogl.hdc, g_ogl.context); } if (made_current && glGetError() == GL_NO_ERROR)