glColor not being used by glBitmap

Hell,

I’m using glBitmap (via glCallList) to draw text over my 3D scene. I know it’s not the most efficient way, but I want my lib to support as many options as possible. The problem is that the text, although prints correctly (characters, positions), always shouws up as black (0, 0, 0), even though I called glColor3f(1, 1, 1) just before glRasterPos.
Any takes ?

I think glBitmap just copies (maybe with blending) the image directly into the framebuffer. This means that each pixel is copied as it’s stored in memory, and does not take care of the currently set color.

Here is the code I use when doing that very same thing and the color does come through, I don’t know if I did something special to get it working now that I’ve read what Bob says.

// now draw the characters in a string
glListBase(1);
glColor4f(1.0,1.0,1.0,1.0);
glRasterPos3f(x,y,0.0);
glCallLists(tend, GL_UNSIGNED_BYTE, str);

Could probably speed it up a bit by using glColor4fv but that is a minor detail since bitmap text is not often drawn.

[This message has been edited by DFrey (edited 07-19-2000).]

My docs say that glBitmap read bits, writes pixels depending on if the bit is set or not, in the current raster color.
Here’s my code (with some unicode support):

<CODE>
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glTranslatef(0, 0, -1);

glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glRasterPos2f(x, y); /* x and y are 0 */

while ((c = ugetc(buf + pos)) != 0) {
pos += ucwidth©;
if ((!range) | | (c < range->start) | | (c > range->end)) {
range = find_range(usefont, c); /* search for a suitable character range */

  if (!range) {
       range = find_range(usefont, (c = '^'));
       if (!range)
            continue;
  }
}
/* draw the character */
c -= range-&gt;start;
c += range-&gt;list_base;

glCallList(c);

}
glPopMatrix();
</CODE>

The string appears correctly, just not in the right color.

Make sure lighting is disabled. It is included in determining the final raster color otherwise. Same goes for texture maps too, make sure textures are disabled (unless you want texture mapped bitmaps). Also ensure blending is disabled (or set to something you specifically want).

[This message has been edited by DFrey (edited 07-19-2000).]

Cool! It Works!
All I had to do though is bind to texture 0 (= disable texturing ?)
Lighting and blending are still on (and I need them on) and the text gets displayed in the correct color.
Thanks everyone!

Ya, that is a common problem (I know I’ve made it more than once). When using multiple textures remember texture 1 goes though texture0.

Just for the protocol:
“All I had to do though is bind to texture 0 (= disable texturing ?)”

No, not disabling. A glBindTexture with 0 as parameter switches back to the immediate texture in the given dimension and for the current texture unit.

> “A glBindTexture with 0 as parameter switches back to the immediate texture in the given dimension and for the current texture unit.”

Huh ?

>>
> “A glBindTexture with 0 as parameter switches back to the immediate texture in the given dimension and for the current texture unit.”
Huh ?
<<

If you don’t use texture objects and download a texture, which texture does OpenGL use? If you use a texture object afterwards, how do you switch back to that first non-object texture?
Answer: Issue glBindtexture with a 0 ID. Viola.
And there are multiple of those, one for 1D, 2D, 3D multiplied by the number of texture units you can switch with glActiveTextureARB.

Oh. I knew that :slight_smile:
Well, something like it anyway
Thanks.