forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem with SDL and graphics

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Eskema



Joined: 26 May 2006
Posts: 6

PostPosted: Fri May 26, 2006 12:05 am    Post subject: Problem with SDL and graphics Reply with quote

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
Back to top
View user's profile Send private message
Fanjita



Joined: 28 Sep 2005
Posts: 217

PostPosted: Fri May 26, 2006 2:41 am    Post subject: Reply with quote

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!
Back to top
View user's profile Send private message
Eskema



Joined: 26 May 2006
Posts: 6

PostPosted: Fri May 26, 2006 3:10 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
pensoffsky



Joined: 13 Nov 2005
Posts: 8

PostPosted: Fri May 26, 2006 7:09 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Eskema



Joined: 26 May 2006
Posts: 6

PostPosted: Sat May 27, 2006 1:11 am    Post subject: Reply with quote

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:

SDL_SetColorKey(image->image, SDL_SRCCOLORKEY, SDL_MapRGB(image->image->format, R, G, B));
Back to top
View user's profile Send private message
Garak



Joined: 27 Jul 2005
Posts: 46

PostPosted: Sat May 27, 2006 4:28 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Send e-mail AIM Address
Eskema



Joined: 26 May 2006
Posts: 6

PostPosted: Sat May 27, 2006 4:59 am    Post subject: Reply with quote

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:

SDL_SetVideoMode(320, 240, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);


for this?
Code:

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:

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));
   }


}
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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