Use unsigned char for colors

This commit is contained in:
Fierelier 2023-06-13 06:06:42 +02:00
parent 061a694bdb
commit 3f9f1276d7
6 changed files with 11 additions and 9 deletions

View File

@ -5,6 +5,7 @@ typesIn = {
"char": "luaL_checkinteger",
"int": "luaL_checkinteger",
"long long": "luaL_checkinteger",
"unsigned char": "luaL_checkinteger",
"char *": "(char *)luaL_checkstring"
}
@ -13,6 +14,7 @@ typesOut = {
"char": "lua_pushinteger",
"int": "lua_pushinteger",
"long long": "lua_pushinteger",
"unsigned char": "lua_pushinteger",
"char *": "lua_pushstring"
}

View File

@ -16,7 +16,7 @@ void engine_memory_free(void * pnt) {
struct ENGINE_TEXTURE { int width; int height; struct ENGINE_FRONTEND_TEXTURE * fe_texture; };
// COLOR
struct ENGINE_COLOR { char r; char g; char b; char a; };
struct ENGINE_COLOR { unsigned char r; unsigned char g; unsigned char b; unsigned char a; };
// WINDOWS
struct ENGINE_WINDOW { struct ENGINE_TEXTURE * texture; struct ENGINE_FRONTEND_WINDOW * fe_window; };

View File

@ -34,7 +34,7 @@ struct ENGINE_COLOR engine_texture_color_get(struct ENGINE_TEXTURE * engine_text
}
// COLOR
void engine_color_set(char r,char g,char b,char a) {
void engine_color_set(unsigned char r,unsigned char g,unsigned char b,unsigned char a) {
}
// RENDERTARGET

View File

@ -38,7 +38,7 @@ void engine_rendertarget_draw_texture(struct ENGINE_TEXTURE * texture,int x,int
}
void engine_rendertarget_draw_file(char * fpath) {
char buffer[engine_rendertarget->width * engine_rendertarget->height * 4];
unsigned char buffer[engine_rendertarget->width * engine_rendertarget->height * 4];
FILE * f = fopen(fpath,"r");
fgets(buffer,engine_rendertarget->width * engine_rendertarget->height * 4,f);
fclose(f);

View File

@ -37,10 +37,10 @@ int engine_luaf_texture_destroy(lua_State *L) {
}
int engine_luaf_color_set(lua_State *L) {
char r = luaL_checkinteger(L,1);
char g = luaL_checkinteger(L,2);
char b = luaL_checkinteger(L,3);
char a = luaL_checkinteger(L,4);
unsigned char r = luaL_checkinteger(L,1);
unsigned char g = luaL_checkinteger(L,2);
unsigned char b = luaL_checkinteger(L,3);
unsigned char a = luaL_checkinteger(L,4);
engine_color_set(r,g,b,a);
return 0;
}

View File

@ -48,7 +48,7 @@ description = "Free a texture from memory."
# COLOR
[engine_color_set]
type = "void"
arguments = ["char","char","char","char"]
arguments = ["unsigned char","unsigned char","unsigned char","unsigned char"]
argNames = ["r", "g", "b", "a"]
description = "Set the color that points (pixels) should be drawn in."