2 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 * Stolen from eglgears
25 * Creates a surface and show that on the first screen
28 #define EGL_EGLEXT_PROTOTYPES
38 #include <EGL/eglext.h>
40 #define MAX_CONFIGS 10
44 main(int argc
, char *argv
[])
47 EGLSurface screen_surf
;
48 EGLConfig configs
[MAX_CONFIGS
];
52 EGLint screenAttribs
[10];
53 EGLModeMESA mode
[MAX_MODES
];
56 EGLint chosenMode
= 0;
57 EGLint width
= 0, height
= 0;
59 d
= eglGetDisplay(EGL_DEFAULT_DISPLAY
);
62 if (!eglInitialize(d
, &maj
, &min
)) {
63 printf("eglscreen: eglInitialize failed\n");
67 printf("eglscreen: EGL version = %d.%d\n", maj
, min
);
68 printf("eglscreen: EGL_VENDOR = %s\n", eglQueryString(d
, EGL_VENDOR
));
70 /* XXX use ChooseConfig */
71 eglGetConfigs(d
, configs
, MAX_CONFIGS
, &numConfigs
);
72 eglGetScreensMESA(d
, &screen
, 1, &count
);
74 if (!eglGetModesMESA(d
, screen
, mode
, MAX_MODES
, &count
) || count
== 0) {
75 printf("eglscreen: eglGetModesMESA failed!\n");
79 /* Print list of modes, and find the one to use */
80 printf("eglscreen: Found %d modes:\n", count
);
81 for (i
= 0; i
< count
; i
++) {
83 eglGetModeAttribMESA(d
, mode
[i
], EGL_WIDTH
, &w
);
84 eglGetModeAttribMESA(d
, mode
[i
], EGL_HEIGHT
, &h
);
85 printf("%3d: %d x %d\n", i
, w
, h
);
86 if (w
> width
&& h
> height
) {
92 printf("eglscreen: Using screen mode/size %d: %d x %d\n", chosenMode
, width
, height
);
94 /* build up screenAttribs array */
96 screenAttribs
[i
++] = EGL_WIDTH
;
97 screenAttribs
[i
++] = width
;
98 screenAttribs
[i
++] = EGL_HEIGHT
;
99 screenAttribs
[i
++] = height
;
100 screenAttribs
[i
++] = EGL_NONE
;
102 screen_surf
= eglCreateScreenSurfaceMESA(d
, configs
[0], screenAttribs
);
103 if (screen_surf
== EGL_NO_SURFACE
) {
104 printf("eglscreen: Failed to create screen surface\n");
108 b
= eglShowScreenSurfaceMESA(d
, screen
, screen_surf
, mode
[chosenMode
]);
110 printf("eglscreen: Show surface failed\n");
116 eglDestroySurface(d
, screen_surf
);