During the Initialization of sdl_ttf, it causes a segmentation fault. This
was returned by the debugger. Lazy Foo says that init. SDL_TTF before SDL is
OK but I’ve tried both ways and that isn’t the problem. I thought also that
maybe putting the font implementation in another file before the program
starts was a problem but that also isn’t what’s wrong. ( oh and how do you
do [source] on this page? )
This is my main function.
int main ( int argc, char** argv )
{
if ( TTF_Init()==-1 )
{
return 1;
}
if ( SDL_Init( SDL_INIT_EVERYTHING ) < 0 )
{
printf( “Unable to init SDL: %s\n”, SDL_GetError() );
return 1;
}
atexit(SDL_Quit);
screen = SDL_SetVideoMode(screen_w, screen_h, screen_bpp,SDL_FULLSCREEN|
SDL_SWSURFACE|SDL_DOUBLEBUF);
if ( !screen )
{
printf("Unable to set 1024x720 video: %s\n", SDL_GetError());
return 1;
}
SDL_WM_SetCaption("The Legacy of Aexidos and Traxhord","aexidos.ico");
while ( !end )
{
timer = SDL_GetTicks();
game();
}
SDL_FreeSurface(screen);
printf("Exited cleanly\n");
exit(0);
return 0;
}
This is what the debugger has returned.
#0 0040458E The Legacy of Aexidos and Traxhord!TTF_WasInit() (??:??)
#1 00409BC7 The Legacy of Aexidos and Traxhord!TTF_WasInit() (??:??)
#2 0040122A ??() (??:??)
#3 0022FFB0 ??() (??:??)
#4 00401222 ??() (??:??)
#5 004C3004 The Legacy of Aexidos and Traxhord!TTF_WasInit() (??:??)
#6 004012B8 ??() (??:??)
#7 00000002 ??() (??:??)
#8 00000009 ??() (??:??)
#9 0022FFF0 ??() (??:??)
#10 7C816FE7 RegisterWaitForInputIdle()
(C:\WINDOWS\system32\kernel32.dll:??)
#11 9FAEC500 ??() (??:??)
#12 01CA047B ??() (??:??)
#13 7FFDB000 ??() (??:??)
#14 8054ABB8 ??() (??:??)
#15 0022FFC8 ??() (??:??)
#16 827E63F0 ??() (??:??)
#17 FFFFFFFF ??() (??:??)
#18 7C839AF0 ValidateLocale() (C:\WINDOWS\system32\kernel32.dll:??)
#19 7C816FF0 RegisterWaitForInputIdle()
(C:\WINDOWS\system32\kernel32.dll:??)
#20 00000000 ??() (??:??)
and in my characters.cpp file, this is where i Use it
SDL_Surface *message;
SDL_Surface *chatbox;
void mudkipchat(std::string Speech, int STATUS = NORMAL, int tyme = 0)
{
chatbox = IMG_Load(“chatbox.bmp”);
if ( !chatbox )
{
printf(“Error Loading Image: %s\n”,IMG_GetError());
exit(0);
}
message = TTF_RenderText_Solid(font,Speech.c_str(),black);
SDL_Rect offset = { 0 , ( screen->h - mudkipnormal->h ) ,
mudkipnormal->w , mudkipnormal->h };
std::string str;–
View this message in context: http://www.nabble.com/SDL_ttf-causes-Segmentation-Faults-tp24535191p24535191.html
Sent from the SDL mailing list archive at Nabble.com.