diff options
| author | jussi | 2024-11-21 00:11:31 +0200 |
|---|---|---|
| committer | jussi | 2024-11-21 00:11:31 +0200 |
| commit | 4c0eb17a9c234bfee73af408faa38e38f2e450d9 (patch) | |
| tree | 4aea4fe804a63ed13a1d092aada0ba5925dcf05f /src | |
| parent | 479726a5e468a2f4d0f9337f082889082e535bfb (diff) | |
| download | reilua-enhanced-4c0eb17a9c234bfee73af408faa38e38f2e450d9.tar.gz reilua-enhanced-4c0eb17a9c234bfee73af408faa38e38f2e450d9.tar.bz2 reilua-enhanced-4c0eb17a9c234bfee73af408faa38e38f2e450d9.zip | |
New raylib 5.5 functions.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core.c | 184 | ||||
| -rw-r--r-- | src/lua_core.c | 44 | ||||
| -rw-r--r-- | src/models.c | 64 | ||||
| -rw-r--r-- | src/platforms/core_desktop_glfw.c (renamed from src/platforms/core_desktop.c) | 0 | ||||
| -rw-r--r-- | src/shapes.c | 57 | ||||
| -rw-r--r-- | src/state.c | 1 | ||||
| -rw-r--r-- | src/text.c | 30 | ||||
| -rw-r--r-- | src/textures.c | 199 |
8 files changed, 538 insertions, 41 deletions
@@ -560,6 +560,19 @@ int lcoreGetClipboardText( lua_State* L ) { } /* +> image = RL.GetClipboardImage() + +Get clipboard image content + +- Success return Image +*/ +int lcoreGetClipboardImage( lua_State* L ) { + uluaPushImage( L, GetClipboardImage() ); + + return 1; +} + +/* > RL.EnableEventWaiting() Enable waiting for events on EndDrawing(), no automatic event polling @@ -1783,6 +1796,60 @@ int lcoreGetApplicationDirectory( lua_State* L ) { } /* +> success = RL.MakeDirectory( string dirPath ) + +Create directories (including full path requested), returns 0 on success + +- Success return int +*/ +int lcoreMakeDirectory( lua_State* L ) { + const char *dirPath = luaL_checkstring( L, 1 ); + + lua_pushinteger( L, MakeDirectory( dirPath ) ); + + return 1; +} + +/* +> success = RL.ChangeDirectory( string directory ) + +Change working directory, return true on success + +- Success return bool +*/ +int lcoreChangeDirectory( lua_State* L ) { + lua_pushboolean( L, ChangeDirectory( luaL_checkstring( L, 1 ) ) ); + + return 1; +} + +/* +> isFile = RL.IsPathFile( string path ) + +Check if a given path is a file or a directory + +- Success return bool +*/ +int lcoreIsPathFile( lua_State* L ) { + lua_pushboolean( L, IsPathFile( luaL_checkstring( L, 1 ) ) ); + + return 1; +} + +/* +> isValid = RL.IsFileNameValid( string fileName ) + +Check if fileName is valid for the platform/OS + +- Success return bool +*/ +int lcoreIsFileNameValid( lua_State* L ) { + lua_pushboolean( L, IsFileNameValid( luaL_checkstring( L, 1 ) ) ); + + return 1; +} + +/* > fileNames = RL.LoadDirectoryFiles( string dirPath ) Load directory filepaths @@ -1832,32 +1899,6 @@ int lcoreLoadDirectoryFilesEx( lua_State* L ) { } /* -> success = RL.ChangeDirectory( string directory ) - -Change working directory, return true on success - -- Success return bool -*/ -int lcoreChangeDirectory( lua_State* L ) { - lua_pushboolean( L, ChangeDirectory( luaL_checkstring( L, 1 ) ) ); - - return 1; -} - -/* -> isFile = RL.IsPathFile( string path ) - -Check if a given path is a file or a directory - -- Success return bool -*/ -int lcoreIsPathFile( lua_State* L ) { - lua_pushboolean( L, IsPathFile( luaL_checkstring( L, 1 ) ) ); - - return 1; -} - -/* > iSFileDropped = RL.IsFileDropped() Check if a file has been dropped into window @@ -1998,6 +2039,81 @@ int lcoreDecodeDataBase64( lua_State* L ) { } /* +> code = RL.ComputeCRC32( Buffer data ) + +Compute CRC32 hash code. Note! Buffer should be type BUFFER_UNSIGNED_CHAR + +- Failure return false +- Success return int +*/ +int lcoreComputeCRC32( lua_State* L ) { + Buffer* buffer = uluaGetBuffer( L, 1 ); + + if ( buffer->type == BUFFER_UNSIGNED_CHAR ) { + lua_pushinteger( L, ComputeCRC32( buffer->data, buffer->size ) ); + } + else { + lua_pushboolean( L, false ); + } + + return 1; +} + +/* +> code = RL.ComputeMD5( Buffer data ) + +Compute MD5 hash code, returns static int[4] (16 bytes). Note! Buffer should be type BUFFER_UNSIGNED_CHAR + +- Failure return false +- Success return int{4} +*/ +int lcoreComputeMD5( lua_State* L ) { + Buffer* buffer = uluaGetBuffer( L, 1 ); + + if ( buffer->type == BUFFER_UNSIGNED_CHAR ) { + unsigned int* code = ComputeMD5( buffer->data, buffer->size ); + lua_createtable( L, 4, 0 ); + + for ( unsigned int i = 0; i < 4; i++ ) { + lua_pushinteger( L, code[i] ); + lua_rawseti( L, -2, i + 1 ); + } + } + else { + lua_pushboolean( L, false ); + } + + return 1; +} + +/* +> code = RL.ComputeSHA1( Buffer data ) + +Compute SHA1 hash code, returns static int[5] (20 bytes). Note! Buffer should be type BUFFER_UNSIGNED_CHAR + +- Failure return false +- Success return int{5} +*/ +int lcoreComputeSHA1( lua_State* L ) { + Buffer* buffer = uluaGetBuffer( L, 1 ); + + if ( buffer->type == BUFFER_UNSIGNED_CHAR ) { + unsigned int* code = ComputeSHA1( buffer->data, buffer->size ); + lua_createtable( L, 5, 0 ); + + for ( unsigned int i = 0; i < 5; i++ ) { + lua_pushinteger( L, code[i] ); + lua_rawseti( L, -2, i + 1 ); + } + } + else { + lua_pushboolean( L, false ); + } + + return 1; +} + +/* ## Core - Automation events functionality */ @@ -2491,6 +2607,22 @@ int lcoreSetGamepadMappings( lua_State* L ) { } /* +> RL.SetGamepadVibration( int gamepad, float leftMotor, float rightMotor, float duration ) + +Set gamepad vibration for both motors (duration in seconds) +*/ +int lcoreSetGamepadVibration( lua_State* L ) { + int gamepad = luaL_checkinteger( L, 1 ); + float leftMotor = luaL_checknumber( L, 2 ); + float rightMotor = luaL_checknumber( L, 2 ); + float duration = luaL_checknumber( L, 2 ); + + SetGamepadVibration( gamepad, leftMotor, rightMotor, duration ); + + return 0; +} + +/* ## Core - Input-related functions: mouse */ diff --git a/src/lua_core.c b/src/lua_core.c index b7a2197..8a6a8f9 100644 --- a/src/lua_core.c +++ b/src/lua_core.c @@ -16,7 +16,7 @@ #include "bitwiseOp.h" #ifdef PLATFORM_DESKTOP - #include "platforms/core_desktop.c" + #include "platforms/core_desktop_glfw.c" #elif PLATFORM_DESKTOP_SDL #include "platforms/core_desktop_sdl.c" #elif PLATFORM_WEB @@ -1310,6 +1310,7 @@ void luaRegister() { assingGlobalFunction( "GetMonitorName", lcoreGetMonitorName ); assingGlobalFunction( "SetClipboardText", lcoreSetClipboardText ); assingGlobalFunction( "GetClipboardText", lcoreGetClipboardText ); + assingGlobalFunction( "GetClipboardImage", lcoreGetClipboardImage ); assingGlobalFunction( "EnableEventWaiting", lcoreEnableEventWaiting ); assingGlobalFunction( "DisableEventWaiting", lcoreDisableEventWaiting ); /* Cursor-related functions. */ @@ -1401,10 +1402,12 @@ void luaRegister() { assingGlobalFunction( "GetPrevDirectoryPath", lcoreGetPrevDirectoryPath ); assingGlobalFunction( "GetWorkingDirectory", lcoreGetWorkingDirectory ); assingGlobalFunction( "GetApplicationDirectory", lcoreGetApplicationDirectory ); - assingGlobalFunction( "LoadDirectoryFiles", lcoreLoadDirectoryFiles ); - assingGlobalFunction( "LoadDirectoryFilesEx", lcoreLoadDirectoryFilesEx ); + assingGlobalFunction( "MakeDirectory", lcoreMakeDirectory ); assingGlobalFunction( "ChangeDirectory", lcoreChangeDirectory ); assingGlobalFunction( "IsPathFile", lcoreIsPathFile ); + assingGlobalFunction( "IsFileNameValid", lcoreIsFileNameValid ); + assingGlobalFunction( "LoadDirectoryFiles", lcoreLoadDirectoryFiles ); + assingGlobalFunction( "LoadDirectoryFilesEx", lcoreLoadDirectoryFilesEx ); assingGlobalFunction( "IsFileDropped", lcoreIsFileDropped ); assingGlobalFunction( "LoadDroppedFiles", lcoreLoadDroppedFiles ); assingGlobalFunction( "GetFileModTime", lcoreGetFileModTime ); @@ -1413,6 +1416,9 @@ void luaRegister() { assingGlobalFunction( "DecompressData", lcoreDecompressData ); assingGlobalFunction( "EncodeDataBase64", lcoreEncodeDataBase64 ); assingGlobalFunction( "DecodeDataBase64", lcoreDecodeDataBase64 ); + assingGlobalFunction( "ComputeCRC32", lcoreComputeCRC32 ); + assingGlobalFunction( "ComputeMD5", lcoreComputeMD5 ); + assingGlobalFunction( "ComputeSHA1", lcoreComputeSHA1 ); /* Automation events functionality. */ assingGlobalFunction( "LoadAutomationEventList", lcoreLoadAutomationEventList ); assingGlobalFunction( "UnloadAutomationEventList", lcoreUnloadAutomationEventList ); @@ -1448,6 +1454,7 @@ void luaRegister() { assingGlobalFunction( "GetGamepadAxisCount", lcoreGetGamepadAxisCount ); assingGlobalFunction( "GetGamepadAxisMovement", lcoreGetGamepadAxisMovement ); assingGlobalFunction( "SetGamepadMappings", lcoreSetGamepadMappings ); + assingGlobalFunction( "SetGamepadVibration", lcoreSetGamepadVibration ); /* Input-related functions: mouse. */ assingGlobalFunction( "IsMouseButtonPressed", lcoreIsMouseButtonPressed ); assingGlobalFunction( "IsMouseButtonDown", lcoreIsMouseButtonDown ); @@ -1531,6 +1538,8 @@ void luaRegister() { /* Shapes. */ /* Basic shapes drawing functions. */ assingGlobalFunction( "SetShapesTexture", lshapesSetShapesTexture ); + assingGlobalFunction( "GetShapesTexture", lshapesGetShapesTexture ); + assingGlobalFunction( "GetShapesTextureRectangle", lshapesGetShapesTextureRectangle ); assingGlobalFunction( "DrawPixel", lshapesDrawPixel ); assingGlobalFunction( "DrawLine", lshapesDrawLine ); assingGlobalFunction( "DrawLineBezier", lshapesDrawLineBezier ); @@ -1582,6 +1591,7 @@ void luaRegister() { assingGlobalFunction( "CheckCollisionRecs", lshapesCheckCollisionRecs ); assingGlobalFunction( "CheckCollisionCircles", lshapesCheckCollisionCircles ); assingGlobalFunction( "CheckCollisionCircleRec", lshapesCheckCollisionCircleRec ); + assingGlobalFunction( "CheckCollisionCircleLine", lshapesCheckCollisionCircleLine ); assingGlobalFunction( "CheckCollisionPointRec", lshapesCheckCollisionPointRec ); assingGlobalFunction( "CheckCollisionPointCircle", lshapesCheckCollisionPointCircle ); assingGlobalFunction( "CheckCollisionPointTriangle", lshapesCheckCollisionPointTriangle ); @@ -1595,6 +1605,7 @@ void luaRegister() { assingGlobalFunction( "LoadImage", ltexturesLoadImage ); assingGlobalFunction( "LoadImageRaw", ltexturesLoadImageRaw ); assingGlobalFunction( "LoadImageAnim", ltexturesLoadImageAnim ); + assingGlobalFunction( "LoadImageAnimFromMemory", ltexturesLoadImageAnimFromMemory ); assingGlobalFunction( "LoadImageFromMemory", ltexturesLoadImageFromMemory ); assingGlobalFunction( "LoadImageFromData", ltexturesLoadImageFromData ); assingGlobalFunction( "LoadImageFromTexture", ltexturesLoadImageFromTexture ); @@ -1617,6 +1628,7 @@ void luaRegister() { /* Image manipulation functions. */ assingGlobalFunction( "ImageCopy", ltexturesImageCopy ); assingGlobalFunction( "ImageFromImage", ltexturesImageFromImage ); + assingGlobalFunction( "ImageFromChannel", ltexturesImageFromChannel ); assingGlobalFunction( "ImageText", ltexturesImageText ); assingGlobalFunction( "ImageTextEx", ltexturesImageTextEx ); assingGlobalFunction( "ImageFormat", ltexturesImageFormat ); @@ -1627,6 +1639,7 @@ void luaRegister() { assingGlobalFunction( "ImageAlphaMask", ltexturesImageAlphaMask ); assingGlobalFunction( "ImageAlphaPremultiply", ltexturesImageAlphaPremultiply ); assingGlobalFunction( "ImageBlurGaussian", ltexturesImageBlurGaussian ); + assingGlobalFunction( "ImageKernelConvolution", ltexturesImageKernelConvolution ); assingGlobalFunction( "ImageResize", ltexturesImageResize ); assingGlobalFunction( "ImageResizeNN", ltexturesImageResizeNN ); assingGlobalFunction( "ImageResizeCanvas", ltexturesImageResizeCanvas ); @@ -1656,10 +1669,16 @@ void luaRegister() { assingGlobalFunction( "ImageClearBackground", ltexturesImageClearBackground ); assingGlobalFunction( "ImageDrawPixel", ltexturesImageDrawPixel ); assingGlobalFunction( "ImageDrawLine", ltexturesImageDrawLine ); + assingGlobalFunction( "ImageDrawLineEx", ltexturesImageDrawLineEx ); assingGlobalFunction( "ImageDrawCircle", ltexturesImageDrawCircle ); assingGlobalFunction( "ImageDrawCircleLines", ltexturesImageDrawCircleLines ); assingGlobalFunction( "ImageDrawRectangle", ltexturesImageDrawRectangle ); assingGlobalFunction( "ImageDrawRectangleLines", ltexturesImageDrawRectangleLines ); + assingGlobalFunction( "ImageDrawTriangle", ltexturesImageDrawTriangle ); + assingGlobalFunction( "ImageDrawTriangleEx", ltexturesImageDrawTriangleEx ); + assingGlobalFunction( "ImageDrawTriangleLines", ltexturesImageDrawTriangleLines ); + assingGlobalFunction( "ImageDrawTriangleFan", ltexturesImageDrawTriangleFan ); + assingGlobalFunction( "ImageDrawTriangleStrip", ltexturesImageDrawTriangleStrip ); assingGlobalFunction( "ImageDraw", ltexturesImageDraw ); assingGlobalFunction( "ImageDrawText", ltexturesImageDrawText ); assingGlobalFunction( "ImageDrawTextEx", ltexturesImageDrawTextEx ); @@ -1697,6 +1716,7 @@ void luaRegister() { assingGlobalFunction( "GetRenderTextureTexture", ltexturesGetRenderTextureTexture ); assingGlobalFunction( "GetRenderTextureDepthTexture", ltexturesGetRenderTextureDepthTexture ); /* Color/pixel related functions */ + assingGlobalFunction( "ColorIsEqual", ltexturesColorIsEqual ); assingGlobalFunction( "Fade", ltexturesFade ); assingGlobalFunction( "ColorToInt", ltexturesColorToInt ); assingGlobalFunction( "ColorNormalize", ltexturesColorNormalize ); @@ -1708,6 +1728,7 @@ void luaRegister() { assingGlobalFunction( "ColorContrast", ltexturesColorContrast ); assingGlobalFunction( "ColorAlpha", ltexturesColorAlpha ); assingGlobalFunction( "ColorAlphaBlend", ltexturesColorAlphaBlend ); + assingGlobalFunction( "ColorLerp", ltexturesColorLerp ); assingGlobalFunction( "GetColor", ltexturesGetColor ); assingGlobalFunction( "GetPixelDataSize", ltexturesGetPixelDataSize ); @@ -1759,6 +1780,8 @@ void luaRegister() { assingGlobalFunction( "DrawModelEx", lmodelsDrawModelEx ); assingGlobalFunction( "DrawModelWires", lmodelsDrawModelWires ); assingGlobalFunction( "DrawModelWiresEx", lmodelsDrawModelWiresEx ); + assingGlobalFunction( "DrawModelPoints", lmodelsDrawModelPoints ); + assingGlobalFunction( "DrawModelPointsEx", lmodelsDrawModelPointsEx ); assingGlobalFunction( "DrawBoundingBox", lmodelsDrawBoundingBox ); assingGlobalFunction( "DrawBillboard", lmodelsDrawBillboard ); assingGlobalFunction( "DrawBillboardRec", lmodelsDrawBillboardRec ); @@ -1770,6 +1793,7 @@ void luaRegister() { assingGlobalFunction( "DrawMeshInstanced", lmodelsDrawMeshInstanced ); assingGlobalFunction( "SetMeshColor", lmodelsSetMeshColor ); assingGlobalFunction( "ExportMesh", lmodelsExportMesh ); + assingGlobalFunction( "ExportMeshAsCode", lmodelsExportMeshAsCode ); assingGlobalFunction( "GetMeshBoundingBox", lmodelsGetMeshBoundingBox ); assingGlobalFunction( "GenMeshTangents", lmodelsGenMeshTangents ); assingGlobalFunction( "GetMeshData", lmodelsGetMeshData ); @@ -1806,6 +1830,7 @@ void luaRegister() { /* Model animations management functions. */ assingGlobalFunction( "LoadModelAnimations", lmodelsLoadModelAnimations ); assingGlobalFunction( "UpdateModelAnimation", lmodelsUpdateModelAnimation ); + assingGlobalFunction( "UpdateModelAnimationBones", lmodelsUpdateModelAnimationBones ); assingGlobalFunction( "UnloadModelAnimation", lmodelsUnloadModelAnimation ); assingGlobalFunction( "UnloadModelAnimations", lmodelsUnloadModelAnimations ); assingGlobalFunction( "IsModelAnimationValid", lmodelsIsModelAnimationValid ); @@ -1891,6 +1916,8 @@ void luaRegister() { assingGlobalFunction( "TextSplit", ltextTextSplit ); assingGlobalFunction( "TextFindIndex", ltextTextFindIndex ); assingGlobalFunction( "TextToPascal", ltextTextToPascal ); + assingGlobalFunction( "TextToSnake", ltextTextToSnake ); + assingGlobalFunction( "TextToCamel", ltextTextToCamel ); /* Audio. */ /* Audio device management functions. */ @@ -3423,6 +3450,17 @@ AutomationEventList* uluaGetAutomationEventList( lua_State* L, int index ) { } } +void getVector2Array( lua_State* L, int index, Vector2 points[] ) { + int t = index, i = 0; + lua_pushnil( L ); + + while ( lua_next( L, t ) != 0 ) { + points[i] = uluaGetVector2( L, lua_gettop( L ) ); + i++; + lua_pop( L, 1 ); + } +} + /* Push types. */ void uluaPushColor( lua_State* L, Color color ) { diff --git a/src/models.c b/src/models.c index 1271713..0caae47 100644 --- a/src/models.c +++ b/src/models.c @@ -983,6 +983,40 @@ int lmodelsDrawModelWiresEx( lua_State* L ) { } /* +> RL.DrawModelPoints( Model model, Vector3 position, float scale, Color tint ) + +Draw a model as points +*/ +int lmodelsDrawModelPoints( lua_State* L ) { + Model* model = uluaGetModel( L, 1 ); + Vector3 position = uluaGetVector3( L, 2 ); + float scale = luaL_checknumber( L, 3 ); + Color tint = uluaGetColor( L, 4 ); + + DrawModelPoints( *model, position, scale, tint ); + + return 0; +} + +/* +> RL.DrawModelPointsEx( Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint ) + +Draw a model as points with extended parameters +*/ +int lmodelsDrawModelPointsEx( lua_State* L ) { + Model* model = uluaGetModel( L, 1 ); + Vector3 position = uluaGetVector3( L, 2 ); + Vector3 rotationAxis = uluaGetVector3( L, 3 ); + float rotationAngle = luaL_checknumber( L, 4 ); + Vector3 scale = uluaGetVector3( L, 5 ); + Color tint = uluaGetColor( L, 6 ); + + DrawModelPointsEx( *model, position, rotationAxis, rotationAngle, scale, tint ); + + return 0; +} + +/* > RL.DrawBoundingBox( BoundingBox box, Color color ) Draw bounding box (wires) @@ -1287,6 +1321,21 @@ int lmodelsExportMesh( lua_State* L ) { } /* +> success = RL.ExportMeshAsCode( Mesh mesh, string fileName ) + +Export mesh as code file (.h) defining multiple arrays of vertex attributes + +- Success return bool +*/ +int lmodelsExportMeshAsCode( lua_State* L ) { + Mesh* mesh = uluaGetMesh( L, 1 ); + + lua_pushboolean( L, ExportMeshAsCode( *mesh, luaL_checkstring( L, 2 ) ) ); + + return 1; +} + +/* > boundingBox = RL.GetMeshBoundingBox( Mesh mesh ) Compute mesh bounding box limits @@ -2191,6 +2240,21 @@ int lmodelsUpdateModelAnimation( lua_State* L ) { } /* +> RL.UpdateModelAnimationBones( Model model, ModelAnimation animation, int frame ) + +Update model animation mesh bone matrices (GPU skinning) +*/ +int lmodelsUpdateModelAnimationBones( lua_State* L ) { + Model* model = uluaGetModel( L, 1 ); + ModelAnimation* animation = uluaGetModelAnimation( L, 2 ); + int frame = luaL_checkinteger( L, 3 ); + + UpdateModelAnimationBones( *model, *animation, frame ); + + return 0; +} + +/* > RL.UnloadModelAnimation( ModelAnimation animation ) Unload animation data diff --git a/src/platforms/core_desktop.c b/src/platforms/core_desktop_glfw.c index 8d9f01c..8d9f01c 100644 --- a/src/platforms/core_desktop.c +++ b/src/platforms/core_desktop_glfw.c diff --git a/src/shapes.c b/src/shapes.c index 2efa78a..07f40c3 100644 --- a/src/shapes.c +++ b/src/shapes.c @@ -4,17 +4,6 @@ #include "lua_core.h" #include "textures.h" -static inline void getVector2Array( lua_State* L, int index, Vector2 points[] ) { - int t = index, i = 0; - lua_pushnil( L ); - - while ( lua_next( L, t ) != 0 ) { - points[i] = uluaGetVector2( L, lua_gettop( L ) ); - i++; - lua_pop( L, 1 ); - } -} - /* ## Shapes - Basic shapes drawing functions */ @@ -30,12 +19,40 @@ int lshapesSetShapesTexture( lua_State* L ) { Texture* texture = uluaGetTexture( L, 1 ); Rectangle source = uluaGetRectangle( L, 2 ); + state->shapesTexture = *texture; + SetShapesTexture( *texture, source ); return 0; } /* +> texture = RL.GetShapesTexture() + +Get texture that is used for shapes drawing. Return as lightuserdata + +- Success return Texture +*/ +int lshapesGetShapesTexture( lua_State* L ) { + lua_pushlightuserdata( L, &state->shapesTexture ); + + return 1; +} + +/* +> source = RL.GetShapesTextureRectangle() + +Get texture source rectangle that is used for shapes drawing + +- Success return Rectangle +*/ +int lshapesGetShapesTextureRectangle( lua_State* L ) { + uluaPushRectangle( L, GetShapesTextureRectangle() ); + + return 1; +} + +/* > RL.DrawPixel( Vector2 pos, Color color ) Draw a pixel @@ -875,6 +892,24 @@ int lshapesCheckCollisionCircleRec( lua_State* L ) { } /* +> collision = RL.CheckCollisionCircleLine( Vector2 center, float radius, Vector2 p1, Vector2 p2 ) + +Check if circle collides with a line created betweeen two points [p1] and [p2] + +- Success return bool +*/ +int lshapesCheckCollisionCircleLine( lua_State* L ) { + Vector2 center = uluaGetVector2( L, 1 ); + float radius = luaL_checknumber( L, 2 ); + Vector2 p1 = uluaGetVector2( L, 3 ); + Vector2 p2 = uluaGetVector2( L, 4 ); + + lua_pushboolean( L, CheckCollisionCircleLine( center, radius, p1, p2 ) ); + + return 1; +} + +/* > collision = RL.CheckCollisionPointRec( Vector2 point, Rectangle rec ) Check if point is inside rectangle diff --git a/src/state.c b/src/state.c index 70045de..9f3fb5a 100644 --- a/src/state.c +++ b/src/state.c @@ -35,6 +35,7 @@ bool stateInit( int argn, const char** argc, const char* basePath ) { state->guiFont = GuiGetFont(); state->defaultMaterial = LoadMaterialDefault(); state->defaultTexture = (Texture){ 1, 1, 1, 1, 7 }; + state->shapesTexture = (Texture){ 1, 1, 1, 1, 7 }; state->RLGLcurrentShaderLocs = malloc( RL_MAX_SHADER_LOCATIONS * sizeof( int ) ); int* defaultShaderLocs = rlGetShaderLocsDefault(); @@ -1242,3 +1242,33 @@ int ltextTextToPascal( lua_State* L ) { return 1; } + +/* +> text = RL.TextToSnake( string text ) + +Get Snake case notation version of provided string + +- Success return string +*/ +int ltextTextToSnake( lua_State* L ) { + const char* text = luaL_checkstring( L, 1 ); + + lua_pushstring( L, TextToSnake( text ) ); + + return 1; +} + +/* +> text = RL.TextToCamel( string text ) + +Get Camel case notation version of provided string + +- Success return string +*/ +int ltextTextToCamel( lua_State* L ) { + const char* text = luaL_checkstring( L, 1 ); + + lua_pushstring( L, TextToCamel( text ) ); + + return 1; +} diff --git a/src/textures.c b/src/textures.c index d571a32..eaf2284 100644 --- a/src/textures.c +++ b/src/textures.c @@ -78,6 +78,24 @@ int ltexturesLoadImageAnim( lua_State* L ) { } /* +> image, frameCount = RL.LoadImageAnimFromMemory( string fileType, Buffer fileData ) + +Load image sequence from memory buffer. All frames are returned in RGBA format + +- Success return Image, int +*/ +int ltexturesLoadImageAnimFromMemory( lua_State* L ) { + const char* fileType = luaL_checkstring( L, 1 ); + Buffer* buffer = uluaGetBuffer( L, 2 ); + + int frameCount = 0; + uluaPushImage( L, LoadImageAnimFromMemory( fileType, buffer->data, buffer->size, &frameCount ) ); + lua_pushinteger( L, frameCount ); + + return 2; +} + +/* > image, frameCount = RL.LoadImageFromMemory( string fileType, Buffer data ) Load image from memory buffer, fileType refers to extension: i.e. '.png' @@ -418,6 +436,22 @@ int ltexturesImageFromImage( lua_State* L ) { } /* +> image = RL.ImageFromChannel( Image image, int selectedChannel ) + +Create an image from a selected channel of another image (GRAYSCALE) + +- Success return Image +*/ +int ltexturesImageFromChannel( lua_State* L ) { + Image* image = uluaGetImage( L, 1 ); + int selectedChannel = luaL_checkinteger( L, 2 ); + + uluaPushImage( L, ImageFromChannel( *image, selectedChannel ) ); + + return 1; +} + +/* > image = RL.ImageText( string text, int fontSize, Color tint ) Create an image from text (default font) @@ -566,6 +600,32 @@ int ltexturesImageBlurGaussian( lua_State* L ) { } /* +> RL.ImageKernelConvolution( Image image, float{} kernel ) + +Apply custom square convolution kernel to image +*/ +int ltexturesImageKernelConvolution( lua_State* L ) { + Image* image = uluaGetImage( L, 1 ); + + int kernelSize = uluaGetTableLen( L, 2 ); + float kernel[ kernelSize ]; + + int t = lua_gettop( L ); + int i = 0; + lua_pushnil( L ); + + while ( lua_next( L, t ) != 0 ) { + kernel[i] = lua_tonumber( L, -1 ); + i++; + lua_pop( L, 1 ); + } + + ImageKernelConvolution( image, kernel, kernelSize ); + + return 0; +} + +/* > RL.ImageResize( Image image, Vector2 size ) Resize image (Bicubic scaling algorithm) @@ -971,7 +1031,7 @@ int ltexturesImageDrawPixel( lua_State* L ) { } /* -> RL.ImageDrawLine( Image dst, Vector2 a, Vector2 b, Color color ) +> RL.ImageDrawLine( Image dst, Vector2 start, Vector2 end, Color color ) Draw line within an image */ @@ -987,6 +1047,23 @@ int ltexturesImageDrawLine( lua_State* L ) { } /* +> RL.ImageDrawLineEx( Image dst, Vector2 start, Vector2 end, int thick, Color color ) + +Draw a line defining thickness within an image +*/ +int ltexturesImageDrawLineEx( lua_State* L ) { + Image* image = uluaGetImage( L, 1 ); + Vector2 start = uluaGetVector2( L, 2 ); + Vector2 end = uluaGetVector2( L, 3 ); + int thick = luaL_checkinteger( L, 4 ); + Color color = uluaGetColor( L, 5 ); + + ImageDrawLineEx( image, start, end, thick, color ); + + return 0; +} + +/* > RL.ImageDrawCircle( Image dst, Vector2 center, int radius, Color color ) Draw circle within an image @@ -1050,6 +1127,93 @@ int ltexturesImageDrawRectangleLines( lua_State* L ) { } /* +> RL.ImageDrawTriangle( Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color color ) + +Draw triangle within an image +*/ +int ltexturesImageDrawTriangle( lua_State* L ) { + Image* image = uluaGetImage( L, 1 ); + Vector2 v1 = uluaGetVector2( L, 2 ); + Vector2 v2 = uluaGetVector2( L, 3 ); + Vector2 v3 = uluaGetVector2( L, 4 ); + Color color = uluaGetColor( L, 5 ); + + ImageDrawTriangle( image, v1, v2, v3, color ); + + return 0; +} + +/* +> RL.ImageDrawTriangleEx( Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color c1, Color c2, Color c3 ) + +Draw triangle with interpolated colors within an image +*/ +int ltexturesImageDrawTriangleEx( lua_State* L ) { + Image* image = uluaGetImage( L, 1 ); + Vector2 v1 = uluaGetVector2( L, 2 ); + Vector2 v2 = uluaGetVector2( L, 3 ); + Vector2 v3 = uluaGetVector2( L, 4 ); + Color c1 = uluaGetColor( L, 5 ); + Color c2 = uluaGetColor( L, 6 ); + Color c3 = uluaGetColor( L, 7 ); + + ImageDrawTriangleEx( image, v1, v2, v3, c1, c2, c3 ); + + return 0; +} + +/* +> RL.ImageDrawTriangleLines( Image *dst, Vector2 v1, Vector2 v2, Vector2 v3, Color color ) + +Draw triangle outline within an image +*/ +int ltexturesImageDrawTriangleLines( lua_State* L ) { + Image* image = uluaGetImage( L, 1 ); + Vector2 v1 = uluaGetVector2( L, 2 ); + Vector2 v2 = uluaGetVector2( L, 3 ); + Vector2 v3 = uluaGetVector2( L, 4 ); + Color color = uluaGetColor( L, 5 ); + + ImageDrawTriangleLines( image, v1, v2, v3, color ); + + return 0; +} + +/* +> RL.ImageDrawTriangleFan( Image *dst, Vector2{} points, Color color ) + +Draw a triangle fan defined by points within an image (first vertex is the center) +*/ +int ltexturesImageDrawTriangleFan( lua_State* L ) { + Image* image = uluaGetImage( L, 1 ); + int pointCount = uluaGetTableLen( L, 2 ); + Vector2 points[ pointCount ]; + getVector2Array( L, 2, points ); + Color color = uluaGetColor( L, 3 ); + + ImageDrawTriangleFan( image, points, pointCount, color ); + + return 0; +} + +/* +> RL.ImageDrawTriangleStrip( Image *dst, Vector2{} points, Color color ) + +Draw a triangle strip defined by points within an image +*/ +int ltexturesImageDrawTriangleStrip( lua_State* L ) { + Image* image = uluaGetImage( L, 1 ); + int pointCount = uluaGetTableLen( L, 2 ); + Vector2 points[ pointCount ]; + getVector2Array( L, 2, points ); + Color color = uluaGetColor( L, 3 ); + + ImageDrawTriangleStrip( image, points, pointCount, color ); + + return 0; +} + +/* > RL.ImageDraw( Image dst, Image src, Rectangle srcRec, Rectangle dstRec, Color tint ) Draw a source image within a destination image (Tint applied to source) @@ -1856,6 +2020,22 @@ int ltexturesGetRenderTextureDepthTexture( lua_State* L ) { */ /* +> isEqual = RL.ColorIsEqual( Color col1, Color col2 ) + +Check if two colors are equal + +- Success return bool +*/ +int ltexturesColorIsEqual( lua_State* L ) { + Color col1 = uluaGetColor( L, 1 ); + Color col2 = uluaGetColor( L, 2 ); + + lua_pushboolean( L, ColorIsEqual( col1, col2 ) ); + + return 1; +} + +/* > color = RL.Fade( Color color, float alpha ) Returns color with alpha applied, alpha goes from 0.0f to 1.0f @@ -2030,6 +2210,23 @@ int ltexturesColorAlphaBlend( lua_State* L ) { } /* +> color = RL.ColorLerp( Color color1, Color color2, float factor ) + +Get color lerp interpolation between two colors, factor [0.0f..1.0f] + +- Success return Color +*/ +int ltexturesColorLerp( lua_State* L ) { + Color color1 = uluaGetColor( L, 1 ); + Color color2 = uluaGetColor( L, 2 ); + float factor = luaL_checknumber( L, 3 ); + + uluaPushColor( L, ColorLerp( color1, color2, factor ) ); + + return 1; +} + +/* > color = RL.GetColor( int hexValue ) Get Color structure from hexadecimal value |
