We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3975 - Add GLES2 support for macOS via ANGLE library
Summary: Add GLES2 support for macOS via ANGLE library
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.1
Hardware: x86_64 Mac OS X (All)
: P2 enhancement
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-20 20:29 UTC by Andrey
Modified: 2018-03-13 01:41 UTC (History)
2 users (show)

See Also:


Attachments
Add GLESv2 & EGL support for macOS via Goolge ANGLE implementation (7.42 KB, patch)
2017-11-26 10:44 UTC, Andrey
Details | Diff
Add GLESv2 & EGL support for macOS via Goolge ANGLE implementation (40.54 KB, patch)
2017-11-26 10:48 UTC, Andrey
Details | Diff
configure patch (842 bytes, patch)
2018-03-04 19:11 UTC, Andrey
Details | Diff
testgles2 screenshot (2.30 MB, image/png)
2018-03-05 00:23 UTC, AriaMoKr
Details
testgl2 screenshot (1.99 MB, image/png)
2018-03-05 00:23 UTC, AriaMoKr
Details
testgles2 demo (53.03 KB, image/png)
2018-03-06 00:06 UTC, Andrey
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey 2017-11-20 20:29:49 UTC
Seems latest google angle library successfully built & tested under macOS'es.

https://github.com/google/angle

We need to use GLES2 to implement true cross-platform code.
Comment 1 Sam Lantinga 2017-11-22 06:01:06 UTC
It looks like Mac OS X support is a work in progress. Feel free to contribute a tested patch!
Comment 2 Andrey 2017-11-26 10:44:02 UTC
Created attachment 3102 [details]
Add GLESv2 & EGL support for macOS via Goolge ANGLE implementation

Ok, here is it :)
Comment 3 Andrey 2017-11-26 10:48:07 UTC
Created attachment 3103 [details]
Add GLESv2 & EGL support for macOS via Goolge ANGLE implementation
Comment 4 Sam Lantinga 2017-12-05 04:35:19 UTC
Patch added, thanks!
https://hg.libsdl.org/SDL/rev/bc7ca7cfa6ca
Comment 5 Andrey 2017-12-05 09:44:36 UTC
Hi Sam Lantinga !)

There are 2 new files SDL_cocoaopengles.h/.m was added in my patch but they're not has been committed to hg repo.
Comment 6 Ryan C. Gordon 2017-12-06 21:38:51 UTC
I put the two missing files into revision control: https://hg.libsdl.org/SDL/rev/49f8fb4f6ce2

--ryan.
Comment 7 Sam Lantinga 2017-12-06 22:07:26 UTC
Oops, thanks Ryan!
Comment 8 Andrey 2018-02-28 13:49:39 UTC
Please add this improvement in WhatsNew.txt file
Comment 9 Sam Lantinga 2018-02-28 18:17:24 UTC
Can you add a patch with a patch note that you'd like for this? ;)
Comment 10 Sam Lantinga 2018-03-01 16:07:08 UTC
Here's the patch note I added:
Added support for OpenGL ES using ANGLE when it's available
Comment 11 Andrey 2018-03-02 18:50:36 UTC
Thanks!)
Comment 12 Sam Lantinga 2018-03-02 19:21:57 UTC
You're welcome! :)
Comment 13 AriaMoKr 2018-03-03 07:01:34 UTC
It looks like configure isn't adding EGL on MacOS even with ANGLE in place.
INFO: SDL_GL_CreateContext(): SDL not configured with EGL support

I can throw AC_DEFINE(SDL_VIDEO_OPENGL_EGL, 1, [ ]) into CheckMacGL then get:
INFO: SDL_GL_CreateContext(): Could not create EGL context (call to eglCreateContext failed, reporting an error of EGL_BAD_CONFIG)
Comment 14 Andrey 2018-03-04 19:11:30 UTC
Created attachment 3184 [details]
configure patch

Seems SDL_VIDEO_OPENGL_EGL is not enough.
Try to add defines from this patch
Comment 15 AriaMoKr 2018-03-05 00:23:11 UTC
Created attachment 3185 [details]
testgles2 screenshot

post 3184 attachment - screenshot
Comment 16 AriaMoKr 2018-03-05 00:23:52 UTC
Created attachment 3186 [details]
testgl2 screenshot

added for comparison sake
Comment 17 AriaMoKr 2018-03-05 00:25:31 UTC
Thanks Andrey, attachment 3184 [details] resolves the EGL issue in configure.
It now looks like I'm getting only a quarter of the image being displayed in testgles2 comparing to testgl2.

testgles2 https://bugzilla.libsdl.org/attachment.cgi?id=3185
testgl2 https://bugzilla.libsdl.org/attachment.cgi?id=3186
Comment 18 Andrey 2018-03-06 00:04:33 UTC
(In reply to AriaMoKr from comment #17)
> Thanks Andrey, attachment 3184 [details] resolves the EGL issue in configure.
> It now looks like I'm getting only a quarter of the image being displayed in
> testgles2 comparing to testgl2.

Strange, but samples looks fine on my Mac mini late 2012.

Try other samples with '--renderer opengles2' parameter.
Comment 19 Andrey 2018-03-06 00:06:06 UTC
Created attachment 3187 [details]
testgles2 demo
Comment 20 Andrey 2018-03-06 00:16:54 UTC
Try to use this angle library (compiled by me for OSX 10.9 and up few month ago from latest google repo):
https://www.dropbox.com/s/uu3fcsb0bpnskhv/ANGLE_MacOS.zip?dl=0
Comment 21 Andrey 2018-03-06 00:22:51 UTC
May be it's a bug with retina display?
Try to run samples without retina
Comment 22 AriaMoKr 2018-03-07 11:31:04 UTC
Bingo! It looks to be a retina issue, trying with an external (non retina) display works just fine.

I didn't suspect it to be a retina issue earlier because I wasn't the same behavior running testgl2, so maybe something specific to ANGLE.
Running something like testdraw2 with --renderer opengles2 will also show the same bottom left quarter view problem.

Testing disable of retina via "sudo defaults write 
/Library/Preferences/com.apple.windowserver.plist DisplayResolutionEnabled -bool true" didn't seem to work for me (probably High Sierra issue) but I was able to run SwitchResX to give me a non-retina mode and that fixed it as well.

Running the attached libraries didn't change the behavior.
Comment 23 Andrey 2018-03-07 12:22:58 UTC
Also try to pack app to bundle with

<key>NSHighResolutionCapable</key>
<true/>
Comment 24 AriaMoKr 2018-03-11 01:45:44 UTC
I packed the testgles2 into an app bundle and that ended up fixing it even without setting NSHighResolutionCapable (or having to create a Info.plist).

mkdir -p testgles2.app/Contents/MacOS 
cp testgles2 testgles2.app/Contents/MacOS
./testgles2.app/Contents/MacOS/testgles2

seems to work fine, but just ./testgles2 gave me the quarter display issue.
(executing both while in my ~/hg/SDL/test directory).
Comment 25 Andrey 2018-03-12 08:59:09 UTC
(In reply to AriaMoKr from comment #24)

> seems to work fine, but just ./testgles2 gave me the quarter display issue.

Fine!)

Sam Lantinga, please add apply this patch to configure script to enable gles2 support

https://bugzilla.libsdl.org/attachment.cgi?id=3184
Comment 26 Sam Lantinga 2018-03-13 01:41:36 UTC
Added, thanks!
https://hg.libsdl.org/SDL/rev/c808a74c019e