diff --git a/implementations/uvm-ncc/xerblin.c b/implementations/uvm-ncc/xerblin.c index c76e77b..5fe2386 100644 --- a/implementations/uvm-ncc/xerblin.c +++ b/implementations/uvm-ncc/xerblin.c @@ -10,8 +10,11 @@ size_t FRAME_HEIGHT = 800; // RGBA pixels: 800 * 600 u32 frame_buffer[1024_000]; +int wid; -void anim_callback() + +void +anim_callback() { // Clear the screen memset(frame_buffer, 0, sizeof(frame_buffer)); @@ -25,13 +28,41 @@ void anim_callback() *pix_ptr = (alpha << 24) | (red << 16) | (green << 8) | blue; } } - window_draw_frame(0, frame_buffer); - time_delay_cb(100, anim_callback); + window_draw_frame(wid, frame_buffer); + // This rate of refresh of the whole screen caused ~60% CPU use. :( + // time_delay_cb(100, anim_callback); } -void main() + +//void +//keydown(u64 window_id, u16 keycode) +//{ +// window_draw_frame(window_id, frame_buffer); +//} + + +void +mousemove(u64 window_id, u64 new_x, u64 new_y) { - window_create(FRAME_WIDTH, FRAME_HEIGHT, "Bouncing Ball Example", 0); + // Redrawing the window on move seems to repair damage from + // dragging portion of the window offscreen then back on as + // you drag, without using too much CPU. + // No, weird, it doesn't. + // It did, once, but maybe that was teh X server somehow doing it for me? + // In any event, moving the mouse over the screen after drag damage + // works fine, as expected. + // (I just really would like to know why it stopped damaging the window + // in the previous try? Ugh!) + window_draw_frame(window_id, frame_buffer); +} + + +void +main() +{ + wid = window_create(FRAME_WIDTH, FRAME_HEIGHT, "Bouncing Ball Example", 0); time_delay_cb(0, anim_callback); + //window_on_keydown(wid, keydown); + window_on_mousemove(wid, mousemove); enable_event_loop(); }