home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mesa5.zip / mesa5src.zip / MesaDLL / GL / win32_x11.h < prev    next >
C/C++ Source or Header  |  2001-09-18  |  10KB  |  327 lines

  1. #ifndef __win32_x11_h__
  2. #define __win32_x11_h__
  3.  
  4. /* Copyright (c) Nate Robins, 1997. */
  5.  
  6. /* This program is freely distributable without licensing fees 
  7.    and is provided without guarantee or warrantee expressed or 
  8.    implied. This program is -not- in the public domain. */
  9.  
  10. #include <stdlib.h>
  11. #include <windows.h>
  12.  
  13. /* These definitions are missing from windows.h */
  14. WINGDIAPI int WINAPI wglChoosePixelFormat(HDC, PIXELFORMATDESCRIPTOR *);
  15. WINGDIAPI int WINAPI wglDescribePixelFormat(HDC, int, UINT, LPPIXELFORMATDESCRIPTOR);
  16. WINGDIAPI int WINAPI wglGetPixelFormat(HDC);
  17. WINGDIAPI BOOL WINAPI wglSetPixelFormat(HDC, int, PIXELFORMATDESCRIPTOR *);
  18. WINGDIAPI BOOL WINAPI wglSwapBuffers(HDC);
  19.  
  20. /* Type definitions (conversions) */
  21. typedef int Visual;            /* Win32 equivalent of X11 type */
  22. typedef HWND Window;
  23. typedef HPALETTE Colormap;
  24. typedef PIXELFORMATDESCRIPTOR XVisualInfo;
  25. typedef BOOL Bool;
  26. typedef MSG XEvent;
  27. typedef HDC Display;
  28. typedef HCURSOR Cursor;
  29.  
  30. typedef int Atom;            /* dummies */
  31. typedef int XDevice;
  32. typedef int Status;
  33.  
  34. #define True  TRUE            /* Win32 equivalents of X11 booleans */
  35. #define False FALSE
  36.  
  37. #define None                 0L    /* universal null resource or null atom */
  38.  
  39. /* Input Event Masks. Used as event-mask window attribute and as arguments
  40.    to Grab requests.  Not to be confused with event names.  */
  41.  
  42. #define NoEventMask            0L
  43. #define KeyPressMask            (1L<<0)  
  44. #define KeyReleaseMask            (1L<<1)  
  45. #define ButtonPressMask            (1L<<2)  
  46. #define ButtonReleaseMask        (1L<<3)  
  47. #define EnterWindowMask            (1L<<4)  
  48. #define LeaveWindowMask            (1L<<5)  
  49. #define PointerMotionMask        (1L<<6)  
  50. #define PointerMotionHintMask        (1L<<7)  
  51. #define Button1MotionMask        (1L<<8)  
  52. #define Button2MotionMask        (1L<<9)  
  53. #define Button3MotionMask        (1L<<10) 
  54. #define Button4MotionMask        (1L<<11) 
  55. #define Button5MotionMask        (1L<<12) 
  56. #define ButtonMotionMask        (1L<<13) 
  57. #define KeymapStateMask            (1L<<14)
  58. #define ExposureMask            (1L<<15) 
  59. #define VisibilityChangeMask        (1L<<16) 
  60. #define StructureNotifyMask        (1L<<17) 
  61. #define ResizeRedirectMask        (1L<<18) 
  62. #define SubstructureNotifyMask        (1L<<19) 
  63. #define SubstructureRedirectMask    (1L<<20) 
  64. #define FocusChangeMask            (1L<<21) 
  65. #define PropertyChangeMask        (1L<<22) 
  66. #define ColormapChangeMask        (1L<<23) 
  67. #define OwnerGrabButtonMask        (1L<<24) 
  68.  
  69. /* Key masks. Used as modifiers to GrabButton and GrabKey, results of
  70.    QueryPointer, state in various key-, mouse-, and button-related
  71.    events. */
  72.  
  73. #define ShiftMask        (1<<0)
  74. #define LockMask        (1<<1)
  75. #define ControlMask        (1<<2)
  76. #define Mod1Mask        (1<<3)
  77. #define Mod2Mask        (1<<4)
  78. #define Mod3Mask        (1<<5)
  79. #define Mod4Mask        (1<<6)
  80. #define Mod5Mask        (1<<7)
  81.  
  82. /* Window classes used by CreateWindow */
  83. /* Note that CopyFromParent is already defined as 0 above */
  84.  
  85. #define InputOutput        1
  86. #define InputOnly        2
  87.  
  88. /* Window attributes for CreateWindow and ChangeWindowAttributes */
  89.  
  90. #define CWBackPixmap        (1L<<0)
  91. #define CWBackPixel        (1L<<1)
  92. #define CWBorderPixmap        (1L<<2)
  93. #define CWBorderPixel           (1L<<3)
  94. #define CWBitGravity        (1L<<4)
  95. #define CWWinGravity        (1L<<5)
  96. #define CWBackingStore          (1L<<6)
  97. #define CWBackingPlanes            (1L<<7)
  98. #define CWBackingPixel            (1L<<8)
  99. #define CWOverrideRedirect    (1L<<9)
  100. #define CWSaveUnder        (1L<<10)
  101. #define CWEventMask        (1L<<11)
  102. #define CWDontPropagate            (1L<<12)
  103. #define CWColormap        (1L<<13)
  104. #define CWCursor            (1L<<14)
  105.  
  106. /* ConfigureWindow structure */
  107.  
  108. #define CWX            (1<<0)
  109. #define CWY            (1<<1)
  110. #define CWWidth            (1<<2)
  111. #define CWHeight        (1<<3)
  112. #define CWBorderWidth        (1<<4)
  113. #define CWSibling        (1<<5)
  114. #define CWStackMode        (1<<6)
  115.  
  116.  
  117. /* Used in GetWindowAttributes reply */
  118.  
  119. #define IsUnmapped        0
  120. #define IsUnviewable        1
  121. #define IsViewable        2
  122.  
  123. /* Window stacking method (in configureWindow) */
  124.  
  125. #define Above                   0
  126. #define Below                   1
  127. #define TopIf                   2
  128. #define BottomIf                3
  129. #define Opposite                4
  130.  
  131. /* For CreateColormap */
  132.  
  133. #define AllocNone        0    /* create map with no entries */
  134. #define AllocAll        1    /* allocate entire map writeable */
  135.  
  136.  
  137. /* Flags used in StoreNamedColor, StoreColors */
  138.  
  139. #define DoRed            (1<<0)
  140. #define DoGreen            (1<<1)
  141. #define DoBlue            (1<<2)
  142.  
  143. /* 
  144.  * Bitmask returned by XParseGeometry().  Each bit tells if the corresponding
  145.  * value (x, y, width, height) was found in the parsed string.
  146.  */
  147. #define NoValue        0x0000
  148. #define XValue      0x0001
  149. #define YValue        0x0002
  150. #define WidthValue      0x0004
  151. #define HeightValue      0x0008
  152. #define AllValues     0x000F
  153. #define XNegative     0x0010
  154. #define YNegative     0x0020
  155.  
  156. /* flags argument in size hints */
  157. #define USPosition    (1L << 0) /* user specified x, y */
  158. #define USSize        (1L << 1) /* user specified width, height */
  159.  
  160. /* definitions for initial window state */
  161. #define WithdrawnState 0    /* for windows that are not mapped */
  162. #define NormalState 1    /* most applications want to start this way */
  163. #define IconicState 3    /* application wants to start as an icon */
  164. #define GameModeState 4  /* Win32 GLUT only (not in Xlib!). */
  165.  
  166. /* Type definitions */
  167.  
  168. typedef struct {
  169.     unsigned int background_pixmap;    /* background pixmap */
  170.     unsigned long background_pixel;    /* background pixel */
  171.     unsigned long border_pixel;    /* border pixel value */
  172.     long event_mask;        /* set of events that should be saved */
  173.     long do_not_propagate_mask;    /* set of events that should not propagate */
  174.     Bool override_redirect;       /* boolean value for override-redirect */
  175.     Colormap colormap;           /* color map to be associated with window */
  176. } XSetWindowAttributes;
  177.  
  178. typedef struct {
  179.   unsigned long pixel;
  180.   unsigned short red, green, blue;
  181.   char flags;  /* do_red, do_green, do_blue */
  182. } XColor;
  183.  
  184. typedef struct {
  185.   unsigned char *value;       /* same as Property routines */
  186.   Atom encoding;       /* prop type */
  187.   int format;           /* prop data format: 8, 16, or 32 */
  188.   unsigned long nitems;       /* number of data items in value */
  189. } XTextProperty;
  190.  
  191. typedef struct {
  192.   long flags;            /* marks which fields in this structure are defined */
  193.   int x, y;        /* obsolete for new window mgrs, but clients */
  194.   int width, height;    /* should set so old wm's don't mess up */
  195. } XSizeHints;
  196.  
  197. /* Functions emulated by macros. */
  198.  
  199. #define XFreeColormap(display, colormap) \
  200.   DeleteObject(colormap)
  201.  
  202. #define XCreateFontCursor(display, shape) \
  203.   LoadCursor(NULL, shape)
  204.  
  205. #define XDefineCursor(display, window, cursor) \
  206.   SetCursor(cursor)
  207.  
  208. #define XFlush(display) \
  209.   /* Nothing. */
  210.  
  211. #define DisplayWidth(display, screen) \
  212.   GetSystemMetrics(SM_CXSCREEN)
  213.  
  214. #define DisplayHeight(display, screen) \
  215.   GetSystemMetrics(SM_CYSCREEN)
  216.  
  217. #define XMapWindow(display, window) \
  218.   ShowWindow(window, SW_SHOWNORMAL)
  219.  
  220. #define XUnmapWindow(display, window) \
  221.   ShowWindow(window, SW_HIDE)
  222.  
  223. #define XIconifyWindow(display, window, screen) \
  224.   ShowWindow(window, SW_MINIMIZE)
  225.  
  226. #define XWithdrawWindow(display, window, screen) \
  227.   ShowWindow(window, SW_HIDE)
  228.  
  229. #define XLowerWindow(display, window) \
  230.   SetWindowPos(window, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE)
  231.  
  232. #define XSetWMName(display, window, tp) \
  233.   SetWindowText(window, (tp)->value)
  234.  
  235. /* There really isn't a way to set the icon name separate from the
  236.    windows name in Win32, so, just set the windows name. */
  237. #define XSetWMIconName(display, window, tp) \
  238.   XSetWMName(display, window, tp)
  239.  
  240. #define XDestroyWindow(display, window) \
  241.   DestroyWindow(window)
  242.  
  243. /* Anything that needs to be freed was allocated with malloc in our
  244.    fake X windows library for Win32, so free it with plain old
  245.    free(). */
  246. #define XFree(data) \
  247.   free(data)
  248.  
  249. /* Nothing to be done for this...the pointer is always 'ungrabbed'
  250.    in Win32. */
  251. #define XUngrabPointer(display, time) \
  252.   /* Nothing. */
  253.  
  254. /* Function prototypes. */
  255.  
  256. extern XVisualInfo* XGetVisualInfo(
  257.   Display* display,
  258.   long mask,
  259.   XVisualInfo* ttemplate,  /* Avoid class with C++ keyword. */
  260.   int*nitems);
  261.  
  262. extern Colormap XCreateColormap(
  263.   Display* display,
  264.   Window root,
  265.   Visual* visual,
  266.   int alloc);
  267.  
  268. extern void XAllocColorCells(
  269.   Display* display,
  270.   Colormap colormap,
  271.   Bool contig, 
  272.   unsigned long plane_masks_return[],
  273.   unsigned int nplanes,
  274.   unsigned long pixels_return[],
  275.   unsigned int npixels);
  276.  
  277. extern void XStoreColor(
  278.   Display* display,
  279.   Colormap colormap,
  280.   XColor* color);
  281.  
  282. extern void XSetWindowColormap(
  283.   Display* display,
  284.   Window window,
  285.   Colormap colormap);
  286.  
  287. extern Bool XTranslateCoordinates(
  288.   Display *display,
  289.   Window src, Window dst, 
  290.   int src_x, int src_y, 
  291.   int* dest_x_return, int* dest_y_return,
  292.   Window* child_return);
  293.  
  294. extern Status XGetGeometry(
  295.   Display* display,
  296.   Window window,
  297.   Window* root_return, 
  298.   int* x_return, int* y_return, 
  299.   unsigned int* width_return, unsigned int* height_return,
  300.   unsigned int *border_width_return,
  301.   unsigned int* depth_return);
  302.  
  303. extern int DisplayWidthMM(
  304.   Display* display,
  305.   int screen);
  306.  
  307. extern int DisplayHeightMM(
  308.   Display* display,
  309.   int screen);
  310.  
  311. extern void XWarpPointer(
  312.   Display* display,
  313.   Window src, Window dst, 
  314.   int src_x, int src_y,
  315.   int src_width, int src_height, 
  316.   int dst_x, int dst_y);
  317.  
  318. extern int XParseGeometry(
  319.   char* string,
  320.   int* x, int* y, 
  321.   unsigned int* width, unsigned int* height);
  322.  
  323. extern int XPending(
  324.   Display* display);
  325.  
  326. #endif /* __win32_x11_h__ */
  327.