我如何在从Linux移植的C ++项目中使用Open GL [英] How do I use Open GL in a C++ project that I am porting from Linux

查看:73
本文介绍了我如何在从Linux移植的C ++项目中使用Open GL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚尝试在Mac上编译一个开源C ++应用程序.我收到未找到错误GL/gl.h的文件.我知道这意味着它找不到需要编译和运行的开放式GL库.下一步我很困惑,因为

I just tried to compile an open source C++ application on my Mac. I get the error GL/gl.h file not found. I know that this means that it can't find the open GL library, which it needs to compile and run. I am confused about what to do next because

  1. 似乎OS X包含对open gl的内置支持.有没什么下载.
  2. 对于OSX和Linux上的OpenGL,头文件名似乎有所不同( 用于OS X&的OpenGL标头Linux )
  1. It seems like OS X includes built-in support for open gl. There is nothing to download.
  2. It seems like the header file names might be different for OpenGL on OSX and Linux ( OpenGL headers for OS X & Linux )

所以我对下一步做什么感到困惑.我是否可以下载OpenGL并将其链接到我的项目?是否将xcode配置为使用OpenGL的本机版本?我要更改标题吗?

So I am confused about what to do next. Do I download OpenGL and link it to my project? Do I configure xcode to use a native version of OpenGL? Do I change the headers?

有人可以提供更多指导吗?这个答案给出了Windows/Linux的答案-但没有提供OS X: 如何获取GL库/标题?

Can someone provide a little more direction. This answer gave windows/linux answers -- but not OS X: How to get the GL library/headers?

推荐答案

Apple认为,如果它们与其他所有人不兼容,那将是明智之举,并将OpenGL标头放置在名为OpenGL的目录中,而不仅仅是GL.所以你必须使用

Apple thought it was clever if they were incompatible to everybody else and placed the OpenGL headers in a directory called OpenGL not just GL. So you must use

#include <OpenGL/gl.h>

在Apple系统上和

#include <GL/gl.h>

其他任何地方.编译器预定义的预处理器宏是您的朋友.

everywhere else. Compiler predefined preprocessor macros are your friend here.

#ifdef __APPLE__
#  include <OpenGL/gl.h>
#else
#  include <GL/gl.h>
#endif/*__APPLE__*/

这篇关于我如何在从Linux移植的C ++项目中使用Open GL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆