summaryrefslogtreecommitdiffstats
path: root/src/glut/os2/os2_glx.cpp
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2003-06-13 21:49:46 +0000
committerBrian Paul <[email protected]>2003-06-13 21:49:46 +0000
commit225517aff0afc3270fab277d1c9ac2864053820c (patch)
treefa00e2b162788b4fe2ebb9254baf6526997c9903 /src/glut/os2/os2_glx.cpp
parent8fa507592b7bdb087c9eb32ed2322cb805b724ec (diff)
GLUT for OS/2 (Evgeny Kotsuba)
Diffstat (limited to 'src/glut/os2/os2_glx.cpp')
-rw-r--r--src/glut/os2/os2_glx.cpp146
1 files changed, 146 insertions, 0 deletions
diff --git a/src/glut/os2/os2_glx.cpp b/src/glut/os2/os2_glx.cpp
new file mode 100644
index 00000000000..ca345ea05b5
--- /dev/null
+++ b/src/glut/os2/os2_glx.cpp
@@ -0,0 +1,146 @@
+/* os2_glx.c */
+
+#include <stdio.h>
+#include <string.h>
+#include <malloc.h>
+#include "gl/gl.h"
+#include "WarpGL.h"
+#include "GL/os2mesa.h"
+
+#define POKA 0
+/* global current HDC */
+
+XVisualInfo *wglDescribePixelFormat(int iPixelFormat);
+
+extern HDC XHDC;
+extern HWND XHWND;
+//extern HPS hpsCurrent;
+extern HAB hab; /* PM anchor block handle */
+
+GLXContext
+glXCreateContext(HPS hps, XVisualInfo * visinfo,
+ GLXContext share, Bool direct)
+{
+ /* KLUDGE: GLX really expects a display pointer to be passed
+ in as the first parameter, but Win32 needs an HDC instead,
+ so BE SURE that the global XHDC is set before calling this
+ routine. */
+ HGLRC context;
+
+ context = wglCreateContext(XHDC,hps,hab);
+
+
+ /* Since direct rendering is implicit, the direct flag is
+ ignored. */
+
+ return context;
+}
+
+
+int
+glXGetConfig(XVisualInfo * visual, int attrib, int *value)
+{
+ if (!visual)
+ return GLX_BAD_VISUAL;
+
+ switch (attrib) {
+ case GLX_USE_GL:
+ if (visual->dwFlags & (PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW)) {
+ /* XXX Brad's Matrix Millenium II has problems creating
+ color index windows in 24-bit mode (lead to GDI crash)
+ and 32-bit mode (lead to black window). The cColorBits
+ filed of the PIXELFORMATDESCRIPTOR returned claims to
+ have 24 and 32 bits respectively of color indices. 2^24
+ and 2^32 are ridiculously huge writable colormaps.
+ Assume that if we get back a color index
+ PIXELFORMATDESCRIPTOR with 24 or more bits, the
+ PIXELFORMATDESCRIPTOR doesn't really work and skip it.
+ -mjk */
+ if (visual->iPixelType == PFD_TYPE_COLORINDEX
+ && visual->cColorBits >= 24) {
+ *value = 0;
+ } else {
+ *value = 1;
+ }
+ } else {
+ *value = 0;
+ }
+ break;
+ case GLX_BUFFER_SIZE:
+ /* KLUDGE: if we're RGBA, return the number of bits/pixel,
+ otherwise, return 8 (we guessed at 256 colors in CI
+ mode). */
+ if (visual->iPixelType == PFD_TYPE_RGBA)
+ *value = visual->cColorBits;
+ else
+ *value = 8;
+ break;
+ case GLX_LEVEL:
+ /* The bReserved flag of the pfd contains the
+ overlay/underlay info. */
+ *value = visual->bReserved;
+ break;
+ case GLX_RGBA:
+ *value = visual->iPixelType == PFD_TYPE_RGBA;
+ break;
+ case GLX_DOUBLEBUFFER:
+ *value = visual->dwFlags & PFD_DOUBLEBUFFER;
+ break;
+ case GLX_STEREO:
+ *value = visual->dwFlags & PFD_STEREO;
+ break;
+ case GLX_AUX_BUFFERS:
+ *value = visual->cAuxBuffers;
+ break;
+ case GLX_RED_SIZE:
+ *value = visual->cRedBits;
+ break;
+ case GLX_GREEN_SIZE:
+ *value = visual->cGreenBits;
+ break;
+ case GLX_BLUE_SIZE:
+ *value = visual->cBlueBits;
+ break;
+ case GLX_ALPHA_SIZE:
+ *value = visual->cAlphaBits;
+ break;
+ case GLX_DEPTH_SIZE:
+ *value = visual->cDepthBits;
+ break;
+ case GLX_STENCIL_SIZE:
+ *value = visual->cStencilBits;
+ break;
+ case GLX_ACCUM_RED_SIZE:
+ *value = visual->cAccumRedBits;
+ break;
+ case GLX_ACCUM_GREEN_SIZE:
+ *value = visual->cAccumGreenBits;
+ break;
+ case GLX_ACCUM_BLUE_SIZE:
+ *value = visual->cAccumBlueBits;
+ break;
+ case GLX_ACCUM_ALPHA_SIZE:
+ *value = visual->cAccumAlphaBits;
+ break;
+#if POKA == 100
+#endif /* POKA == 100 */
+ default:
+ return GLX_BAD_ATTRIB;
+ }
+ return 0;
+}
+
+
+XVisualInfo * glXChooseVisual(int mode)
+{ int imode = 2;
+ if(mode & GLUT_DOUBLE)
+ imode = 1;
+ return
+ wglDescribePixelFormat(imode);
+}
+
+
+#if POKA
+#endif /* POKA */
+
+ \ No newline at end of file