1 2 function findOpenGL() 3 configuration{} 4 if os.is("Linux") then 5 return true 6 end 7 --assume OpenGL is available on Mac OSX, Windows etc 8 return true 9 end 10 11 function findOpenGL3() 12 configuration{} 13 if os.is("MacOSX") then 14 local osversion = os.getversion() 15 --Mac OSX 10.9 and above supports OpenGL 3, below doesn't, so ... 16 if osversion.majorversion > 10 or (osversion.majorversion == 10 and osversion.minorversion >=9) then 17 return findOpenGL() 18 else 19 return false 20 end 21 else 22 return findOpenGL() 23 end 24 end 25 26 27 function initOpenGL() 28 configuration {} 29 configuration {"Windows"} 30 links {"opengl32","glu32"} 31 configuration {"MacOSX"} 32 links { "OpenGL.framework"} 33 configuration {"not Windows", "not MacOSX"} 34 if os.is("Linux") then 35 if _OPTIONS["enable_system_opengl"] and (os.isdir("/usr/include") and os.isfile("/usr/include/GL/gl.h")) then 36 links {"GL"} 37 else 38 print("No GL/gl.h found, using dynamic loading of GL using glew") 39 defines {"GLEW_INIT_OPENGL11_FUNCTIONS=1"} 40 links {"dl"} 41 end 42 end 43 configuration{} 44 end 45 46 47 function initGlew() 48 configuration {} 49 if os.is("Windows") then 50 configuration {"Windows"} 51 defines { "GLEW_STATIC"} 52 includedirs { 53 projectRootDir .. "ThirdPartyLibs/Glew" 54 } 55 files { projectRootDir .. "ThirdPartyLibs/Glew/glew.c"} 56 end 57 if os.is("Linux") then 58 configuration{"Linux"} 59 if _OPTIONS["enable_system_opengl"] and (os.isdir("/usr/include") and os.isfile("/usr/include/GL/gl.h") and os.isfile("/usr/include/GL/glew.h")) then 60 links {"GLEW"} 61 print ("linking against system GLEW") 62 else 63 print("Using static glew and dynamic loading of glx functions") 64 defines { "GLEW_STATIC","GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS=1"} 65 includedirs { 66 projectRootDir .. "ThirdPartyLibs/Glew" 67 } 68 files { projectRootDir .. "ThirdPartyLibs/Glew/glew.c"} 69 links {"dl"} 70 end 71 72 end 73 configuration{} 74 end 75 76 function initX11() 77 if os.is("Linux") then 78 if _OPTIONS["enable_system_x11"] and (os.isdir("/usr/include") and os.isfile("/usr/include/X11/X.h")) then 79 links{"X11","pthread"} 80 else 81 print("No X11/X.h found, using dynamic loading of X11") 82 includedirs { 83 projectRootDir .. "ThirdPartyLibs/optionalX11" 84 } 85 defines {"DYNAMIC_LOAD_X11_FUNCTIONS"} 86 links {"dl","pthread"} 87 end 88 end 89 end 90 91