diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2006-09-21 15:14:30 +0000 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2011-07-11 20:03:34 +0100 |
commit | 3da244fc5b84bd5a073428eb312b38f68bd3661e (patch) | |
tree | 5083d157d4628734aec7b1e7bd16f5bf06decb3d /src/glut/glx/glut_cmap.c | |
parent | 6d720fc05121f005c0f54d4825ee815d45a2d7a4 (diff) | |
download | glut-3da244fc5b84bd5a073428eb312b38f68bd3661e.tar.gz |
new code to init DirectColor colormaps
Diffstat (limited to 'src/glut/glx/glut_cmap.c')
-rw-r--r-- | src/glut/glx/glut_cmap.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/glut/glx/glut_cmap.c b/src/glut/glx/glut_cmap.c index 1c496ad..a6ff126 100644 --- a/src/glut/glx/glut_cmap.c +++ b/src/glut/glx/glut_cmap.c @@ -177,7 +177,6 @@ __glutSetupColormap(XVisualInfo * vi, GLUTcolormap ** colormap, Colormap * cmap) } break; case TrueColor: - case DirectColor: *colormap = NULL; /* NULL if RGBA */ /* Hewlett-Packard supports a feature called "HP Color @@ -254,6 +253,28 @@ __glutSetupColormap(XVisualInfo * vi, GLUTcolormap ** colormap, Colormap * cmap) *cmap = XCreateColormap(__glutDisplay, __glutRoot, vi->visual, AllocNone); break; + case DirectColor: + *colormap = NULL; /* NULL if RGBA */ + *cmap = XCreateColormap(__glutDisplay, __glutRoot, + vi->visual, AllocAll); + if (vi->depth == 24) { + /* init the red, green, blue maps to linear ramps */ + XColor xc[256]; + int i; + for (i = 0; i < 256; i++) { + xc[i].pixel = (i << 16) | (i << 8) | i; + xc[i].red = (i << 8) | i; + xc[i].green = (i << 8) | i; + xc[i].blue = (i << 8) | i; + xc[i].flags = DoRed | DoGreen | DoBlue; + } + XStoreColors(__glutDisplay, *cmap, xc, 256); + } + else { + fprintf(stderr, "GLUT Error: DirectColor visuals other than 24-bits " + "not fully supported.\n"); + } + break; case StaticColor: case StaticGray: case GrayScale: |