Archived

This topic is now archived and is closed to further replies.

Tszafran

Display Format Question

Recommended Posts

Hi, I use the SDL_DisplayFormat function on surfaces once they are made and when they are modified (transparent, etc...) because its supposed to speed things up on blitting. I was wondering if this is ok. (NOTE: MySurface is a SDL Surface obvioulsy :-)) 1. MySurface=SDL_DisplayFormat(MySurface); or is it better to 2. SDL_Surface *Temp; Temp=SDL_DisplayFormat(MySurface); MySurface=Temp; SDL_FreeSurface(Temp); Does 1 do the same as number 2?

Share this post


Link to post
Share on other sites
I don''t even know why you''d bother with temp. It''d just slow it down. Anyway, SDL_DisplayFormat() usually disables alpha blending because it''s slow on non-Hardware-Accelerated systems. Just to let you know...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
i know i know this thread is "a bit" dated, but i was browsing through the old threads and stumbled accross this one.. so here''s what i think:

the way u put it theres no difference between method 1 and method 2, but i guess what u wanted to post as second method is more like:

2.
temp = SDL_LoadBMP("blabla.bmp";
MySurface = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);

and THAT actually makes a difference.. as far as i know converting a surface with SDL_DisplayFormat() not only converts the surface but creates a new surface with changed specs... therefore if u have "Temp" point to the newly created surface (as u do in ur method 2) u would loose control over the old formatted surface in memory... which would mean a memory leak...

so... by using the mothod i described above u create a surface ( which is referred to by temp) and then convert (ergo create a new converted surface, as explained above) the surface which is referred to by MySurface... difference to ur version is that we have still control about the memory assigned for the old formatted surface through "temp"... which we use in the next step by freeing up this (now) unused memory....

hope that helps,
cucumber

btw: if all that is written above is true i wonder y ur method 2 even worked since u free the surface that is referred to by temp AND MySurface, but leave the old surface in memory...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
for christs sake .... u damn smileys get out of my post!
that damn grin is supposed to be a )

you get the idea...

greetz,
cucumber

Share this post


Link to post
Share on other sites
why not register so you can edit?



Sharp Basic - Coming summer 2004!
typedef unsigned long long int me;
typedef signed short char you;

Share this post


Link to post
Share on other sites