diff options
author | Sean D'Epagnier <geckosenator@freedesktop.org> | 2006-08-27 01:16:09 +0000 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2011-07-11 20:03:34 +0100 |
commit | 6d720fc05121f005c0f54d4825ee815d45a2d7a4 (patch) | |
tree | a3c9dc13caa67e03c52500ec1944975b27462a3b /src/glut/fbdev/colormap.c | |
parent | 8a89ae39952f700760adb33a66e0e2b709640718 (diff) | |
download | glut-6d720fc05121f005c0f54d4825ee815d45a2d7a4.tar.gz |
The colormap code is now simpler, 15bpp works where it did not before.
The input is fixed so that delete reports '\b' and backspace 127
The vt switching works both right and left.
Diffstat (limited to 'src/glut/fbdev/colormap.c')
-rw-r--r-- | src/glut/fbdev/colormap.c | 63 |
1 files changed, 24 insertions, 39 deletions
diff --git a/src/glut/fbdev/colormap.c b/src/glut/fbdev/colormap.c index 4c013c7..89556ef 100644 --- a/src/glut/fbdev/colormap.c +++ b/src/glut/fbdev/colormap.c @@ -97,54 +97,39 @@ void RestoreColorMap(void) void LoadColorMap(void) { - /* we're assuming 256 entries here */ - int i; - - switch(VarInfo.bits_per_pixel) { - case 8: - case 24: - case 32: - ColorMap.len = 256; - break; - case 15: - ColorMap.len = 32; - break; - case 16: - ColorMap.len = 64; - break; - } - ColorMap.start = 0; ColorMap.red = RedColorMap; ColorMap.green = GreenColorMap; ColorMap.blue = BlueColorMap; ColorMap.transp = NULL; - if (ioctl(FrameBufferFD, FBIOGETCMAP, (void *) &ColorMap) < 0) - sprintf(exiterror, "ioctl(FBIOGETCMAP) failed!\n"); - - switch(VarInfo.bits_per_pixel) { - case 15: - for(i=0; i<32; i++) - RedColorMap[i] = GreenColorMap[i] = BlueColorMap[i] = i*65535/31; - break; - case 16: - for(i=0; i<32; i++) - RedColorMap[i] = BlueColorMap[i] = i*65535/31; - for(i=0; i<64; i++) - GreenColorMap[i] = i*65535/63; - break; - case 24: - case 32: - for(i=0; i<256; i++) - RedColorMap[i] = GreenColorMap[i] = BlueColorMap[i] = i*257; - break; - } + if(DisplayMode & GLUT_INDEX) { + ColorMap.len = 256; - RestoreColorMap(); + if (ioctl(FrameBufferFD, FBIOGETCMAP, (void *) &ColorMap) < 0) + sprintf(exiterror, "ioctl(FBIOGETCMAP) failed!\n"); - if(DisplayMode & GLUT_INDEX) FillReverseColorMap(); + } else { + int rcols = 1 << VarInfo.red.length; + int gcols = 1 << VarInfo.green.length; + int bcols = 1 << VarInfo.blue.length; + + int i; + + ColorMap.len = gcols; + + for (i = 0; i < rcols ; i++) + RedColorMap[i] = (65536/(rcols-1)) * i; + + for (i = 0; i < gcols ; i++) + GreenColorMap[i] = (65536/(gcols-1)) * i; + + for (i = 0; i < bcols ; i++) + BlueColorMap[i] = (65536/(bcols-1)) * i; + + RestoreColorMap(); + } } void glutSetColor(int cell, GLfloat red, GLfloat green, GLfloat blue) |