# glDrawPixelf with GL_ALPHA pixel data, colored how?

## Recommended Posts

Hi! Font rendering.. Characters are greyscale bitmaps (anti-aliased). I draw characters: glDrawPixels( c.m_width, c.m_height, GL_ALPHA, GL_UNSIGNED_BYTE, & c.m_data[0] ); Blend is enabled and blendFunc is glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); This way I get transparent text background, black text. But I'd like text to be colored by glColor values. I have not found any blending combination that gives desired result (for me it is much of gues and try). Is it possible with this setup to have blending so that Text is rendered with the color and without black background? Lighting is disabled. Thanks in advance.

##### Share on other sites
Mind using glColor ?

##### Share on other sites
Quote:
 Original post by vincoofMind using glColor ?

I use glColor, but it has no effect if I use GL_ALPHA or GL_LUMINANCE format. Or I have not found right blend function.

##### Share on other sites
My bad, I forgot that one. Sorry !
Well you can use the scale and/or bias parameters.
I did it many times with glBitmap it should work fine with glDrawPixels too.

##### Share on other sites
Yes, it works perfectly.
glPixelTransferf( GL_RED_SCALE, 0.0 ); glPixelTransferf( GL_RED_BIAS, c.red ); glPixelTransferf( GL_GREEN_SCALE, 0.0 ); glPixelTransferf( GL_GREEN_BIAS, c.green );glPixelTransferf( GL_BLUE_SCALE, 0.0 ); glPixelTransferf( GL_BLUE_BIAS, c.blue ); glPixelTransferf( GL_ALPHA_SCALE, c.alpha ); glPixelTransferf( GL_ALPHA_BIAS, 0.0 );

Thank you so much!

##### Share on other sites
I noticed that drawing text with glDrawPixels (using display list) is very very slow compared to texture mapped text. At least on my GF2.

##### Share on other sites
Yes I noticed that too. The reason is that this feature is rarely used in games, and GeForce-class hardware are designed for gaming before all. So does the Radeon-class hardware.

So far the only good point I've found with glBitmap and glDrawPixels is that you don't have to worry about pixel-aligned primitives : everything's always rasterized along the pixel grid perfectly and very easily.

If you want to get the best performance out of your graphics card you'll have to deal with textures, which are more powerful but also much harder to use than glDrawPixels.

##### Share on other sites
Yes! With texture mapped font I don't see change in fps when I draw one text line through screen while bitmap font halved fps :s

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627651
• Total Posts
2978407

• 10
• 12
• 22
• 13
• 33