Sign in to follow this  
Shamus

Bitmap-Font problem

Recommended Posts

Hi, I just solved the problem with the buttons, but immediately came up the next problem... *sigh* I tried to involve a bitmap font, but it somehow interfers with ONLY ONE of the buttons. I've uploaded two screenshots (in one picture): _http://img228.imageshack.us/img228/229/snap2copymp3.jpg Maybe somebody could take a quick look ? :) 1) The upper one shows the text, when the Image for the "Exit"-button is loaded -> The text in the middle has the colour of the background !!! (translucent?) 2) The picture below shows the text, when the Image for the "Exit"-button is NOT loaded -> The text in the middle shows up normally, with the defined colour ! This seems to have no logic for me, and I only found it out by accident, because I was trying the whole day everything to see the bitmap-font-text readable (in colours)... :/ I've got NO special Extensions enabled: Init: invoke glEnable, GL_TEXTURE_2D invoke glShadeModel,GL_SMOOTH _glClearColor 0.5f, 0.5f, 0.5f, 1.0f _glClearDepth 1.0f invoke glEnable, GL_DEPTH_TEST invoke glDepthFunc, GL_LEQUAL invoke glHint,GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST invoke glGenLists, 96 mov base, eax invoke CreateFont, -44, 10, 0, 0, FW_BOLD, 0, 0, 0, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, FF_DONTCARE, addr fontfamily mov font, eax invoke SelectObject, hDC, font mov oldfont, eax invoke wglUseFontBitmaps, hDC, 32, 96, base invoke SelectObject, hDC, oldfont invoke DeleteObject, font invoke glBlendFunc, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA invoke glEnable, GL_BLEND invoke glFogi, GL_FOG_MODE, fogmode invoke glFogfv, GL_FOG_COLOR, addr fogcolor _glFogf GL_FOG_DENSITY, 0.35f _glFogf GL_FOG_DENSITY, 0.25f invoke glHint, GL_FOG_HINT, GL_DONT_CARE _glFogf GL_FOG_START, 2.5f _glFogf GL_FOG_END, 6.0f invoke glEnable, GL_FOG And this is the way I'm rendering the bitmap-font: ... invoke glLoadIdentity _glTranslatef 0.0f,0.0f,-1.0f _glColor3f 0.9f,0.5f,0.5f _glRasterPos2f -0.3f,-0.2f invoke FpuFLtoA, 0, 2, ADDR buffer1, SRC1_FPU or SRC2_DIMM invoke RtlZeroMemory, ADDR buffer2, 50 invoke szCatStr, addr buffer2, addr TheText invoke szCatStr, addr buffer2, addr buffer1 invoke glPushAttrib, GL_LIST_BIT mov eax , base sub eax, 32 invoke glListBase, eax invoke StrLen, Thetext invoke glCallLists, eax, GL_UNSIGNED_BYTE, buffer2 invoke glPopAttrib ... (then comes the rendering of the cube and the buttons) Did anybody else have such a weird problem and solved it ??? Thanks PS: Disabling Fog didn't change anything... [Edited by - Shamus on March 21, 2007 4:18:31 AM]

Share this post


Link to post
Share on other sites
It looks like the text is writing to the depth buffer only (or at least blending is almost unnoticable). Remember that each pixel that passes the depth test will udpate the depth buffer with its own depth without caring of blending.

So I guess there's something wrong in your rendering function, i.e. after rendering the buttons there's a weird alpha value set that influences the text's final alpha. This could be the origin of the 'exit' texture set to alpha = 0 and then being loaded and used in the second texture stage with texcoords always 0/0. In this case the read alpha value would always be 0 (or nearly 0) thus having your text's final alpha be nearly 0.

Try the following:
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER,0.1f); // the threshold value can vary

Does the text still cut out the cube? Note that the text won't show up now if you have an alpha problem (pixels with alpha < threshold will be skipped).

P.S.: Could you post source code rather than assembler? This would be much easier to read. And please post the full render function (including the glClear and button rendering sections).

Share this post


Link to post
Share on other sites
Quote:
Original post by Lord_Evil...
Yay, thanks for your explaination ! :)
Got it now...
But while trying out your post, I already stumbled about a bug(?) in
my rendering source:
Right before the text-rendering I simply tried out
to place a "invoke glBindTexture, GL_TEXTURE_2D, NULL",
and it already worked. I guess I have to release this function
by loading a "NULL" into it, before rendering stuff, which doesn't
use textures ???
I didn't know, yet...

Quote:
Could you post source code rather than assembler? This would be much easier to read.
I'm always posting my source code -
I'm just playing only with MASM atm.
I didn't try yet to code in C++... :/

Share this post


Link to post
Share on other sites
I've got another problem with the rendered text now:
I thought I could use blank button-BMPs and render the buttontext
over them.

I should look like with my Nvidia:
_http://img225.imageshack.us/img225/9479/test2ij3.jpg

But on an ATI the text is hidden by the button-BMP:
_http://img225.imageshack.us/img225/3133/test1hs4.jpg
As you can see the text is even hidden by the Alpha-Channel of
the button (on the right of the button).

-I render the text AFTER the rendering of the buttons.
-The button's Z-Axis is at the SAME depth into the screen as the text.
Button:
...
glTranslatef -0.0588f, -0.0423f, -0.11f ; Z = -0.11f !!
...
...
Text:
...
glTranslatef -0.0f,0.0f,-0.11f ; Z = -0.11f !!
...


Is there another trick to make the text TOPMOST ???

Thanks

Share this post


Link to post
Share on other sites

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