SDL2 and ANGLE on MacOS

1,100 views
Skip to first unread message

Nick Anderson

unread,
Apr 6, 2019, 6:59:32 AM4/6/19
to angleproject
Hi everyone. I have a cross-platform game I'm working on which I'd like to use ANGLE in both Windows and OSX (it's main targets are native GLES2 on Raspberry Pi and iPhone though).

I've had no problem building and running the ANGLE libraries, samples and tests on both Windows and MacOS. However I'm getting (null) as a result from GL queries of GL_RENDERER, GL_VENDOR etc. on Mac in the SDL application.

2019-04-06 11:53:58.550 voxel[5802:153931] INFO: GL SwapInterval (vsync) : 1
2019-04-06 11:53:58.550 voxel[5802:153931] INFO: Window: 1024, 512
2019-04-06 11:53:58.550 voxel[5802:153931] INFO: Renderer: 1024, 512
2019-04-06 11:53:58.550 voxel[5802:153931] INFO: Logical: 0, 0
2019-04-06 11:53:58.550 voxel[5802:153931] INFO: Using GL Renderer: (null)
2019-04-06 11:53:58.551 voxel[5802:153931] INFO: Using OpenGL version: (null)
2019-04-06 11:53:58.551 voxel[5802:153931] INFO: Using Vendor: (null)
2019-04-06 11:53:58.551 voxel[5802:153931] INFO: Using GLSL version: (null)
2019-04-06 11:53:58.551 voxel[5802:153931] INFO: ------------> -345639520, 32766
2019-04-06 11:53:58.551 voxel[5802:153931] INFO: MAX TEXTURE SIZE: -345639520
2019-04-06 11:53:58.551 voxel[5802:153931] INFO: GL texture allocated with ID: 0
2019-04-06 11:53:58.554 voxel[5802:153931] INFO: Cleaned up SDL_Surface...
2019-04-06 11:53:58.554 voxel[5802:153931] INFO: GL texture allocated with ID: 372523514
2019-04-06 11:53:58.555 voxel[5802:153931] INFO: Cleaned up SDL_Surface...

Sadly, I'm not getting any errors from SDL_Error() to suggest anything is reported as wrong in SDL's startup. Given the ANGLE samples run fine on MacOS, and don't use SDL2, I'm guessing it's something SDL-related?

    if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) < 0) {
        nda
::Err();
   
}
   
else {
#if defined(_WIN32) || defined(__MACOSX__)
        SDL_SetHint
(SDL_HINT_OPENGL_ES_DRIVER, "1"); // Force SDL to use ANGLE for it's OpenGLES2 implementation
#endif
       
        SDL_GL_SetAttribute
(SDL_GL_CONTEXT_EGL, 1);
        SDL_GL_SetAttribute
(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
        SDL_GL_SetAttribute
(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
        SDL_GL_SetAttribute
(SDL_GL_CONTEXT_MINOR_VERSION, 0);

        SDL_SetEventFilter
(HandleAppEvents, NULL);

       
Uint32 windowFlags = SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS;
#if defined(__IPHONEOS__)
        windowFlags
|= SDL_WINDOW_FULLSCREEN | SDL_WINDOW_ALLOW_HIGHDPI;
#endif
       
#if defined(NDEBUG) && ( defined(_WIN32) || defined(__MACOSX__) )
        windowFlags
|= SDL_WINDOW_FULLSCREEN_DESKTOP;
#endif

        gWindow
.reset(SDL_CreateWindow("Game", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 1024, 512, windowFlags));
       
if (!gWindow) {
            nda
::Err();
       
}
       
else {
            gRenderer
.reset(SDL_CreateRenderer(gWindow.get(), -1, SDL_RENDERER_PRESENTVSYNC));
           
if (gRenderer) {
                context
= SDL_GL_CreateContext(gWindow.get());
               
// context seems to be valid here on OSX?


Running "otool -L" on the executable to make sure it's definitely linked against ANGLE

$ otool -L ./voxel
./voxel:
   
@rpath/libGLESv2.dylib (compatibility version 0.0.0, current version 0.0.0)
   
@rpath/libEGL.dylib (compatibility version 0.0.0, current version 0.0.0)
   
/usr/local/opt/libomp/lib/libomp.dylib (compatibility version 5.0.0, current version 5.0.0)
   
@rpath/SDL2.framework/Versions/A/SDL2 (compatibility version 1.0.0, current version 10.0.0)
   
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 23.0.0)
   
@rpath/SDL2_image.framework/Versions/A/SDL2_image (compatibility version 3.0.0, current version 3.2.0)
   
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
   
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.250.1)

It's not the end of the world if I can't use ANGLE in MacOS (can just use GLEW and an ES2 compatibility profile) but curious if anyone has successfully combined ANGLE and SDL2 on MacOS?

Geoff Lang

unread,
Apr 8, 2019, 9:47:02 AM4/8/19
to arkir...@gmail.com, angleproject
My guess is that even though you use SDL_HINT_OPENGL_ES_DRIVER, SDL doesn't know how to load OpenGL ES on Mac.  You may have to look through the SDL code to see what libraries it searches for.

--
You received this message because you are subscribed to the Google Groups "angleproject" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angleproject...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrey Dj

unread,
May 3, 2019, 4:39:07 PM5/3/19
to angleproject

Yes, i used angle with SDL2 & proposed patches described in this topic:

https://groups.google.com/forum/m/#!msg/angleproject/bYx5S4DWDbI/93LlIZspBgAJ

Nick Anderson

unread,
May 5, 2019, 6:36:34 AM5/5/19
to angleproject
HI Andrey,

Thanks for linking those patches, from what I understand these were accepted in SDL 2.0.8, and I'm working with SDL 2.0.9 which seems to include these already?

Is it because the default MacOS SDL release binaries don't include EGL support out of the box?

i.e., should I rebuild SDL from Mercurial on MacOS with different configure arguments (e.g., "-enable_video_opengles")?

Nicholas Anderson

unread,
May 5, 2019, 7:33:20 AM5/5/19
to angleproject

Okay, I'm embarrassed to say that ANGLE support was working all along.

I looked at my project build script and my FindSDL2.cmake was pulling an ancient version of SDL (2.0.4) from a Framework I'd installed in ~/Library/Frameworks rather than the SDL (2.0.9) that I had built locally for /usr/local.

Pays to read ../configure output properly sometimes!

All working great now.

Cheers,
Nick

--
You received this message because you are subscribed to the Google Groups "angleproject" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angleproject...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
-- 
Nick Anderson
www.andersonart.co.uk

Jamie Madill

unread,
May 5, 2019, 10:50:39 PM5/5/19
to arkir...@gmail.com, angleproject
Glad to hear it!
Reply all
Reply to author
Forward
0 new messages