Display Format Question

Started by
3 comments, last by Tszafran 20 years, 1 month ago
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?
MSN Messenger: Thomas_Szafran@hotmail.com
Advertisement
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...
Sup guys?
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...
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
why not register so you can edit?


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

This topic is closed to new replies.

Advertisement