started using 'use'
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Wed, 23 Sep 2020 17:45:32 +0000 (12:45 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Wed, 23 Sep 2020 17:45:32 +0000 (12:45 -0500)
src/font.onyx
src/main.onyx

index 0ec7779c56d0e372e509b94c8c49aec884e16762..48597d1c13434b989c09cfe1fd6ca99be2783848 100644 (file)
@@ -706,28 +706,28 @@ ttf_render_glyph :: proc (use ttf: ^TrueTypeFont, glyph: ^TTGlyph, data: ^u8, wi
             count += 1;
             state = 0;
 
-            for p: poly_points {
-                print_vec(p);
+            // for p: poly_points {
+            //     print_vec(p);
 
-                tx := cast(i32) (~~p.x * height / ~~units_per_em);
-                ty := cast(i32) (~~p.y * height / ~~units_per_em);
+            //     tx := cast(i32) (~~p.x * height / ~~units_per_em);
+            //     ty := cast(i32) (~~p.y * height / ~~units_per_em);
 
-                if tx >= 0 && ty >= 0 && tx < width && ty < height {
-                    data[tx + (height - 1 - ty) * width] += cast(u8) 100;
-                }
-            }
-
-            // for y: 0 .. height do for x: 0 .. width {
-            //     sx := x * ~~units_per_em / width;
-            //     sy := y * ~~units_per_em / height;
-
-            //     if is_inside_polygon(array_to_slice(^poly_points), V2i.{ sx, sy }) {
-            //         curr := data[x + (height - 1 - y) * width];
-            //         if curr == ~~0 do data[x + (height - 1 - y) * width] = cast(u8) 255;
-            //         else           do data[x + (height - 1 - y) * width] = cast(u8) 0;
+            //     if tx >= 0 && ty >= 0 && tx < width && ty < height {
+            //         data[tx + (height - 1 - ty) * width] += cast(u8) 100;
             //     }
             // }
 
+            for y: 0 .. height do for x: 0 .. width {
+                sx := x * ~~units_per_em / width;
+                sy := y * ~~units_per_em / height;
+
+                if is_inside_polygon(array_to_slice(^poly_points), V2i.{ sx, sy }) {
+                    curr := data[x + (height - 1 - y) * width];
+                    if curr == ~~0 do data[x + (height - 1 - y) * width] = cast(u8) 255;
+                    else           do data[x + (height - 1 - y) * width] = cast(u8) 0;
+                }
+            }
+
             array_clear(^poly_points);
         }
     }
index 1d095525204f50141858349b2929961a6d0e0c63..e07a9ff57439c4430d59657083d39e6941a781ee 100644 (file)
@@ -91,17 +91,13 @@ player : Player
 
 
 poll_events :: proc () {
+    use event.DomEventKind;
+
     ev : event.Event;
     while event.poll(^ev) do switch ev.kind {
-        case event.DomEventKind.KeyDown,
-             event.DomEventKind.KeyUp,
-             event.DomEventKind.MouseDown,
-             event.DomEventKind.MouseUp,
-             event.DomEventKind.MouseMove {
-            input.process_event(^input_state, ^ev);
-        }
+        case KeyDown, KeyUp, MouseDown, MouseUp, MouseMove do input.process_event(^input_state, ^ev);
 
-        case event.DomEventKind.Resize {
+        case Resize {
             window_width  = ev.resize.width;
             window_height = ev.resize.height;
 
@@ -209,7 +205,7 @@ main :: proc (args: [] cstring) {
     ttf = ttf_create(ttf_data);
 
     glyph : ^TTGlyph = null;
-    glyph_index := ttf_lookup_glyph_by_char(^ttf, ~~ #char "~");
+    glyph_index := ttf_lookup_glyph_by_char(^ttf, ~~ #char "A");
     glyph = ttf_read_glyph(^ttf, glyph_index);
     if glyph == null do return;
     defer ttf_glyph_destroy(glyph);