I want to draw a black, but transparent box on the whole game screen.
void draw_messagebox(int x, int y, int width, int height, string msg) { SDL_Rect background; background.x = x; background.y = y; background.w = width; background.h = height; SDL_Rect fade; fade.x = 0; fade.y = 0; fade.w = MENU_WIDTH; fade.h = MENU_WIDTH; apply_surface(0,0,bac_menu,screen); SDL_FillRect(bac_fade, &fade, SDL_MapRGB(screen->format, 0x0, 0x0, 0x0)); SDL_SetAlpha(bac_fade, SDL_SRCALPHA, 200); apply_surface(0,0,bac_fade,screen); SDL_FillRect(screen, &background, SDL_MapRGB(screen->format, 0xFF, 0, 0)); SDL_Surface *msg_message = TTF_RenderText_Blended(fnt_score, msg.c_str(), BLACK); apply_surface(x+16,y+16,msg_message,screen); }
But the program returns 3, that is the error code that says TTF_Init() failed.
Maybe something doesn't work together or something, I don't know.
But it's kinda odd because TTF_Init() is called right after the window is created, but the error doesn't occur before the draw_messagebox() function is called.
And don't care about the bad way I am doing this, I know I don't need to update the message all the time and such, but I'll fix that later. ;)