Check that the framebuffer image matches expectations
This commit is contained in:
parent
d562f588cf
commit
4003931ed9
1 changed files with 13 additions and 0 deletions
|
@ -31,6 +31,14 @@ static bool CheckShm() {
|
||||||
return exists;
|
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() {
|
void createFramebuffer() {
|
||||||
gc = DefaultGC(xDisplay, DefaultScreen(xDisplay));
|
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);
|
XSetWMProtocols(xDisplay, window, &WM_DELETE_WINDOW, 1);
|
||||||
|
|
||||||
createFramebuffer();
|
createFramebuffer();
|
||||||
|
if(checkImageOK(framebufferImage) == false) {
|
||||||
|
Backend_PrintError("Something's off with the framebuffer.\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if(framebufferImage == 0) {
|
if(framebufferImage == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
framebufferPitch = screen_width * 4;
|
framebufferPitch = screen_width * 4;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue