[Scummvm-cvs-logs] CVS: scummvm/backends/x11 x11.cpp,1.21,1.22
Jonathan Gray
khalek at users.sourceforge.net
Thu Feb 12 16:50:07 CET 2004
Update of /cvsroot/scummvm/scummvm/backends/x11
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23579
Modified Files:
x11.cpp
Log Message:
patch #896094, Some X11 backend fixes from Gregor Jasny
Index: x11.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/x11/x11.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- x11.cpp 18 Dec 2003 20:20:01 -0000 1.21
+++ x11.cpp 13 Feb 2004 00:44:30 -0000 1.22
@@ -22,6 +22,7 @@
/* The bare pure X11 port done by Lionel 'BBrox' Ulmer */
+#include "common/stdafx.h"
#include "backends/intern.h"
#include "common/util.h"
#include "base/engine.h" // Only #included for error() and warning()
@@ -166,7 +167,7 @@
uint16 *palette;
bool _palette_changed;
Display *display;
- int screen;
+ int screen, depth;
Window window;
GC black_gc;
XImage *image;
@@ -352,7 +353,14 @@
error("Could not open display !\n");
exit(1);
}
+
+ if (XShmQueryExtension(display)!=True)
+ error("No Shared Memory Extension present");
+
screen = DefaultScreen(display);
+ depth = DefaultDepth(display,screen);
+ if (depth != 16)
+ error("Your screen depth is %ibit. Values other than 16bit are currently not supported", depth);
window_width = 320;
window_height = 200;
@@ -425,10 +433,16 @@
XConfigureWindow(display, window, CWWidth | CWHeight, &new_values);
}
- image = XShmCreateImage(display, DefaultVisual(display, screen), 16, ZPixmap, NULL, &shminfo, fb_width, fb_height);
- shminfo.shmid = shmget(IPC_PRIVATE, fb_width * fb_height * 2, IPC_CREAT | 0700);
- shminfo.shmaddr = (char *)shmat(shminfo.shmid, 0, 0);
- image->data = shminfo.shmaddr;
+
+ image = XShmCreateImage(display, DefaultVisual(display, screen), depth, ZPixmap, NULL, &shminfo, fb_width, fb_height);
+ if (!image)
+ error("Couldn't get image by XShmCreateImage()");
+
+ shminfo.shmid = shmget(IPC_PRIVATE, image->bytes_per_line * image->height, IPC_CREAT | 0700);
+ if (shminfo.shmid < 0)
+ error("Couldn't allocate image data by shmget()");
+
+ image->data = shminfo.shmaddr = (char *)shmat(shminfo.shmid, 0, 0);
shminfo.readOnly = False;
if (XShmAttach(display, &shminfo) == 0) {
error("Could not attach shared memory segment !\n");
More information about the Scummvm-git-logs
mailing list