[SDL] Speeding up my render.. SOLVED

Alan Wolfe atrix2 at cox.net
Thu Jun 16 13:48:02 PDT 2005


theres a super cool function to convert any surface to the same format as
the screen.

if you have a surface called S1 that is in a format that may or may not be
the same as the screen you can do this:

SDL_Surface *S2;
S2=SDL_DisplayFormat(S1);
SDL_FreSurface(S1);
S1=S2;

then S1 will be converted to the screen format, super easy :P

there is also SDL_DisplayFormatAlpha although im not real keen on the
differences between the two functions

----- Original Message ----- 
From: "Matt Pruett" <entelin at logicaldreams.net>
To: "SDL" <sdl at libsdl.org>
Sent: Thursday, June 16, 2005 2:55 PM
Subject: Re: [SDL] Speeding up my render.. SOLVED


> Ok looks like they were not at the screen format, so I changed the masks
> so it was and this gave me a 200% boost. I am now clipping along at
> 200fps, and adding the delay 2ms in there dropped my cpu down to 2%, so
> this is a good place to work from, thanks everyone for the tips it
> helped me out. :)
>
> On Thu, 2005-06-16 at 13:01 -0700, Matt Pruett wrote:
> > On Thu, 2005-06-16 at 08:28 -0400, Ryan C. Gordon wrote:
> > > > However I think it should go faster... Any suggestions?
> > >
> > > Did you convert the tiles to screen format?
> >
> > I was a little confused on this actually... I think they are the same,
> > how can I be sure? This is how I init the screen and then the surface I
> > am blitting from...
> >
> > this->screen = SDL_SetVideoMode (SCREENSIZEX, SCREENSIZEY, SCREENSIZED,
> > SDL_FULLSCREEN|SDL_SWSURFACE|SDL_DOUBLEBUF);
> >
> > this->tilelayer = SDL_CreateRGBSurface(SDL_SWSURFACE, 2560, 2560,
> > SCREENSIZED, RMASK, GMASK, BMASK, 0);
> >
> > #if SDL_BYTEORDER == SDL_BIG_ENDIAN
> > #define RMASK 0xff000000
> > #define GMASK 0x00ff0000
> > #define BMASK 0x0000ff00
> > #define AMASK 0x00000000
> > #else
> > #define RMASK 0x000000ff
> > #define GMASK 0x0000ff00
> > #define BMASK 0x00ff0000
> > #define AMASK 0x00000000
> > #endif
> >
> > >
> > > Try rendering with OpenGL and get several thousand frames per second.
> > >
> > > Those are my recommendations without having seen the code. Those are
the
> > > usual culprits.
> >
> > Its a good idea.. I think perhaps it would be best if I did that later,
> > under gl I could pretty much tell it to do anything and it would get
> > done and at blazing speeds, but I want to make sure it will run well
> > regardless.
> >
> > >
> > > --ryan.
> > >
> > >
> > >
> > > _______________________________________________
> > > SDL mailing list
> > > SDL at libsdl.org
> > > http://www.libsdl.org/mailman/listinfo/sdl
> > >
> > >
> > >
> > >
> -- 
> Matt Pruett <entelin at logicaldreams.net>
>
>
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl





More information about the SDL mailing list