[SDL] SDL-ttf (PATCH)

Nicolai Haehnle prefect_ at gmx.net
Tue Sep 3 08:34:01 PDT 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tuesday 03 September 2002 17:20, Pete Shinners wrote:
> Nick Whitelegg wrote:
> > I attempt to use TTF_Initialized (a global variable representing
> > whether or not the SDL_TTF library is initialised or not, declared as a
> > static int in SDL_ttf.c) in the constructor of my TTFont class, to
> > determine whether or not the SDL_TTF library is initialised or not. I
> > declare it as extern in the header for my TTFont class.
>
> you're stuck here. there's nothing you can do if you want access to this
> variable. because the variable is declared "static int TTF_initialized =
> 0;" this means it is 'private' to the SDL_ttf.c source, there's no way
> for you to access it from your own program.
>
> now you can safely call TTF_Init() multiple times and there will be no
> problems. you can call TTF_Quit() multiple times too and it will not die,
> but the first call to TTF_Quit will really uninitialize the library, so
> any other code that still thinks it has initialized the library will
> surely cause trouble.
>
> SDL has a "SDL_WasInit" function, here is a patch to add a similar
> "TTF_WasInit" function. hopefully you'll see it in the next release.

- From a design POV I think it would be better to use TTF_initialized as a 
counter of how often TTF_Init() has been called, then only shutting down 
when the counter reaches 0 again.
This way, you'll have to remember whether TTF was init when you started up 
so you'll know whether to call the Quit function or not.

cu,
Nicolai
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9dNagsxPozBga0lwRAi5zAKDKb+csJ9NjiKMEUR/D3tse/qZCigCfT7A0
XfS3LVYztbrMW01obb83cHA=
=p81D
-----END PGP SIGNATURE-----





More information about the SDL mailing list