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 (x < 480) {
while (y < 272) {
blitAlphaImageToScreen(0 ,0 ,32 , 32, ourImage, 0, 0);
printf("image drawn");
y += 32;
}
x+=32;
y=0;
}
flipScreen();
}
sceKernelSleepThread();
return 0;
}
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...
while (x < 480) {
while (y < 272) {
blitAlphaImageToScreen(0 ,0 ,32 , 32, ourImage, 0, 0);
printf("image drawn");
y += 32;
}
x+=32;
y=0;
}
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.
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!
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.