[SDL] SDL-ttf (PATCH)

Pete Shinners pete at shinners.org
Tue Sep 3 08:26:00 PDT 2002


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.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: TTF_WasInit.patch
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020903/c10c4989/attachment-0007.asc>


More information about the SDL mailing list