 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
plysek
Joined: 16 Feb 2009 Posts: 7
|
Posted: Mon Feb 23, 2009 9:22 am Post subject: Displaying image in SDL |
|
|
This simple program should display an image:
| Code: |
#include <SDL/SDL.h>
#include <pspdebug.h>
#include <pspkernel.h>
#define SCREEN_WIDTH 480
#define SCREEN_HEIGHT 272
PSP_MODULE_INFO("Przykladowa aplikacja SDL", 0, 1, 1);
PSP_HEAP_SIZE_KB(20480);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER|PSP_THREAD_ATTR_VFPU);
#define printf pspDebugScreenPrintf
int exit_callback( int arg1, int arg2, void *common )
{
sceKernelExitGame( );
return 0;
}
int CallbackThread( SceSize args, void *argp )
{
int cbid;
cbid = sceKernelCreateCallback( "Exit Callback", exit_callback, NULL );
sceKernelRegisterExitCallback( cbid );
sceKernelSleepThreadCB( );
return 0;
}
int SetupCallbacks( void )
{
int thid = 0;
thid = sceKernelCreateThread( "update_thread", CallbackThread, 0x11, 0xFA0, 0, 0 );
if(thid >= 0)
{
sceKernelStartThread( thid, 0, 0 );
}
return 0;
}
int InitVideo( )
{
if (SDL_Init( SDL_INIT_VIDEO ) != 0)
{
printf( "SDL_Init(): %s\n", SDL_GetError() );
SDL_Quit( );
return 1;
} else return 0;
}
int main( int argc, char **argv )
{
pspDebugScreenInit( );
SetupCallbacks( );
SDL_Surface *screen;
screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, 32, SDL_FULLSCREEN | SDL_DOUBLEBUF | SDL_HWSURFACE );
SDL_Surface *image;
SDL_Surface *temp;
temp = SDL_LoadBMP( "image.bmp" );
if( temp == NULL )
{
printf( "SDL_LoadBMP(): %s\n", SDL_GetError( ) );
}
image = SDL_DisplayFormat( temp );
if( image == NULL )
{
printf( "SDL_DisplayFormat( ): %s\n", SDL_GetError( ) );
}
SDL_FreeSurface( temp );
SDL_Rect src, dest;
src.x = 0;
src.y = 0;
src.w = image->w;
src.h = image->h;
dest.x = 100;
dest.y = 100;
dest.w = image->w;
dest.h = image->h;
SDL_Flip( screen );
SDL_Delay( 2500 );
SDL_FreeSurface( image );
return 0;
}
|
i have modified the code from SDL wiki, but it doesnt work. Why?
Here is my makefile:
| Code: |
TARGET = hello
OBJS = sdl.o
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
EXTRA_TARGETS = EBOOT.PBP
LIBS = -lSDL -lGL -lz -lpng -lm -ljpeg -lpsppower_driver -lpspvfpu -lpsphprm -lpsprtc -lpspaudio -lpspgu -lpspirkeyb -lpsppower
PSP_EBOOT_TITLE = Test SDL
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
|
and the image.bmp:
http://lysek.y0.pl/image.bmp |
|
| Back to top |
|
 |
plysek
Joined: 16 Feb 2009 Posts: 7
|
Posted: Mon Feb 23, 2009 9:31 am Post subject: |
|
|
hmm i forgot to init the video, but still it doesnt show the image...
ekhm ok i did now the SDL_BlitSurface( image, NULL, screen, &src);
and it works! but he problem that it waits a moment with the image displayed and then psp power off automaticly, and i can even push home to exit, why is that? |
|
| Back to top |
|
 |
Wally

Joined: 26 Sep 2005 Posts: 672
|
Posted: Mon Feb 23, 2009 9:43 am Post subject: |
|
|
| plysek wrote: | hmm i forgot to init the video, but still it doesnt show the image...
ekhm ok i did now the SDL_BlitSurface( image, NULL, screen, &src);
and it works! but he problem that it waits a moment with the image displayed and then psp power off automaticly, and i can even push home to exit, why is that? |
Sounds like a bus error.. I suggest setting PSPLink up will fix it |
|
| Back to top |
|
 |
plysek
Joined: 16 Feb 2009 Posts: 7
|
Posted: Tue Feb 24, 2009 1:42 am Post subject: |
|
|
| it doesnt work on my psp, i have 5.0m33-3 slim it says with v1.0 "The game could not be started" and with v1.5 and v1.5_nocorrupt it is corrupted data. |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Tue Feb 24, 2009 5:27 pm Post subject: |
|
|
| You have to use psplinkusb with the Slim. |
|
| Back to top |
|
 |
|
|
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
|