|
|
@ -39,20 +39,17 @@ int main(int argc, char *argv[]) {
|
|
39
|
39
|
return 1;
|
|
40
|
40
|
}
|
|
41
|
41
|
|
|
42
|
|
char *msg = "howdy there, enby!🐘";
|
|
|
42
|
SDL_Surface *surface = SDL_GetWindowSurface(window);
|
|
|
43
|
|
|
|
44
|
char *msg = "howdy there, enby! 🐘";
|
|
43
|
45
|
|
|
44
|
46
|
// thanks to https://stackoverflow.com/questions/22886500/how-to-render-text-in-sdl2 for some actually useful code here
|
|
45
|
47
|
SDL_Color white = {255, 255, 255};
|
|
46
|
48
|
SDL_Color black = {0, 0, 0};
|
|
47
|
|
SDL_Surface* surfaceMessage = TTF_RenderUTF8_Blended(font, msg, white);
|
|
48
|
|
SDL_Texture* message = SDL_CreateTextureFromSurface(renderer, surfaceMessage);
|
|
49
|
|
|
|
50
|
|
SDL_Rect text_rect;
|
|
51
|
|
text_rect.x = 0;
|
|
52
|
|
text_rect.y = 0;
|
|
53
|
|
text_rect.w = surfaceMessage->w;
|
|
54
|
|
text_rect.h = surfaceMessage->h;
|
|
|
49
|
SDL_Surface* text = TTF_RenderUTF8_Blended(font, msg, white);
|
|
|
50
|
SDL_BlitSurface(text, NULL, surface, NULL);
|
|
55
|
51
|
|
|
|
52
|
// monospace -> fixed width (duh)
|
|
56
|
53
|
int advance = 0;
|
|
57
|
54
|
for (int i = 0; i < strlen(msg); i++) {
|
|
58
|
55
|
TTF_GlyphMetrics(font, msg[i], NULL, NULL, NULL, NULL, &advance);
|
|
|
@ -67,15 +64,10 @@ int main(int argc, char *argv[]) {
|
|
67
|
64
|
break;
|
|
68
|
65
|
}
|
|
69
|
66
|
|
|
70
|
|
SDL_RenderClear(renderer);
|
|
71
|
|
SDL_RenderCopy(renderer, message, NULL, &text_rect);
|
|
72
|
|
SDL_RenderPresent(renderer);
|
|
73
|
|
|
|
|
67
|
SDL_UpdateWindowSurface(window);
|
|
74
|
68
|
SDL_Delay(16);
|
|
75
|
69
|
}
|
|
76
|
70
|
|
|
77
|
|
SDL_FreeSurface(surfaceMessage);
|
|
78
|
|
SDL_DestroyTexture(message);
|
|
79
|
71
|
SDL_DestroyWindow(window);
|
|
80
|
72
|
|
|
81
|
73
|
SDL_Quit();
|