diff options
| -rw-r--r-- | API.md | 6 | ||||
| -rw-r--r-- | ReiLua_API.lua | 6 | ||||
| -rw-r--r-- | changelog | 1 | ||||
| -rw-r--r-- | src/textures.c | 62 |
4 files changed, 11 insertions, 64 deletions
@@ -7611,17 +7611,15 @@ Unload render texture from GPU memory (VRAM) --- -> RL.UpdateTexture( Texture texture, int{} pixels ) +> RL.UpdateTexture( Texture texture, Buffer pixels ) Update GPU texture with new data -NOTE! Should be TEXTURE_TYPE_TEXTURE. Pixel should be in format { { 255, 255, 255, 255 }... } depending on the pixel format --- -> RL.UpdateTextureRec( Texture texture, Rectangle rec, int{} pixels ) +> RL.UpdateTextureRec( Texture texture, Rectangle rec, Buffer pixels ) Update GPU texture rectangle with new data. -Pixel should be in format { { 255, 255, 255, 255 }... } depending on the pixel format --- diff --git a/ReiLua_API.lua b/ReiLua_API.lua index 4621123..47e4903 100644 --- a/ReiLua_API.lua +++ b/ReiLua_API.lua @@ -4133,17 +4133,15 @@ function RL.IsRenderTextureValid( target ) end function RL.UnloadRenderTexture( target ) end ---Update GPU texture with new data ----NOTE! Should be TEXTURE_TYPE_TEXTURE. Pixel should be in format { { 255, 255, 255, 255 }... } depending on the pixel format ---@param texture any ----@param pixels table +---@param pixels any ---@return any RL.UpdateTexture function RL.UpdateTexture( texture, pixels ) end ---Update GPU texture rectangle with new data. ----Pixel should be in format { { 255, 255, 255, 255 }... } depending on the pixel format ---@param texture any ---@param rec table ----@param pixels table +---@param pixels any ---@return any RL.UpdateTextureRec function RL.UpdateTextureRec( texture, rec, pixels ) end @@ -36,6 +36,7 @@ DETAILED CHANGES: - FIXED: Bitwise functions now use 64 bit integers. - CHANGE: SetBufferData takes table of values. - ADDED: Texture atlas repeat example. + - CHANGE: UpdateTexture and UpdateTextureRec now take pixel data as Buffer. ------------------------------------------------------------------------ Release: ReiLua version 0.8.0 Using Raylib 5.0 and Forked Raygui 4.0 diff --git a/src/textures.c b/src/textures.c index e185470..89b6e8f 100644 --- a/src/textures.c +++ b/src/textures.c @@ -1480,80 +1480,30 @@ int ltextureUnloadRenderTexture( lua_State* L ) { } /* -> RL.UpdateTexture( Texture texture, int{} pixels ) +> RL.UpdateTexture( Texture texture, Buffer pixels ) Update GPU texture with new data -NOTE! Should be TEXTURE_TYPE_TEXTURE. Pixel should be in format { { 255, 255, 255, 255 }... } depending on the pixel format */ int ltexturesUpdateTexture( lua_State* L ) { Texture* texture = uluaGetTexture( L, 1 ); - size_t len = uluaGetTableLen( L, 2 ); + Buffer* pixels = uluaGetBuffer( L, 2 ); - unsigned char* pixels = malloc( len * 4 * sizeof( unsigned char ) ); - - int t = lua_gettop( L ); - unsigned int i = 0; - lua_pushnil( L ); - - while ( lua_next( L, t ) != 0 ) { - size_t colLen = uluaGetTableLen( L, lua_gettop( L ) ); - - int t2 = lua_gettop( L ); - unsigned int j = 0; - lua_pushnil( L ); - - while ( lua_next( L, t2 ) != 0 ) { - *( pixels + ( i * colLen ) + j ) = lua_tointeger( L, -1 ); - - j++; - lua_pop( L, 1 ); - } - i++; - lua_pop( L, 1 ); - } - UpdateTexture( *texture, pixels ); - free( pixels ); + UpdateTexture( *texture, pixels->data ); return 0; } /* -> RL.UpdateTextureRec( Texture texture, Rectangle rec, int{} pixels ) +> RL.UpdateTextureRec( Texture texture, Rectangle rec, Buffer pixels ) Update GPU texture rectangle with new data. -Pixel should be in format { { 255, 255, 255, 255 }... } depending on the pixel format */ int ltexturesUpdateTextureRec( lua_State* L ) { Texture* texture = uluaGetTexture( L, 1 ); Rectangle rec = uluaGetRectangle( L, 2 ); - size_t len = uluaGetTableLen( L, 3 ); - - unsigned char* pixels = malloc( len * 4 * sizeof( unsigned char ) ); - - int t = lua_gettop( L ); - unsigned int i = 0; - lua_pushnil( L ); - - while ( lua_next( L, t ) != 0 ) { - size_t colLen = uluaGetTableLen( L, lua_gettop( L ) ); - - int t2 = lua_gettop( L ); - unsigned int j = 0; - lua_pushnil( L ); - - while ( lua_next( L, t2 ) != 0 ) { - *( pixels + ( i * colLen ) + j ) = lua_tointeger( L, -1 ); - - j++; - lua_pop( L, 1 ); - } - i++; - lua_pop( L, 1 ); - } - lua_pop( L, 1 ); /* Pixels arg. */ + Buffer* pixels = uluaGetBuffer( L, 3 ); - UpdateTextureRec( *texture, rec, pixels ); - free( pixels ); + UpdateTextureRec( *texture, rec, pixels->data ); return 0; } |
