2 * Exercise EGL API functions
5 #define EGL_EGLEXT_PROTOTYPES
8 #include <EGL/eglext.h>
16 * Test EGL_MESA_screen_surface functions
19 TestScreens(EGLDisplay dpy
)
22 EGLScreenMESA screens
[MAX
];
26 eglGetScreensMESA(dpy
, screens
, MAX
, &numScreens
);
27 printf("Found %d screens\n", numScreens
);
28 for (i
= 0; i
< numScreens
; i
++) {
29 printf(" Screen %d handle: %d\n", i
, (int) screens
[i
]);
34 * Print table of all available configurations.
37 PrintConfigs(EGLDisplay d
)
42 eglGetConfigs(d
, NULL
, 0, &numConfigs
);
43 configs
= malloc(sizeof(*configs
) *numConfigs
);
44 eglGetConfigs(d
, configs
, numConfigs
, &numConfigs
);
46 printf("Configurations:\n");
47 printf(" bf lv d st colorbuffer dp st supported \n");
48 printf(" id sz l b ro r g b a th cl surfaces \n");
49 printf("----------------------------------------------\n");
50 for (i
= 0; i
< numConfigs
; i
++) {
51 EGLint id
, size
, level
;
52 EGLint red
, green
, blue
, alpha
;
53 EGLint depth
, stencil
;
55 EGLint doubleBuf
= 1, stereo
= 0;
56 char surfString
[100] = "";
58 eglGetConfigAttrib(d
, configs
[i
], EGL_CONFIG_ID
, &id
);
59 eglGetConfigAttrib(d
, configs
[i
], EGL_BUFFER_SIZE
, &size
);
60 eglGetConfigAttrib(d
, configs
[i
], EGL_LEVEL
, &level
);
62 eglGetConfigAttrib(d
, configs
[i
], EGL_RED_SIZE
, &red
);
63 eglGetConfigAttrib(d
, configs
[i
], EGL_GREEN_SIZE
, &green
);
64 eglGetConfigAttrib(d
, configs
[i
], EGL_BLUE_SIZE
, &blue
);
65 eglGetConfigAttrib(d
, configs
[i
], EGL_ALPHA_SIZE
, &alpha
);
66 eglGetConfigAttrib(d
, configs
[i
], EGL_DEPTH_SIZE
, &depth
);
67 eglGetConfigAttrib(d
, configs
[i
], EGL_STENCIL_SIZE
, &stencil
);
68 eglGetConfigAttrib(d
, configs
[i
], EGL_SURFACE_TYPE
, &surfaces
);
70 if (surfaces
& EGL_WINDOW_BIT
)
71 strcat(surfString
, "win,");
72 if (surfaces
& EGL_PBUFFER_BIT
)
73 strcat(surfString
, "pb,");
74 if (surfaces
& EGL_PIXMAP_BIT
)
75 strcat(surfString
, "pix,");
76 if (strlen(surfString
) > 0)
77 surfString
[strlen(surfString
) - 1] = 0;
79 printf("0x%02x %2d %2d %c %c %2d %2d %2d %2d %2d %2d %-12s\n",
81 doubleBuf
? 'y' : '.',
83 red
, green
, blue
, alpha
,
84 depth
, stencil
, surfString
);
92 main(int argc
, char *argv
[])
97 EGLConfig configs
[10];
99 const EGLint pbufAttribs
[] = {
106 EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
108 EGLDisplay d
= eglGetDisplay((EGLNativeDisplayType
) "!EGL_i915");
111 if (!eglInitialize(d
, &maj
, &min
)) {
112 printf("demo: eglInitialize failed\n");
116 printf("EGL version = %d.%d\n", maj
, min
);
117 printf("EGL_VENDOR = %s\n", eglQueryString(d
, EGL_VENDOR
));
121 ctx
= eglCreateContext(d
, configs
[0], EGL_NO_CONTEXT
, NULL
);
122 if (ctx
== EGL_NO_CONTEXT
) {
123 printf("failed to create context\n");
127 pbuffer
= eglCreatePbufferSurface(d
, configs
[0], pbufAttribs
);
128 if (pbuffer
== EGL_NO_SURFACE
) {
129 printf("failed to create pbuffer\n");
133 b
= eglMakeCurrent(d
, pbuffer
, pbuffer
, ctx
);
135 printf("make current failed\n");
139 b
= eglMakeCurrent(d
, EGL_NO_SURFACE
, EGL_NO_SURFACE
, EGL_NO_CONTEXT
);
143 eglDestroySurface(d
, pbuffer
);
144 eglDestroyContext(d
, ctx
);