Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

www 2e org

OpenGL black 2d text in OpenGL

This topic is 5862 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

Hey guys and gals! I have been working on this on and off for months and I''m just STUCK! I''m trying to draw 2D text (bitmap fonts) and I can get everything to work, EXCEPT what I want: Black text with transparent background. I have looked at some NeHe tutorials and others. I can get it to work with ANY other color BUT black. I''m trying to use TGA files (with 256 characters on them) and I''ve used a few different TGA loaders and I''ve tried saving them with white text on black background and vice-versa. I''m at wit''s end. Please can someone point out what I''m missing!?!? Thank you! Steven www.2e.org to see what I''m working on: www.stevenshultz.com/impera

Share this post


Link to post
Share on other sites
Advertisement
Yes, I think I can. I too have had this problem, and the reason it happens is this: a black value (0, 0, 0) means that the stencil becomes useless. The value (0, 0, 0) can''t be used to mask with, as it''s zero, basically. In your TGA font files, you need to make the characters in the alpha channel, not the RGB channels. Look at the Quake III engine. If you have Quake III, unzip the pk3 files in the baseq3 folder and look at the font ones in Paint or something. Nothing. Blackness. It''s not until you view them with something like Paint Shop Pro (which can read the TGA alpha channel) that you see the font masks.

You need to change your blend func setup too. I''m not 100% sure what you need to do, but I think it''s this: glBlendFunc(GL_SRC_ALPHA, GL_SRC_COLOR). Like I say, I''m not too sure about this (if it doesn''t work, experiment with some different values), but you definitely need to use the alpha channel (which will have your font in it) to "mask" the parts of the quad you want to be transparent, not the RGB values. I''m sure there''s a tutorial out there somewhere on this...



Coding Stuff ->  [ iNsAn1tY Games | DarkVertex | How To Do CSG | Direct3D Vs. OpenGL | Google ]
Fun Stuff    ->  [ Evil T-Shirts | Stick-Based Comedy | You''re Already Here | The Best Film Reviews ]

Share this post


Link to post
Share on other sites
months? u need to create an alpha channel in your texture + enable alphatesting


http://uk.geocities.com/sloppyturds/kea/kea.html
http://uk.geocities.com/sloppyturds/gotterdammerung.html

Share this post


Link to post
Share on other sites
What''s you problem.I spend 5(five)!!! months in trying to understand something so simple like the alpha test.And not i''m happy couse i can render everything,that has a background, without it with a alpha func of GL_NOTEQUAL,0



The pain is coming...this sommer!!!

Share this post


Link to post
Share on other sites
W00t!
I mean... THANK YOU
iNsAn1ty, ZedZeek and Mihail121!

I got it to finally work!
glBlendFunc(GL_DST_COLOR,GL_ZERO);

I''ve even messed with Photoshop7, PSP7 and BitmapFont builder to see if I was saving the images incorrectly.

But iNsAn1ty, you were right with the whole 0,0,0 is not a color thing...

btw - this is for an OpenGL Civ2 clone (game). I''m working on an OpenGL UI right now. I''ve got the mouse, buttons, a few other things going... obviously text is important here.

Thank you all again!

you can reach me at:
2e_at_2e.org (damn spambots)

take care guys!

ps - zedzeek, your skills and CV scare me! ha! Good luck mate!

Share this post


Link to post
Share on other sites
i have a white font on black background
glBlendfunc(GL_SRC_COLOR,GL_ONE_MINUS_SRC_COLOR);
the darker it is the less it is blended with the destination color 1-0=1

Share this post


Link to post
Share on other sites
>>I got it to finally work!
glBlendFunc(GL_DST_COLOR,GL_ZERO);<<

unfortunatly this might give the impression of working but its not correct, u need an alpha channel in your texture. i''ll write up a small explanation tonight (finally) + see if i can get it put into the faq

ps thats my old cv (my new one is MUCH better )

http://uk.geocities.com/sloppyturds/kea/kea.html
http://uk.geocities.com/sloppyturds/gotterdammerung.html

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!