1 #define USE_OPENGLES2 1
11 #include <X11/Xutil.h>
15 EGLDisplay egldisplay;
20 static EGLint attributeList[] = {
25 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
30 static EGLint attributeList[] = {
39 createEGLWindow(int width, int height, char *name)
45 XSetWindowAttributes swa;
50 EGLint aEGLContextAttributes[] = {
51 EGL_CONTEXT_CLIENT_VERSION, 2,
57 egldisplay = eglGetDisplay(dpy = XOpenDisplay(NULL));
58 eglInitialize(egldisplay, 0, 0);
60 (egldisplay, attributeList, config,
61 sizeof config / sizeof config[0], &nconfig)) {
62 dbg(0, "can't find requested config\n");
66 cx = eglCreateContext(egldisplay, config[0], EGL_NO_CONTEXT, aEGLContextAttributes);
68 cx = eglCreateContext(egldisplay, config[0], EGL_NO_CONTEXT, NULL);
71 eglGetConfigAttrib(egldisplay, config[0], EGL_NATIVE_VISUAL_ID,
74 vi = XGetVisualInfo(dpy, VisualIDMask, &tmp, &n);
76 XCreateColormap(dpy, RootWindow(dpy, vi->screen), vi->visual,
79 sizehints.flags = PMinSize | PMaxSize;
80 sizehints.min_width = sizehints.max_width = width;
81 sizehints.min_height = sizehints.max_height = height;
86 ExposureMask | StructureNotifyMask | KeyPressMask |
87 ButtonPressMask | ButtonReleaseMask;
89 XCreateWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, width,
90 height, 0, vi->depth, InputOutput, vi->visual,
91 CWBorderPixel | CWColormap | CWEventMask, &swa);
92 XMapWindow(dpy, window);
93 XSetStandardProperties(dpy, window, name, name, None, (void *) 0, 0, &sizehints);
95 eglwindow = eglCreateWindowSurface(egldisplay, config[0], (NativeWindowType) window, 0);
96 eglMakeCurrent(egldisplay, eglwindow, eglwindow, cx);