diff options
| author | jussi | 2023-10-29 18:36:23 +0200 |
|---|---|---|
| committer | jussi | 2023-10-29 18:36:23 +0200 |
| commit | fcd2d2d8b583f6a11a9ce32a75da8e18c8c88d32 (patch) | |
| tree | 026920ed99483731ba7ea07b8c211754a059485d /src | |
| parent | 0df40e2ac080364bcebd4fe0445b814230545477 (diff) | |
| download | reilua-enhanced-fcd2d2d8b583f6a11a9ce32a75da8e18c8c88d32.tar.gz reilua-enhanced-fcd2d2d8b583f6a11a9ce32a75da8e18c8c88d32.tar.bz2 reilua-enhanced-fcd2d2d8b583f6a11a9ce32a75da8e18c8c88d32.zip | |
LoadTextureFromData and LoadRenderTextureFromData. Documentation updates.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core.c | 2 | ||||
| -rw-r--r-- | src/lua_core.c | 2 | ||||
| -rw-r--r-- | src/textures.c | 73 |
3 files changed, 76 insertions, 1 deletions
@@ -544,7 +544,7 @@ int lcoreOpenURL( lua_State *L ) { /* > buffer = RL.LoadBuffer( data{} buffer, int type ) -Creates buffer as userdata. Type should be one of the Buffer types +Load Buffer. Type should be one of the Buffer types - Success return Buffer */ diff --git a/src/lua_core.c b/src/lua_core.c index 659cf56..6d54d27 100644 --- a/src/lua_core.c +++ b/src/lua_core.c @@ -1791,7 +1791,9 @@ void luaRegister() { assingGlobalFunction( "LoadTexture", ltexturesLoadTexture ); assingGlobalFunction( "LoadTextureFromImage", ltexturesLoadTextureFromImage ); assingGlobalFunction( "LoadTextureCubemap", ltexturesLoadTextureCubemap ); + assingGlobalFunction( "LoadTextureFromData", ltexturesLoadTextureFromData ); assingGlobalFunction( "LoadRenderTexture", ltexturesLoadRenderTexture ); + assingGlobalFunction( "LoadRenderTextureFromData", ltexturesLoadRenderTextureFromData ); assingGlobalFunction( "IsTextureReady", ltexturesIsTextureReady ); assingGlobalFunction( "UpdateTexture", ltexturesUpdateTexture ); assingGlobalFunction( "UpdateTextureRec", ltexturesUpdateTextureRec ); diff --git a/src/textures.c b/src/textures.c index aa78ce8..94c88aa 100644 --- a/src/textures.c +++ b/src/textures.c @@ -940,6 +940,44 @@ int ltexturesLoadTextureCubemap( lua_State *L ) { } /* +> texture = RL.LoadTextureFromData( Texture{} textureData ) + +Load Texture from data + +- Success return Texture +*/ +int ltexturesLoadTextureFromData( lua_State *L ) { + luaL_checktype( L, 1, LUA_TTABLE ); + + Texture2D texture = { 0 }; + + int t = 1; + lua_pushnil( L ); + + while ( lua_next( L, t ) != 0 ) { + if ( strcmp( "id", (char*)lua_tostring( L, -2 ) ) == 0 ) { + texture.id = (unsigned int)luaL_checkinteger( L, -1 ); + } + else if ( strcmp( "width", (char*)lua_tostring( L, -2 ) ) == 0 ) { + texture.width = luaL_checkinteger( L, -1 ); + } + else if ( strcmp( "height", (char*)lua_tostring( L, -2 ) ) == 0 ) { + texture.height = luaL_checkinteger( L, -1 ); + } + else if ( strcmp( "mipmaps", (char*)lua_tostring( L, -2 ) ) == 0 ) { + texture.mipmaps = luaL_checkinteger( L, -1 ); + } + else if ( strcmp( "format", (char*)lua_tostring( L, -2 ) ) == 0 ) { + texture.format = luaL_checkinteger( L, -1 ); + } + lua_pop( L, 1 ); + } + uluaPushTexture( L, texture ); + + return 1; +} + +/* > renderTexture = RL.LoadRenderTexture( Vector2 size ) Load texture for rendering (framebuffer) @@ -955,6 +993,41 @@ int ltexturesLoadRenderTexture( lua_State *L ) { } /* +> renderTexture = RL.LoadRenderTextureFromData( Texture{} renderTextureData ) + +Load RenderTexture from data (framebuffer) + +- Success return RenderTexture +*/ +int ltexturesLoadRenderTextureFromData( lua_State *L ) { + luaL_checktype( L, 1, LUA_TTABLE ); + + RenderTexture renTexture = { 0 }; + + int t = 1; + lua_pushnil( L ); + + while ( lua_next( L, t ) != 0 ) { + if ( strcmp( "id", (char*)lua_tostring( L, -2 ) ) == 0 ) { + renTexture.id = (unsigned int)luaL_checkinteger( L, -1 ); + } + else if ( strcmp( "texture", (char*)lua_tostring( L, -2 ) ) == 0 ) { + Texture *texture = luaL_checkudata( L, -1, "Texture" ); + renTexture.texture = *texture; + } + else if ( strcmp( "depth", (char*)lua_tostring( L, -2 ) ) == 0 ) { + Texture *depth = luaL_checkudata( L, -1, "Texture" ); + renTexture.depth = *depth; + } + lua_pop( L, 1 ); + } + uluaPushRenderTexture( L, renTexture ); + + return 1; +} + + +/* > isReady = RL.IsTextureReady( Texture texture ) Check if a texture is ready |
