From 7ef52b31864696747396945b2ca8892d8796f96c Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Sat, 17 Jun 2023 22:20:22 +0300 Subject: [PATCH] font rendering and redraw fixes --- libs/drawtext/drawrast.c | 4 ++-- src/app.c | 7 +++++-- src/app.h | 1 + src/font.c | 2 +- src/font.h | 2 +- src/modern/main.c | 18 ------------------ src/rtk.c | 8 +++++--- src/scr_mod.c | 9 +++++++-- tools/procdata | 1 + 9 files changed, 23 insertions(+), 29 deletions(-) diff --git a/libs/drawtext/drawrast.c b/libs/drawtext/drawrast.c index 99106c8..f54c25d 100644 --- a/libs/drawtext/drawrast.c +++ b/libs/drawtext/drawrast.c @@ -119,9 +119,9 @@ static void blit_thres(unsigned char *dest, unsigned char *src, int xsz, int ysz for(j=0; j threshold) { - *dest++ = col[0]; - *dest++ = col[1]; *dest++ = col[2]; + *dest++ = col[1]; + *dest++ = col[0]; *dest++ = col[3]; } else { dest += 4; diff --git a/src/app.c b/src/app.c index 1d45cdd..c538bb1 100644 --- a/src/app.c +++ b/src/app.c @@ -82,10 +82,12 @@ int app_init(void) app_fullscreen(1); } - dtx_target_user(txdraw, 0); + /*dtx_target_user(txdraw, 0);*/ + dtx_target_raster((unsigned char*)framebuf, win_width, win_height); + dtx_set(DTX_RASTER_THRESHOLD, 127); uifont = malloc_nf(sizeof *uifont); - if(load_font(uifont, "data/uifont12.gmp") == -1) { + if(load_font(uifont, "data/uifont14.gmp") == -1) { free(uifont); return -1; } @@ -174,6 +176,7 @@ void app_reshape(int x, int y) #ifdef GFX_SW gaw_sw_framebuffer(x, y, framebuf); #endif + dtx_target_raster((unsigned char*)framebuf, x, y); win_width = x; win_height = y; diff --git a/src/app.h b/src/app.h index 8a07379..acd6a71 100644 --- a/src/app.h +++ b/src/app.h @@ -21,6 +21,7 @@ along with this program. If not, see . #include "sizeint.h" #include "logger.h" #include "scene.h" +#include "font.h" enum { KEY_BACKSP = 8, diff --git a/src/font.c b/src/font.c index 4374e6d..e9c730d 100644 --- a/src/font.c +++ b/src/font.c @@ -1,5 +1,5 @@ /* -Deep Runner - 6dof shooter game for the SGI O2. +RetroRay - integrated standalone vintage modeller/renderer Copyright (C) 2023 John Tsiombikas This program is free software: you can redistribute it and/or modify diff --git a/src/font.h b/src/font.h index be8d5d1..f0bdd2f 100644 --- a/src/font.h +++ b/src/font.h @@ -1,5 +1,5 @@ /* -Deep Runner - 6dof shooter game for the SGI O2. +RetroRay - integrated standalone vintage modeller/renderer Copyright (C) 2023 John Tsiombikas This program is free software: you can redistribute it and/or modify diff --git a/src/modern/main.c b/src/modern/main.c index e60329f..ea10805 100644 --- a/src/modern/main.c +++ b/src/modern/main.c @@ -31,7 +31,6 @@ static void skeyup(int key, int x, int y); static void mouse(int bn, int st, int x, int y); static void motion(int x, int y); static int translate_skey(int key); -static void draw_cursor(int x, int y); #if defined(__unix__) || defined(unix) #include @@ -183,9 +182,6 @@ void app_vsync(int vsync) static void display(void) { app_display(); - - draw_cursor(mouse_x, mouse_y); - app_swap_buffers(); } @@ -262,17 +258,3 @@ static int translate_skey(int key) return -1; } - -static void draw_cursor(int x, int y) -{ - int i; - uint32_t *fbptr = framebuf + y * win_width + x; - - for(i=0; i<3; i++) { - int offs = i + 1; - if(y > offs) fbptr[-win_width * offs] ^= 0xffffff; - if(y < win_height - offs - 1) fbptr[win_width * offs] ^= 0xffffff; - if(x > offs) fbptr[-offs] ^= 0xffffff; - if(x < win_width - offs - 1) fbptr[offs] ^= 0xffffff; - } -} diff --git a/src/rtk.c b/src/rtk.c index c9de38f..b9d06d5 100644 --- a/src/rtk.c +++ b/src/rtk.c @@ -739,8 +739,6 @@ int rtk_input_mmotion(rtk_widget *w, int x, int y) return res; } - sethover(w); - if(w->type == RTK_WIN) { c = w->win.clist; while(c) { @@ -751,5 +749,9 @@ int rtk_input_mmotion(rtk_widget *w, int x, int y) } } - return 1; + if(hover != w) { + sethover(w); + return 1; + } + return 0; } diff --git a/src/scr_mod.c b/src/scr_mod.c index 1ef5a9f..917747e 100644 --- a/src/scr_mod.c +++ b/src/scr_mod.c @@ -192,6 +192,7 @@ static void mdl_stop(void) static void mdl_display(void) { int i, num; + static int frameno; gaw_clear(GAW_COLORBUF | GAW_DEPTHBUF); @@ -230,6 +231,11 @@ static void mdl_display(void) } } + use_font(uifont); + dtx_position(560, 475); + dtx_color(1, 1, 0, 1); + dtx_printf("frame: %ld", frameno++); + if(rband_valid) { draw_rband(); } @@ -350,7 +356,6 @@ static void mdl_mouse(int bn, int press, int x, int y) vpdrag &= ~(1 << bn); if(rband_valid) { - printf("rubber band: %d,%d %dx%d\n", rband.x, rband.y, rband.width, rband.height); rband_valid = 0; } else if(bn == 0 && x == rband.x && y == rband.y) { @@ -413,8 +418,8 @@ static void mdl_motion(int x, int y) default: break; } + app_redisplay(); } - app_redisplay(); } } diff --git a/tools/procdata b/tools/procdata index f0fbd5b..c4af10f 100755 --- a/tools/procdata +++ b/tools/procdata @@ -7,5 +7,6 @@ genglyphmap() } genglyphmap data/src/sans.ttf data/uifont12.gmp 12 32-128 +genglyphmap data/src/sans.ttf data/uifont14.gmp 14 32-128 exit 0 -- 1.7.10.4