Reputation: 1
I am making a blackjack game using SDL2 and C++. I want to print text to the screen using SDL_ttf. My code compiles but does not display text to the screen.
SDL_Surface* display = NULL;
TTF_Font* font;
font = TTF_OpenFont("C:\\Users\\Owner\\source\\repos\\Project94\\Debug\\Arial.ttf", 12);
SDL_Surface* text;
SDL_Color text_color = { 255,255,255 };
text = TTF_RenderText_Solid(font, "Hello", text_color);
SDL_BlitSurface(text, NULL, display, NULL);
Upvotes: -2
Views: 104
Reputation: 1
SDL_Rect score_one;
score_one.x = 800;
score_one.y = 600;
int score = 0;
char buffer[50];
sprintf_s(buffer, "%d", score);
SDL_Surface* screen=NULL;
SDL_Surface* surface=NULL;
SDL_Color textColor = { 255, 255, 255, 0 };
surface = TTF_RenderText_Solid(font, buffer, textColor);
SDL_BlitSurface(surface, NULL, gScreenSurface, &score_one);
Upvotes: -2