Problem with SDL and graphics

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

Moderators: cheriff, TyRaNiD

Post Reply
Eskema
Posts: 6
Joined: Fri May 26, 2006 12:00 am

Problem with SDL and graphics

Post by Eskema »

Hi all, i have an SDL game that i've made for pc, now im doing a port to DC, XBOX and GP2X. Im porting to psp and the graphics dont show correctly. The res its 320x240x16 and the tiles 32x32, ¿any idea of whats happening?

Im using png format and converting to .h, the game runs perfect in other platforms, with the same code, i dont know why in psp i see all the tiles corrupted. ¿I need any special size for the tiles to show them correctly?


Heres a link to an image to see the problem www.telefonica.net/web2/eskematico/corrupted.JPG
Fanjita
Posts: 217
Joined: Wed Sep 28, 2005 9:31 am

Post by Fanjita »

It looks like your images are at the wrong bits-per-pixel depth.

Sadly I don't know what pixel depth SDL uses, but presumably it's in the documentation somewhere.
Got a v2.0-v2.80 firmware PSP? Download the eLoader here to run homebrew on it!
The PSP Homebrew Database needs you!
Eskema
Posts: 6
Joined: Fri May 26, 2006 12:00 am

Post by Eskema »

i think if the images are at the wrong depth its due a psp limitation, ¿isn't it? in the xbox or dc the game runs without any trouble, even in gp2x.
Maybe its any lack of functionality in the SDL port or maybe im a noob thinking that i can port any of my SDL games without change anything in the code
pensoffsky
Posts: 8
Joined: Sun Nov 13, 2005 7:23 am

Post by pensoffsky »

hi,
i also ran into some problems with sdl on the psp
i had to learn that the psp doesn't like small 16bit surfaces

you could try to initialize sdl with 32bpp, just to see if it works

pensoffsky
Eskema
Posts: 6
Joined: Fri May 26, 2006 12:00 am

Post by Eskema »

pensoffsky wrote:hi,
i also ran into some problems with sdl on the psp
i had to learn that the psp doesn't like small 16bit surfaces

you could try to initialize sdl with 32bpp, just to see if it works

pensoffsky
Ok i've used 32bpp and now works, but its too slow, and ¿why the SRCCOLORKEY doesnt work?

Code: Select all

SDL_SetColorKey(image->image, SDL_SRCCOLORKEY, SDL_MapRGB(image->image->format, R, G, B));
Garak
Posts: 46
Joined: Wed Jul 27, 2005 1:59 am

Post by Garak »

If you want a speed increase, use 16 bit mode as your graphics mode.

You have to convert all surfaces to 16 bit mode as well to realize a speed beneift. Also, when converting you need to make sure you convert the surfaces to Software surfaces. By default it will convert them to HARDWARE surafces (at least it will if that is what your screen mode is set to, which it should be).

If some of the images use an alpha channel for transparency, you will lose that transparnecy when you got to 16bit mode. Those graphics you will have to leave in 32 bit mode and suffer a small speed hit. If the image just uses a tranparent color, you shoudl not have any troubles once you set your image to 16bit mode and make it a sofdtware surface.

These rules worked for me using an older PSP SDL port. I think most of the above is still true for the latest builds.

Garak
Eskema
Posts: 6
Joined: Fri May 26, 2006 12:00 am

Post by Eskema »

Garak wrote:If you want a speed increase, use 16 bit mode as your graphics mode.

You have to convert all surfaces to 16 bit mode as well to realize a speed beneift. Also, when converting you need to make sure you convert the surfaces to Software surfaces. By default it will convert them to HARDWARE surafces (at least it will if that is what your screen mode is set to, which it should be).

Garak
So are u telling me that i need to change this

Code: Select all

SDL_SetVideoMode(320, 240, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
for this?

Code: Select all

SDL_SetVideoMode(320, 240, 16, SDL_SWSURFACE | SDL_DOUBLEBUF);
and change all the images to 16bpp in photoshop, ¿isn't it?

Im using a function like this to manage all images

Code: Select all

void LoadImage(tObjeto *image, tObjeto *tmp, unsigned char *name, int size,int R, int G, int B)
{

    tmp->tmp=IMG_Load_RW(SDL_RWFromMem(name,size),0);
    image->image=SDL_DisplayFormat(tmp->tmp);
    SDL_FreeSurface(tmp->tmp);
    if(R>-1 && G>-1 && B>-1){
	SDL_SetColorKey(image->image, SDL_SRCCOLORKEY, SDL_MapRGB(image->image->format, R, G, B));
	}


}
Post Reply