kakashidinho / metalangle

MetalANGLE: OpenGL ES to Metal API translation layer
Other
462 stars 65 forks source link

Header file and link lib #57

Closed mb12 closed 3 years ago

mb12 commented 3 years ago

Can you please kindly confirm whether the following is correct (or not) esp. point 2?

1.) The calling application should include#include <MetalANGLE/GLES3/gl3.h> and link against MetalANGLE.framework 2.) The calling application should NOT link against Metal.Framework and OpenGlES.framework. <== Can you please confirm this?This would ensure that all gl* calls resolve with Metal.Framework, which would internally dispatch them to either opengl or metal

Question regarding calling using function pointers I have a current application that makes opengl calls using function pointers. On iOS these are initialized like this. void ( const glBindBuffer)(GLenum, GLuint) = ::glBindBuffer On desktop these are initialized like this. void ( const glBindBuffer)(GLenum, GLuint) = [](auto... args) { return QOpenGLContext::currentContext()->functions()->glBindBuffer(args...); };

*_If I like the application only against Metal.Framework, would all the gl functions resolve correctly at link time?_**

kakashidinho commented 3 years ago

Hi,

  1. Yes, you should #include <MetalANGLE/GLES3/gl3.h> and link against MetalANGLE.framework. But you need to modify your opengl context initialization code as well, since MetalANGLE's context creation is a bit different from Apple's OpenGL/ES.
  2. Linking against Metal.framework is fine, but don't link against OpenGLES.framework. The latter would cause incorrect gl* symbols to be resolved.
  3. If you are using function pointers, and link against MetalANGLE.framework, assigning function pointers to exact symbols like ::glBindBuffer will work, they will point to correct functions inside MetalANGLE.framework. If you link against OpenGLES.framework, these direct symbols would incorrectly point to Apple's gl functions. However you can use MetalANGLE's eglGetProcAddress to obtain true pointer to a gl function inside MetalANGLE.framework.
mb12 commented 3 years ago

Thank you very much for adding eglGetProcAddress in Metal Angle. I am able to get the right function pointers using this API.