Make engine_texture_color_get output into pointer
This commit is contained in:
parent
d24bd5c9f6
commit
aeeafde2b1
@ -57,15 +57,13 @@ void engine_texture_destroy(struct ENGINE_TEXTURE * engine_texture) {
|
|||||||
engine_memory_free(engine_texture);
|
engine_memory_free(engine_texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ENGINE_COLOR engine_texture_color_get(struct ENGINE_TEXTURE * engine_texture,int x,int y) {
|
void engine_texture_color_get(struct ENGINE_COLOR * color,struct ENGINE_TEXTURE * engine_texture,int x,int y) {
|
||||||
struct ENGINE_COLOR color;
|
|
||||||
Uint32 pixelIndex = (x + (y * engine_texture -> width)) * 4;
|
Uint32 pixelIndex = (x + (y * engine_texture -> width)) * 4;
|
||||||
unsigned char * pixels = engine_texture -> fe_texture -> pixels;
|
unsigned char * pixels = engine_texture -> fe_texture -> pixels;
|
||||||
color.r = pixels[pixelIndex];
|
color -> r = pixels[pixelIndex];
|
||||||
color.g = pixels[pixelIndex + 1];
|
color -> g = pixels[pixelIndex + 1];
|
||||||
color.b = pixels[pixelIndex + 2];
|
color -> b = pixels[pixelIndex + 2];
|
||||||
color.a = pixels[pixelIndex + 3];
|
color -> a = pixels[pixelIndex + 3];
|
||||||
return color;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ENGINE_TEXTURE * engine_rendertarget;
|
struct ENGINE_TEXTURE * engine_rendertarget;
|
||||||
|
@ -44,7 +44,7 @@ void engine_rendertarget_draw_texture(struct ENGINE_TEXTURE * texture,int x,int
|
|||||||
int tx = sx;
|
int tx = sx;
|
||||||
while (sy < ey) {
|
while (sy < ey) {
|
||||||
while (tx < ex) {
|
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_color_set(color.r,color.g,color.b,color.a);
|
||||||
engine_rendertarget_draw_point(x + tx,y + sy);
|
engine_rendertarget_draw_point(x + tx,y + sy);
|
||||||
++tx;
|
++tx;
|
||||||
|
@ -22,7 +22,8 @@ int engine_luaf_texture_color_get(lua_State *L) {
|
|||||||
struct ENGINE_TEXTURE * texture = lua_touserdata(L,1);
|
struct ENGINE_TEXTURE * texture = lua_touserdata(L,1);
|
||||||
int x = luaL_checkinteger(L,2);
|
int x = luaL_checkinteger(L,2);
|
||||||
int y = luaL_checkinteger(L,3);
|
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.r);
|
||||||
lua_pushinteger(L,color.g);
|
lua_pushinteger(L,color.g);
|
||||||
lua_pushinteger(L,color.b);
|
lua_pushinteger(L,color.b);
|
||||||
|
@ -33,10 +33,10 @@ argNames = ["width","height"]
|
|||||||
description = "Create a texture."
|
description = "Create a texture."
|
||||||
|
|
||||||
[engine_texture_color_get]
|
[engine_texture_color_get]
|
||||||
type = "struct ENGINE_COLOR"
|
type = "void"
|
||||||
arguments = ["struct ENGINE_TEXTURE *","int","int"]
|
arguments = ["struct ENGINE_COLOR *","struct ENGINE_TEXTURE *","int","int"]
|
||||||
argNames = ["texture", "x", "y"]
|
argNames = ["color", "texture", "x", "y"]
|
||||||
description = "Get color out of a texture."
|
description = "Get color out of a texture. ENGINE_COLOR pointer not required in lua."
|
||||||
lua = "manual"
|
lua = "manual"
|
||||||
|
|
||||||
[engine_texture_destroy]
|
[engine_texture_destroy]
|
||||||
|
Loading…
Reference in New Issue
Block a user