| View previous topic :: View next topic |
| Author |
Message |
_.-noel-._
Joined: 13 Aug 2007 Posts: 49
|
Posted: Wed Aug 15, 2007 2:40 am Post subject: How can I load a PNG? |
|
|
Hi...
For my project, I need to load PNGs.
I have paked the code to load PNG in a Header.
My Header: (bg.h)
| Code: |
#ifdef __cplusplus
extern "C" {
#endif
#include <malloc.h>
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspdebug.h>
#include <stdio.h>
#include "graphics.h"
#include "framebuffer.h"
void bg(void) {
Image* bg;
bg = loadImage("bg.png");
while(1)
{
blitAlphaImageToScreen(0, 0, 480, 272, bg, 0, 0);
}
}
#ifdef __cplusplus
}
#endif
|
and in my main.c I have included the "bg.h" with
an I loade the function with
But when I Start my programm, the LCD is black.
My makefile:
| Code: |
TARGET = V1.0
OBJS = main.o graphics.o framebuffer.o
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = V1.0
LIBS = -lpspgu -lpng -lz -lm -lpspumd -lpspusb -lpspusbstor -lpspctrl
PSPSDK= D:\pspdev\psp\sdk
include $(PSPSDK)\lib\build.mak
|
I hope anybody can help me... _________________ Sry for my english |
|
| Back to top |
|
 |
2.6,CRACKED!
Joined: 26 Jul 2007 Posts: 18
|
Posted: Wed Aug 15, 2007 4:00 am Post subject: |
|
|
Did you put the file in the folder?
I always forget to do that, and i solve it by making sure if its there or not. Check |
|
| Back to top |
|
 |
_.-noel-._
Joined: 13 Aug 2007 Posts: 49
|
Posted: Wed Aug 15, 2007 6:44 am Post subject: |
|
|
yes, i did....
but must the file also stay at the project folder?
and the code is okay, istn't it? _________________ Sry for my english |
|
| Back to top |
|
 |
Xfacter
Joined: 28 Feb 2007 Posts: 9
|
Posted: Wed Aug 15, 2007 6:57 am Post subject: Re: How can I load a PNG? |
|
|
| _.-noel-._ wrote: | | But when I Start my programm, the LCD is black. |
Probably because you have an endless loop that never swaps draw buffers. |
|
| Back to top |
|
 |
2.6,CRACKED!
Joined: 26 Jul 2007 Posts: 18
|
Posted: Wed Aug 15, 2007 7:42 am Post subject: |
|
|
make sure when you call the function you have:
sceDisplayWaitVblankStart();
flipScreen(); |
|
| Back to top |
|
 |
_.-noel-._
Joined: 13 Aug 2007 Posts: 49
|
Posted: Wed Aug 15, 2007 11:46 pm Post subject: |
|
|
yes i have...
okay....now it works, but i have another problem...
The image overwrithe the text...
how can i use the image at background? _________________ Sry for my english |
|
| Back to top |
|
 |
Xfacter
Joined: 28 Feb 2007 Posts: 9
|
Posted: Thu Aug 16, 2007 2:38 am Post subject: |
|
|
| You need to draw the image, then print the text. What you are doing now is not the proper way to use a background. What you need to do is load your image, then start a game/display loop. In the loop you process whatever needs to be processed, then draw whatever needs to be drawn in the order it needs to be drawn (lowest to highest). Then swap your buffers (i.e., call flipScreen()). |
|
| Back to top |
|
 |
_.-noel-._
Joined: 13 Aug 2007 Posts: 49
|
Posted: Thu Aug 16, 2007 8:38 pm Post subject: |
|
|
ookkayy...
i haven't understand all... _________________ Sry for my english |
|
| Back to top |
|
 |
|