Problem with intraFont

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Problem with intraFont

Post by ne0h »

I've to print a text over a image loaded with the graphic.c library,
bu the image will not display correctly!
Here is a sample of my source code:

Code: Select all

...
intraFontInit();
intraFont* ltn;
char filen[40];
sprintf(filen, "flash0:/font/ltn8.pgf");
ltn = intraFontLoad(filen,INTRAFONT_CACHE_ASCII);
initGraphics();
while(running){
...
draw various image with blitAlphaImageTo Screen();
...
guStart();
    
intraFontSetStyle(ltn, 0.75f,BLACK,WHITE,0);
intraFontPrint(ltn, 36, 12, "Nome path \n");
    
sceGuFinish();
sceGuSync(0,0);
    
sceDisplayWaitVblankStart();
    
flipScreen();

}
intraFontUnload(ltn);
intraFontShutdown();
sceKernelSleepThread();	
return 0;

}
I've try with this solution but the image on background will show bad!
I've seen Umd Dumper that print text over images with the intraFont,
so is possible but how?
Last edited by ne0h on Sat May 10, 2008 10:21 pm, edited 1 time in total.
whistler
Posts: 39
Joined: Tue Mar 04, 2008 7:08 am

Post by whistler »

ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

Yes, i can use OS-lib but i want to use graphic.c for this!
because it is much easy than oslib,
can anyone explain me how to do this?
hibbyware
Posts: 78
Joined: Wed Mar 28, 2007 10:29 am

Post by hibbyware »

intrafont comes with a good example of use with graphics.h
psPea
Posts: 60
Joined: Sat Sep 01, 2007 12:51 pm

Post by psPea »

Code: Select all

intraFont* ltn[1];
then

Code: Select all

ltn[8] = intraFontLoad(filen,INTRAFONT_CACHE_ASCII); 
???
Try this
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

See the first couple of posts in this thread: http://forums.qj.net/f-psp-development- ... ost2011599
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

psPea, don't see this part of code, it's a example
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

... the screen is black, and nothing appear on the screen!
But, i've think to convert all my code for the osl lib if is to difficult to do this with the simple graphics lib.
However, can I load a object image included with bin2o with the osl?
Cpasjuste
Posts: 214
Joined: Sun May 29, 2005 8:28 am

Post by Cpasjuste »

Porting your code to oslib is a great idea for me, i don't think there is an easier and better librarie for the psp yet.
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

I've just finished to port my code to using osl, but not all the same image are display ( i've writed a gui file manager and when list the file if is a folder show the folder.png image in the correct position, with the graphics lib that work great, but now with osl only 1 or (rarely) 2 folder are show whit image!
and than, after i've draw a image whit oslDrawImageXY(...) i've to do somthing or I have only to do oslEndDrawing(); and oslSyncFrame(); at
the end of the while loop? ( excuse me for my very bad english )
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

@ne0h: If you noticed psPea's comment, your problem (at least one of them) was that you were using an array index that was out of range. No telling what happened to the font pointer when you stored it into a non-existent array index. In the intraFont example, Ben used an array because he opened more than one font. If you only open one font, don't use an array! It's a waste, and you only wound up confusing yourself. Just go with something like

Code: Select all

intraFont* ltn8;
ltn8 = intraFontLoad("flash0:/font/ltn8.pgf",INTRAFONT_CACHE_ASCII);
Then just use ltn8 anywhere you currently use ltn[8].
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

Yes, I've paste a part of the code of 2 sample!
I've writed my code right! It is a example, not a part of my code!
I'm not stupid, I know the difference beetween a array and a single declaration!
hlide
Posts: 739
Joined: Sun Sep 10, 2006 2:31 am

Post by hlide »

ne0h wrote:Yes, I've paste a part of the code of 2 sample!
I've writed my code right! It is a example, not a part of my code!
I'm not stupid, I know the difference beetween a array and a single declaration!
I'm sorry to say that you're more stupid than you think : if you want for us to help you, you need to paste your real code which has a problem, not any example.
Last edited by hlide on Sat May 10, 2008 9:38 am, edited 1 time in total.
whistler
Posts: 39
Joined: Tue Mar 04, 2008 7:08 am

Post by whistler »

ne0h wrote:I've just finished to port my code to using osl, but not all the same image are display ( i've writed a gui file manager and when list the file if is a folder show the folder.png image in the correct position, with the graphics lib that work great, but now with osl only 1 or (rarely) 2 folder are show whit image!
and than, after i've draw a image whit oslDrawImageXY(...) i've to do somthing or I have only to do oslEndDrawing(); and oslSyncFrame(); at
the end of the while loop? ( excuse me for my very bad english )
there are some good oslib tutorials here
http://oslib.playeradvance.org/doku.php?id=home

as for the oslib intrafont mod, you'll need to check the sakya's src example
Chrighton
Posts: 58
Joined: Wed Jun 15, 2005 8:24 pm

Post by Chrighton »

hlide wrote:I'm sorry to say that you're are more stupid than you think : if you want for us to help you, you need to paste your real code which has a problem, not any example.
Yeah.
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

Yeah!
Not that any advice given would have helped :D

You need to add this:

Code: Select all

	guStart();
	sceGuTexMode(GU_PSM_8888, 0, 0, 0);
	sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
	sceGuTexFilter(GU_NEAREST, GU_NEAREST);
	sceGuFinish();
	sceGuSync(0,0);
At the end of every Intrafont function before flipping the screen.

So the whole thing looks like this:

Code: Select all

		guStart();
		intraFontSetStyle(ltn8, 1.5f,optioncol,0,0);
		intraFontPrint(ltn8, 10, 10, "Hello");
		sceGuFinish();
		sceGuSync(0,0);

	guStart();
	sceGuTexMode(GU_PSM_8888, 0, 0, 0);
	sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
	sceGuTexFilter(GU_NEAREST, GU_NEAREST);
	sceGuFinish();
	sceGuSync(0,0);
So to expanded further, asuming your image is already loaded,
and you're going to take J.F.'s advice:

Code: Select all

intraFontInit();
intraFont* ltn8;
ltn8 = intraFontLoad("flash0:/font/ltn8.pgf",INTRAFONT_CACHE_ASCII); 
initGraphics();

blitAlphaImageToScreen(0, 0, 480, 272, backgroundimage, 0,0);
		guStart();
		intraFontSetStyle(ltn8, 1.5f,optioncol,0,0);
		intraFontPrint(ltn8, 10, 10, "Hello");
		sceGuFinish();
		sceGuSync(0,0);

	guStart();
	sceGuTexMode(GU_PSM_8888, 0, 0, 0);
	sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGBA);
	sceGuTexFilter(GU_NEAREST, GU_NEAREST);
	sceGuFinish();
	sceGuSync(0,0);

		sceDisplayWaitVblankStart();
		flipScreen();
Great when you actually get help on a forum eh? ;)

Now in the author's defence, you only needed to RTFM! :D
If you're using the graphics library then you may need to reset the sceGuTex* states to what
they are defaulted to in the initGraphics() functions, after using the intraFont* functions.
Cheers, Art.
If not actually, then potentially.
User avatar
jean
Posts: 489
Joined: Sat Jan 05, 2008 2:44 am

Post by jean »

Yes, I've paste a part of the code of 2 sample!
He's right, dudes...he had to post partial code because maybe we can steal his precious code! Because he's asking only to stress we understood, not that he really needs it...
[WARNING: sarchasm relevations are beyond safety level...evacuate area immediately]
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

...
whistler, i've already read the example!
( the part that i've writed wrong in the example is not important for do this, and in a following post i've already writed that this is not a problem )
However thanks Art.
jean, la smetti di rompere i coglioni cazzo? Fatti i cazzi tuoi ogni tanto e non rompere le palle agli altri su 20 forums diversi!
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

Maybe just break everyone's balls on 19 forums.
I think it's how people are amused in programming breaks.
If not actually, then potentially.
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

I've don't understand very well your post, is reported to me?
However i've just rebuilted my code and it's works great, thanks!
User avatar
jean
Posts: 489
Joined: Sat Jan 05, 2008 2:44 am

Post by jean »

Don't want to start a flame or go completely O.T... It's just a little quarrel between me and Mr neoh because here he demonstrate his little knowledge and huge need of help in pc/psp programming, but in other forums he boasts of great capabilities releasing some code you all contributed to write line by line answering his pressing (and sometimes silly) questions. I could never address someone like this only because i'm bored: i was silent for months, but now i'm sick of it; i'm italian too and now i understand why sometimes italians are avoided like pest. Please, don't make me feel ashamed of being from the same country as you.
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

I've never do this! I've never boasts for my project, i've lot to learn and I never write that I'm a good programmer!
Please, if are jealous of my compliments also tries you to write a good project, but leaves alone me!
I know that you from bother because I am not a great programmer and the whole forum of pspdev has given me a lot of help, a lot of times also on stupid things, therefore thanks to the whole forum of pspdev and excuse for all the my stupid posts!
I want to learn not write other post like this to you!, so please leave me alone!
hlide
Posts: 739
Joined: Sun Sep 10, 2006 2:31 am

Post by hlide »

No wonder Mr neoh's topics were too miscellaneous in their subjects. Thanks Jean.
Post Reply