findOpenGLGlewGlut.lua 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 initGlew()
  42. configuration {}
  43. if os.is("Windows") then
  44. configuration {"Windows"}
  45. defines { "GLEW_STATIC"}
  46. includedirs {
  47. projectRootDir .. "examples/ThirdPartyLibs/glad"
  48. }
  49. files { projectRootDir .. "examples/ThirdPartyLibs/glad/glad.c"}
  50. end
  51. if os.is("MacOSX") then
  52. includedirs {
  53. projectRootDir .. "examples/ThirdPartyLibs/glad"
  54. }
  55. files { projectRootDir .. "examples/ThirdPartyLibs/glad/glad.c"}
  56. end
  57. if os.is("Linux") then
  58. configuration{"Linux"}
  59. if _OPTIONS["enable_system_glx"] then --# and (os.isdir("/usr/include") and os.isfile("/usr/include/GL/glx.h")) then
  60. links{"X11","pthread"}
  61. print("Using system GL/glx.h")
  62. else
  63. print("Using glad_glx")
  64. defines { "GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS=1"}
  65. files {
  66. projectRootDir .. "examples/ThirdPartyLibs/glad/glad_glx.c"}
  67. end
  68. print("Using glad and dynamic loading of GL functions")
  69. defines { "GLEW_STATIC"}
  70. includedirs {
  71. projectRootDir .. "examples/ThirdPartyLibs/glad"
  72. }
  73. files { projectRootDir .. "examples/ThirdPartyLibs/glad/glad.c"}
  74. links {"dl"}
  75. end
  76. configuration{}
  77. end
  78. function initX11()
  79. if os.is("Linux") then
  80. if _OPTIONS["enable_system_x11"] and (os.isdir("/usr/include") and os.isfile("/usr/include/X11/X.h")) then
  81. links{"X11","pthread"}
  82. else
  83. print("No X11/X.h found, using dynamic loading of X11")
  84. includedirs {
  85. projectRootDir .. "examples/ThirdPartyLibs/optionalX11"
  86. }
  87. defines {"DYNAMIC_LOAD_X11_FUNCTIONS"}
  88. links {"dl","pthread"}
  89. end
  90. end
  91. end