Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use EGL in OSX?

I am trying to use Cairo library in a C++ application utilizing its GL acceleration in Mac. (I made same tests with its Quartz backend but the performance was disappointing.) It says it supports EGL and GLX. Use of GLX requires (externally installed) XQuartz and opens an XWindow so I lean towards EGL:

Apple's programming guide pages tell to use NSOpenGL*, which this page and others say it uses CGL.

This (2012) page says Mac has EAGL and it is only similar to EGL (I suppose it refers to IOS, not MAC as its EAGL reference links to IOS help pages).

Angle says it supports EGL but it is for Direct3D in windows, as I understand(?)

GLFW v3 is also said to support (in future releases?) but via GLX, it is said (?).

Mali says it has a simulator for Mac but I don't know if it is accelerated or is only for its hardware (it also says it only supports a subset of EGL on different platforms).

Most of the links refer to mobile when EGL is used. I am using Mac OS 10.8 and XCode 4.6. What is the current situation / How can I (if I can) use EGL in Mac (now)?

like image 283
user3648895 Avatar asked May 23 '14 19:05

user3648895


1 Answers

Here it is https://github.com/SRA-SiliconValley/cairogles/

clone cairo, checkout branch nsgl. This cairo is our fork of cairo 1.12.14 that has the following enhancement vs the upstream cairo

  1. support OpenGL ES 3.0, and support OpenGL ES 2.0 angle MSAA extension
  2. new convex tessellator for fill circle for msaa compositor
  3. new cairo API - cairo_rounded_rectangle() - it is optimized for MSAA compositor
  4. support gaussian blur for four backends: GL/GLES, quartz, xcb and image
  5. support drop shadow and inset for four backends: GL/GLES, quartz, xcv and image with shaow cache
  6. support faster stroke when stroke width = 1 - we call hairline stroke
  7. add integration for NSOpenGL
  8. various bug fixes and optimization.

On Mac OSX, you have two choices: GLX or NSOpenGL - they are mutually exclusive. You can get mesa glx from macport. 1. To compile for NSOpenGL - ./configure --prefix=your_install_location --enable-gl=yes --enable-nsgl=yes --enable-glx=no --enable-egl=no

  1. To compile for GLX - ./configure --prefix=your_install_location --enable-gl=yes --enable-glx=yes --enable-nsgl=no --enable-egl=no.

If you are interested in egl (no available on mac, but mesa 9.1+ on linux and various embedded platform form has egl) do ./configure --prefix=your_install_location --enable-gl=no --enable-egl=yes --enable-glesv2=yes --enable-glesv3= no ===== this compiles for gles2 drivers.

./confgure --prefix=your_install_location --enable-gl=no --enable-egl=yes --enable-glesv2=no --enable-glesv3=yes ==== this compiles for glesv3 driver (mesa 9.1+ has glesv3)

you can have CFLAGS="-g" for debug or CFLAGS="-O2" for optimization.

cairo gl/gles has 3 GL compositors (rendering paths for GL/GLES backend). The default one is span compositor which is software simulation of AA and is slow. If your driver supports MSAA, use msaa compositor. To use MSAA compositor, you can export CAIRO_GL_COMPOSITOR=msaa in terminal, or you can setenv() in your program.

I have sample code to show cairo for quartz, xcv, image, glx, gel or nsgl. If you are interested, I can send you.

Any bug reports/patches are welcome. I have not have time to get wgl (MS windows) to work yet. Additional, it would be nice to have a d3d backend for cairo, I just don't have time to do that - on the todo list.

Enjoy

like image 159
henry Avatar answered Oct 23 '22 11:10

henry