summaryrefslogtreecommitdiff
path: root/main.c3
blob: f349205924e8c1535194a89edddb9d386efc6dab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
module c3term;
import std::io;

struct TPixel {
  char r; char g; char b; char a;
}

struct Tigr {
  CInt w; CInt h;
  CInt cx; CInt cy; CInt cw; CInt ch;
  TPixel* pix;
  void* handle;
  CInt blitMode;
}

struct TigrGlyph {
  CInt code; CInt x; CInt y; CInt w; CInt h;
}

struct TigrFont {
  Tigr* bitmap;
  CInt numglyphs;
  TigrGlyph* glyphs;
}

extern fn Tigr* tigrWindow(CInt, CInt, ZString, CInt);
extern fn CInt tigrClosed(Tigr*);
extern fn void tigrUpdate(Tigr*);
extern fn void tigrClear(Tigr*, TPixel);
extern fn void tigrPrint(Tigr*, TigrFont*, CInt, CInt, TPixel, ZString);
extern TigrFont* tfont;

fn int main(String[] args)
{
  io::printn(*tfont);
  io::printn("init");
  Tigr* screen = tigrWindow(320, 240, "title", 0);
  while (!tigrClosed(screen)) {
    TPixel p = {
      .r = 0x80,
      .g = 0x90,
      .b = 0xA0,
      .a = 0x00,
    };
    TPixel w = {
      .r = 0xFF,
      .g = 0xFF,
      .b = 0xFF,
      .a = 0xFF,
    };
    tigrClear(screen, p);
    tigrPrint(screen, tfont, 120, 110, w, "Hello, world.");
    tigrUpdate(screen);
  }
  io::printn("tschuess");
  return(0);
}