GLExtensions.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (C) 2010 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include <stdlib.h>
  17. #include <stdio.h>
  18. #include <stdint.h>
  19. #include "GLExtensions.h"
  20. namespace android {
  21. // ---------------------------------------------------------------------------
  22. ANDROID_SINGLETON_STATIC_INSTANCE( GLExtensions )
  23. GLExtensions::GLExtensions()
  24. : mHaveFramebufferObject(false)
  25. {
  26. }
  27. void GLExtensions::initWithGLStrings(
  28. GLubyte const* vendor,
  29. GLubyte const* renderer,
  30. GLubyte const* version,
  31. GLubyte const* extensions)
  32. {
  33. mVendor = (char const*)vendor;
  34. mRenderer = (char const*)renderer;
  35. mVersion = (char const*)version;
  36. mExtensions = (char const*)extensions;
  37. char const* curr = (char const*)extensions;
  38. char const* head = curr;
  39. do {
  40. head = strchr(curr, ' ');
  41. String8 s(curr, head ? head-curr : strlen(curr));
  42. if (s.length()) {
  43. mExtensionList.add(s);
  44. }
  45. curr = head+1;
  46. } while (head);
  47. if (hasExtension("GL_OES_framebuffer_object")) {
  48. mHaveFramebufferObject = true;
  49. }
  50. }
  51. bool GLExtensions::hasExtension(char const* extension) const
  52. {
  53. const String8 s(extension);
  54. return mExtensionList.indexOf(s) >= 0;
  55. }
  56. char const* GLExtensions::getVendor() const {
  57. return mVendor.string();
  58. }
  59. char const* GLExtensions::getRenderer() const {
  60. return mRenderer.string();
  61. }
  62. char const* GLExtensions::getVersion() const {
  63. return mVersion.string();
  64. }
  65. char const* GLExtensions::getExtension() const {
  66. return mExtensions.string();
  67. }
  68. // ---------------------------------------------------------------------------
  69. }; // namespace android