我正在使用 SDL2 和 C++ 制作二十一点游戏。我想使用 SDL_ttf 将文本打印到屏幕上。我的代码可以编译,但不会在屏幕上显示文本。
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);
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);
上一页 1 2在此输入代码