Fixed the color problem of the editor

This commit is contained in:
George Sokianos 2021-12-19 22:24:44 +00:00
parent 3a5cadc116
commit 1abca0d4c7
4 changed files with 31 additions and 27 deletions

View File

@ -4,7 +4,7 @@
# #
# Project: lite # 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 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) lite: $(lite_OBJ)
@echo "Linking lite" @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" @echo "Removing stale debug target: lite"
@rm -f lite.debug @rm -f lite.debug
@ -86,16 +86,18 @@ lite: $(lite_OBJ)
src/api/api.o: src/api/api.c 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/system.o: src/api/system.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/api.h
src/main.o: src/main.c src/api/api.h src/renderer.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 src/renderer.o: src/renderer.c src/lib/stb/stb_truetype.h

View File

@ -1,10 +1,10 @@
<?xml version="1.0" ?> <?xml version="1.0" ?>
<CodeBench_Project name="lite" path="Applications:Programming&#047;workspace&#047;OtherProjects&#047;lite&#047;lite.cbp" created="1387049720" lastmodified="1387055061"> <CodeBench_Project name="lite" path="SDH3:Programming&#047;workspace&#047;MyProjects&#047;lite&#047;lite.cbp" created="1387049720" lastmodified="1387152257">
<plugin name="PROGDIR:Plugins&#047;AmigaOS4SDK.CCPlugin" flags="0"/> <plugin name="PROGDIR:Plugins&#047;AmigaOS4SDK.CCPlugin" flags="0"/>
<target/> <target/>
<homedir name="Applications:Programming&#047;workspace&#047;OtherProjects&#047;lite"/> <homedir name="SDH3:Programming&#047;workspace&#047;MyProjects&#047;lite"/>
<includedir name="Applications:Programming&#047;workspace&#047;OtherProjects&#047;lite&#047;src"/> <includedir name="Applications:Programming&#047;workspace&#047;OtherProjects&#047;lite&#047;src"/>
<compiler name="gcc:bin&#047;gcc" switches="-D__USE_INLINE__ -Wall -Werror -Wwrite-strings -Isrc" stack="131072"/> <compiler name="gcc:bin&#047;gcc" switches="-D__USE_INLINE__ -Wall -Werror -Wwrite-strings" stack="131072"/>
<linker switches="-lauto"/> <linker switches="-lauto"/>
<debugger name="SDK:c&#047;gdb"/> <debugger name="SDK:c&#047;gdb"/>
<builder name="SDK:c&#047;make -f"/> <builder name="SDK:c&#047;make -f"/>
@ -20,7 +20,7 @@
<file name="src&#047;api&#047;renderer.c" open="0"/> <file name="src&#047;api&#047;renderer.c" open="0"/>
<file name="src&#047;api&#047;renderer_font.c" open="0"/> <file name="src&#047;api&#047;renderer_font.c" open="0"/>
<file name="src&#047;api&#047;system.c" open="0"/> <file name="src&#047;api&#047;system.c" open="0"/>
<file name="src&#047;main.c" open="1" current="1" top="0" left="0" line="119" row="25"/> <file name="src&#047;main.c" open="1" current="1" top="75" left="0" line="97" row="16"/>
<file name="src&#047;rencache.c" open="0"/> <file name="src&#047;rencache.c" open="0"/>
<file name="src&#047;renderer.c" open="0"/> <file name="src&#047;renderer.c" open="0"/>
<file name="src&#047;lib&#047;stb&#047;stb_truetype.c" open="0"/> <file name="src&#047;lib&#047;stb&#047;stb_truetype.c" open="0"/>
@ -28,9 +28,9 @@
<flags value="0x0000000000078005"/> <flags value="0x0000000000078005"/>
<buildscript name="Makefile" depth="3" open="0"/> <buildscript name="Makefile" depth="3" open="0"/>
<projectnotes open="0"/> <projectnotes open="0"/>
<buildwindow open="1"/> <buildwindow open="0"/>
<targets> <targets>
<target name="lite" linker="gcc:bin&#047;gcc" switches="-llua -lSDL2 -lfreetype -lpthread -lauto" flags="0x00000002"> <target name="lite" linker="gcc:bin&#047;gcc" switches="-llua -lSDL2 -lpthread -lauto" flags="0x00000002">
<file name="src&#047;lib&#047;stb&#047;stb_truetype.c"/> <file name="src&#047;lib&#047;stb&#047;stb_truetype.c"/>
<file name="src&#047;api&#047;renderer.c"/> <file name="src&#047;api&#047;renderer.c"/>
<file name="src&#047;api&#047;renderer_font.c"/> <file name="src&#047;api&#047;renderer_font.c"/>
@ -41,6 +41,9 @@
<file name="src&#047;renderer.c"/> <file name="src&#047;renderer.c"/>
</target> </target>
</targets> </targets>
<includepath>
<include path="src"/>
</includepath>
<logfile name="RAM Disk:Build.log"/> <logfile name="RAM Disk:Build.log"/>
<search lastsearch="stbtt_Scale" sensecase="1" replace_state="0"/> <search lastsearch="stbtt_Scale" sensecase="1" replace_state="0"/>
</CodeBench_Project> </CodeBench_Project>

View File

@ -1,15 +1,9 @@
#ifndef API_H #ifndef API_H
#define 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/lua.h"
#include "lib/lua52/lauxlib.h" #include "lib/lua52/lauxlib.h"
#include "lib/lua52/lualib.h" #include "lib/lua52/lualib.h"
#endif
#define API_TYPE_FONT "Font" #define API_TYPE_FONT "Font"

View File

@ -270,7 +270,7 @@ static inline RenColor blend_pixel2(RenColor dst, RenColor src, RenColor color)
for (int j = y1; j < y2; j++) { \ for (int j = y1; j < y2; j++) { \
for (int i = x1; i < x2; i++) { \ for (int i = x1; i < x2; i++) { \
*d = expr; \ *d = expr; \
d++; \ d++; \
} \ } \
d += dr; \ d += dr; \
} }
@ -284,17 +284,22 @@ void ren_draw_rect(RenRect rect, RenColor color) {
int y2 = rect.y + rect.height; int y2 = rect.y + rect.height;
x2 = x2 > clip.right ? clip.right : x2; x2 = x2 > clip.right ? clip.right : x2;
y2 = y2 > clip.bottom ? clip.bottom : y2; 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); SDL_Surface *surf = SDL_GetWindowSurface(window);
RenColor *d = (RenColor*) surf->pixels; RenColor *d = (RenColor*) surf->pixels;
d += x1 + y1 * surf->w; printf("DBG: surf\tr: %d\tg: %d\tb:%d\ta:%d\tw: %d\n", d->r, d->g, d->b, d->a, surf->w);
int dr = surf->w - (x2 - x1); 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) { 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 { } else {
rect_draw_loop(blend_pixel(*d, color)); rect_draw_loop(blend_pixel(*d, color));
} }
printf("======================\n");
} }