MCPcopy Create free account
hub / github.com/OneLoneCoder/olcPixelGameEngine / Platform_Linux

Class Platform_Linux

olcPixelGameEngine.h:7001–7266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6999namespace olc
7000{
7001 class Platform_Linux : public olc::Platform
7002 {
7003 private:
7004 X11::Display* olc_Display = nullptr;
7005 X11::Window olc_WindowRoot;
7006 X11::Window olc_Window;
7007 X11::XVisualInfo* olc_VisualInfo;
7008 X11::Colormap olc_ColourMap;
7009 X11::XSetWindowAttributes olc_SetWindowAttribs;
7010
7011 public:
7012 virtual olc::rcode ApplicationStartUp() override
7013 {
7014 return olc::rcode::OK;
7015 }
7016
7017 virtual olc::rcode ApplicationCleanUp() override
7018 {
7019 XDestroyWindow(olc_Display, olc_Window);
7020 return olc::rcode::OK;
7021 }
7022
7023 virtual olc::rcode ThreadStartUp() override
7024 {
7025 return olc::rcode::OK;
7026 }
7027
7028 virtual olc::rcode ThreadCleanUp() override
7029 {
7030 renderer->DestroyDevice();
7031 return olc::OK;
7032 }
7033
7034 virtual olc::rcode CreateGraphics(bool bFullScreen, bool bEnableVSYNC, const olc::vi2d& vViewPos, const olc::vi2d& vViewSize) override
7035 {
7036 if (renderer->CreateDevice({ olc_Display, &olc_Window, olc_VisualInfo }, bFullScreen, bEnableVSYNC) == olc::rcode::OK)
7037 {
7038 renderer->UpdateViewport(vViewPos, vViewSize);
7039 return olc::rcode::OK;
7040 }
7041 else
7042 return olc::rcode::FAIL;
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;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected