colour-index and XAllocColorCells - Xwindows
This is a discussion on colour-index and XAllocColorCells - Xwindows ; Hello Readers,
I am attempting to use XAllocColorCells to allocate a color map for
for a colour-index opengl window on my workstation.
Firstly I trying to determine the number of colours that I can create?
From my program I find ...
-
colour-index and XAllocColorCells
Hello Readers,
I am attempting to use XAllocColorCells to allocate a color map for
for a colour-index opengl window on my workstation.
Firstly I trying to determine the number of colours that I can create?
From my program I find that only 242 can be allocated with XAllocColorCells.
This is a bit strange since xdpyinfo gives the following information.
depth of root window: 8 planes
number of colormaps: minimum 1, maximum 1
default colormap: 0x21
default number of colormap cells: 256
preallocated pixels: black 0, white 1
default visual id: 0x22
visual:
visual id: 0x22
class: PseudoColor
depth: 8 planes
size of colormap: 256 entries
red, green, blue masks: 0x0, 0x0, 0x0
significant bits in color specification: 8 bits
What is the number of colors that I can define???
Why does XAllocColorCells fail above 242??
Unfortuately when I try to define the colors I get a black screen.
Here is the code I am using?
int maxcolor;
maxcolor = 242;
unsigned long pixels[256];
GLint IndexMap[256];
XColor xcolours[256];
long status;
status = XAllocColorCells(display, cmap, False, NULL, 0, pixels, maxcolor );
if (status == 0) printf("Failed to allocate color cells\n");
for (n = 0; n < maxcolor; n++)
{
IndexMap[n] = pixels[n];
xcolours[n].pixel = pixels[n];
xcolours[n].red = (long)(n << 8);
xcolours[n].blue = (long)(n << 8);
xcolours[n].green = (long)(n << 8);
xcolours[n].flags = DoRed | DoGreen | DoBlue;
}
XStoreColors(display, cmap, xcolours, maxcolor);
Could it be explained what I have done wrong when creating my colourmap?
Thanks
Stuart
-
Re: colour-index and XAllocColorCells
Hi Stuart!
On 18 Feb 04 at 04:51, "Stuart" (Stuart Norris) wrote:
Stuart> Why does XAllocColorCells fail above 242??
Most probably, the other X clients already use the other 14 free color
cells. Note that XAllocColorCells allocates read-write cells, and the amount
of these is not guaranteed to be a particular integer on a shared
colormap. You can use a private colormap where it is, but this may lead
to display flashing when colormaps switch.
Also, if your application can live with inexact color match and read-only color
cells, you probably should use XAllocColor instead.
--
Sincerely,
Dmitry
--- www.karasik.eu.org ---
The woods are full of people who want this job -- Dilbert