| 7043 | } |
| 7044 | |
| 7045 | virtual olc::rcode CreateWindowPane(const olc::vi2d& vWindowPos, olc::vi2d& vWindowSize, bool bFullScreen) override |
| 7046 | { |
| 7047 | using namespace X11; |
| 7048 | XInitThreads(); |
| 7049 | |
| 7050 | // Grab the deafult display and window |
| 7051 | olc_Display = XOpenDisplay(NULL); |
| 7052 | olc_WindowRoot = DefaultRootWindow(olc_Display); |
| 7053 | |
| 7054 | // Based on the display capabilities, configure the appearance of the window |
| 7055 | GLint olc_GLAttribs[] = { GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None }; |
| 7056 | olc_VisualInfo = glXChooseVisual(olc_Display, 0, olc_GLAttribs); |
| 7057 | olc_ColourMap = XCreateColormap(olc_Display, olc_WindowRoot, olc_VisualInfo->visual, AllocNone); |
| 7058 | olc_SetWindowAttribs.colormap = olc_ColourMap; |
| 7059 | |
| 7060 | // Register which events we are interested in receiving |
| 7061 | olc_SetWindowAttribs.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | |
| 7062 | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | FocusChangeMask | StructureNotifyMask; |
| 7063 | |
| 7064 | // Create the window |
| 7065 | olc_Window = XCreateWindow(olc_Display, olc_WindowRoot, vWindowPos.x, vWindowPos.y, |
| 7066 | vWindowSize.x, vWindowSize.y, |
| 7067 | 0, olc_VisualInfo->depth, InputOutput, olc_VisualInfo->visual, |
| 7068 | CWColormap | CWEventMask, &olc_SetWindowAttribs); |
| 7069 | |
| 7070 | Atom wmDelete = XInternAtom(olc_Display, "WM_DELETE_WINDOW", true); |
| 7071 | XSetWMProtocols(olc_Display, olc_Window, &wmDelete, 1); |
| 7072 | |
| 7073 | XMapWindow(olc_Display, olc_Window); |
| 7074 | XStoreName(olc_Display, olc_Window, "OneLoneCoder.com - Pixel Game Engine"); |
| 7075 | |
| 7076 | if (bFullScreen) // Thanks DragonEye, again :D |
| 7077 | { |
| 7078 | Atom wm_state; |
| 7079 | Atom fullscreen; |
| 7080 | wm_state = XInternAtom(olc_Display, "_NET_WM_STATE", False); |
| 7081 | fullscreen = XInternAtom(olc_Display, "_NET_WM_STATE_FULLSCREEN", False); |
| 7082 | XEvent xev{ 0 }; |
| 7083 | xev.type = ClientMessage; |
| 7084 | xev.xclient.window = olc_Window; |
| 7085 | xev.xclient.message_type = wm_state; |
| 7086 | xev.xclient.format = 32; |
| 7087 | xev.xclient.data.l[0] = (bFullScreen ? 1 : 0); // the action (0: off, 1: on, 2: toggle) |
| 7088 | xev.xclient.data.l[1] = fullscreen; // first property to alter |
| 7089 | xev.xclient.data.l[2] = 0; // second property to alter |
| 7090 | xev.xclient.data.l[3] = 0; // source indication |
| 7091 | XMapWindow(olc_Display, olc_Window); |
| 7092 | XSendEvent(olc_Display, DefaultRootWindow(olc_Display), False, |
| 7093 | SubstructureRedirectMask | SubstructureNotifyMask, &xev); |
| 7094 | XFlush(olc_Display); |
| 7095 | XWindowAttributes gwa; |
| 7096 | XGetWindowAttributes(olc_Display, olc_Window, &gwa); |
| 7097 | vWindowSize.x = gwa.width; |
| 7098 | vWindowSize.y = gwa.height; |
| 7099 | } |
| 7100 | |
| 7101 | // Create Keyboard Mapping |
| 7102 | mapKeys[NoSymbol] = Key::NONE; |
nothing calls this directly
no outgoing calls
no test coverage detected