[SDL] Problens with free surface
Ulrich Eckhardt
doomster at knuut.de
Sat Jul 14 22:43:57 PDT 2007
On Saturday 14 July 2007 16:23:18 David Olsen wrote:
> ----- Original Message -----
> From: "Ulrich Eckhardt" <doomster at knuut.de>
[..]
> > I can't find this function anywhere in SDL, are you using the external
> > SDL_Resize lib? If so, this function supposedly returns a new surface(!)
> > which obviously needs to be used from then on and also freed. Digging
> > into said library, it gets even worse: it seems like the input surface is
> > destroyed(WTF?) so you must not use sfcResized after calling this
> > function.
> > This library is so broken, words fail me. Well, after all the behaviour
> > is documented (read the headers!) but still.
>
> Hi Ulrich,
> I don't understand why you say it is "so broken" that words fail you!
I'm sorry, those words were harsh and also due to the fact that up to that
point I hadn't completely read the header/docs either. Please accept my
excuse.
> Of course it returns a new surface - if you want a resized surface, it
> can't be just the old one! Is there something "broken" about returning an
> SDL_Surface *?
There are two ways it could work, either if you supply a target surface, just
like SDL_StretchBlit() or the way you do it, i.e. returning a new surface.
> As to why the input surface is destroyed, this is for ease of
> implementation, as one can throw a SDL_LoadBMP or IMG_Load or TTF_Render
> (something that gives you an SDL_Surface *) directly into the function
> call, and resize it and free it all at once.
> e.g.
> SDL_Surface * mytext = SDL_ResizeXY(TTF_RenderText_Blended(myfont,"SDL is
> great",mycolor), 150, 20, 7);
This is the point I don't agree with. I would assume that the function doesn't
touch the input surface and I wouldn't sacrifice it for this ease of use.
Thinking about it, I would prefer the SDL_StretchBlit interface, because it
allows me to compose and simultaneously resize images, i.e. it doesn't have
the enforced allocation overhead. Creating the current behaviour from this
interface would be feasible without overhead then.
Uli
More information about the SDL
mailing list