Finding eglCreateWindowSurface fail cause?

170 views
Skip to first unread message

Noel Dillabough

unread,
Jan 7, 2022, 11:35:54 AM1/7/22
to angleproject
I have a very simple GLES program that draws a texture on Mac; however eglCreateWindowSurface is returning NULL.

I am passing this from an NSView: (__bridge EGLNativeWindowType)self); 

eglGetDisplay, eglInitialize, chooseConfig, and eglCreateContext are all working as expected.  

2022-01-06 18:31:57.677 [INFO] GLWindow.cpp(60)create: eglInit: version 5.5, Red: 8, Green: 8, Blue: 8, Alpha: 8, Depth: 24

2022-01-06 18:31:57.677 [ERROR] GLWindow.cpp(93)createSurface: Failed to create GLWindow surface.

Does anyone have any tips to figure out the cause?  I've tried passing [self window] from the NSView, but no change.  Note this program works as is with PowerVR SDK so I'm thinking its got to be something very simple.

Any help is appreciated!

-Noel


Hamish Arblaster

unread,
Jan 8, 2022, 5:06:00 PM1/8/22
to angleproject
I recommend using MetalANGLE on macOS & iOS to make your life easier (https://github.com/kakashidinho/metalangle).
It can also run on Metal rather than OpenGL, and I have found it to be much faster for most applications on macOS.
I'm not sure what to put in for eglCreateWindowSurface, but I thought I had to use the NSLayer on macOS when I was trying to use google/angle, so maybe try that if you don't want to use MetalANGLE.

Geoff Lang

unread,
Jan 10, 2022, 9:29:16 AM1/10/22
to hama...@gmail.com, angleproject
ANGLE expects a CALayer for the window parameter. I believe you need to make a CALayer-backed NSView and pass the layer into ANGLE. You can see an example of this here: https://source.chromium.org/chromium/chromium/src/+/main:third_party/angle/util/osx/OSXWindow.mm. We use the result of OSXWindow::getNativeWindow() as the window param when calling eglCreateWindowSurface.

MetalANGLE has been upstreamed into the ANGLE repository. New development has all been upstream for a while, so I would recommend using the upstream repository now.

To debug issues like this in general, you can use the EGL_KHR_debug extension to get error message callbacks.



--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/angleproject/31b8a1a6-d682-4494-aa2e-27c1abe5324an%40googlegroups.com.

Hamish Arblaster

unread,
Jan 10, 2022, 2:49:16 PM1/10/22
to angleproject
I still use MetalANGLE because it is apparently faster and it also has the MGLKit API that is an absolute must-have for me (https://github.com/kakashidinho/metalangle#differences-between-metalangle-and-googles-angle). If the MGLKit API were brought into ANGLE, I would switch to using actual ANGLE again. Also, according to MetalANGLE there are some changes that reduce performance, but increase conformance, perhaps it would be nice if they could be disabled with a context flag or something to regain the performance (I'm unsure how much is actually lost).
Also, in addition to all of that though, ANGLE doesn't support iOS, whereas MetalANGLE does, so if you were wanting to make an iOS app with ANGLE, you may as well use the easier MetalANGLE on macOS since you'd be forced to use it on iOS.
Note: I actually use my own modified MetalANGLE since I have some problems with some of its apis. My branch supports switching GPU on the fly by creating a new context and specifying it, I'd love to see this in ANGLE and MetalANGLE (currently they pick one initially and I think you're stuck with it when using the Metal backend), but I have no idea how to implement the switch with flags for eglCreateContext, so some changes would need to be made to my method. I also changed some of the apis in MetalANGLE's MGLKit since eg. they only support integer framerate, I changed it to a double.

Hamish Arblaster

unread,
Jan 10, 2022, 2:51:36 PM1/10/22
to angleproject
Also, I didn't know about EGL_KHR_debug, so thankyou for that :)
Reply all
Reply to author
Forward
0 new messages