Open dortamiguel opened 3 years ago
This is a bit complicated. Even though MetalANGLE implements the same OpenGL ES APIs as Apple's. There are differences in the way OpenGL contexts are created (OpenGL context creation API is not part of OpenGL standards, so it's understandable that MetalANGLE and Apple's GL are different in this area). Because SDL creates the OpenGL context for you internally, and SDL currently uses Apple's GL context API, it cannot be used with MetalANGLE atm.
There are some efforts to port MetalANGLE to SDL https://github.com/libsdl-org/SDL/pull/4333 or you can use his SDL fork here. Besides I think @elix22's Urho3d fork also has some modifications to make SDL work with MetalANGLE (perhaps without modifying SDL itself). Perhaps SDL already has supports for EGL context API which MetalANGLE implemented. @elix22 pls let us know if you have any insights, it would be a great help, thanks.
Can MetalAngle be used with a Metal context created in GLFW?
After some research I noticed that SDL can be used with MetalANGLE. However, you need to compile SDL with these flags:
SDL_VIDEO_OPENGL_CGL=0
SDL_VIDEO_OPENGL=0
SDL_VIDEO_OPENGL_EGL=1
SDL_VIDEO_OPENGL_ES2=1
Note: you can only use OpenGL ES API (not full Desktop OpenGL APIs) in this case.
And need to set DYLD_LIBRARY_PATH
env to point to directory containing libEGL.dylib
& libGLESv2.dylib
before starting the app so that SDL can dynamically load these libraries when creating OpenGL context.
Can MetalAngle be used with a Metal context created in GLFW?
@MikeHart66 MetalANGLE can interoperate with Metal context created in GLFW. i.e. MetalANGLE and Metal can both draw to a shared metal texture. This requires some knowledge about Metal though. I can create an example some time later if you need.
I've been prototyping a (potentially worse) way to do this in one of my apps. The approach is to take an SDL window and add an MGLLayer into it:
https://github.com/TrajansRow/alephone/blob/angle/Source_Files/RenderOther/MacOSHelper.mm
Can MetalAngle be used with a Metal context created in GLFW?
@MikeHart66 MetalANGLE can interoperate with Metal context created in GLFW. i.e. MetalANGLE and Metal can both draw to a shared metal texture. This requires some knowledge about Metal though. I can create an example some time later if you need.
Of course it would help tremendously. But we don't need to draw from Metal and MetalAngle. Currently we use Glfw for setting up the context for OpenGl and use OpenGl ES2 to draw stuff.
Hi, I have and OpenGL app using SDL and I will like to try metalangle
I downloaded the MetalANGLE.dylib.mac.zip file but I'm not sure how I'm supposed to use it.
The headers is easy, I just include them, but, what I do with this dylib files?
I should include them all?
After including the headers, and linking the dylib files. Should I do something special to start using OpenGL on the app?
The only thing I can get is a black screen