Przeglądaj źródła

Demonstrate how to render a single emojii

Luna Stadler 4 lat temu
rodzic
commit
0a9fad79b0
1 zmienionych plików z 4 dodań i 4 usunięć
  1. 4 4
      c/sdl/hello_sdl.c

+ 4 - 4
c/sdl/hello_sdl.c

1
#include <SDL.h>
1
#include <SDL.h>
2
#include <SDL_ttf.h>
2
#include <SDL_ttf.h>
3
3
4
char *font_file = "./FantasqueSansMono-Regular.ttf";
4
char *font_file = "./NotoColorEmoji.ttf";
5
5
6
int main(int argc, char *argv[]) {
6
int main(int argc, char *argv[]) {
7
	printf("hello, world!\n");
7
	printf("hello, world!\n");
41
41
42
	SDL_Surface *surface = SDL_GetWindowSurface(window);
42
	SDL_Surface *surface = SDL_GetWindowSurface(window);
43
43
44
	char *msg = "howdy there, enby! 🐘";
44
	char *msg = "🐘";
45
45
46
	// thanks to https://stackoverflow.com/questions/22886500/how-to-render-text-in-sdl2 for some actually useful code here
46
	// thanks to https://stackoverflow.com/questions/22886500/how-to-render-text-in-sdl2 for some actually useful code here
47
	SDL_Color white = {255, 255, 255};
47
	SDL_Color white = {255, 255, 255, 255};
48
	SDL_Color black = {0, 0, 0};
48
	SDL_Color black = {0, 0, 0};
49
	SDL_Surface* text = TTF_RenderUTF8_Blended(font, msg, white);
49
	SDL_Surface* text = TTF_RenderUTF8_Shaded(font, msg, white, black);
50
	SDL_BlitSurface(text, NULL, surface, NULL);
50
	SDL_BlitSurface(text, NULL, surface, NULL);
51
51
52
	// monospace -> fixed width (duh)
52
	// monospace -> fixed width (duh)