/xbmc/screensavers/rsxs-0.9/src/hyperspace/extensions.cc

http://github.com/xbmc/xbmc · C++ · 83 lines · 48 code · 12 blank · 23 comment · 10 complexity · a0d4c2116a3194eae368e3a60359d91b MD5 · raw file

  1. /*
  2. * Really Slick XScreenSavers
  3. * Copyright (C) 2002-2006 Michael Chapman
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. *
  18. *****************************************************************************
  19. *
  20. * This is a Linux port of the Really Slick Screensavers,
  21. * Copyright (C) 2005 Terence M. Welsh, available from www.reallyslick.com
  22. */
  23. #include <common.hh>
  24. #include <extensions.hh>
  25. #if USE_GL_EXTENSIONS
  26. namespace Extensions {
  27. PFNGLACTIVETEXTUREARBPROC glActiveTextureARB;
  28. PFNGLDELETEPROGRAMSARBPROC glDeleteProgramsARB;
  29. PFNGLGENPROGRAMSARBPROC glGenProgramsARB;
  30. PFNGLBINDPROGRAMARBPROC glBindProgramARB;
  31. PFNGLPROGRAMSTRINGARBPROC glProgramStringARB;
  32. };
  33. #if GLX_ARB_get_proc_address
  34. void Extensions::init() {
  35. std::string extensions((const char*)glGetString(GL_EXTENSIONS));
  36. TRACE("Extensions: " << extensions);
  37. std::string::size_type a = 0;
  38. unsigned int count = 0;
  39. while (a < extensions.size()) {
  40. std::string::size_type b = extensions.find(' ', a);
  41. if (b == std::string::npos) b = extensions.size();
  42. std::string s(extensions.substr(a, b - a));
  43. if (
  44. s == "GL_ARB_multitexture" ||
  45. s == "GL_ARB_texture_cube_map" ||
  46. s == "GL_ARB_vertex_program" ||
  47. s == "GL_ARB_fragment_program"
  48. )
  49. count++;
  50. a = b + 1;
  51. }
  52. if (count != 4)
  53. throw Exception("Not all required GL extensions available");
  54. glActiveTextureARB = PFNGLACTIVETEXTUREARBPROC(
  55. glXGetProcAddressARB((const GLubyte*)"glActiveTextureARB"));
  56. glDeleteProgramsARB = PFNGLDELETEPROGRAMSARBPROC(
  57. glXGetProcAddressARB((const GLubyte*)"glDeleteProgramsARB"));
  58. glGenProgramsARB = PFNGLGENPROGRAMSARBPROC(
  59. glXGetProcAddressARB((const GLubyte*)"glGenProgramsARB"));
  60. glBindProgramARB = PFNGLBINDPROGRAMARBPROC(
  61. glXGetProcAddressARB((const GLubyte*)"glBindProgramARB"));
  62. glProgramStringARB = PFNGLPROGRAMSTRINGARBPROC(
  63. glXGetProcAddressARB((const GLubyte*)"glProgramStringARB"));
  64. }
  65. #else // !GLX_ARB_get_proc_address
  66. void Extensions::init() {
  67. // This one's easy!
  68. throw Exception("Can not dynamically get GL procedure addresses");
  69. }
  70. #endif // !GLX_ARB_get_proc_address
  71. #endif // USE_GL_EXTENSIONS