findOpenGLGlewGlut.lua 3.7 KB

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