SDL_WM_SetIcon

Both the SDL wiki and SDL_video.h state “This function must be called before
the first call to SDL_SetVideoMode”. If I call it before SDL_SetVideoMode,
it always segfaults. If I call it after SDL_SetVideoMode, it works great.
Do the official docs have this backwars, or is it my strange system that
works this way? (gentoo linux amd64 native 64-bit, xorg-x11, libsdl-1.2.8)

Both the SDL wiki and SDL_video.h state “This function must be called before
the first call to SDL_SetVideoMode”. If I call it before SDL_SetVideoMode,
it always segfaults. If I call it after SDL_SetVideoMode, it works great.
Do the official docs have this backwars, or is it my strange system that
works this way? (gentoo linux amd64 native 64-bit, xorg-x11, libsdl-1.2.8)

Works for me in Linux, Windows and Mac. Are you absolutely sure the
crash is in the SDL_WM_SetIcon() call and not doing SDL_DisplayFormat on
the icon or something like that?

--Gabriel

'lo Tyler,On 16/04/2005, Tyler Montbriand, you wrote:

Both the SDL wiki and SDL_video.h state “This function must be called
before the first call to SDL_SetVideoMode”. If I call it before
SDL_SetVideoMode, it always segfaults. If I call it after
SDL_SetVideoMode, it works great.

I call SDL_WM_SetIcon() just before SDL_SetVideoMode(), and it works
under Windows 98 and XP with SDL 1.2.6, and under MacOS X 10.3 and
Linux Debian PPC 2.6.8 with SDL 1.2.8. (I don’t have any icon under
Linux though, but at least it doesn’t crash.)


Please remove “.ARGL.invalid” from my email when replying.
Incoming HTML mails are automatically deleted.

The following code snipet has worked for me on all the GNU/linux
distros and even FreeBSD:

const int bpp = 16;
const int width = 480;
const int height = 270;
const Uint32 vflags = SDL_DOUBLEBUF|SDL_HWSURFACE;

   if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO)) {
            cerr<<"Unable to initialize SDL: "<<SDL_GetError()<<'.'<<endl;
            exit(EXIT_FAILURE);
    } atexit (SDL_Quit);
    SDL_WM_SetIcon(IMG_Load(icon), NULL);
    SDL_ShowCursor(SDL_DISABLE);

    screen = SDL_SetVideoMode(width, height, bpp, vflags);

The above code is textbook example of properly initializing SDL, you
should have no trouble if you stick to that.

Happy hacking.> On 16/04/2005, Tyler Montbriand, you wrote:

Both the SDL wiki and SDL_video.h state “This function must be called
before the first call to SDL_SetVideoMode”. If I call it before
SDL_SetVideoMode, it always segfaults. If I call it after
SDL_SetVideoMode, it works great.

Almost forgot IMG_Load is not standard, just substitute that to
whatever you like as long as it returns a pointer to a SDL_Surface.
Good luck.On 4/16/05, Jack Doe <@Juan_D_Espinoza> wrote:

    SDL_WM_SetIcon(IMG_Load(icon), NULL);

That example works, so it must be something silly in my own code that’s
broken. Thanks.On Saturday 16 April 2005 09:59, Jack Doe wrote:


The above code is textbook example of properly initializing SDL, you
should have no trouble if you stick to that.

Happy hacking.

Hi… i just actually compiled one of my games incluind all the sounds and gfx as
header files so everything is compiled into the binary…

only thing is now (windows) i want to set the little icon on the top of the
window, previously i used SDL_WM_SetIcon( SDL_LoadBMP(icom.bmp) , NULL ); but
this leaves me with a rogue image file outside my exe… so i was trying to get
it to load an xpm instead, but it dosnt seem to want to work…

What type / size surface does the SDL_WM_SetIcon expect?

I read in the man pages it has to be MSB format… what does this mean?

Has anyone had expeirence in hiding the icon in the exe?

Is it just becasaue it is a xpm…?

i have SDL_WM_SetIcon( loadxpm( slogo_xpm ) /* my function */ , NULL );

load xpm looks like this

SDL_Surface *loadxpm(char **xpm)
{
SDL_Surface *surface;
SDL_Surface *image;
surface = IMG_ReadXPMFromArray(xpm);
SDL_SetColorKey(surface, SDL_SRCCOLORKEY,
SDL_MapRGB(surface->format,255,255,255));
image = SDL_DisplayFormat(surface);
SDL_FreeSurface(surface);

return image;

}

sny help / tips apprectiated!

Hello,

When one tries to do SDL_WM_SetIcon after a SDL_SetVideoMode, it does
not work. I know that. But, when you do this:

Pseudo code:
SDL_WM_SetIcon(“someicon.bmp”);
SDL_SetVideoMode()…
SDL_WM_SetIcon(“someothericon.bmp”);

It takes someothericon.bmp.

Is this intended?

I ask this because my game/engine has to be extremely flexible and i’d
like to want to make the WM Icon customizable. I can choose to have a
default bitmap location with a default name, so someone can change
that picture and replace it with their own. However, i’d rather let my
users specify where the bitmap is as well and then link it as an ICON.

Thanks for any advice given,

Regards,–
Stefan Hendriks

http://www.fundynamic.nl
http://www.fundynamic.com