glTestLib.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * Copyright (C) 2011 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. */
  17. /*
  18. * Graphics Test Library
  19. */
  20. #include <glTestLib.h>
  21. #include <EGL/egl.h>
  22. #include <EGL/eglext.h>
  23. #include <GLES2/gl2.h>
  24. #include <GLES2/gl2ext.h>
  25. #include "EGLUtils.h"
  26. #include <utils/Log.h>
  27. #include <testUtil.h>
  28. using namespace std;
  29. using namespace android;
  30. void glTestPrintGLString(const char *name, GLenum s)
  31. {
  32. const char *v = (const char *) glGetString(s);
  33. if (v == NULL) {
  34. testPrintI("GL %s unknown", name);
  35. } else {
  36. testPrintI("GL %s = %s", name, v);
  37. }
  38. }
  39. void glTestCheckEglError(const char* op, EGLBoolean returnVal)
  40. {
  41. if (returnVal != EGL_TRUE) {
  42. testPrintE("%s() returned %d", op, returnVal);
  43. }
  44. for (EGLint error = eglGetError(); error != EGL_SUCCESS; error
  45. = eglGetError()) {
  46. testPrintE("after %s() eglError %s (0x%x)",
  47. op, EGLUtils::strerror(error), error);
  48. }
  49. }
  50. void glTestCheckGlError(const char* op)
  51. {
  52. for (GLint error = glGetError(); error; error
  53. = glGetError()) {
  54. testPrintE("after %s() glError (0x%x)", op, error);
  55. }
  56. }
  57. void glTestPrintEGLConfiguration(EGLDisplay dpy, EGLConfig config)
  58. {
  59. #define X(VAL) {VAL, #VAL}
  60. struct {EGLint attribute; const char* name;} names[] = {
  61. X(EGL_BUFFER_SIZE),
  62. X(EGL_ALPHA_SIZE),
  63. X(EGL_BLUE_SIZE),
  64. X(EGL_GREEN_SIZE),
  65. X(EGL_RED_SIZE),
  66. X(EGL_DEPTH_SIZE),
  67. X(EGL_STENCIL_SIZE),
  68. X(EGL_CONFIG_CAVEAT),
  69. X(EGL_CONFIG_ID),
  70. X(EGL_LEVEL),
  71. X(EGL_MAX_PBUFFER_HEIGHT),
  72. X(EGL_MAX_PBUFFER_PIXELS),
  73. X(EGL_MAX_PBUFFER_WIDTH),
  74. X(EGL_NATIVE_RENDERABLE),
  75. X(EGL_NATIVE_VISUAL_ID),
  76. X(EGL_NATIVE_VISUAL_TYPE),
  77. X(EGL_SAMPLES),
  78. X(EGL_SAMPLE_BUFFERS),
  79. X(EGL_SURFACE_TYPE),
  80. X(EGL_TRANSPARENT_TYPE),
  81. X(EGL_TRANSPARENT_RED_VALUE),
  82. X(EGL_TRANSPARENT_GREEN_VALUE),
  83. X(EGL_TRANSPARENT_BLUE_VALUE),
  84. X(EGL_BIND_TO_TEXTURE_RGB),
  85. X(EGL_BIND_TO_TEXTURE_RGBA),
  86. X(EGL_MIN_SWAP_INTERVAL),
  87. X(EGL_MAX_SWAP_INTERVAL),
  88. X(EGL_LUMINANCE_SIZE),
  89. X(EGL_ALPHA_MASK_SIZE),
  90. X(EGL_COLOR_BUFFER_TYPE),
  91. X(EGL_RENDERABLE_TYPE),
  92. X(EGL_CONFORMANT),
  93. };
  94. #undef X
  95. for (size_t j = 0; j < sizeof(names) / sizeof(names[0]); j++) {
  96. EGLint value = -1;
  97. EGLint returnVal = eglGetConfigAttrib(dpy, config, names[j].attribute,
  98. &value);
  99. EGLint error = eglGetError();
  100. if (returnVal && error == EGL_SUCCESS) {
  101. testPrintI(" %s: %d (%#x)", names[j].name, value, value);
  102. }
  103. }
  104. testPrintI("");
  105. }