summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjussi2023-05-06 23:40:27 +0300
committerjussi2023-05-06 23:40:27 +0300
commit429a9dff96a5dbe1f526ae7cc6e41815eb862cf0 (patch)
treed8e081074498425f17c0fda3d8cb6d929403d1e3
parentcf92c94097e1e8ce61a6bc73671be4ee5e229571 (diff)
downloadreilua-enhanced-429a9dff96a5dbe1f526ae7cc6e41815eb862cf0.tar.gz
reilua-enhanced-429a9dff96a5dbe1f526ae7cc6e41815eb862cf0.tar.bz2
reilua-enhanced-429a9dff96a5dbe1f526ae7cc6e41815eb862cf0.zip
uluaGetBoundingBoxIndex, IsTextureReady.
-rw-r--r--API.md13
-rw-r--r--ReiLua_API.lua7
-rw-r--r--changelog2
-rw-r--r--doc_parser.lua4
-rw-r--r--examples/lightmap/main.lua9
-rw-r--r--include/textures.h1
-rw-r--r--src/lua_core.c3
-rw-r--r--src/textures.c31
8 files changed, 54 insertions, 16 deletions
diff --git a/API.md b/API.md
index c0dcadc..44d4775 100644
--- a/API.md
+++ b/API.md
@@ -1071,9 +1071,9 @@ Raycast hit information. NOTE: Data in named keys
---
-> BoundingBox = { { 0.0, 0.0, 0.0 }, { 1.0, 1.0, 1.0 } }
+> BoundingBox = { { 0.0, 0.0, 0.0 }, { 1.0, 1.0, 1.0 } } or { min = { 0.0, 0.0, 0.0 }, max = { 1.0, 1.0, 1.0 } }
-{ min, max }. Bounding box type for 3d mesh
+{ min, max }. Accepts Vector3. Bounding box type for 3d mesh
---
@@ -3560,6 +3560,15 @@ Unload texture from GPU memory ( VRAM )
---
+> isReady = RL.IsTextureReady( Texture2D texture )
+
+Check if a texture is ready
+
+- Failure return nil
+- Success return true
+
+---
+
> success = RL.UpdateTexture( Texture2D texture, int{} pixels )
Update GPU texture with new data
diff --git a/ReiLua_API.lua b/ReiLua_API.lua
index c8e187e..285a9b6 100644
--- a/ReiLua_API.lua
+++ b/ReiLua_API.lua
@@ -2639,6 +2639,13 @@ function RL.LoadRenderTexture( size ) end
---@return any success
function RL.UnloadTexture( texture ) end
+---Check if a texture is ready
+---- Failure return nil
+---- Success return true
+---@param texture any
+---@return any isReady
+function RL.IsTextureReady( texture ) 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
---- Failure return false
diff --git a/changelog b/changelog
index ef38434..44ca81e 100644
--- a/changelog
+++ b/changelog
@@ -65,6 +65,8 @@ Detailed changes:
- REMOVED: UnloadRenderTexture
- ADDED: GetTextureType
- FIXED: Vector3RotateByAxisAngle was not connected.
+ - FIXED: uluaGetBoundingBoxIndex was looking for numbers instead of tables.
+ - ADDED: IsTextureReady
------------------------------------------------------------------------
Release: ReiLua version 0.4.0 Using Raylib 4.2
diff --git a/doc_parser.lua b/doc_parser.lua
index 52e9fe7..cf7fb28 100644
--- a/doc_parser.lua
+++ b/doc_parser.lua
@@ -234,8 +234,8 @@ apiFile:write( "\n> Ray = { { 0.0, 0.0, 0.0 }, { 1.0, 0.0, 0.0 } } or { position
{ position, direction }. Ray type (useful for raycast)\n\n---\n" )
apiFile:write( "\n> RayCollision = { hit = true, distance = 1.0, point = { 0.0, 0.0, 0.0 }, normal = { 0.0, 0.0, 1.0 } }\n\
Raycast hit information. NOTE: Data in named keys\n\n---\n" )
-apiFile:write( "\n> BoundingBox = { { 0.0, 0.0, 0.0 }, { 1.0, 1.0, 1.0 } }\n\
-{ min, max }. Bounding box type for 3d mesh\n\n---\n" )
+apiFile:write( "\n> BoundingBox = { { 0.0, 0.0, 0.0 }, { 1.0, 1.0, 1.0 } } or { min = { 0.0, 0.0, 0.0 }, max = { 1.0, 1.0, 1.0 } }\n\
+{ min, max }. Accepts Vector3. Bounding box type for 3d mesh\n\n---\n" )
apiFile:write( "\n> Sound = SoundId\n\
int id. Basic Sound source and buffer\n\n---\n" )
apiFile:write( "\n> NPatchInfo = { { 0, 0, 24, 24 }, 8, 8, 8, 8, NPATCH_NINE_PATCH } or { source = { 0, 0, 24, 24 }, left = 8, top = 8, right = 8, bottom = 8, layout = NPATCH_NINE_PATCH }\n\
diff --git a/examples/lightmap/main.lua b/examples/lightmap/main.lua
index a6a5bde..9dc5609 100644
--- a/examples/lightmap/main.lua
+++ b/examples/lightmap/main.lua
@@ -23,12 +23,7 @@ function RL.init()
RL.SetWindowState( RL.FLAG_VSYNC_HINT )
RL.SetWindowPosition( { mPos[1] + mSize[1] / 2 - winSize[1] / 2, mPos[2] + mSize[2] / 2 - winSize[2] / 2 } )
- -- camera = RL.CreateCamera3D()
- -- RL.SetCamera3DPosition( camera, { 0, 8, 16 } )
- -- RL.SetCamera3DTarget( camera, { 0, 0, 0 } )
- -- RL.SetCamera3DUp( camera, { 0, 1, 0 } )
camera = Cam3D:new()
-
camera:setPosition( { 0, 8, 16 } )
camera:setTarget( { 0, 0, 0 } )
camera:setUp( { 0, 1, 0 } )
@@ -55,9 +50,7 @@ function RL.init()
RL.GenTextureMipmaps( tileTexture )
RL.SetTextureFilter( tileTexture, RL.TEXTURE_FILTER_TRILINEAR )
lightmap = RL.LoadTexture( RL.GetBasePath().."../resources/images/lightmap.png" )
- RL.GenTextureMipmaps( lightmap )
RL.SetTextureFilter( lightmap, RL.TEXTURE_FILTER_TRILINEAR )
- RL.SetTextureWrap( lightmap, RL.TEXTURE_WRAP_CLAMP )
shader = RL.LoadShader( RL.GetBasePath().."../resources/shaders/glsl330/lightmap.vs",
RL.GetBasePath().."../resources/shaders/glsl330/lightmap.fs" )
@@ -108,5 +101,5 @@ function RL.draw()
camera:beginMode3D()
RL.DrawMesh( mesh, material, matrix )
- camera:endMode3D()
+ camera:endMode3D()
end
diff --git a/include/textures.h b/include/textures.h
index 386e72d..61c5c7d 100644
--- a/include/textures.h
+++ b/include/textures.h
@@ -76,6 +76,7 @@ int ltexturesLoadTextureFromImage( lua_State *L );
int ltexturesLoadTextureCubemap( lua_State *L );
int ltexturesLoadRenderTexture( lua_State *L );
int ltexturesUnloadTexture( lua_State *L );
+int ltexturesIsTextureReady( lua_State *L );
int ltexturesUpdateTexture( lua_State *L );
int ltexturesUpdateTextureRec( lua_State *L );
/* Texture Drawing. */
diff --git a/src/lua_core.c b/src/lua_core.c
index bc2c7e3..a718de5 100644
--- a/src/lua_core.c
+++ b/src/lua_core.c
@@ -997,6 +997,7 @@ void luaRegister() {
assingGlobalFunction( "LoadTextureCubemap", ltexturesLoadTextureCubemap );
assingGlobalFunction( "LoadRenderTexture", ltexturesLoadRenderTexture );
assingGlobalFunction( "UnloadTexture", ltexturesUnloadTexture );
+ assingGlobalFunction( "IsTextureReady", ltexturesIsTextureReady );
assingGlobalFunction( "UpdateTexture", ltexturesUpdateTexture );
assingGlobalFunction( "UpdateTextureRec", ltexturesUpdateTextureRec );
/* Texture Drawing. */
@@ -1763,7 +1764,7 @@ BoundingBox uluaGetBoundingBoxIndex( lua_State *L, int index ) {
lua_pushnil( L );
while ( lua_next( L, t ) != 0 ) {
- if ( lua_isnumber( L, -1 ) ) {
+ if ( lua_istable( L, -1 ) ) {
if ( lua_isnumber( L, -2 ) ) {
switch ( i ) {
case 0:
diff --git a/src/textures.c b/src/textures.c
index 4def06e..291a7ad 100644
--- a/src/textures.c
+++ b/src/textures.c
@@ -1740,14 +1740,14 @@ int ltexturesUnloadTexture( lua_State *L ) {
lua_pushboolean( L, false );
return 1;
}
- size_t id = lua_tointeger( L, 1 );
+ size_t texId = lua_tointeger( L, 1 );
- if ( !validTexture( id, TEXTURE_TYPE_ALL ) ) {
+ if ( !validTexture( texId, TEXTURE_TYPE_ALL ) ) {
lua_pushboolean( L, false );
return 1;
}
// UnloadTexture( *state->textures[ id ] );
- texturesFreeTexture( id );
+ texturesFreeTexture( texId );
// state->textures[ id ] = NULL;
lua_pushboolean( L, true );
@@ -1755,6 +1755,31 @@ int ltexturesUnloadTexture( lua_State *L ) {
}
/*
+> isReady = RL.IsTextureReady( Texture2D texture )
+
+Check if a texture is ready
+
+- Failure return nil
+- Success return true
+*/
+int ltexturesIsTextureReady( lua_State *L ) {
+ if ( !lua_isnumber( L, 1 ) ) {
+ TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.IsTextureReady( Texture2D texture )" );
+ lua_pushnil( L );
+ return 1;
+ }
+ size_t texId = lua_tointeger( L, 1 );
+
+ if ( !validTexture( texId, TEXTURE_TYPE_TEXTURE ) ) {
+ lua_pushnil( L );
+ return 1;
+ }
+ lua_pushboolean( L, IsTextureReady( state->textures[ texId ]->texture) );
+
+ return 1;
+}
+
+/*
> success = RL.UpdateTexture( Texture2D texture, int{} pixels )
Update GPU texture with new data