New Homebrew Programmer.... images

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

Moderators: cheriff, TyRaNiD

Post Reply
BlackRogue
Posts: 2
Joined: Mon Jun 25, 2007 1:31 am

New Homebrew Programmer.... images

Post by BlackRogue »

Code: Select all

int main() {
          char buffer[200];
          Image* ourImage; 
	  sprintf(buffer, "ourImage.png");
          ourImage = loadImage(buffer); 
	  if (!ourImage) {
                    //Image load failed
                    printf("Image load failed!\n");
          } else { 
		int x = 0;
                int y = 0;
                sceDisplayWaitVblankStart(); 
	
	        while &#40;x < 480&#41; &#123;
		       while &#40;y < 272&#41; &#123;
				blitAlphaImageToScreen&#40;0 ,0 ,32 , 32, ourImage, 0, 0&#41;;
				printf&#40;"image drawn"&#41;;
				y += 32;
			&#125;
			x+=32;
			y=0;
		&#125;
		flipScreen&#40;&#41;;	
	  &#125;

	sceKernelSleepThread&#40;&#41;;
	return 0;
&#125;
from psp-programming.com, i am starting to try get familiar with the dev tools and such but the one where it handles images, I copied and pasted the code, and yet, it freezes on my psp. Is there anything that looks odd in my main method? Please help me out with this...
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

FIRST: If you have problems with code from psp-programming.com, you should ask your questions there.

SECOND:

Code: Select all

while &#40;x < 480&#41; &#123;
             while &#40;y < 272&#41; &#123;
            blitAlphaImageToScreen&#40;0 ,0 ,32 , 32, ourImage, 0, 0&#41;;
            printf&#40;"image drawn"&#41;;
            y += 32;
         &#125;
         x+=32;
         y=0;
      &#125; 
This will just try to draw a 32x32 pixel part of the image to always the same position on screen. So it's quite useless.

THIRD: Make sure you set PSP_MODULE_INFO and PSP_THREAD_ATTR

FOURTH: You need to call sceKernelExitGame() at the point where you want to have the program quit, not sceKernelSleepThread() or else it will just infinitely sit waiting.
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
BlackRogue
Posts: 2
Joined: Mon Jun 25, 2007 1:31 am

Testing it...

Post by BlackRogue »

the 0,0 positioning was when i commented everything out and just left the image draw in the code, but that had the same results.
There is other code defined for when the HOME button is selected so that handles correctly if i was to press HOME, YES, to exit.
And I already have module info defined but I can't google PSP_THREAD_ATTR - what is that? what are the attributes?

I dont know.... if you could give me a sample of a program that has images being used other than psp-programming.com i would greatly appreciate it so i could learn from looking at it. Thank you for your response though!
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

It was supposed to be PSP_MAIN_THREAD_ATTR
And there's hundreds of sample codes available spread all over psp-programming.com, especially in the forums. Just use the search function. You should easily be able to find some better code than that one.

PS: You need to init the GU if you want to use it, so you need at least call sceGuInit();
If you use graphics.c you also need to call graphicsInit once on startup, though it does nothing but set a flag - yeah it's immensely stupid.
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
Post Reply