1#include <stdio.h>
2#include "raylib.h"
3
4#include "data/armor.h"
5#include "data/dejavusans-mono.h"
6
7#define FONT_SIZE 24
8
9int main(void) {
10 SetConfigFlags(FLAG_WINDOW_RESIZABLE | FLAG_VSYNC_HINT | FLAG_WINDOW_HIGHDPI);
11 InitWindow(900, 400, "Embedding assets");
12 SetTargetFPS(60);
13
14 // Load font from memory.
15 Font font = LoadFontFromMemory(".ttf", data_dejavusans_mono_ttf, data_dejavusans_mono_ttf_len, FONT_SIZE, NULL, 0);
16 SetTextureFilter(font.texture, TEXTURE_FILTER_TRILINEAR); // Font antialising.
17
18 // Load image from memory and create texture from it.
19 Image armor = LoadImageFromMemory(".png", data_armor_png, data_armor_png_len);
20 Texture2D armor_texture = LoadTextureFromImage(armor);
21 UnloadImage(armor);
22
23 while (!WindowShouldClose()) {
24 BeginDrawing();
25 ClearBackground(BLACK);
26
27 // Draw the armor texture.
28 DrawTexture(armor_texture, 20, 20, WHITE);
29
30 // Draw some text on the screen.
31 DrawTextEx(font, "Hello embedded assets.", (Vector2){ 400, 20 }, FONT_SIZE, 0, WHITE);
32 DrawTextEx(font, "This is example how we can use embedded fonts.", (Vector2){ 400, 50 }, FONT_SIZE - 4, 0, WHITE);
33
34 EndDrawing();
35 }
36
37 UnloadTexture(armor_texture);
38 CloseWindow();
39 return 0;
40}