mouse cursor
authorJohn Tsiombikas <nuclear@member.fsf.org>
Mon, 3 Sep 2018 10:02:00 +0000 (13:02 +0300)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Mon, 3 Sep 2018 10:02:00 +0000 (13:02 +0300)
src/demo.c
src/demo.h
src/parts/rtxonoff.c
src/sdl/main.c

index 0874104..7d927ea 100644 (file)
 #include "tinyfps.h"
 #include "util.h"
 
-int fb_width = 320;
-int fb_height = 240;
+#define FB_WIDTH       320
+#define FB_HEIGHT      240
+
+int fb_width = FB_WIDTH;
+int fb_height = FB_HEIGHT;
 int fb_bpp = 16;
 uint16_t *fb_pixels, *vmem_back, *vmem_front;
 unsigned long time_msec;
@@ -102,6 +105,49 @@ void demo_draw(void)
        ++nframes;
 }
 
+
+
+#define DEST(x, y)     dest[(y) * FB_WIDTH + (x)]
+void draw_mouse_pointer(uint16_t *fb)
+{
+       uint16_t *dest = fb + mouse_y * FB_WIDTH + mouse_x;
+
+       DEST(0, 0) = 0xffff;
+       DEST(1, 1) = 0xffff;
+       DEST(2, 2) = 0xffff;
+       DEST(3, 3) = 0xffff;
+       DEST(4, 4) = 0xffff;
+       DEST(5, 5) = 0xffff;
+       DEST(6, 6) = 0xffff;
+       DEST(0, 1) = 0xffff;
+       DEST(0, 2) = 0xffff;
+       DEST(0, 3) = 0xffff;
+       DEST(0, 4) = 0xffff;
+       DEST(0, 5) = 0xffff;
+       DEST(0, 6) = 0xffff;
+       DEST(0, 7) = 0xffff;
+       DEST(0, 8) = 0xffff;
+       DEST(0, 9) = 0xffff;
+       DEST(1, 8) = 0xffff;
+       DEST(2, 7) = 0xffff;
+       DEST(3, 6) = 0xffff;
+       DEST(4, 6) = 0xffff;
+       DEST(5, 6) = 0xffff;
+       DEST(1, 2) = 0;
+       DEST(1, 3) = 0;
+       DEST(2, 3) = 0;
+       DEST(1, 4) = 0;
+       DEST(2, 4) = 0;
+       DEST(3, 4) = 0;
+       DEST(1, 5) = 0;
+       DEST(2, 5) = 0;
+       DEST(3, 5) = 0;
+       DEST(4, 5) = 0;
+       DEST(1, 6) = 0;
+       DEST(2, 6) = 0;
+       DEST(1, 7) = 0;
+}
+
 static void change_screen(int idx)
 {
        printf("change screen %d\n", idx);
@@ -228,6 +274,7 @@ void mouse_orbit_update(float *theta, float *phi, float *dist)
                        }
                }
        }
+
        prev_mx = mouse_x;
        prev_my = mouse_y;
        prev_bmask = mouse_bmask;
index ac5ca06..bf3eaa6 100644 (file)
@@ -43,4 +43,6 @@ void swap_buffers(void *pixels);
 /* call each frame to get 3D viewing spherical coordinates */
 void mouse_orbit_update(float *theta, float *phi, float *dist);
 
+void draw_mouse_pointer(uint16_t *fb);
+
 #endif /* DEMO_H_ */
index e56baeb..fc0d52b 100644 (file)
@@ -212,6 +212,8 @@ static void draw(void)
        g3d_light_color(0, 1, 1, 1);
        draw_mesh(&mesh_car[0]);
 
+       draw_mouse_pointer(fb_pixels);
+
        swap_buffers(fb_pixels);
 }
 
index 65ddd35..e7e161e 100644 (file)
@@ -46,6 +46,7 @@ int main(int argc, char **argv)
                return 1;
        }
        SDL_WM_SetCaption("dosdemo/SDL", 0);
+       SDL_ShowCursor(0);
 
        time_msec = 0;
        if(demo_init(argc, argv) == -1) {