aboutsummaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMarvin Borner2020-09-04 16:04:33 +0200
committerMarvin Borner2020-09-04 16:04:33 +0200
commit538ac0e639ad190fe7dee0fb7029fb536761c471 (patch)
tree35221e1b7766fa159076d695e3159e0d83ef802d /apps
parentb8f00b77e965c73a047e71193c8c6e2d7488f34d (diff)
Strange keyboard resolution changing thing
Diffstat (limited to 'apps')
-rw-r--r--apps/mandelbrot.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/apps/mandelbrot.c b/apps/mandelbrot.c
index 6b6d45c..2165217 100644
--- a/apps/mandelbrot.c
+++ b/apps/mandelbrot.c
@@ -18,16 +18,11 @@ void draw_pixel(struct window *win, int x, int y, u32 c)
win->fb[pos + 3] = GET_ALPHA(c);
}
-int main()
+void draw_mandelbrot(struct window *win, int resolution)
{
- print("[mandelbrot window loaded]\n");
-
- struct window *win = gui_new_window(WF_DEFAULT);
- gui_fill(win, BG_COLOR);
-
int height = win->height;
int width = win->width;
- int max = 500;
+ int max = resolution;
for (int row = 0; row < height; row++) {
for (int col = 0; col < width; col++) {
@@ -49,9 +44,26 @@ int main()
}
}
gui_redraw();
+ yield();
+}
+int main()
+{
+ print("[mandelbrot window loaded]\n");
+
+ struct window *win = gui_new_window(WF_DEFAULT);
+ gui_fill(win, BG_COLOR);
+ event_register(EVENT_KEYBOARD);
+
+ int resolution = 0;
+ struct message *msg;
while (1) {
- yield();
+ if (!(msg = msg_receive())) {
+ yield();
+ continue;
+ }
+ if (msg->type == EVENT_KEYBOARD && ((struct event_keyboard *)msg->data)->press)
+ draw_mandelbrot(win, ++resolution);
};
return 0;