GP32 Printf In A Gp Program...


Dumoria

Still Fresh
Joined
Feb 18, 2005
Messages
5
Hello,

This is rather a newb question, i'm sorry, but I have some experience in standard C, so I prefer asking it there.

In fact, I'd like to print the value of a float on the GP screen. Doesn't seem difficult, but does the sdk have an equivalent of the printf function ? I found GpTextOut, but it doesn't have all the printf formats...

Maybe a conversion from float to char*, but I have no idea on how to do...

Does anyone have a clue ?
 
how about this instead?

char string[100];
sprintf(string, "int = %d, double = %d. Hello whatever", 32, 3.65);
GpTextOut(x, y, string);

I don't remember everything exactly, but that's the basic jist of it.

Use sprintf to print to a string, then use GpTextOut to draw the string onscreen.
 
Rattboi posted on Feb 19 2005 at 11:05 AM said:
how about this instead?

char string[100];
sprintf(string, "int = %d, double = %d. Hello whatever", 32, 3.65);
GpTextOut(x, y, string);

I don't remember everything exactly, but that's the basic jist of it.

Use sprintf to print to a string, then use GpTextOut to draw the string onscreen.

I think you should use gm_sprintf() instead of sprintf() as it is included in the official GP SDK.

By the way Rattboi, have you seen the new version of my OKF Font Engine? One of the additions I've made is specially for you: see the okf.background structure and related functions. It's your emu that inspired me, and I though that that green color behind the menu options wasn't that nice and that I could help you doing something nicer ;)
 
Last edited by a moderator:
char string[100];
sprintf(string, "int = %d, double = %d. Hello whatever", 32, 3.65);
GpTextOut(x, y, string);

That should work fine ! I didn't think about it. Thanks !
 
Yo Oankali,

No, I hadn't seen anywhere that you'd updated your font lib. I'm busy trying to add sound atm, but later on, I'll look at it. What would be nice is if you could get me a small font that's similar to the one I'm using. I'm using verdana8b_pm and it'd be nice to have something like a 5-6 height font with the same style.
 
Rattboi posted on Feb 19 2005 at 10:05 AM said:
how about this instead?

char string[100];
sprintf(string, "int = %d, double = %d. Hello whatever", 32, 3.65);
GpTextOut(x, y, string);

I don't remember everything exactly, but that's the basic jist of it.

Use sprintf to print to a string, then use GpTextOut to draw the string onscreen.

Wouldn't that just print the "3.65" value rounded to "3"? I mean, "%d" prints decimals and "%f" prints floats, right? But maybe its the same for double, not sure.
By the way, I tried printf with a "%f" parameter and the app then always crashed, could be my old GCC version though.
 
Last edited by a moderator:
WhiteFalcon posted on Feb 20 2005 at 12:49 PM said:
Rattboi posted on Feb 19 2005 at 10:05 AM said:
how about this instead?

char string[100];
sprintf(string, "int = %d, double = %d. Hello whatever", 32, 3.65);
GpTextOut(x, y, string);

I don't remember everything exactly, but that's the basic jist of it.

Use sprintf to print to a string, then use GpTextOut to draw the string onscreen.

Wouldn't that just print the "3.65" value rounded to "3"? I mean, "%d" prints decimals and "%f" prints floats, right? But maybe its the same for double, not sure.
By the way, I tried printf with a "%f" parameter and the app then always crashed, could be my old GCC version though.

Actually, I think it will cast 3.65 to an integer which is likely some very large decimal, and then print that.

But I think it was just a typo on Rattboi's part.
 
Last edited by a moderator:
Actually I used this :
Code:
gm_sprintf(message,"%lf Hz %d ms", frequency, time);

and that works fine. I didn't see the wrong %d before :)
 
Back
Top