Where exactly would i call SDL_DisplayFormat?

Where exactly would i call SDL_DisplayFormat ?

Hi,

Someone made suggestion that i call SDL_DisplayFormat for each SDL_Surface.

Where would i call SDL_DisplayFormat?
Would I call it BEFORE I load an image into each SDL_Surface ?

Like this:----------------------------------------------------------------------------------
Sprite[1] = SDL_DisplayFormat(Screen);
Sprite[1] = IMG_Load(“data/visuals/Simple_Directmedia_Layer_Logo.gif”);

Also, would NOT using SDL_DisplayFormat in game cause performance issues
with image drawings?

Thanks…

Jesse “JeZ+Lee” Palser, BS, A+, Network+, MCP
SLNTHERO at aol.com
Silent Hero Productions®
Video Game Design Studio
http://www.SilentHeroProductions.com

Here is the way I use it:

/* after a display surface have been initialized
successfully /
void load_images (void)
{
(…)
/
Temporary surface */
SDL_Surface * surf;
(…)

surf = IMG_Load(“some stuff.jpg”);
sprite1 = SDL_DisplayFormat(surf);
SDL_FreeSurface(surf);

surf = IMG_Load(“some other stuff.png”);
sprite2 = SDL_DisplayFormat(surf);
SDL_FreeSurface(surf);

( … and so on … )

}

Maybe not the best way to do it. But it works ^^

Cheers

Julien

— En date de?: Sam 9.8.08, Jesse P. a ?crit?:> De: Jesse P.

Objet: [SDL] Where exactly would i call SDL_DisplayFormat ?
?: “A list for developers using the SDL library. (includes SDL-announce)”
Date: Samedi 9 Ao?t 2008, 15h08
Where exactly would i call SDL_DisplayFormat ?

Hi,

Someone made suggestion that i call SDL_DisplayFormat for
each SDL_Surface.

Where would i call SDL_DisplayFormat?
Would I call it BEFORE I load an image into each
SDL_Surface ?

Like this:

Sprite[1] = SDL_DisplayFormat(Screen);
Sprite[1] =
IMG_Load(“data/visuals/Simple_Directmedia_Layer_Logo.gif”);

Also, would NOT using SDL_DisplayFormat in game cause
performance issues
with image drawings?

Thanks…

Jesse “JeZ+Lee” Palser, BS, A+, Network+, MCP
SLNTHERO at aol.com
Silent Hero Productions®
Video Game Design Studio
http://www.SilentHeroProductions.com


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

  _____________________________________________________________________________ 

Envoyez avec Yahoo! Mail. Une boite mail plus intelligente http://mail.yahoo.fr

Yeah, let me echo Julien and add a little explanation (it’s all in the docs anyhow).

SDL_DisplayFormat and SDL_DisplayFormatAlpha make a copy of a given surface that is optimized for fast blitting to your screen surface. If you don’t make these conversions, then SDL_BlitSurface has to do extra work to convert between the different pixel types. This slows your blitting by a surprising amount (my previously mentioned full-screen blitting went from ~26ms to ~4ms). Since for a game you usually don’t want the old copies hanging around, I suggest writing quick inline functions like so:

inline SDL_Surface* SPG_DisplayFormat(SDL_Surface* surf)
{
SDL_Surface* temp = SDL_DisplayFormat(surf);
SDL_FreeSurface(surf);
return temp;
}

inline SDL_Surface* SPG_DisplayFormatAlpha(SDL_Surface* surf)
{
SDL_Surface* temp = SDL_DisplayFormatAlpha(surf);
SDL_FreeSurface(surf);
return temp;
}

Jonny D> Date: Sat, 9 Aug 2008 09:08:01 -0400

From: slnthero at aol.com
To: sdl at lists.libsdl.org
Subject: [SDL] Where exactly would i call SDL_DisplayFormat ?

Where exactly would i call SDL_DisplayFormat ?

Hi,

Someone made suggestion that i call SDL_DisplayFormat for each SDL_Surface.

Where would i call SDL_DisplayFormat?
Would I call it BEFORE I load an image into each SDL_Surface ?

Like this:

Sprite[1] = SDL_DisplayFormat(Screen);
Sprite[1] = IMG_Load(“data/visuals/Simple_Directmedia_Layer_Logo.gif”);

Also, would NOT using SDL_DisplayFormat in game cause performance issues
with image drawings?

Thanks…

Jesse “JeZ+Lee” Palser, BS, A+, Network+, MCP
SLNTHERO at aol.com
Silent Hero Productions®
Video Game Design Studio
http://www.SilentHeroProductions.com


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org