1 /*
2 ** Copyright 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
17 #include <stdlib.h>
18 #include <stdio.h>
19
20 #include <EGL/egl.h>
21 #include <EGL/eglext.h>
22
23 #define ATTRIBUTE(_attr) { _attr, #_attr }
24
25 struct Attribute {
26 EGLint attribute;
27 char const* name;
28 };
29
30 // clang-format off
31 Attribute attributes[] = {
32 ATTRIBUTE( EGL_BUFFER_SIZE ),
33 ATTRIBUTE( EGL_ALPHA_SIZE ),
34 ATTRIBUTE( EGL_BLUE_SIZE ),
35 ATTRIBUTE( EGL_GREEN_SIZE ),
36 ATTRIBUTE( EGL_RED_SIZE ),
37 ATTRIBUTE( EGL_DEPTH_SIZE ),
38 ATTRIBUTE( EGL_STENCIL_SIZE ),
39 ATTRIBUTE( EGL_CONFIG_CAVEAT ),
40 ATTRIBUTE( EGL_CONFIG_ID ),
41 ATTRIBUTE( EGL_LEVEL ),
42 ATTRIBUTE( EGL_MAX_PBUFFER_HEIGHT ),
43 ATTRIBUTE( EGL_MAX_PBUFFER_WIDTH ),
44 ATTRIBUTE( EGL_MAX_PBUFFER_PIXELS ),
45 ATTRIBUTE( EGL_NATIVE_RENDERABLE ),
46 ATTRIBUTE( EGL_NATIVE_VISUAL_ID ),
47 ATTRIBUTE( EGL_NATIVE_VISUAL_TYPE ),
48 ATTRIBUTE( EGL_SAMPLES ),
49 ATTRIBUTE( EGL_SAMPLE_BUFFERS ),
50 ATTRIBUTE( EGL_SURFACE_TYPE ),
51 ATTRIBUTE( EGL_TRANSPARENT_TYPE ),
52 ATTRIBUTE( EGL_TRANSPARENT_BLUE_VALUE ),
53 ATTRIBUTE( EGL_TRANSPARENT_GREEN_VALUE ),
54 ATTRIBUTE( EGL_TRANSPARENT_RED_VALUE ),
55 ATTRIBUTE( EGL_BIND_TO_TEXTURE_RGB ),
56 ATTRIBUTE( EGL_BIND_TO_TEXTURE_RGBA ),
57 ATTRIBUTE( EGL_MIN_SWAP_INTERVAL ),
58 ATTRIBUTE( EGL_MAX_SWAP_INTERVAL ),
59 ATTRIBUTE( EGL_LUMINANCE_SIZE ),
60 ATTRIBUTE( EGL_ALPHA_MASK_SIZE ),
61 ATTRIBUTE( EGL_COLOR_BUFFER_TYPE ),
62 ATTRIBUTE( EGL_RENDERABLE_TYPE ),
63 ATTRIBUTE( EGL_MATCH_NATIVE_PIXMAP ),
64 ATTRIBUTE( EGL_CONFORMANT ),
65 ATTRIBUTE( EGL_COLOR_COMPONENT_TYPE_EXT ),
66 };
67 // clang-format on
68
main(int,char **)69 int main(int /*argc*/, char** /*argv*/) {
70 EGLConfig* configs;
71 EGLint n;
72
73 EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
74 eglInitialize(dpy, 0, 0);
75 eglGetConfigs(dpy, NULL, 0, &n);
76 configs = new EGLConfig[n];
77 eglGetConfigs(dpy, configs, n, &n);
78
79 for (EGLint i=0 ; i<n ; i++) {
80 printf("EGLConfig[%d]\n", i);
81 for (unsigned attr = 0 ; attr<sizeof(attributes)/sizeof(Attribute) ; attr++) {
82 EGLint value;
83 eglGetConfigAttrib(dpy, configs[i], attributes[attr].attribute, &value);
84 printf("\t%-32s: %10d (0x%08x)\n", attributes[attr].name, value, value);
85 }
86 }
87
88 delete [] configs;
89 eglTerminate(dpy);
90 return 0;
91 }
92