Jump to content
  • Advertisement
Sign in to follow this  
Moriquendi

Problem after changing numbers to variables

This topic is 3078 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);	

  		glNewList(base+licznik,GL_COMPILE);
			glBegin(GL_QUADS);
glTexCoord2f(0.5937			,1-0.00195);
 glVertex2i(0,0);
				
glTexCoord2f(0.5937+0.06445 ,1-0.00195);
glVertex2i(20,0);
				
glTexCoord2f(0.5937+0.06445 ,1-0.00195-0.1035);			glVertex2i(20,50);						
				
glTexCoord2f(0.5937	, 1-0.00195-0.1035);
 glVertex2i(0,50);

			glEnd();
			glTranslated(10,0,0);
		glEndList();
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));
 glVertex2i(0,0);
				
glTexCoord2f((poz_x+z_width) ,(1-poz_y));	
 glVertex2i(20,0);
.....
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
Advertisement
Quote:
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?

-me

Share this post


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

Edit:
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
Hey,
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);
glVertex2i(0,0);
..........

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? : -<

http://wklej.to/4640

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.

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!