BsGLSupport.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "BsGLSupport.h"
  4. #include "BsGLTexture.h"
  5. #if BS_PLATFORM != BS_PLATFORM_OSX
  6. #include "GL/glew.h"
  7. GLenum glewContextInit(bs::ct::GLSupport* glSupport);
  8. #endif
  9. namespace bs { namespace ct
  10. {
  11. void GLSupport::initializeExtensions()
  12. {
  13. #if BS_PLATFORM != BS_PLATFORM_OSX
  14. glewContextInit(this);
  15. BS_CHECK_GL_ERROR();
  16. #endif
  17. // Set version string
  18. const GLubyte* pcVer = glGetString(GL_VERSION);
  19. assert(pcVer && "Problems getting GL version string using glGetString");
  20. String tmpStr = (const char*)pcVer;
  21. mVersion = tmpStr.substr(0, tmpStr.find(" "));
  22. // Get vendor
  23. const GLubyte* pcVendor = glGetString(GL_VENDOR);
  24. tmpStr = (const char*)pcVendor;
  25. mVendor = tmpStr.substr(0, tmpStr.find(" "));
  26. // Set extension list
  27. INT32 numExtensions = 0;
  28. glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
  29. BS_CHECK_GL_ERROR();
  30. for (INT32 i = 0; i < numExtensions; i++)
  31. extensionList.insert(String((char*)glGetStringi(GL_EXTENSIONS, i)));
  32. }
  33. bool GLSupport::checkExtension(const String& ext) const
  34. {
  35. if(extensionList.find(ext) == extensionList.end())
  36. return false;
  37. return true;
  38. }
  39. }}