OpenGL headers for OS X & Linux

前端 未结 4 568
谎友^
谎友^ 2021-02-05 22:58

I\'d like to have both the includes for OS X as well as linux in my opengl program (C++) how can I set my program to use one if the other is not available? Here\'s what i\'m cur

4条回答
  •  别那么骄傲
    2021-02-05 23:21

    Here is what I use:

    #ifdef __APPLE__
    #include 
    #include 
    #include 
    #else
    #ifdef _WIN32
      #include 
    #endif
    #include 
    #include 
    #include 
    #endif
    

    All compilers for the mac (well,I guess that's gcc, and maybe clang) should define __APPLE__. I throw the _WIN32 in there since windows.h must be included before gl.h on windows platforms, it seems.

    You can put this in its own include file (say gl_includes.h) if you have many files that need OpenGL

    -matt

提交回复
热议问题