diff --git a/src/frontend/sdl/main.c b/src/frontend/sdl/main.c index 0445d1f..e369243 100644 --- a/src/frontend/sdl/main.c +++ b/src/frontend/sdl/main.c @@ -57,15 +57,13 @@ void engine_texture_destroy(struct ENGINE_TEXTURE * engine_texture) { engine_memory_free(engine_texture); } -struct ENGINE_COLOR engine_texture_color_get(struct ENGINE_TEXTURE * engine_texture,int x,int y) { - struct ENGINE_COLOR color; +void engine_texture_color_get(struct ENGINE_COLOR * color,struct ENGINE_TEXTURE * engine_texture,int x,int y) { Uint32 pixelIndex = (x + (y * engine_texture -> width)) * 4; unsigned char * pixels = engine_texture -> fe_texture -> pixels; - color.r = pixels[pixelIndex]; - color.g = pixels[pixelIndex + 1]; - color.b = pixels[pixelIndex + 2]; - color.a = pixels[pixelIndex + 3]; - return color; + color -> r = pixels[pixelIndex]; + color -> g = pixels[pixelIndex + 1]; + color -> b = pixels[pixelIndex + 2]; + color -> a = pixels[pixelIndex + 3]; } struct ENGINE_TEXTURE * engine_rendertarget; diff --git a/src/helpers.c b/src/helpers.c index 3ed87d5..411b199 100644 --- a/src/helpers.c +++ b/src/helpers.c @@ -44,7 +44,7 @@ void engine_rendertarget_draw_texture(struct ENGINE_TEXTURE * texture,int x,int int tx = sx; while (sy < ey) { while (tx < ex) { - color = engine_texture_color_get(texture,tx,sy); + engine_texture_color_get(&color,texture,tx,sy); engine_color_set(color.r,color.g,color.b,color.a); engine_rendertarget_draw_point(x + tx,y + sy); ++tx; diff --git a/src/lua_manual.c b/src/lua_manual.c index 35e1a87..c9d70c4 100644 --- a/src/lua_manual.c +++ b/src/lua_manual.c @@ -22,7 +22,8 @@ int engine_luaf_texture_color_get(lua_State *L) { struct ENGINE_TEXTURE * texture = lua_touserdata(L,1); int x = luaL_checkinteger(L,2); int y = luaL_checkinteger(L,3); - struct ENGINE_COLOR color = engine_texture_color_get(texture,x,y); + struct ENGINE_COLOR color; + engine_texture_color_get(&color,texture,x,y); lua_pushinteger(L,color.r); lua_pushinteger(L,color.g); lua_pushinteger(L,color.b); diff --git a/src/values/functions.toml b/src/values/functions.toml index fefbfbd..e27cb0b 100644 --- a/src/values/functions.toml +++ b/src/values/functions.toml @@ -33,10 +33,10 @@ argNames = ["width","height"] description = "Create a texture." [engine_texture_color_get] -type = "struct ENGINE_COLOR" -arguments = ["struct ENGINE_TEXTURE *","int","int"] -argNames = ["texture", "x", "y"] -description = "Get color out of a texture." +type = "void" +arguments = ["struct ENGINE_COLOR *","struct ENGINE_TEXTURE *","int","int"] +argNames = ["color", "texture", "x", "y"] +description = "Get color out of a texture. ENGINE_COLOR pointer not required in lua." lua = "manual" [engine_texture_destroy]