2 * Exercise EGL API functions
13 * Test EGL_MESA_screen_surface functions
16 TestScreens(EGLDisplay dpy
)
19 EGLScreenMESA screens
[MAX
];
23 eglGetScreensMESA(dpy
, screens
, MAX
, &numScreens
);
24 printf("Found %d screens\n", numScreens
);
25 for (i
= 0; i
< numScreens
; i
++) {
26 printf(" Screen %d handle: %d\n", i
, (int) screens
[i
]);
31 * Print table of all available configurations.
34 PrintConfigs(EGLDisplay d
)
39 eglGetConfigs(d
, NULL
, 0, &numConfigs
);
40 configs
= malloc(sizeof(*configs
) *numConfigs
);
41 eglGetConfigs(d
, configs
, numConfigs
, &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
;
52 EGLint doubleBuf
= 1, stereo
= 0;
53 char surfString
[100] = "";
55 eglGetConfigAttrib(d
, configs
[i
], EGL_CONFIG_ID
, &id
);
56 eglGetConfigAttrib(d
, configs
[i
], EGL_BUFFER_SIZE
, &size
);
57 eglGetConfigAttrib(d
, configs
[i
], EGL_LEVEL
, &level
);
59 eglGetConfigAttrib(d
, configs
[i
], EGL_RED_SIZE
, &red
);
60 eglGetConfigAttrib(d
, configs
[i
], EGL_GREEN_SIZE
, &green
);
61 eglGetConfigAttrib(d
, configs
[i
], EGL_BLUE_SIZE
, &blue
);
62 eglGetConfigAttrib(d
, configs
[i
], EGL_ALPHA_SIZE
, &alpha
);
63 eglGetConfigAttrib(d
, configs
[i
], EGL_DEPTH_SIZE
, &depth
);
64 eglGetConfigAttrib(d
, configs
[i
], EGL_STENCIL_SIZE
, &stencil
);
65 eglGetConfigAttrib(d
, configs
[i
], EGL_SURFACE_TYPE
, &surfaces
);
67 if (surfaces
& EGL_WINDOW_BIT
)
68 strcat(surfString
, "win,");
69 if (surfaces
& EGL_PBUFFER_BIT
)
70 strcat(surfString
, "pb,");
71 if (surfaces
& EGL_PIXMAP_BIT
)
72 strcat(surfString
, "pix,");
73 if (strlen(surfString
) > 0)
74 surfString
[strlen(surfString
) - 1] = 0;
76 printf("0x%02x %2d %2d %c %c %2d %2d %2d %2d %2d %2d %-12s\n",
78 doubleBuf
? 'y' : '.',
80 red
, green
, blue
, alpha
,
81 depth
, stencil
, surfString
);
89 main(int argc
, char *argv
[])
94 EGLConfig configs
[10];
96 const EGLint pbufAttribs
[] = {
103 EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
105 EGLDisplay d
= eglGetDisplay("!fb_dri");
108 if (!eglInitialize(d
, &maj
, &min
)) {
109 printf("demo: eglInitialize failed\n");
113 printf("EGL version = %d.%d\n", maj
, min
);
114 printf("EGL_VENDOR = %s\n", eglQueryString(d
, EGL_VENDOR
));
118 ctx
= eglCreateContext(d
, configs
[0], EGL_NO_CONTEXT
, NULL
);
119 if (ctx
== EGL_NO_CONTEXT
) {
120 printf("failed to create context\n");
124 pbuffer
= eglCreatePbufferSurface(d
, configs
[0], pbufAttribs
);
125 if (pbuffer
== EGL_NO_SURFACE
) {
126 printf("failed to create pbuffer\n");
130 b
= eglMakeCurrent(d
, pbuffer
, pbuffer
, ctx
);
132 printf("make current failed\n");
136 b
= eglMakeCurrent(d
, EGL_NO_SURFACE
, EGL_NO_SURFACE
, EGL_NO_CONTEXT
);
140 eglDestroySurface(d
, pbuffer
);
141 eglDestroyContext(d
, ctx
);