GLSupport.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
  3. Permission is hereby granted, free of charge, to any person
  4. obtaining a copy of this software and associated documentation
  5. files (the "Software"), to deal in the Software without
  6. restriction, including without limitation the rights to use,
  7. copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the
  9. Software is furnished to do so, subject to the following
  10. conditions:
  11. The above copyright notice and this permission notice shall be
  12. included in all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  14. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  15. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  16. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  17. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  18. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. OTHER DEALINGS IN THE SOFTWARE.
  21. */
  22. #include <GL/glew.h>
  23. #include "GLSupport.h"
  24. #include "Str.h"
  25. #include "Types.h"
  26. namespace Crown
  27. {
  28. GLSupport::GLSupport() :
  29. mVendor("unknown"),
  30. mRenderer("unknown"),
  31. mVersion("unknown")
  32. {
  33. }
  34. GLSupport::~GLSupport()
  35. {
  36. }
  37. const Str& GLSupport::GetVendor() const
  38. {
  39. return mVendor;
  40. }
  41. const Str& GLSupport::GetRenderer() const
  42. {
  43. return mRenderer;
  44. }
  45. const Str& GLSupport::GetVersion() const
  46. {
  47. return mVersion;
  48. }
  49. bool GLSupport::CheckExtension(const Str& extension) const
  50. {
  51. if (mExtensionList.Find(extension) == -1)
  52. {
  53. return false;
  54. }
  55. return true;
  56. }
  57. void GLSupport::BuildExtensionList()
  58. {
  59. char* string = (char*)glGetString(GL_VENDOR);
  60. mVendor = string;
  61. string = (char*)glGetString(GL_RENDERER);
  62. mRenderer = string;
  63. string = (char*)glGetString(GL_VERSION);
  64. mVersion = string;
  65. string = (char*)glGetString(GL_EXTENSIONS);
  66. Str extensions = string;
  67. extensions.Split(' ', mExtensionList);
  68. }
  69. GLSupport glSupport;
  70. GLSupport* GetGLSupport()
  71. {
  72. return &glSupport;
  73. }
  74. } // namespace Crown