gdk_visual_get_best_depth() - Usage Question

I have the following code (snippet):

depth = gdk_visual_get_best_depth();
pmap=gdk_pixmap_new(NULL, 100, 100, depth);

ctxt = gdk_gc_new(pmap);
gdk_gc_set_rgb_fg_color (ctxt, fg);

I have recently upgraded my OS to Ubuntu and after the upgrade, this code
caused the program to fail to start and produced the following output
(this worked without problem under FC4):

(pqlx:13657): Gdk-WARNING **: gdk_gc_set_rgb_fg_color() and
gdk_gc_set_rgb_bg_color() can only be used on GC's with a colormap. A GC
will have a colormap if it is created for a drawable with a colormap, or
if a colormap has been set explicitly with gdk_gc_set_colormap.

The Xorg.log contains the following re: screen depth:

(II) RADEON(0): Creating default Display subsection in Screen section
        "Default Screen" for depth/fbbpp 24/32
(==) RADEON(0): Depth 24, (==) framebuffer bpp 32
(II) RADEON(0): Pixel depth = 24 bits stored in 4 bytes (32 bpp pixmaps)
(==) RADEON(0): Default visual is TrueColor

And when I modify the above code to hardcode the depth to 24 bits, the
problem is resolved.

So my question is, generally: where does the origin of this problem reside
exactly?  with Ubuntu, Xorg setup, gdk, my code, other?

Specifically: is it incorrect to assume that gdk_visual_get_best_depth()
will return the depth I can specify when creating a pixmap?

In the meantime, I have coded that 24 is the maximum depth I can specify
when creating a pixmap, and this works, but I'm not convinced it's
necessarily the best solution since I don't understand why the problem
happens in the first place.

Any and all insights appreciated.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]