Sorry to be a pest again but I’m having a problem. I have been messing
around with ttflib, and it compiles OK but I am getting segfaults every
time I try to run the code.
If someone could tell me what to fix and more importantly what I am
doing wrong it would be greatly appreciated. I have spun my wheels for
3 hours now and gotten nowhere…
Michael Fletcher
---- cut
bash-2.01$ ./lsim
lsim: graphics: ttf: initOK
lsim: graphics: initOK - changing vmode…
You must be root to set a fullscreen mode
lsim: graphics: vmodeOK
lsim: graphics: gw: render…
lsim: graphics: gw: renderOK
lsim: graphics: gw: map…
Fatal signal: Segmentation Fault (SDL Parachute Deployed)
SDL Warning: 1 SDL surfaces extant
---- cut
---- cut
SDL_Surface *screen;
SDL_Surface *buffer;
TTF_Font *font;
void graph_write(char message[128], int x, int y, SDL_Color fg,
SDL_Color bg) {
SDL_Surface *text;
fprintf(stderr, “lsim: graphics: gw: render…\n”);
text = TTF_RenderText(font, message, fg, bg);
if (text = NULL) {
fprintf(stderr, “lsim: graphics: TTF: couldn’t render text\n”);
}
fprintf(stderr, “lsim: graphics: gw: renderOK\n”);
fprintf(stderr, “lsim: graphics: gw: map…\n”);
if (SDL_MapSurface(*text, screen->format) != 0) {
fprintf(stderr, “lsim: graphics: TTF: couldn’t map text\n”);
}
fprintf(stderr, “lsim: graphics: gw: mapOK\n”);
// why?
fprintf(stderr, “lsim: graphics: gw: blit…\n”);
SDL_BlitSurface(text, NULL, screen, NULL);
fprintf(stderr, “lsim: graphics: gw: blitOK\n”);
SDL_FreeSurface(text);
fprintf(stderr, “lsim: graphics: gwOK\n”);
}
---- cut