uluaGetBoundingBoxIndex, IsTextureReady.

This commit is contained in:
jussi
2023-05-06 23:40:27 +03:00
parent cf92c94097
commit 429a9dff96
8 changed files with 54 additions and 16 deletions

13
API.md
View File

@@ -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 ) > success = RL.UpdateTexture( Texture2D texture, int{} pixels )
Update GPU texture with new data Update GPU texture with new data

View File

@@ -2639,6 +2639,13 @@ function RL.LoadRenderTexture( size ) end
---@return any success ---@return any success
function RL.UnloadTexture( texture ) end 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 ---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 ---NOTE! Should be TEXTURE_TYPE_TEXTURE. Pixel should be in format { { 255, 255, 255, 255 }... } depending on the pixel format
---- Failure return false ---- Failure return false

View File

@@ -65,6 +65,8 @@ Detailed changes:
- REMOVED: UnloadRenderTexture - REMOVED: UnloadRenderTexture
- ADDED: GetTextureType - ADDED: GetTextureType
- FIXED: Vector3RotateByAxisAngle was not connected. - 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 Release: ReiLua version 0.4.0 Using Raylib 4.2

View File

@@ -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" ) { 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\ 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" ) 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\ 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 }. Bounding box type for 3d mesh\n\n---\n" ) { min, max }. Accepts Vector3. Bounding box type for 3d mesh\n\n---\n" )
apiFile:write( "\n> Sound = SoundId\n\ apiFile:write( "\n> Sound = SoundId\n\
int id. Basic Sound source and buffer\n\n---\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\ 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\

View File

@@ -23,12 +23,7 @@ function RL.init()
RL.SetWindowState( RL.FLAG_VSYNC_HINT ) RL.SetWindowState( RL.FLAG_VSYNC_HINT )
RL.SetWindowPosition( { mPos[1] + mSize[1] / 2 - winSize[1] / 2, mPos[2] + mSize[2] / 2 - winSize[2] / 2 } ) 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 = Cam3D:new()
camera:setPosition( { 0, 8, 16 } ) camera:setPosition( { 0, 8, 16 } )
camera:setTarget( { 0, 0, 0 } ) camera:setTarget( { 0, 0, 0 } )
camera:setUp( { 0, 1, 0 } ) camera:setUp( { 0, 1, 0 } )
@@ -55,9 +50,7 @@ function RL.init()
RL.GenTextureMipmaps( tileTexture ) RL.GenTextureMipmaps( tileTexture )
RL.SetTextureFilter( tileTexture, RL.TEXTURE_FILTER_TRILINEAR ) RL.SetTextureFilter( tileTexture, RL.TEXTURE_FILTER_TRILINEAR )
lightmap = RL.LoadTexture( RL.GetBasePath().."../resources/images/lightmap.png" ) lightmap = RL.LoadTexture( RL.GetBasePath().."../resources/images/lightmap.png" )
RL.GenTextureMipmaps( lightmap )
RL.SetTextureFilter( lightmap, RL.TEXTURE_FILTER_TRILINEAR ) RL.SetTextureFilter( lightmap, RL.TEXTURE_FILTER_TRILINEAR )
RL.SetTextureWrap( lightmap, RL.TEXTURE_WRAP_CLAMP )
shader = RL.LoadShader( RL.GetBasePath().."../resources/shaders/glsl330/lightmap.vs", shader = RL.LoadShader( RL.GetBasePath().."../resources/shaders/glsl330/lightmap.vs",
RL.GetBasePath().."../resources/shaders/glsl330/lightmap.fs" ) RL.GetBasePath().."../resources/shaders/glsl330/lightmap.fs" )
@@ -108,5 +101,5 @@ function RL.draw()
camera:beginMode3D() camera:beginMode3D()
RL.DrawMesh( mesh, material, matrix ) RL.DrawMesh( mesh, material, matrix )
camera:endMode3D() camera:endMode3D()
end end

View File

@@ -76,6 +76,7 @@ int ltexturesLoadTextureFromImage( lua_State *L );
int ltexturesLoadTextureCubemap( lua_State *L ); int ltexturesLoadTextureCubemap( lua_State *L );
int ltexturesLoadRenderTexture( lua_State *L ); int ltexturesLoadRenderTexture( lua_State *L );
int ltexturesUnloadTexture( lua_State *L ); int ltexturesUnloadTexture( lua_State *L );
int ltexturesIsTextureReady( lua_State *L );
int ltexturesUpdateTexture( lua_State *L ); int ltexturesUpdateTexture( lua_State *L );
int ltexturesUpdateTextureRec( lua_State *L ); int ltexturesUpdateTextureRec( lua_State *L );
/* Texture Drawing. */ /* Texture Drawing. */

View File

@@ -997,6 +997,7 @@ void luaRegister() {
assingGlobalFunction( "LoadTextureCubemap", ltexturesLoadTextureCubemap ); assingGlobalFunction( "LoadTextureCubemap", ltexturesLoadTextureCubemap );
assingGlobalFunction( "LoadRenderTexture", ltexturesLoadRenderTexture ); assingGlobalFunction( "LoadRenderTexture", ltexturesLoadRenderTexture );
assingGlobalFunction( "UnloadTexture", ltexturesUnloadTexture ); assingGlobalFunction( "UnloadTexture", ltexturesUnloadTexture );
assingGlobalFunction( "IsTextureReady", ltexturesIsTextureReady );
assingGlobalFunction( "UpdateTexture", ltexturesUpdateTexture ); assingGlobalFunction( "UpdateTexture", ltexturesUpdateTexture );
assingGlobalFunction( "UpdateTextureRec", ltexturesUpdateTextureRec ); assingGlobalFunction( "UpdateTextureRec", ltexturesUpdateTextureRec );
/* Texture Drawing. */ /* Texture Drawing. */
@@ -1763,7 +1764,7 @@ BoundingBox uluaGetBoundingBoxIndex( lua_State *L, int index ) {
lua_pushnil( L ); lua_pushnil( L );
while ( lua_next( L, t ) != 0 ) { while ( lua_next( L, t ) != 0 ) {
if ( lua_isnumber( L, -1 ) ) { if ( lua_istable( L, -1 ) ) {
if ( lua_isnumber( L, -2 ) ) { if ( lua_isnumber( L, -2 ) ) {
switch ( i ) { switch ( i ) {
case 0: case 0:

View File

@@ -1740,20 +1740,45 @@ int ltexturesUnloadTexture( lua_State *L ) {
lua_pushboolean( L, false ); lua_pushboolean( L, false );
return 1; 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 ); lua_pushboolean( L, false );
return 1; return 1;
} }
// UnloadTexture( *state->textures[ id ] ); // UnloadTexture( *state->textures[ id ] );
texturesFreeTexture( id ); texturesFreeTexture( texId );
// state->textures[ id ] = NULL; // state->textures[ id ] = NULL;
lua_pushboolean( L, true ); lua_pushboolean( L, true );
return 1; return 1;
} }
/*
> 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 ) > success = RL.UpdateTexture( Texture2D texture, int{} pixels )