ES3, SDL & Emscripten

60 views
Skip to first unread message

キャロウ マーク

unread,
Jul 19, 2019, 8:38:19 PM7/19/19
to emscripten-discuss
I have an app that uses OpenGL ES3 and SDL2. When I try to run it I get "Could not create GLES window surface” which is coming from SDL. The app works fine natively on iOS, macOS, Linux and Windows. I’m having trouble getting source map debugging set up so am struggling a bit to figure out what’s wrong. Does anyone have any thoughts?

Regards

-Mark

signature.asc

キャロウ マーク

unread,
Jul 19, 2019, 9:40:17 PM7/19/19
to emscripten-discuss


On Jul 19, 2019, at 17:38, キャロウ マーク <git...@callow.im> wrote:

I have an app that uses OpenGL ES3 and SDL2. When I try to run it I get "Could not create GLES window surface” which is coming from SDL. The app works fine natively on iOS, macOS, Linux and Windows. I’m having trouble getting source map debugging set up so am struggling a bit to figure out what’s wrong. Does anyone have any thoughts?


Here is the SDL_CreateWindow call that is failing.

    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASKSDL_GL_CONTEXT_PROFILE_ES);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
    SDL_GL_SetAttribute(SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, 1);
#if defined(DEBUG)
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);
#endif
    
    pswMainWindow = SDL_CreateWindow(
                        szName,
                        SDL_WINDOWPOS_UNDEFINED,
                        SDL_WINDOWPOS_UNDEFINED,
                        w_width, w_height,
                        SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE
                    );



signature.asc

キャロウ マーク

unread,
Jul 22, 2019, 1:44:48 PM7/22/19
to emscripten-discuss


On Jul 19, 2019, at 18:40, キャロウ マーク <git...@callow.im> wrote:

Here is the SDL_CreateWindow call that is failing.

    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASKSDL_GL_CONTEXT_PROFILE_ES);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
    SDL_GL_SetAttribute(SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, 1);
#if defined(DEBUG)
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);
#endif
    
    pswMainWindow = SDL_CreateWindow(
                        szName,
                        SDL_WINDOWPOS_UNDEFINED,
                        SDL_WINDOWPOS_UNDEFINED,
                        w_width, w_height,
                        SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE
                    );

SDL_GL_FRAMEBUFFER_SRGB_CAPABLE and SDL_GL_CONTEXT_DEBUG_FLAG are the issues here. Except they shouldn’t be. The SDL_GL_SetAttribute documentation says these settings are *requests* and apps must use SDL_GL_GetAttribute after window and context creation to see if those features are available. It looks like a bug in the Emscripten SDL2 port that window creation is failing.

Regards

    -Mark
signature.asc

Gabriel Cuvillier

unread,
Jul 23, 2019, 1:22:20 AM7/23/19
to emscripte...@googlegroups.com

Hi,

I had a similar issue, and it is probably a bug:

With the SDL2 port to Emscripten, most SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS*) calls after SDL_GL_CONTEXT_PROFILE_MASK and MAJOR/MINOR will make things fail...

So you need to remove SDL_GL_CONTEXT_FLAGS call, and probably the SDL_GL_FRAMEBUFFER_SRGB_CAPABLE (or put it before the calls to PROFILE_MASK/MAJOR/MINOR)

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/DEA50B6B-ACD8-4F1C-AFFF-E2A8944435C2%40callow.im.

キャロウ マーク

unread,
Jul 23, 2019, 1:29:01 PM7/23/19
to emscripten-discuss


On Jul 22, 2019, at 22:22, Gabriel Cuvillier <gabriel....@gmail.com> wrote:

Hi,

I had a similar issue, and it is probably a bug:

With the SDL2 port to Emscripten, most SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS*) calls after SDL_GL_CONTEXT_PROFILE_MASK and MAJOR/MINOR will make things fail...

So you need to remove SDL_GL_CONTEXT_FLAGS call, and probably the SDL_GL_FRAMEBUFFER_SRGB_CAPABLE (or put it before the calls to PROFILE_MASK/MAJOR/MINOR)

Thank you. I removed them for Emscripten builds. WebGL doesn’t support SRGB drawing buffers anyway so removal is no loss. But I may try again with a different order so my code will be the same across platforms.

Regards

    -Mark

signature.asc

キャロウ マーク

unread,
Jul 24, 2019, 12:20:42 AM7/24/19
to emscripten-discuss
On Jul 22, 2019, at 22:22, Gabriel Cuvillier <gabriel....@gmail.com> wrote:

(or put it before the calls to PROFILE_MASK/MAJOR/MINOR)

This doesn’t help. I had to remove them.

signature.asc
Reply all
Reply to author
Forward
0 new messages