forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How do I write the text in printTextScreen(); ?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Acegikmo



Joined: 19 Jul 2008
Posts: 15

PostPosted: Mon Jul 28, 2008 5:40 am    Post subject: How do I write the text in printTextScreen(); ? Reply with quote

Another question how to write something :)

extern void printTextScreen(int x, int y, const char* text, u32 color);

How do I write the text?
I want it to show the value of this variable:

double dist;

But this doesn't work:

printTextScreen(32, 32, dist, 0xFFFFFFFF);
Back to top
View user's profile Send private message MSN Messenger
pspZorba



Joined: 22 Sep 2007
Posts: 156
Location: NY

PostPosted: Mon Jul 28, 2008 5:54 am    Post subject: Reply with quote

never used this function but from its prototype:

char buffer[42];
sprintf( buffer,"%lf", dist);
printTextScreen(32, 32, buffer, 0xFFFFFFFF);
_________________
--pspZorba--
NO to K1.5 !
Back to top
View user's profile Send private message
Acegikmo



Joined: 19 Jul 2008
Posts: 15

PostPosted: Mon Jul 28, 2008 6:16 am    Post subject: Reply with quote

Works great :)
But could you explain what this line does?
sprintf( buffer,"%lf", dist);

I mean, what's "%lf" ?
Back to top
View user's profile Send private message MSN Messenger
pspZorba



Joined: 22 Sep 2007
Posts: 156
Location: NY

PostPosted: Mon Jul 28, 2008 6:42 am    Post subject: Reply with quote

your printTextScreen needs a char * .

you want to print a double (dist, so you have to translate the double into a string. sprintf does the job.

sprintf needs a string ( buffer) that will contain the string, the variable you want to translate (dist) and the format => "%lf"

lt means the variable (dist) is a double.

If you wanted to transform an integer you would have set "%d".
_________________
--pspZorba--
NO to K1.5 !
Back to top
View user's profile Send private message
Acegikmo



Joined: 19 Jul 2008
Posts: 15

PostPosted: Mon Jul 28, 2008 6:53 am    Post subject: Reply with quote

What about float variables?
Back to top
View user's profile Send private message MSN Messenger
hibbyware



Joined: 28 Mar 2007
Posts: 78

PostPosted: Mon Jul 28, 2008 7:22 am    Post subject: Reply with quote

Have a read of this http://www.cplusplus.com/reference/clibrary/cstdio/sprintf.html
Back to top
View user's profile Send private message
WosRet



Joined: 23 Apr 2008
Posts: 15
Location: Confoederatio Helveticae

PostPosted: Mon Jul 28, 2008 7:22 am    Post subject: Reply with quote

for float use: "%f".
see this http://www.opengroup.org/onlinepubs/007908799/xsh/fprintf.html page for more information about using conversion specification
Back to top
View user's profile Send private message
Acegikmo



Joined: 19 Jul 2008
Posts: 15

PostPosted: Mon Jul 28, 2008 8:23 am    Post subject: Reply with quote

Thanks :)
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group