Article View: comp.graphics.api.opengl
Article #18Losing colors on X Mesa
From: Benjamin M. Burack
Date: Tue, 23 Mar 1999 00:00
Date: Tue, 23 Mar 1999 00:00
85 lines
3495 bytes
3495 bytes
My program loads 24-bit textures and displays them with Mesa on XWindows
with a Voodoo2 card. I'm using double-buffering and depth buffering in RGBA
mode (not color index). For some reason, I am losing a lot of my colors.
For example, if I have a texture with 8 similar shades of gray, many will
appear as exactly the same color. Only 2 or 3 shades will be rendered for
all 8. Since my program involves subtle contrast variations, this is a huge
problem. I thought I would be running in a true color mode since X is set
to 24 or 32 bit color depth, but apparently this isn't the case. Why does
this happen? How can I fix it?
Posted below is some of the code, such as the colormap initialization, that
may cause the problem.
Thanks for any help, and please mail responses to rascal@tseinc.com ,
Benjamin Burack
int configuration[] = {GLX_DOUBLEBUFFER, GLX_RGBA, GLX_DEPTH_SIZE, 16,
None};
void main(int argc, char **argv)
{
XVisualInfo *vi;
XSetWindowAttributes swa;
XWMHints *wmHints;
Atom wmDeleteWindow;
GLXContext cx;
<snip>
/*** find an appropriate visual and a colormap for it ***/
/* find an OpenGL-capable RGB visual with depth buffer */
if (!bDoubleBuffer) goto SingleBufferOverride;
vi = glXChooseVisual(pDisplay, DefaultScreen(pDisplay), configuration);
if (vi == NULL) {
SingleBufferOverride:
vi = glXChooseVisual(pDisplay, DefaultScreen(pDisplay),
&configuration[1]);
if (vi == NULL)
fatal_error("no appropriate RGB visual with depth buffer");
bDoubleBuffer = GL_FALSE;
}
cmap = getColormap(vi);
<snip>
/*** create an OpenGL rendering context ***/
cx = glXCreateContext(pDisplay, vi, /* no sharing of display lists */
NULL,
/* direct rendering if possible */ GL_TRUE);
if (cx == NULL) fatal_error("could not create rendering context");
<snip>
}
Colormap getColormap(XVisualInfo* vi)
{
Status status;
XStandardColormap* standardCmaps;
Colormap cmap;
int i, numCmaps;
status = XmuLookupStandardColormap(pDisplay, vi->screen, vi->visualid,
vi->depth, XA_RGB_DEFAULT_MAP, FALSE, TRUE);
if (status == 1) {
status = XGetRGBColormaps(pDisplay, RootWindow(pDisplay, vi->screen),
&standardCmaps, &numCmaps, XA_RGB_DEFAULT_MAP);
if (status == 1)
for (i = 0; i < numCmaps; i++)
if (standardCmaps[i].visualid == vi->visualid) {
cmap = standardCmaps[i].colormap;
XFree(standardCmaps);
return cmap;
}
}
cmap = XCreateColormap(pDisplay, RootWindow(pDisplay, vi->screen),
vi->visual, AllocNone);
return cmap;
}
Technical Details
Message-ID:
<alVJ2.129$E04.420@news9.ispnews.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f65bb,fe70503bb01cdf44,start X-Google-Attributes: gidf65bb,public X-Google-Thread: 104191,fe70503bb01cdf44,start X-Google-Attributes: gid104191,public X-Google-Thread: f9b07,fe70503bb01cdf44,start X-Google-Attributes: gidf9b07,public From: "Benjamin M. Burack" <admin@no-god.org> Subject: Losing colors on X Mesa Date: 1999/03/23 Message-ID: <alVJ2.129$E04.420@news9.ispnews.com> X-Deja-AN: 458157498 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 X-Trace: news9.ispnews.com 922231238 209.83.134.26 (Tue, 23 Mar 1999 18:20:38 EST) NNTP-Posting-Date: Tue, 23 Mar 1999 18:20:38 EST Newsgroups: comp.graphics.api.opengl,3dfx.glide.linux,3dfx.linux.dev.glide