summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2022-11-30 19:25:53 -0800
committerVito Caputo <vcaputo@pengaru.com>2022-11-30 19:25:53 -0800
commit1d18b18e06bd0ea38e48265a09d129406a346e87 (patch)
tree9cfd378d2862a51ae59d32a2400fa882b913b3b5
parent5d205a850b85a5ad003d8a6fd9671d6aa4196b82 (diff)
sars: only request a real GLES2 context on emscripten
On MacOS the window create can't even succeed when requesting the GLES2 context. Seeing as this GLES2 transition was done just to get emscripten support, let's limit requesting an actual GLES2 context to the emscripten builds, and still request the same old GL2.1 context as pre-emscripten for everything else. It's unclear to me if this will actually work on win/macos, since the code is still all targeting the GLES2 API - even the glad abstraction is the GLES2 variant. But the thing is, GLES2 API is largely just a subset of GL2.1, in some ways it's a cleanup of GL2.1 like removing a bunch of the fixed function stuff I never used anyways. The main annoyance with GLES2 is the shader language version is older than GL2.1 supports. But if I can live with constraining my API/shader usage to GLES2 land, it might just work on GL2.1 contexts without modifications.
-rw-r--r--src/sars.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/sars.c b/src/sars.c
index b43eb6b..47572df 100644
--- a/src/sars.c
+++ b/src/sars.c
@@ -269,12 +269,26 @@ static void * sars_init(play_t *play, int argc, char *argv[], unsigned flags)
/* TODO: add --fullscreen? */
}
+#ifdef __EMSCRIPTEN__
+/* XXX only request an actual GLES2 context on emscripten,
+ * everywhere else (macos/win/linux) GL2.1 seems to be far more reliably available.
+ * Let's just hope limiting our API/shader use to GLES2 can be a happy compromise on
+ * a GL2.1 context - apparently it's largely a subset of GL2.1.
+ */
fatal_if(SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES) < 0,
"Unable to set GL core profile attribute");
fatal_if(SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2) < 0,
"Unable to set GL major version attribute");
fatal_if(SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0) < 0,
"Unable to set GL minor version attribute");
+#else
+ fatal_if(SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY) < 0,
+ "Unable to set GL core profile attribute");
+ fatal_if(SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2) < 0,
+ "Unable to set GL major version attribute");
+ fatal_if(SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1) < 0,
+ "Unable to set GL minor version attribute");
+#endif
fatal_if(SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1) < 0,
"Unable to set GL doublebuffer attribute");
© All Rights Reserved