From 1abca0d4c75be307ed153ca837b2fe4ad05843f5 Mon Sep 17 00:00:00 2001 From: George Sokianos Date: Sun, 19 Dec 2021 22:24:44 +0000 Subject: [PATCH] Fixed the color problem of the editor --- Makefile | 18 ++++++++++-------- lite.cbp | 15 +++++++++------ src/api/api.h | 6 ------ src/renderer.c | 19 ++++++++++++------- 4 files changed, 31 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index 6cdca3a..d3bab7f 100755 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ # # Project: lite # -# Created on: 14-12-2021 20:40:46 +# Created on: 15-12-2021 22:58:23 # # @@ -28,9 +28,9 @@ lite_OBJ := \ CC := gcc:bin/gcc -INCPATH := -I. +INCPATH := -I. -Isrc -CFLAGS := $(INCPATH) -D__USE_INLINE__ -Wall -Werror -Wwrite-strings -Isrc +CFLAGS := $(INCPATH) -D__USE_INLINE__ -Wall -Werror -Wwrite-strings ################################################################### @@ -66,7 +66,7 @@ realclean: lite: $(lite_OBJ) @echo "Linking lite" - @gcc:bin/gcc -o lite $(lite_OBJ) -llua -lSDL2 -lfreetype -lpthread -lauto + @gcc:bin/gcc -o lite $(lite_OBJ) -llua -lSDL2 -lpthread -lauto @echo "Removing stale debug target: lite" @rm -f lite.debug @@ -86,16 +86,18 @@ lite: $(lite_OBJ) src/api/api.o: src/api/api.c -src/api/renderer.o: src/api/renderer.c +src/api/renderer.o: src/api/renderer.c src/api/api.h src/renderer.h \ + -src/api/renderer_font.o: src/api/renderer_font.c +src/api/renderer_font.o: src/api/renderer_font.c src/api/api.h src/renderer.h \ + -src/api/system.o: src/api/system.c +src/api/system.o: src/api/system.c src/api/api.h src/main.o: src/main.c src/api/api.h src/renderer.h \ -src/rencache.o: src/rencache.c src/rencache.h +src/rencache.o: src/rencache.c src/renderer.o: src/renderer.c src/lib/stb/stb_truetype.h diff --git a/lite.cbp b/lite.cbp index 2c175e5..5c3004e 100755 --- a/lite.cbp +++ b/lite.cbp @@ -1,10 +1,10 @@ - + - + - + @@ -20,7 +20,7 @@ - + @@ -28,9 +28,9 @@ - + - + @@ -41,6 +41,9 @@ + + + diff --git a/src/api/api.h b/src/api/api.h index dc2225f..b6813e5 100644 --- a/src/api/api.h +++ b/src/api/api.h @@ -1,15 +1,9 @@ #ifndef API_H #define API_H -#if __amigaos4__ -#include "lua.h" -#include "lauxlib.h" -#include "lualib.h" -#else #include "lib/lua52/lua.h" #include "lib/lua52/lauxlib.h" #include "lib/lua52/lualib.h" -#endif #define API_TYPE_FONT "Font" diff --git a/src/renderer.c b/src/renderer.c index 0751d0b..4e833c5 100644 --- a/src/renderer.c +++ b/src/renderer.c @@ -270,7 +270,7 @@ static inline RenColor blend_pixel2(RenColor dst, RenColor src, RenColor color) for (int j = y1; j < y2; j++) { \ for (int i = x1; i < x2; i++) { \ *d = expr; \ - d++; \ + d++; \ } \ d += dr; \ } @@ -284,17 +284,22 @@ void ren_draw_rect(RenRect rect, RenColor color) { int y2 = rect.y + rect.height; x2 = x2 > clip.right ? clip.right : x2; y2 = y2 > clip.bottom ? clip.bottom : y2; - +printf("DBG: rect\tx1: %d\ty1: %d\tx2:%d\ty2:%d\n", x1, y1, x2, y2); SDL_Surface *surf = SDL_GetWindowSurface(window); RenColor *d = (RenColor*) surf->pixels; - d += x1 + y1 * surf->w; - int dr = surf->w - (x2 - x1); - +printf("DBG: surf\tr: %d\tg: %d\tb:%d\ta:%d\tw: %d\n", d->r, d->g, d->b, d->a, surf->w); + d += x1 + y1 * (surf->pitch / 4); +//printf("DBG: surf\tr: %d\tg: %d\tb:%d\ta:%d\n", d->r, d->g, d->b, d->a); + int dr = (surf->pitch / 4) - (x2 - x1); +printf("DBG: r: %d\tg: %d\tb:%d\ta:%d\n", color.r, color.g, color.b, color.a); if (color.a == 0xff) { - rect_draw_loop(color); + //rect_draw_loop(color); + SDL_Rect rect = { x1, y1, x2 - x1, y2 - y1 }; + SDL_FillRect(surf, &rect, SDL_MapRGBA(surf->format, color.r, color.g, color.b, color.a)); } else { - rect_draw_loop(blend_pixel(*d, color)); + rect_draw_loop(blend_pixel(*d, color)); } +printf("======================\n"); }