diff --git a/src/Backends/Rendering/Window/Software/X11.cpp b/src/Backends/Rendering/Window/Software/X11.cpp index 36827fc9..e5f8f0dc 100644 --- a/src/Backends/Rendering/Window/Software/X11.cpp +++ b/src/Backends/Rendering/Window/Software/X11.cpp @@ -31,6 +31,14 @@ static bool CheckShm() { return exists; } +bool checkImageOK(XImage* image) { + bool ok = true; + ok &= (image->width == screenWidth); + ok &= (image->bytes_per_line == screenWidth * 4); + ok &= (image->depth == 24 || image->depth == 32); + return ok; +} + void createFramebuffer() { gc = DefaultGC(xDisplay, DefaultScreen(xDisplay)); @@ -83,10 +91,15 @@ bool WindowBackend_Software_CreateWindow(const char *window_title, size_t screen XSetWMProtocols(xDisplay, window, &WM_DELETE_WINDOW, 1); createFramebuffer(); + if(checkImageOK(framebufferImage) == false) { + Backend_PrintError("Something's off with the framebuffer.\n"); + return false; + } if(framebufferImage == 0) { return false; } + framebufferPitch = screen_width * 4; return true; }