home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mesa5.zip / mesa5src.zip / MesaDLL / GL / WarpGL.h < prev    next >
C/C++ Source or Header  |  2002-12-08  |  12KB  |  377 lines

  1. /* WarpGL.h */
  2. #ifndef __WarpGL_x11_h__
  3. #define __WarpGL_x11_h__
  4.  
  5.    #include "GL\os2_x11.h"
  6.  
  7. #include "GL\gl.h"
  8. #include "GL\glut.h"
  9.  
  10. #include "WarpWin.h"
  11.  
  12. #define CALLBACK
  13.  
  14. #define HGLRC GLXContext
  15.    typedef void * GLXContext;
  16.  
  17. struct PixelFormatDescriptor
  18. { int nSize;    //    sizeof(struct PixelFormatDescriptor),  αẼÑα ßΓαπ¬Γπαδ
  19.   int nVersion; // ¡«¼Ñα óÑαß¿¿
  20.   int dwFlags;
  21.   int iPixelType;  // αáºα∩ñ«ó ¡á µóÑΓ
  22. int cColorBits;    
  23. int cAlphaBits;    // á½∞Σá »áαá¼ÑΓα
  24. int cRedBits;      // í¿Γδ µóÑΓá
  25. int cGreenBits;
  26. int cBlueBits;
  27.  
  28. int cAccumBits;     // íπΣÑα á¬¬π¼π½∩Γ«αá
  29. int cAccumRedBits;  // í¿Γδ á¬¬π¼π½∩Γ«αá
  30. int cAccumBlueBits;
  31. int cAccumGreenBits;
  32. int cAccumAlphaBits;
  33.  
  34. int cDepthBits;     // páºα∩ñ«ó íπΣÑα ú½πí¿¡δ
  35. int cStencilBits;   // íπΣÑα ΓαáΣáαÑΓá
  36.  
  37. int cAuxBuffers;    // óß»«¼«úáΓѽ∞¡δ⌐ íπΣÑα 
  38. int bReserved;      // ºáαѺÑαó¿α«óá¡
  39.  
  40.   int buf[10]; //??
  41. };
  42.  
  43. typedef struct PixelFormatDescriptor XVisualInfo;
  44. typedef  XVisualInfo PIXELFORMATDESCRIPTOR;
  45.  
  46.  
  47. /* Type definitions (conversions) */
  48. typedef HPAL Colormap;
  49. typedef QMSG XEvent;
  50.  
  51. typedef int Visual;                    /* Win32 equivalent of X11 type */
  52. typedef HWND Window;
  53. typedef BOOL Bool;
  54. typedef HDC Display;
  55.  
  56. //typedef HCURSOR Cursor;
  57.  
  58. typedef int Atom;                      /* dummies */
  59. typedef int XDevice;
  60. typedef int Status;
  61.  
  62. #define True  TRUE                     /* Win32 equivalents of X11 booleans */
  63. #define False FALSE
  64.  
  65. #define None                 0L        /* universal null resource or null atom */
  66.  
  67. /* Input Event Masks. Used as event-mask window attribute and as arguments
  68.    to Grab requests.  Not to be confused with event names.  */
  69.  
  70. #define NoEventMask                    0L
  71. #define KeyPressMask                   (1L<<0)
  72. #define KeyReleaseMask                 (1L<<1)
  73. #define ButtonPressMask                        (1L<<2)
  74. #define ButtonReleaseMask              (1L<<3)
  75. #define EnterWindowMask                        (1L<<4)
  76. #define LeaveWindowMask                        (1L<<5)
  77. #define PointerMotionMask              (1L<<6)
  78. #define PointerMotionHintMask          (1L<<7)
  79. #define Button1MotionMask              (1L<<8)
  80. #define Button2MotionMask              (1L<<9)
  81. #define Button3MotionMask              (1L<<10)
  82. #define Button4MotionMask              (1L<<11)
  83. #define Button5MotionMask              (1L<<12)
  84. #define ButtonMotionMask               (1L<<13)
  85. #define KeymapStateMask                        (1L<<14)
  86. #define ExposureMask                   (1L<<15)
  87. #define VisibilityChangeMask           (1L<<16)
  88. #define StructureNotifyMask            (1L<<17)
  89. #define ResizeRedirectMask             (1L<<18)
  90. #define SubstructureNotifyMask         (1L<<19)
  91. #define SubstructureRedirectMask       (1L<<20)
  92. #define FocusChangeMask                        (1L<<21)
  93. #define PropertyChangeMask             (1L<<22)
  94. #define ColormapChangeMask             (1L<<23)
  95. #define OwnerGrabButtonMask            (1L<<24)
  96.  
  97. /* Key masks. Used as modifiers to GrabButton and GrabKey, results of
  98.    QueryPointer, state in various key-, mouse-, and button-related
  99.    events. */
  100.  
  101. #define ShiftMask              (1<<0)
  102. #define LockMask               (1<<1)
  103. #define ControlMask            (1<<2)
  104. #define Mod1Mask               (1<<3)
  105. #define Mod2Mask               (1<<4)
  106. #define Mod3Mask               (1<<5)
  107. #define Mod4Mask               (1<<6)
  108. #define Mod5Mask               (1<<7)
  109.  
  110. /* Window classes used by CreateWindow */
  111. /* Note that CopyFromParent is already defined as 0 above */
  112.  
  113. #define InputOutput            1
  114. #define InputOnly              2
  115.  
  116. /* Window attributes for CreateWindow and ChangeWindowAttributes */
  117.  
  118. #define CWBackPixmap           (1L<<0)
  119. #define CWBackPixel            (1L<<1)
  120. #define CWBorderPixmap         (1L<<2)
  121. #define CWBorderPixel           (1L<<3)
  122. #define CWBitGravity           (1L<<4)
  123. #define CWWinGravity           (1L<<5)
  124. #define CWBackingStore          (1L<<6)
  125. #define CWBackingPlanes                (1L<<7)
  126. #define CWBackingPixel         (1L<<8)
  127. #define CWOverrideRedirect     (1L<<9)
  128. #define CWSaveUnder            (1L<<10)
  129. #define CWEventMask            (1L<<11)
  130. #define CWDontPropagate                (1L<<12)
  131. #define CWColormap             (1L<<13)
  132. #define CWCursor               (1L<<14)
  133.  
  134. /* ConfigureWindow structure */
  135.  
  136. #define CWX                    (1<<0)
  137. #define CWY                    (1<<1)
  138. #define CWWidth                        (1<<2)
  139. #define CWHeight               (1<<3)
  140. #define CWBorderWidth          (1<<4)
  141. #define CWSibling              (1<<5)
  142. #define CWStackMode            (1<<6)
  143.  
  144.  
  145. /* Used in GetWindowAttributes reply */
  146.  
  147. #define IsUnmapped             0
  148. #define IsUnviewable           1
  149. #define IsViewable             2
  150.  
  151. /* Window stacking method (in configureWindow) */
  152.  
  153. #define Above                   0
  154. #define Below                   1
  155. #define TopIf                   2
  156. #define BottomIf                3
  157. #define Opposite                4
  158.  
  159. /* For CreateColormap */
  160.  
  161. #define AllocNone              0       /* create map with no entries */
  162. #define AllocAll               1       /* allocate entire map writeable */
  163.  
  164.  
  165. /* Flags used in StoreNamedColor, StoreColors */
  166.  
  167. #define DoRed                  (1<<0)
  168. #define DoGreen                        (1<<1)
  169. #define DoBlue                 (1<<2)
  170.  
  171. /* For XStoreColor */
  172. #define LONGFromRGB(R,G,B) (LONG)(((LONG)R<<16)+((LONG)G<<8)+(LONG)B)
  173.  
  174. /*
  175.  * Bitmask returned by XParseGeometry().  Each bit tells if the corresponding
  176.  * value (x, y, width, height) was found in the parsed string.
  177.  */
  178. #define NoValue                0x0000
  179. #define XValue         0x0001
  180. #define YValue         0x0002
  181. #define WidthValue     0x0004
  182. #define HeightValue    0x0008
  183. #define AllValues      0x000F
  184. #define XNegative      0x0010
  185. #define YNegative      0x0020
  186.  
  187. /* flags argument in size hints */
  188. #define USPosition     (1L << 0) /* user specified x, y */
  189. #define USSize         (1L << 1) /* user specified width, height */
  190.  
  191. /* definitions for initial window state */
  192. #define WithdrawnState 0       /* for windows that are not mapped */
  193. #define NormalState 1  /* most applications want to start this way */
  194. #define IconicState 3  /* application wants to start as an icon */
  195. #define GameModeState 4  /* Win32 GLUT only (not in Xlib!). */
  196.  
  197. /* Type definitions */
  198.  
  199. typedef struct {
  200.     unsigned int background_pixmap;    /* background pixmap */
  201.     unsigned long background_pixel;    /* background pixel */
  202.     unsigned long border_pixel;        /* border pixel value */
  203.     long event_mask;           /* set of events that should be saved */
  204.     long do_not_propagate_mask;        /* set of events that should not propagate */
  205.     Bool override_redirect;       /* boolean value for override-redirect */
  206.     Colormap colormap;            /* color map to be associated with window */
  207. } XSetWindowAttributes;
  208.  
  209. typedef struct {
  210.   unsigned long pixel;
  211.   unsigned short red, green, blue;
  212.   char flags;  /* do_red, do_green, do_blue */
  213. } XColor;
  214.  
  215. typedef struct {
  216.   unsigned char *value;           /* same as Property routines */
  217.   Atom encoding;          /* prop type */
  218.   int format;             /* prop data format: 8, 16, or 32 */
  219.   unsigned long nitems;           /* number of data items in value */
  220. } XTextProperty;
  221.  
  222. typedef struct {
  223.   long flags;          /* marks which fields in this structure are defined */
  224.   int x, y;            /* obsolete for new window mgrs, but clients */
  225.   int width, height;   /* should set so old wm's don't mess up */
  226. } XSizeHints;
  227.  
  228. #define WPARAM MPARAM
  229. #define LPARAM MPARAM
  230.  
  231. #define DisplayWidth(display, screen) \
  232.   GetSystemMetrics(SM_CXSCREEN)
  233.  
  234. #define DisplayHeight(display, screen) \
  235.   GetSystemMetrics(SM_CYSCREEN)
  236.  
  237. extern Colormap XCreateColormap(
  238.   Display* display,
  239.   Window root,
  240.   Visual* visual,
  241.   int alloc);
  242.  
  243. #define __glutStrdup  strdup
  244.  
  245.  
  246. struct timeval {
  247.         long    tv_sec;         /* seconds */
  248.         long    tv_usec;        /* and microseconds */
  249. };
  250.  
  251.  
  252. int gettimeofday(struct timeval* tp, void* tzp);
  253.  
  254.  
  255. /* Type definitions (conversions). */
  256.  
  257. #define PFD_TYPE_COLORINDEX 1
  258. #define PFD_DRAW_TO_WINDOW  2
  259. #define PFD_SUPPORT_OPENGL  4
  260. #define PFD_GENERIC_FORMAT  8
  261. #define PFD_DOUBLEBUFFER    0x10
  262. #define PFD_SWAP_COPY       0x20
  263. #define PFD_TYPE_RGBA       0x40
  264. #define PFD_STEREO          0x80 
  265. #define PFD_DRAW_TO_BITMAP  0x100
  266. #define PFD_SUPPORT_GDI     0x200
  267. #define PFD_DOUBLEBUFFER_DONTCARE  0x400
  268. #define PFD_STEREO_DONTCARE        0x800
  269. #define PFD_NEED_PALETTE          0x1000
  270.  
  271. #define GLX_USE_GL              1       /* support GLX rendering */
  272. #define GLX_BUFFER_SIZE         2       /* depth of the color buffer */
  273. #define GLX_LEVEL               3       /* level in plane stacking */
  274. #define GLX_RGBA                4       /* true if RGBA mode */
  275. #define GLX_DOUBLEBUFFER        5       /* double buffering supported */
  276. #define GLX_STEREO              6       /* stereo buffering supported */
  277. #define GLX_AUX_BUFFERS         7       /* number of aux buffers */
  278. #define GLX_RED_SIZE            8       /* number of red component bits */
  279. #define GLX_GREEN_SIZE          9       /* number of green component bits */
  280. #define GLX_BLUE_SIZE           10      /* number of blue component bits */
  281. #define GLX_ALPHA_SIZE          11      /* number of alpha component bits */
  282. #define GLX_DEPTH_SIZE          12      /* number of depth bits */
  283. #define GLX_STENCIL_SIZE        13      /* number of stencil bits */
  284. #define GLX_ACCUM_RED_SIZE      14      /* number of red accum bits */
  285. #define GLX_ACCUM_GREEN_SIZE    15      /* number of green accum bits */
  286. #define GLX_ACCUM_BLUE_SIZE     16      /* number of blue accum bits */
  287. #define GLX_ACCUM_ALPHA_SIZE    17      /* number of alpha accum bits */
  288.  
  289. #define GLX_BAD_ATTRIB  2
  290. #define GLX_BAD_VISUAL  4
  291.  
  292. int XPending(Display* display);
  293.  
  294. GLXContext glXCreateContext(Display* display,
  295.   XVisualInfo* visinfo,  GLXContext share,  Bool direct);
  296.  
  297. #define XMapWindow(display, window) \
  298.   WinShowWindow(window, TRUE)
  299.  
  300. #define XUnmapWindow(display, window) \
  301.   WinShowWindow(window, FALSE)
  302.  
  303. #define XWithdrawWindow(display, window, screen) \
  304.   WinShowWindow(window, FALSE)
  305.  
  306. #define XIconifyWindow(display, window, screen) \
  307.   WinShowWindow(window, FALSE)
  308.  
  309. #define XFlush(display) \
  310.   /* Nothing. */
  311.  
  312. #define glXDestroyContext(display, context) \
  313.   /* Nothing. */
  314.  
  315. #define XDestroyWindow(display, window) \
  316.   WinDestroyWindow(window)
  317.  
  318. #define XFree(data) \
  319.   free(data)
  320.  
  321. #define XFreeColormap(display, colormap) \
  322.      GpiDeletePalette(colormap)
  323.  
  324. #define glXSwapBuffers(display, window) \
  325.      wglSwapBuffers() 
  326.  
  327. #define glXMakeCurrent(display, window, context) \
  328.   wglMakeCurrent(WinQueryWindowDC(window), context)
  329.  
  330. BOOL  wglSwapBuffers(void);
  331. int  wglChoosePixelFormat(HDC hdc,  PIXELFORMATDESCRIPTOR *ppfd);
  332.  
  333. XVisualInfo *wglDescribePixelFormat(int iPixelFormat);
  334.  
  335.  
  336. int SetLastError(int nerr);
  337. int GetLastError(void);
  338.  
  339. XVisualInfo * glXChooseVisual(int mode);
  340. int glXGetConfig(XVisualInfo* visual, int attrib, int* value);
  341.  
  342. void
  343. XStoreColor(Display* display, Colormap colormap, XColor* color);
  344. void
  345. XSetWindowColormap(Display* display, Window window, Colormap colormap);
  346. Bool
  347. XTranslateCoordinates(Display *display, Window src, Window dst,
  348.               int src_x, int src_y,
  349.               int* dest_x_return, int* dest_y_return,
  350.               Window* child_return);
  351. Status
  352. XGetGeometry(Display* display, Window window, Window* root_return,
  353.          int* x_return, int* y_return,
  354.          unsigned int* width_return, unsigned int* height_return,
  355.          unsigned int *border_width_return, unsigned int* depth_return);
  356.  
  357. int XParseGeometry(char *string, int *x, int *y, unsigned int *width, unsigned int *height);
  358.  
  359. int DisplayHeightMM(Display* display, int screen);
  360. int DisplayWidthMM(Display* display, int screen);
  361.  
  362. #ifdef __cplusplus
  363. extern "C" {
  364. #endif
  365.  
  366. LONG *GetVideoConfig(HDC hdc);
  367. void ScreenToClient( HWND hwnd,   POINTL *point);
  368. int  wglGetPixelFormat(HDC hdc);
  369.  
  370. #ifdef __cplusplus
  371. }
  372. #endif
  373.  
  374.  
  375. #endif /* __WarpGL_x11_h__ */
  376.  
  377.