Sign in to follow this  

glDrawPixelf with GL_ALPHA pixel data, colored how?

This topic is 4693 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Quote:
Original post by vincoof
Mind 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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites

This topic is 4693 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this