From 7e1d4f843cec812df1b7602f3202215e1cd21da8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Robert=20M=C3=BCller?= <[EMAIL REDACTED]>
Date: Thu, 24 Apr 2025 19:57:55 +0200
Subject: [PATCH] Emscripten: fix incorrect error check for WebGL context
creation
According to the documentation and testing the `emscripten_webgl_create_context` function returns `0` on error as oppposed to a negative number. This was causing the error message to be empty when the later `emscripten_webgl_make_context_current` call fails given the invalid context.
See https://emscripten.org/docs/api_reference/html5.h.html#c.emscripten_webgl_create_context
---
src/video/emscripten/SDL_emscriptenopengles.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/video/emscripten/SDL_emscriptenopengles.c b/src/video/emscripten/SDL_emscriptenopengles.c
index 227cdc55606ad..bb490bb016afb 100644
--- a/src/video/emscripten/SDL_emscriptenopengles.c
+++ b/src/video/emscripten/SDL_emscriptenopengles.c
@@ -101,7 +101,7 @@ SDL_GLContext Emscripten_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *
context = emscripten_webgl_create_context(window_data->canvas_id, &attribs);
- if (context < 0) {
+ if (!context) {
SDL_SetError("Could not create webgl context");
return NULL;
}