home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mesa5.zip / mesa5src.zip / MesaDLL / os2_glx.cpp < prev    next >
Text File  |  2000-02-10  |  4KB  |  146 lines

  1. /* os2_glx.c */
  2.  
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <malloc.h>
  6. #include "gl/gl.h"
  7. #include "WarpGL.h"
  8. #include "GL/os2mesa.h"
  9.  
  10. #define POKA 0
  11. /* global current HDC */
  12.  
  13. XVisualInfo *wglDescribePixelFormat(int iPixelFormat);
  14.  
  15. extern HDC XHDC;
  16. extern HWND XHWND;
  17. extern HPS hpsCurrent;
  18. extern HAB   hab;      /* PM anchor block handle */
  19.  
  20. GLXContext
  21. glXCreateContext(Display * display, XVisualInfo * visinfo,
  22.   GLXContext share, Bool direct)
  23. {
  24.   /* KLUDGE: GLX really expects a display pointer to be passed
  25.      in as the first parameter, but Win32 needs an HDC instead,
  26.      so BE SURE that the global XHDC is set before calling this
  27.      routine. */
  28.   HGLRC context;
  29.  
  30.   context = wglCreateContext(XHDC,hpsCurrent,hab);
  31.  
  32.  
  33.   /* Since direct rendering is implicit, the direct flag is
  34.      ignored. */
  35.  
  36.   return context;
  37. }
  38.  
  39.  
  40. int
  41. glXGetConfig(XVisualInfo * visual, int attrib, int *value)
  42. {
  43.   if (!visual)
  44.     return GLX_BAD_VISUAL;
  45.  
  46.   switch (attrib) {
  47.   case GLX_USE_GL:
  48.     if (visual->dwFlags & (PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW)) {
  49.       /* XXX Brad's Matrix Millenium II has problems creating
  50.          color index windows in 24-bit mode (lead to GDI crash)
  51.          and 32-bit mode (lead to black window).  The cColorBits
  52.          filed of the PIXELFORMATDESCRIPTOR returned claims to
  53.          have 24 and 32 bits respectively of color indices. 2^24
  54.          and 2^32 are ridiculously huge writable colormaps.
  55.          Assume that if we get back a color index
  56.          PIXELFORMATDESCRIPTOR with 24 or more bits, the
  57.          PIXELFORMATDESCRIPTOR doesn't really work and skip it.
  58.          -mjk */
  59.       if (visual->iPixelType == PFD_TYPE_COLORINDEX
  60.         && visual->cColorBits >= 24) {
  61.         *value = 0;
  62.       } else {
  63.        *value = 1;
  64.       }
  65.     } else {
  66.       *value = 0;
  67.     }
  68.     break;
  69.   case GLX_BUFFER_SIZE:
  70.     /* KLUDGE: if we're RGBA, return the number of bits/pixel,
  71.        otherwise, return 8 (we guessed at 256 colors in CI
  72.        mode). */
  73.     if (visual->iPixelType == PFD_TYPE_RGBA)
  74.       *value = visual->cColorBits;
  75.     else
  76.       *value = 8;
  77.     break;
  78.   case GLX_LEVEL:
  79.     /* The bReserved flag of the pfd contains the
  80.        overlay/underlay info. */
  81.     *value = visual->bReserved;
  82.     break;
  83.   case GLX_RGBA:
  84.     *value = visual->iPixelType == PFD_TYPE_RGBA;
  85.     break;
  86.   case GLX_DOUBLEBUFFER:
  87.     *value = visual->dwFlags & PFD_DOUBLEBUFFER;
  88.     break;
  89.   case GLX_STEREO:
  90.     *value = visual->dwFlags & PFD_STEREO;
  91.     break;
  92.   case GLX_AUX_BUFFERS:
  93.     *value = visual->cAuxBuffers;
  94.     break;
  95.   case GLX_RED_SIZE:
  96.     *value = visual->cRedBits;
  97.     break;
  98.   case GLX_GREEN_SIZE:
  99.     *value = visual->cGreenBits;
  100.     break;
  101.   case GLX_BLUE_SIZE:
  102.     *value = visual->cBlueBits;
  103.     break;
  104.   case GLX_ALPHA_SIZE:
  105.     *value = visual->cAlphaBits;
  106.     break;
  107.   case GLX_DEPTH_SIZE:
  108.     *value = visual->cDepthBits;
  109.     break;
  110.   case GLX_STENCIL_SIZE:
  111.     *value = visual->cStencilBits;
  112.     break;
  113.   case GLX_ACCUM_RED_SIZE:
  114.     *value = visual->cAccumRedBits;
  115.     break;
  116.   case GLX_ACCUM_GREEN_SIZE:
  117.     *value = visual->cAccumGreenBits;
  118.     break;
  119.   case GLX_ACCUM_BLUE_SIZE:
  120.     *value = visual->cAccumBlueBits;
  121.     break;
  122.   case GLX_ACCUM_ALPHA_SIZE:
  123.     *value = visual->cAccumAlphaBits;
  124.     break;
  125. #if POKA == 100
  126. #endif /*  POKA == 100 */
  127.   default:
  128.     return GLX_BAD_ATTRIB;
  129.   }
  130.   return 0;
  131. }
  132.  
  133.  
  134. XVisualInfo * glXChooseVisual(int mode)
  135. {  int imode = 2;
  136.    if(mode & GLUT_DOUBLE)
  137.             imode = 1;
  138.    return
  139.          wglDescribePixelFormat(imode);
  140. }
  141.  
  142.  
  143. #if POKA
  144. #endif /* POKA */
  145.  
  146.