2 * eglinfo - like glxinfo but for EGL
7 * Copyright (C) 2005 Brian Paul All Rights Reserved.
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:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
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.
27 #define EGL_EGLEXT_PROTOTYPES
30 #include <EGL/eglext.h>
36 #define MAX_CONFIGS 1000
37 #define MAX_MODES 1000
38 #define MAX_SCREENS 10
40 /* These are X visual types, so if you're running eglinfo under
41 * something not X, they probably don't make sense. */
42 static const char *vnames
[] = { "SG", "GS", "SC", "PC", "TC", "DC" };
45 * Print table of all available configurations.
48 PrintConfigs(EGLDisplay d
)
50 EGLConfig configs
[MAX_CONFIGS
];
53 eglGetConfigs(d
, configs
, MAX_CONFIGS
, &numConfigs
);
55 printf("Configurations:\n");
56 printf(" bf lv colorbuffer dp st ms vis cav bi renderable supported\n");
57 printf(" id sz l r g b a th cl ns b id eat nd gl es es2 vg surfaces \n");
58 printf("---------------------------------------------------------------------\n");
59 for (i
= 0; i
< numConfigs
; i
++) {
60 EGLint id
, size
, level
;
61 EGLint red
, green
, blue
, alpha
;
62 EGLint depth
, stencil
;
63 EGLint renderable
, surfaces
;
64 EGLint vid
, vtype
, caveat
, bindRgb
, bindRgba
;
65 EGLint samples
, sampleBuffers
;
66 char surfString
[100] = "";
68 eglGetConfigAttrib(d
, configs
[i
], EGL_CONFIG_ID
, &id
);
69 eglGetConfigAttrib(d
, configs
[i
], EGL_BUFFER_SIZE
, &size
);
70 eglGetConfigAttrib(d
, configs
[i
], EGL_LEVEL
, &level
);
72 eglGetConfigAttrib(d
, configs
[i
], EGL_RED_SIZE
, &red
);
73 eglGetConfigAttrib(d
, configs
[i
], EGL_GREEN_SIZE
, &green
);
74 eglGetConfigAttrib(d
, configs
[i
], EGL_BLUE_SIZE
, &blue
);
75 eglGetConfigAttrib(d
, configs
[i
], EGL_ALPHA_SIZE
, &alpha
);
76 eglGetConfigAttrib(d
, configs
[i
], EGL_DEPTH_SIZE
, &depth
);
77 eglGetConfigAttrib(d
, configs
[i
], EGL_STENCIL_SIZE
, &stencil
);
78 eglGetConfigAttrib(d
, configs
[i
], EGL_NATIVE_VISUAL_ID
, &vid
);
79 eglGetConfigAttrib(d
, configs
[i
], EGL_NATIVE_VISUAL_TYPE
, &vtype
);
81 eglGetConfigAttrib(d
, configs
[i
], EGL_CONFIG_CAVEAT
, &caveat
);
82 eglGetConfigAttrib(d
, configs
[i
], EGL_BIND_TO_TEXTURE_RGB
, &bindRgb
);
83 eglGetConfigAttrib(d
, configs
[i
], EGL_BIND_TO_TEXTURE_RGBA
, &bindRgba
);
84 eglGetConfigAttrib(d
, configs
[i
], EGL_RENDERABLE_TYPE
, &renderable
);
85 eglGetConfigAttrib(d
, configs
[i
], EGL_SURFACE_TYPE
, &surfaces
);
87 eglGetConfigAttrib(d
, configs
[i
], EGL_SAMPLES
, &samples
);
88 eglGetConfigAttrib(d
, configs
[i
], EGL_SAMPLE_BUFFERS
, &sampleBuffers
);
90 if (surfaces
& EGL_WINDOW_BIT
)
91 strcat(surfString
, "win,");
92 if (surfaces
& EGL_PBUFFER_BIT
)
93 strcat(surfString
, "pb,");
94 if (surfaces
& EGL_PIXMAP_BIT
)
95 strcat(surfString
, "pix,");
96 #ifdef EGL_MESA_screen_surface
97 if (surfaces
& EGL_SCREEN_BIT_MESA
)
98 strcat(surfString
, "scrn,");
100 if (strlen(surfString
) > 0)
101 surfString
[strlen(surfString
) - 1] = 0;
103 printf("0x%02x %2d %2d %2d %2d %2d %2d %2d %2d %2d%2d 0x%02x%s ",
105 red
, green
, blue
, alpha
,
107 samples
, sampleBuffers
, vid
, vtype
< 6 ? vnames
[vtype
] : "--");
108 printf(" %c %c %c %c %c %c %s\n",
109 (caveat
!= EGL_NONE
) ? 'y' : ' ',
110 (bindRgba
) ? 'a' : (bindRgb
) ? 'y' : ' ',
111 (renderable
& EGL_OPENGL_BIT
) ? 'y' : ' ',
112 (renderable
& EGL_OPENGL_ES_BIT
) ? 'y' : ' ',
113 (renderable
& EGL_OPENGL_ES2_BIT
) ? 'y' : ' ',
114 (renderable
& EGL_OPENVG_BIT
) ? 'y' : ' ',
121 * Print table of all available configurations.
124 PrintModes(EGLDisplay d
)
126 #ifdef EGL_MESA_screen_surface
127 const char *extensions
= eglQueryString(d
, EGL_EXTENSIONS
);
128 if (strstr(extensions
, "EGL_MESA_screen_surface")) {
129 EGLScreenMESA screens
[MAX_SCREENS
];
130 EGLint numScreens
= 1, scrn
;
131 EGLModeMESA modes
[MAX_MODES
];
133 eglGetScreensMESA(d
, screens
, MAX_SCREENS
, &numScreens
);
134 printf("Number of Screens: %d\n\n", numScreens
);
136 for (scrn
= 0; scrn
< numScreens
; scrn
++) {
139 eglGetModesMESA(d
, screens
[scrn
], modes
, MAX_MODES
, &numModes
);
141 printf("Screen %d Modes:\n", scrn
);
142 printf(" id width height refresh name\n");
143 printf("-----------------------------------------\n");
144 for (i
= 0; i
< numModes
; i
++) {
147 eglGetModeAttribMESA(d
, modes
[i
], EGL_MODE_ID_MESA
, &id
);
148 eglGetModeAttribMESA(d
, modes
[i
], EGL_WIDTH
, &w
);
149 eglGetModeAttribMESA(d
, modes
[i
], EGL_HEIGHT
, &h
);
150 eglGetModeAttribMESA(d
, modes
[i
], EGL_REFRESH_RATE_MESA
, &r
);
151 str
= eglQueryModeStringMESA(d
, modes
[i
]);
152 printf("0x%02x %5d %5d %.3f %s\n", id
, w
, h
, r
/ 1000.0, str
);
160 PrintExtensions(EGLDisplay d
)
162 const char *extensions
, *p
, *end
, *next
;
165 printf("EGL extensions string:\n");
167 extensions
= eglQueryString(d
, EGL_EXTENSIONS
);
170 end
= extensions
+ strlen(extensions
);
172 for (p
= extensions
; p
< end
; p
= next
+ 1) {
173 next
= strchr(p
, ' ');
177 if (column
> 0 && column
+ next
- p
+ 1 > 70) {
185 column
+= next
- p
+ 1;
187 printf("%.*s", (int) (next
- p
), p
);
197 main(int argc
, char *argv
[])
200 EGLDisplay d
= eglGetDisplay(EGL_DEFAULT_DISPLAY
);
202 if (!eglInitialize(d
, &maj
, &min
)) {
203 printf("eglinfo: eglInitialize failed\n");
207 printf("EGL API version: %d.%d\n", maj
, min
);
208 printf("EGL vendor string: %s\n", eglQueryString(d
, EGL_VENDOR
));
209 printf("EGL version string: %s\n", eglQueryString(d
, EGL_VERSION
));
210 #ifdef EGL_VERSION_1_2
211 printf("EGL client APIs: %s\n", eglQueryString(d
, EGL_CLIENT_APIS
));