Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

eglinfo.c 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*
  2. * eglinfo - like glxinfo but for EGL
  3. *
  4. * Brian Paul
  5. * 11 March 2005
  6. *
  7. * Copyright (C) 2005 Brian Paul All Rights Reserved.
  8. *
  9. * Permission is hereby granted, free of charge, to any person obtaining a
  10. * copy of this software and associated documentation files (the "Software"),
  11. * to deal in the Software without restriction, including without limitation
  12. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  13. * and/or sell copies of the Software, and to permit persons to whom the
  14. * Software is furnished to do so, subject to the following conditions:
  15. *
  16. * The above copyright notice and this permission notice shall be included
  17. * in all copies or substantial portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  20. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  22. * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  23. * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  24. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25. */
  26. #include <GLES/egl.h>
  27. #include <assert.h>
  28. #include <stdio.h>
  29. #include <stdlib.h>
  30. #include <string.h>
  31. #define MAX_CONFIGS 1000
  32. #define MAX_MODES 1000
  33. #define MAX_SCREENS 10
  34. /**
  35. * Print table of all available configurations.
  36. */
  37. static void
  38. PrintConfigs(EGLDisplay d)
  39. {
  40. EGLConfig configs[MAX_CONFIGS];
  41. EGLint numConfigs, i;
  42. eglGetConfigs(d, configs, MAX_CONFIGS, &numConfigs);
  43. printf("Configurations:\n");
  44. printf(" bf lv d st colorbuffer dp st supported\n");
  45. printf(" id sz l b ro r g b a th cl surfaces \n");
  46. printf("---------------------------------------------------\n");
  47. for (i = 0; i < numConfigs; i++) {
  48. EGLint id, size, level;
  49. EGLint red, green, blue, alpha;
  50. EGLint depth, stencil;
  51. EGLint surfaces;
  52. EGLint doubleBuf = 1, stereo = 0;
  53. char surfString[100] = "";
  54. eglGetConfigAttrib(d, configs[i], EGL_CONFIG_ID, &id);
  55. eglGetConfigAttrib(d, configs[i], EGL_BUFFER_SIZE, &size);
  56. eglGetConfigAttrib(d, configs[i], EGL_LEVEL, &level);
  57. eglGetConfigAttrib(d, configs[i], EGL_RED_SIZE, &red);
  58. eglGetConfigAttrib(d, configs[i], EGL_GREEN_SIZE, &green);
  59. eglGetConfigAttrib(d, configs[i], EGL_BLUE_SIZE, &blue);
  60. eglGetConfigAttrib(d, configs[i], EGL_ALPHA_SIZE, &alpha);
  61. eglGetConfigAttrib(d, configs[i], EGL_DEPTH_SIZE, &depth);
  62. eglGetConfigAttrib(d, configs[i], EGL_STENCIL_SIZE, &stencil);
  63. eglGetConfigAttrib(d, configs[i], EGL_SURFACE_TYPE, &surfaces);
  64. if (surfaces & EGL_WINDOW_BIT)
  65. strcat(surfString, "win,");
  66. if (surfaces & EGL_PBUFFER_BIT)
  67. strcat(surfString, "pb,");
  68. if (surfaces & EGL_PIXMAP_BIT)
  69. strcat(surfString, "pix,");
  70. #ifdef EGL_MESA_screen_surface
  71. if (surfaces & EGL_SCREEN_BIT_MESA)
  72. strcat(surfString, "scrn,");
  73. #endif
  74. if (strlen(surfString) > 0)
  75. surfString[strlen(surfString) - 1] = 0;
  76. printf("0x%02x %2d %2d %c %c %2d %2d %2d %2d %2d %2d %-12s\n",
  77. id, size, level,
  78. doubleBuf ? 'y' : '.',
  79. stereo ? 'y' : '.',
  80. red, green, blue, alpha,
  81. depth, stencil, surfString);
  82. }
  83. }
  84. /**
  85. * Print table of all available configurations.
  86. */
  87. static void
  88. PrintModes(EGLDisplay d)
  89. {
  90. #ifdef EGL_MESA_screen_surface
  91. const char *extensions = eglQueryString(d, EGL_EXTENSIONS);
  92. if (strstr(extensions, "EGL_MESA_screen_surface")) {
  93. EGLScreenMESA screens[MAX_SCREENS];
  94. EGLint numScreens = 1, scrn;
  95. EGLModeMESA modes[MAX_MODES];
  96. eglGetScreensMESA(d, screens, MAX_SCREENS, &numScreens);
  97. printf("Number of Screens: %d\n\n", numScreens);
  98. for (scrn = 0; scrn < numScreens; scrn++) {
  99. EGLint numModes, i;
  100. eglGetModesMESA(d, screens[scrn], modes, MAX_MODES, &numModes);
  101. printf("Screen %d Modes:\n", scrn);
  102. printf(" id width height refresh name\n");
  103. printf("-----------------------------------------\n");
  104. for (i = 0; i < numModes; i++) {
  105. EGLint id, w, h, r;
  106. const char *str;
  107. eglGetModeAttribMESA(d, modes[i], EGL_MODE_ID_MESA, &id);
  108. eglGetModeAttribMESA(d, modes[i], EGL_WIDTH, &w);
  109. eglGetModeAttribMESA(d, modes[i], EGL_HEIGHT, &h);
  110. eglGetModeAttribMESA(d, modes[i], EGL_REFRESH_RATE_MESA, &r);
  111. str = eglQueryModeStringMESA(d, modes[i]);
  112. printf("0x%02x %5d %5d %.3f %s\n", id, w, h, r / 1000.0, str);
  113. }
  114. }
  115. }
  116. #endif
  117. }
  118. int
  119. main(int argc, char *argv[])
  120. {
  121. int maj, min;
  122. /*EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);*/
  123. EGLDisplay d = eglGetDisplay(":0");
  124. if (!eglInitialize(d, &maj, &min)) {
  125. printf("eglinfo: eglInitialize failed\n");
  126. exit(1);
  127. }
  128. printf("EGL API version: %d.%d\n", maj, min);
  129. printf("EGL vendor string: %s\n", eglQueryString(d, EGL_VENDOR));
  130. printf("EGL version string: %s\n", eglQueryString(d, EGL_VERSION));
  131. printf("EGL extensions string:\n");
  132. printf(" %s\n", eglQueryString(d, EGL_EXTENSIONS));
  133. printf("\n");
  134. PrintConfigs(d);
  135. printf("\n");
  136. PrintModes(d);
  137. eglTerminate(d);
  138. return 0;
  139. }