简体   繁体   English

何时在OS X上使用OpenGL vs GL

[英]When to use OpenGL vs GL on OS X

After fighting to get something to try to compile I realized some code needed to change: 努力争取可以编译的东西后,我意识到需要更改一些代码:

#ifdef __APPLE__
#include "OpenGL/gl.h"
#include "OpenGL/glx.h"
#else 
...

needed to change into: 需要更改为:

#ifdef __APPLE__ 
#include "GL/gl.h"
#include "GL/glx.h"
#else
#...

After installing Quartz. 安装完Quartz之后。 However, this also worked: 但是,这也起作用:

#ifdef __APPLE__ 
#include "OpenGL/gl.h"
#include "GL/glx.h"
#else
#...

But OpenGL/glx.h doesn't exist. 但是OpenGL/glx.h不存在。

What do the different header locations on OS X mean? OS X上不同的标头位置是什么意思? Why do I have two different places for OpenGL files? 为什么在OpenGL文件中有两个不同的位置?

First: You're using the wrong kind of include path; 第一:您使用了错误的包含路径; I'm surprised this works at all. 我很惊讶这一切都奏效。 What you want is: 您想要的是:

#include <OpenGL/gl.h>

Note the use of angle brackets instead of quotation marks and he capitalization of OpenGL . 请注意使用尖括号代替引号,并大写OpenGL

(You may need to add the OpenGL framework to your project to make this work. If you aren't using XCode, add -framework OpenGL to your compiler flags.) (您可能需要将OpenGL框架添加到项目中才能完成此工作。如果您不使用XCode,请在编译器标志中添加-framework OpenGL 。)

Second: Don't use glx.h in Mac applications. 第二:不要在Mac应用程序中使用glx.h GLX is an extension to the X11 windowing system that provides support for GL -- it is primarily meant for use on UNIX/Linux systems that use X11 as their desktop interface. GLX是X11窗口系统的扩展,它提供了对GL的支持-它主要用于在使用X11作为其桌面界面的UNIX / Linux系统上使用。 The macOS desktop interface is not based on X11, so you shouldn't need GLX. macOS桌面界面不基于X11,因此您不需要GLX。


An explanation of the paths: 路径说明:

  • The GL/ path on macOS refers to the X11 GL headers, which may be present if you have XQuartz installed. macOS上的GL/路径指的是X11 GL标头,如果您安装了XQuartz,则该标头可能会出现。 They are not what you want. 它们不是您想要的。

  • OpenGL/ refers to the OpenGL framework. OpenGL/是指OpenGL框架。

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

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