aboutsummaryrefslogtreecommitdiff
path: root/teensy
diff options
context:
space:
mode:
authoriamcheeseman <[email protected]>2026-05-27 16:34:31 -0400
committeriamcheeseman <[email protected]>2026-05-27 16:34:31 -0400
commita875e0155ec7757c7b487bee0b4a8fbfa8574888 (patch)
treee35b5384478371a8708e6adeeb4f49201b618364 /teensy
parent9d997b496f9d475c6e08e33f9aa2555612c8f87b (diff)
build for w*ndows
Diffstat (limited to 'teensy')
-rw-r--r--teensy/teensy_context.c10
-rw-r--r--teensy/teensy_renderer.c8
-rw-r--r--teensy/teensy_ui.c20
3 files changed, 23 insertions, 15 deletions
diff --git a/teensy/teensy_context.c b/teensy/teensy_context.c
index ad7c79e..2eb1df3 100644
--- a/teensy/teensy_context.c
+++ b/teensy/teensy_context.c
@@ -2,7 +2,11 @@
#include <math.h>
#include <stdarg.h>
+#ifdef _WIN32
+#include <windows.h>
+#else
#include <time.h>
+#endif
#include "teensy_platform.h"
#include "teensy_renderer.h"
@@ -81,7 +85,7 @@ int ty_tick(void)
double current_time = ty_get_time();
double time_since_tic = current_time - ctx.prev_tic_ts;
- int tics = time_since_tic / ctx.ticrate;
+ int tics = (int)(time_since_tic / ctx.ticrate);
if (tics > 0) {
update_buttons();
ctx.prev_tic_ts = current_time;
@@ -95,10 +99,14 @@ void ty_sleep(uint64_t ms)
{
assert(is_init());
+#ifdef _WIN32
+ Sleep((DWORD)ms);
+#else
struct timespec ts;
ts.tv_sec = ms / 1000;
ts.tv_nsec = (ms % 1000) * 1000000;
nanosleep(&ts, NULL);
+#endif
}
char *ty_format_args(const char *fmt, va_list list)
diff --git a/teensy/teensy_renderer.c b/teensy/teensy_renderer.c
index 564718a..863fa25 100644
--- a/teensy/teensy_renderer.c
+++ b/teensy/teensy_renderer.c
@@ -227,8 +227,8 @@ void ty_draw_image_rot(
double s = sin(-rot);
double c = cos(-rot);
- int blit_width = ceil(img.width * fabs(c) + img.height * fabs(s));
- int blit_height = ceil(img.width * fabs(s) + img.height * fabs(c));
+ int blit_width = (int)ceil(img.width * fabs(c) + img.height * fabs(s));
+ int blit_height = (int)ceil(img.width * fabs(s) + img.height * fabs(c));
int startx = -blit_width / 2;
int starty = -blit_height / 2;
@@ -237,8 +237,8 @@ void ty_draw_image_rot(
for (int img_y = starty; img_y < endy; img_y++) {
for (int img_x = startx; img_x < endx; img_x++) {
- int dx = floor(img_x * c - img_y * s - offset.x);
- int dy = floor(img_x * s + img_y * c - offset.y);
+ int dx = (int)floor(img_x * c - img_y * s - offset.x);
+ int dy = (int)floor(img_x * s + img_y * c - offset.y);
if (dx < 0 || dx >= img.width || dy < 0 || dy >= img.height)
continue;
diff --git a/teensy/teensy_ui.c b/teensy/teensy_ui.c
index f518431..4dd9d5d 100644
--- a/teensy/teensy_ui.c
+++ b/teensy/teensy_ui.c
@@ -162,10 +162,10 @@ int get_column_width(const Layout *l)
{
float width = l->column_widths[l->idx];
if (width < 0)
- return width + l->width - l->x + 1;
+ return (int)(width + l->width - l->x + 1);
if (width < 1)
- return (l->width - tyui.style.padding * 2) * width;
- return width;
+ return (int)((l->width - tyui.style.padding * 2) * width);
+ return (int)width;
}
static
@@ -175,7 +175,7 @@ ty_Recti next_rect(int height)
l->max_height = ty_max(l->max_height, height);
- float width = get_column_width(l);
+ float width = (float)get_column_width(l);
int x = 0;
int y = 0;
@@ -190,11 +190,11 @@ ty_Recti next_rect(int height)
width = ty_max(width, 0);
height = ty_max(height, 0);
- l->x += width + tyui.style.padding;
+ l->x += (int)width + tyui.style.padding;
advance_layout();
- return ty_recti(x, y, width, height);
+ return ty_recti(x, y, (int)width, height);
}
static
@@ -518,7 +518,7 @@ void tyui_slider_ex(
if (clicked) {
ty_Vec2i mp = ty_mouse_pos();
- float x = mp.x - rect.x;
+ float x = (float)(mp.x - rect.x);
float p = x / (rect.w - 1);
*value_ptr = ty_clamp(p * (max - min) + min, min, max);
}
@@ -538,7 +538,7 @@ void tyui_slider_ex(
{
value = ty_clamp(value, min, max);
float p = (value - min) / max;
- int x = (rect.w - grabber_size) * p + rect.x;
+ int x = (int)((rect.w - grabber_size) * p + rect.x);
ty_Recti grabber_rect = ty_recti(
x, rect.y,
@@ -583,14 +583,14 @@ void tyui_text_input(tyui_Text_Input *input)
ty_Recti text_rect = ty_recti_shrink(rect, tyui.style.control_padding);
int text_width = ty_font_width(tyui.font, input->chars);
- text_rect.w = fmin(text_rect.w, text_width);
+ text_rect.w = (int)fmin(text_rect.w, text_width);
text_cmd(
input->chars,
text_rect,
focused ? TYUI_ALIGN_RIGHT : TYUI_ALIGN_LEFT
);
if (focused && (int)(ty_get_time() * 2) % 2 == 0) {
- text_rect.x += fmin(text_width, text_rect.w - 1);
+ text_rect.x += (int)fmin(text_width, text_rect.w - 1);
text_rect.w = 1;
rect_cmd(text_rect, tyui.style.fg_normal);
}