简体   繁体   English

我可以在OSX中使用EGL吗?

[英]Can I use EGL in OSX?

I am trying to use Cairo library in a C++ application utilizing its GL acceleration in Mac. 我试图在C ++应用程序中使用Cairo库,利用它在Mac中的GL加速。 (I made same tests with its Quartz backend but the performance was disappointing.) It says it supports EGL and GLX. (我使用Quartz后端进行了相同的测试,但性能令人失望。)它说它支持EGL和GLX。 Use of GLX requires (externally installed) XQuartz and opens an XWindow so I lean towards EGL: 使用GLX需要(外部安装) XQuartz并打开一个XWindow,所以我倾向于EGL:

Apple's programming guide pages tell to use NSOpenGL*, which this page and others say it uses CGL. Apple的编程指南页面告诉我们使用NSOpenGL *, 这个页面和其他人说它使用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). 这个 (2012)页面说Mac有EAGL,它只与EGL类似(我想它指的是IOS,而不是MAC,因为它的EAGL参考链接到IOS帮助页面)。

Angle says it supports EGL but it is for Direct3D in windows, as I understand(?) Angle说它支持EGL但它适用于Windows中的Direct3D,据我所知(?)

GLFW v3 is also said to support (in future releases?) but via GLX, it is said (?). 据说GLFW v3支持(在未来的版本中?)但是通过GLX,它被称为(?)。

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). Mali表示它有一个适用于Mac的模拟器,但我不知道它是加速还是仅用于其硬件(它还说它只支持不同平台上的EGL子集)。

Most of the links refer to mobile when EGL is used. 当使用EGL时,大多数链接指的是移动设备。 I am using Mac OS 10.8 and XCode 4.6. 我使用的是Mac OS 10.8和XCode 4.6。 What is the current situation / How can I (if I can) use EGL in Mac (now)? 目前的情况是什么/我如何(如果可以的话)在Mac(现在)中使用EGL?

yes. 是。 cairo has been ported to use nsopengl. cairo已被移植到使用nsopengl。 I will show you howto. 我会告诉你如何。 amd sample code if you are interested. 如果您有兴趣,请使用示例代码。 performance is much faster than quaetz gl. 性能比quaetz gl快得多。

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

clone cairo, checkout branch nsgl. clone cairo,checkout branch nsgl。 This cairo is our fork of cairo 1.12.14 that has the following enhancement vs the upstream cairo 这个cairo是我们的cairo 1.12.14的分支,与上游cairo相比具有以下增强功能

  1. support OpenGL ES 3.0, and support OpenGL ES 2.0 angle MSAA extension 支持OpenGL ES 3.0,并支持OpenGL ES 2.0角度MSAA扩展
  2. new convex tessellator for fill circle for msaa compositor 用于msaa合成器的填充圆的新凸曲面细分器
  3. new cairo API - cairo_rounded_rectangle() - it is optimized for MSAA compositor 新的cairo API - cairo_rounded_rectangle() - 它针对MSAA合成器进行了优化
  4. support gaussian blur for four backends: GL/GLES, quartz, xcb and image 支持四个后端的高斯模糊:GL / GLES,石英,xcb和图像
  5. support drop shadow and inset for four backends: GL/GLES, quartz, xcv and image with shaow cache 支持四个后端的投影和插入:GL / GLES,石英,xcv和带有shaow缓存的图像
  6. support faster stroke when stroke width = 1 - we call hairline stroke 当笔划宽度= 1时支持更快的笔划 - 我们称之为发际线笔划
  7. add integration for NSOpenGL 为NSOpenGL添加集成
  8. various bug fixes and optimization. 各种错误修复和优化。

On Mac OSX, you have two choices: GLX or NSOpenGL - they are mutually exclusive. 在Mac OSX上,您有两种选择:GLX或NSOpenGL - 它们是互斥的。 You can get mesa glx from macport. 你可以从macport获得mesa glx。 1. To compile for NSOpenGL - ./configure --prefix=your_install_location --enable-gl=yes --enable-nsgl=yes --enable-glx=no --enable-egl=no 1.编译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. 要编译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. 如果你对egl感兴趣(在Mac上没有,但是linux上的mesa 9.1+以及各种嵌入式平台表格有egl)./configure --prefix = your_install_location --enable-gl = no --enable-egl = yes - -enable-glesv2 = yes --enable-glesv3 = no =====这为gles2驱动程序编译。

./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) ./confgure --prefix = your_install_location --enable-gl = no --enable-egl = yes --enable-glesv2 = no --enable-glesv3 = yes ====这为glesv3驱动程序编译(mesa 9.1+已经glesv3)

you can have CFLAGS="-g" for debug or CFLAGS="-O2" for optimization. 您可以使用CFLAGS =“ - g”进行调试,或者使用CFLAGS =“ - O2”进行优化。

cairo gl/gles has 3 GL compositors (rendering paths for GL/GLES backend). cairo gl / gles有3个GL合成器(GL / GLES后端的渲染路径)。 The default one is span compositor which is software simulation of AA and is slow. 默认的是span compositor,它是AA的软件模拟并且很慢。 If your driver supports MSAA, use msaa compositor. 如果您的驱动程序支持MSAA,请使用msaa compositor。 To use MSAA compositor, you can export CAIRO_GL_COMPOSITOR=msaa in terminal, or you can setenv() in your program. 要使用MSAA合成器,可以在终端中导出CAIRO_GL_COMPOSITOR = msaa,也可以在程序中输出setenv()。

I have sample code to show cairo for quartz, xcv, image, glx, gel or nsgl. 我有示例代码来显示石英,xcv,图像,glx,凝胶或nsgl的cairo。 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. 我还没有时间让wgl(MS windows)工作。 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. 另外,为cairo设置一个d3d后端会很好,我只是没有时间去做 - 在todo列表上。

Enjoy 请享用

You definitely can use angle: 你绝对可以使用角度:

#define GL_GLEXT_PROTOTYPES
#include <GLES2/gl2.h>
#include <EGL/egl.h>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM