Jump to content
  • Advertisement
Sign in to follow this  

Problem after changing numbers to variables

This topic is 3167 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! I have strange problem. I want to make bitmap fonts. I loaded texture, and now I have to set coords for each letter. Here it is:
glBindTexture(GL_TEXTURE_2D, tex_font);	

glTexCoord2f(0.5937			,1-0.00195);
glTexCoord2f(0.5937+0.06445 ,1-0.00195);
glTexCoord2f(0.5937+0.06445 ,1-0.00195-0.1035);			glVertex2i(20,50);						
glTexCoord2f(0.5937	, 1-0.00195-0.1035);

And it's "working". As you can see I put static numbers. These numbers are coords for letter "0" (number actually). But when I put variables into this code:
glTexCoord2f(poz_x	,(1-poz_y));
glTexCoord2f((poz_x+z_width) ,(1-poz_y));	
It's nor working. I can see just a black background - no letters. I'm 100% sure that variables have the same value. So why it's not working? (Variables are float)

Share this post

Link to post
Share on other sites
Original post by Moriquendi
I'm 100% sure that variables have the same value.

100% sure as in you put a breakpoint and inspected the value just before those functions are called?


Share this post

Link to post
Share on other sites
Yep, I had put breakpoint and checked value.
The same.

I don't know, it sounds stupid.
I create this letters in a loop. Maybe somethings goes wrong when I create many latters with different coords...
Do you have any article about bitmap fonts? :\

Share this post

Link to post
Share on other sites
I don't know what's happening.

When I put in code this:

poz_x = StringToInt(pozyc_x);
poz_y = StringToInt(pozyc_y);
i_width = StringToInt(s_width); ///s_width - string with number
i_height = StringToInt(s_height);

poz_x = 0.5937;
poz_y = 0.00195;
z_width = 0.06445;
z_height = 0.1035;

... glTexCoord2f(poz_x ,1-poz_y);

it work's fine. But when I don't - variables are the same (checked thanks to breakpoints) but it doesn't work...

So I variables have correct values...
I guess that there is sth wrong when I convert string to Int.
Here's stringtoInt function:

int StringToInt(string str)
std::stringstream ss;
int temp;
ss << str;
ss >> temp;
return temp;

[Edited by - Moriquendi on April 16, 2010 11:23:50 AM]

Share this post

Link to post
Share on other sites
Ok, I changed StringToInt to atof() function, but it doesn't metter becouse I convert strings that have int variables.
Later, I write:
poz_x = poz_x/512;

I think the problem isn't variables. I have to do sth wrong in my code...
Can anybody look at it? : -<


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!