+#if defined(USE_X11)\r
+ // Initializes the display and screen\r
+ x11Display = XOpenDisplay( ":0" );\r
+ if (!x11Display)\r
+ {\r
+ printf("GLES Error: Unable to open X display\n");\r
+ return -1;\r
+ }\r
+ x11Screen = XDefaultScreen( x11Display );\r
+\r
+ // Gets the display parameters so we can pass the same parameters to the window to be created.\r
+ sRootWindow = RootWindow(x11Display, x11Screen);\r
+ i32Depth = DefaultDepth(x11Display, x11Screen);\r
+ px11Visual = &x11Visual;\r
+ XMatchVisualInfo( x11Display, x11Screen, i32Depth, TrueColor, px11Visual);\r
+ if (!px11Visual)\r
+ {\r
+ printf("GLES Error: Unable to acquire visual\n");\r
+ return -1;\r
+ }\r
+ // Colormap of the specified visual type for the display.\r
+ x11Colormap = XCreateColormap( x11Display, sRootWindow, px11Visual->visual, AllocNone );\r
+ sWA.colormap = x11Colormap;\r
+\r
+ // List of events to be handled by the application. Add to these for handling other events.\r
+ sWA.event_mask = StructureNotifyMask | ExposureMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask;\r
+\r
+ // Display capabilities list.\r
+ ui32Mask = CWBackPixel | CWBorderPixel | CWEventMask | CWColormap;\r
+\r
+ // Creates the X11 window\r
+ x11Window = XCreateWindow( x11Display, RootWindow(x11Display, x11Screen), 0, 0, iResX, iResY,\r
+ 0, CopyFromParent, InputOutput, CopyFromParent, ui32Mask, &sWA);\r
+\r
+ // Make the window viewable and flush the output buffer.\r
+ XMapWindow(x11Display, x11Window);\r
+ XFlush(x11Display);\r
+\r
+ // Make the window fullscreen\r
+ unsigned char fullScreen = 1;\r
+ Atom wmState = XInternAtom(x11Display, "_NET_WM_STATE", False);\r
+ Atom wmFullScreen = XInternAtom(x11Display,"_NET_WM_STATE_FULLSCREEN", False);\r
+\r
+ XEvent xev;\r
+ xev.xclient.type = ClientMessage;\r
+ xev.xclient.serial = 0;\r
+ xev.xclient.send_event = True;\r
+ xev.xclient.window = x11Window;\r
+ xev.xclient.message_type = wmState;\r
+ xev.xclient.format = 32;\r
+ xev.xclient.data.l[0] = (fullScreen ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE);\r
+ xev.xclient.data.l[1] = wmFullScreen;\r
+ xev.xclient.data.l[2] = 0;\r
+\r
+ XSendEvent(x11Display, DefaultRootWindow(x11Display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);\r
+\r
+ display = eglGetDisplay( (EGLNativeDisplayType)x11Display );\r
+ window = x11Window;\r
+#else\r
+ display = eglGetDisplay( (EGLNativeDisplayType)0 );\r
+#endif\r
+\r
+ if( display == EGL_NO_DISPLAY )\r