]> icculus.org git repositories - theoddone33/hhexen.git/blob - include/xshmext.h
osezer patch 003
[theoddone33/hhexen.git] / include / xshmext.h
1 #ifndef XSHMEXT_H
2 #define XSHMEXT_H
3 //============================================================================
4 //
5 // $Id$
6 //
7 // MIT Shared Memory Extension for X
8 //
9 //============================================================================
10
11
12 #include <X11/Xlib.h>
13 #include <X11/Xutil.h>
14 #include <sys/ipc.h>
15 #include <sys/shm.h>
16 #include <X11/extensions/XShm.h>
17
18
19 // Not in any Linux header file...
20 extern "C" {
21     //extern int XShmQueryExtension( Display* );
22     extern int XShmGetEventBase( Display* );
23 }
24
25
26 class ShmImage
27 {
28 public:
29
30         static int query( Display* );
31
32     static int completionType( Display* dis )
33     {
34         return XShmGetEventBase( dis ) + ShmCompletion;
35     }
36
37     ShmImage( Display*, int width, int height, XVisualInfo* );
38
39     ~ShmImage();
40
41     XImage* image() { return _XImage; }
42         
43     void put( Drawable d, GC gc )
44     {
45         XShmPutImage( _display, d, gc, _XImage, 0, 0, 0, 0,
46                       _XImage->width, _XImage->height, False );
47     }
48
49 private:
50
51     XImage* _XImage;
52     Display* _display;
53     XShmSegmentInfo _si;
54 };
55
56
57 class ShmPixmap
58 {
59 public:
60
61         static int query( Display* );
62
63     ShmPixmap( Display*, Drawable, int width, int height, int depth = 0 );
64
65     ~ShmPixmap();
66
67     Pixmap pixmap() { return _pix; }
68
69 private:
70     
71     Pixmap _pix;
72     Display* _display;
73     XShmSegmentInfo _si;
74 };
75
76
77 #endif // XSHMEXT_H
78