Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use Open GL in a C++ project that I am porting from Linux

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. 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 )

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?

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

like image 422
bernie2436 Avatar asked Dec 19 '22 23:12

bernie2436


1 Answers

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>

on Apple systems and

#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__*/
like image 64
datenwolf Avatar answered Dec 22 '22 14:12

datenwolf