diff options
| author | jussi | 2023-04-09 22:19:47 +0300 |
|---|---|---|
| committer | jussi | 2023-04-09 22:19:47 +0300 |
| commit | f4ae19ca7d62a2bc6b125a1ddb678300b30790d2 (patch) | |
| tree | 057373c6d815aacfc5127bdba274b848ccbd93be | |
| parent | 6dad6544d7196905668b4863487daa00ac9843f7 (diff) | |
| download | reilua-enhanced-f4ae19ca7d62a2bc6b125a1ddb678300b30790d2.tar.gz reilua-enhanced-f4ae19ca7d62a2bc6b125a1ddb678300b30790d2.tar.bz2 reilua-enhanced-f4ae19ca7d62a2bc6b125a1ddb678300b30790d2.zip | |
New argument style for rlgl, text, lights and math.
| -rw-r--r-- | changelog | 3 | ||||
| -rw-r--r-- | devnotes | 9 | ||||
| -rw-r--r-- | src/lights.c | 48 | ||||
| -rw-r--r-- | src/rlgl.c | 4 | ||||
| -rw-r--r-- | src/rmath.c | 723 | ||||
| -rw-r--r-- | src/text.c | 161 |
6 files changed, 433 insertions, 515 deletions
@@ -33,7 +33,8 @@ Detailed changes: - CHANGED: DrawLineStrip no longer require pointsCount - CHANGED: DrawTriangleFan no longer require pointsCount - CHANGED: DrawTriangleStrip no longer require pointsCount - - REVISED: How argumets are handled. Now uluaGet* functions can take index. Also using mostly positive stack indexing. + - REVISED: How argumets are handled. Now uluaGet*Index functions can take stack index(positive only). + Also using mostly positive stack indexing. ------------------------------------------------------------------------ Release: ReiLua version 0.4.0 Using Raylib 4.2 @@ -1,13 +1,14 @@ Current { + * New argument styles for: models, rgui, easings. * ReiLua camera3D lib. * Check new functions from https://github.com/raysan5/raylib/blob/master/CHANGELOG } Backlog { - * IsWaveReady and others like that. + * IsWaveReady and other Is* ready functions. * rlgl - * More low level functions. Could be usefull now when draw polygon is removed. + * More low level functions. Could be usefull now when for example draw polygon is removed. * Text * Ability to set font texture filtering. * Codepoints? @@ -29,4 +30,8 @@ Backlog { * LoadShader * LoadShaderFromMemory * LoadSoundFromWave + * LoadFont + * LoadFontEx + * LoadFontFromImage + * DrawText } diff --git a/src/lights.c b/src/lights.c index b82ba8d..180cbd1 100644 --- a/src/lights.c +++ b/src/lights.c @@ -32,6 +32,20 @@ bool validLight( size_t id ) { } } +static int newLight() { + int i = 0; + + for ( i = 0; i < state->lightCount; i++ ) { + if ( state->lights[i] == NULL ) { + break; + } + } + state->lights[i] = malloc( sizeof( Light ) ); + checkLightRealloc( i ); + + return i; +} + /* ## Lights - Basics */ @@ -45,32 +59,21 @@ Create a light and get shader locations - Success return int */ int llightsCreateLight( lua_State *L ) { - if ( !lua_isnumber( L, -5 ) || !lua_istable( L, -4 ) || !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_isnumber( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) + || !lua_istable( L, 4 ) || !lua_isnumber( L, 5 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.CreateLight( int type, Vector3 position, Vector3 target, Color color, Shader shader )" ); lua_pushinteger( L, -1 ); return 1; } - size_t shaderId = lua_tointeger( L, -1 ); - lua_pop( L, 1 ); - Color color = uluaGetColor( L ); - lua_pop( L, 1 ); - Vector3 target = uluaGetVector3( L ); - lua_pop( L, 1 ); - Vector3 position = uluaGetVector3( L ); - lua_pop( L, 1 ); - int type = lua_tointeger( L, -1 ); - - int i = 0; + int type = lua_tointeger( L, 1 ); + Vector3 position = uluaGetVector3Index( L, 2 ); + Vector3 target = uluaGetVector3Index( L, 3 ); + Color color = uluaGetColorIndex( L, 4 ); + size_t shaderId = lua_tointeger( L, 5 ); - for ( i = 0; i < state->lightCount; i++ ) { - if ( state->lights[i] == NULL ) { - break; - } - } - state->lights[i] = malloc( sizeof( Light ) ); + int i = newLight(); *state->lights[i] = CreateLight( type, position, target, color, *state->shaders[ shaderId ] ); lua_pushinteger( L, i ); - checkLightRealloc( i ); return 1; } @@ -84,14 +87,13 @@ Send light properties to shader - Success return true */ int llightsUpdateLightValues( lua_State *L ) { - if ( !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.UpdateLightValues( Shader shader, Light light )" ); lua_pushboolean( L, false ); return 1; } - size_t lightId = lua_tointeger( L, -1 ); - lua_pop( L, 1 ); - size_t shaderId = lua_tointeger( L, -1 ); + size_t shaderId = lua_tointeger( L, 1 ); + size_t lightId = lua_tointeger( L, 2 ); if ( !validLight( lightId ) ) { lua_pushboolean( L, false ); @@ -16,12 +16,12 @@ Set the line drawing width - Success return true */ int lrlglSetLineWidth( lua_State *L ) { - if ( !lua_isnumber( L, -1 ) ) { + if ( !lua_isnumber( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.rlSetLineWidth( float width )" ); lua_pushboolean( L, false ); return 1; } - rlSetLineWidth( lua_tonumber( L, -1 ) ); + rlSetLineWidth( lua_tonumber( L, 1 ) ); lua_pushboolean( L, true ); return 1; diff --git a/src/rmath.c b/src/rmath.c index 0b4623d..850a88b 100644 --- a/src/rmath.c +++ b/src/rmath.c @@ -24,14 +24,14 @@ Clamp float value - Success return float */ int lmathClamp( lua_State *L ) { - if ( !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Clamp( float value, float min, float max )" ); lua_pushboolean( L, false ); return 1; } - float max = lua_tonumber( L, -1 ); - float min = lua_tonumber( L, -2 ); - float value = lua_tonumber( L, -3 ); + float value = lua_tonumber( L, 1 ); + float min = lua_tonumber( L, 2 ); + float max = lua_tonumber( L, 3 ); lua_pushnumber( L, Clamp( value, min, max ) ); @@ -47,14 +47,14 @@ Calculate linear interpolation between two floats - Success return float */ int lmathLerp( lua_State *L ) { - if ( !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Lerp( float start, float end, float amount )" ); lua_pushboolean( L, false ); return 1; } - float amount = lua_tonumber( L, -1 ); - float end = lua_tonumber( L, -2 ); - float start = lua_tonumber( L, -3 ); + float start = lua_tonumber( L, 1 ); + float end = lua_tonumber( L, 2 ); + float amount = lua_tonumber( L, 3 ); lua_pushnumber( L, Lerp( start, end, amount ) ); @@ -70,14 +70,14 @@ Normalize input value within input range - Success return float */ int lmathNormalize( lua_State *L ) { - if ( !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Normalize( float value, float start, float end )" ); lua_pushboolean( L, false ); return 1; } - float end = lua_tonumber( L, -1 ); - float start = lua_tonumber( L, -2 ); - float value = lua_tonumber( L, -3 ); + float value = lua_tonumber( L, 1 ); + float start = lua_tonumber( L, 2 ); + float end = lua_tonumber( L, 3 ); lua_pushnumber( L, Normalize( value, start, end ) ); @@ -93,17 +93,17 @@ Remap input value within input range to output range - Success return float */ int lmathRemap( lua_State *L ) { - if ( !lua_isnumber( L, -5 ) || !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) - || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) + || !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Remap( float value, float inputStart, float inputEnd, float outputStart, float outputEnd )" ); lua_pushboolean( L, false ); return 1; } - float outputEnd = lua_tonumber( L, -1 ); - float outputStart = lua_tonumber( L, -2 ); - float inputEnd = lua_tonumber( L, -3 ); - float inputStart = lua_tonumber( L, -4 ); - float value = lua_tonumber( L, -5 ); + float value = lua_tonumber( L, 1 ); + float inputStart = lua_tonumber( L, 2 ); + float inputEnd = lua_tonumber( L, 3 ); + float outputStart = lua_tonumber( L, 4 ); + float outputEnd = lua_tonumber( L, 5 ); lua_pushnumber( L, Remap( value, inputStart, inputEnd, outputStart, outputEnd ) ); @@ -119,14 +119,14 @@ Wrap input value from min to max - Success return float */ int lmathWrap( lua_State *L ) { - if ( !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Wrap( float value, float min, float max )" ); lua_pushboolean( L, false ); return 1; } - float max = lua_tonumber( L, -1 ); - float min = lua_tonumber( L, -2 ); - float value = lua_tonumber( L, -3 ); + float value = lua_tonumber( L, 1 ); + float min = lua_tonumber( L, 2 ); + float max = lua_tonumber( L, 3 ); lua_pushnumber( L, Wrap( value, min, max ) ); @@ -142,13 +142,13 @@ Check whether two given floats are almost equal - Success return int */ int lmathFloatEquals( lua_State *L ) { - if ( !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.FloatEquals( float x, float y )" ); lua_pushboolean( L, false ); return 1; } - float y = lua_tonumber( L, -1 ); - float x = lua_tonumber( L, -2 ); + float x = lua_tonumber( L, 1 ); + float y = lua_tonumber( L, 2 ); lua_pushinteger( L, FloatEquals( x, y ) ); @@ -194,14 +194,13 @@ Add two vectors (v1 + v2) - Success return Vector2 */ int lmathVector2Add( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector2Add( Vector2 v1, Vector2 v2 )" ); lua_pushboolean( L, false ); return 1; } - Vector2 v2 = uluaGetVector2( L ); - lua_pop( L, 1 ); - Vector2 v1 = uluaGetVector2( L ); + Vector2 v1 = uluaGetVector2Index( L, 1 ); + Vector2 v2 = uluaGetVector2Index( L, 2 ); uluaPushVector2( L, Vector2Add( v1, v2 ) ); @@ -217,14 +216,13 @@ Add vector and float value - Success return Vector2 */ int lmathVector2AddValue( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector2AddValue( Vector2 v, float add )" ); lua_pushboolean( L, false ); return 1; } - float add = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - Vector2 v = uluaGetVector2( L ); + Vector2 v = uluaGetVector2Index( L, 1 ); + float add = lua_tonumber( L, 2 ); uluaPushVector2( L, Vector2AddValue( v, add ) ); @@ -240,14 +238,13 @@ Subtract two vectors (v1 - v2) - Success return Vector2 */ int lmathVector2Subtract( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector2Subtract( Vector2 v1, Vector2 v2 )" ); lua_pushboolean( L, false ); return 1; } - Vector2 v2 = uluaGetVector2( L ); - lua_pop( L, 1 ); - Vector2 v1 = uluaGetVector2( L ); + Vector2 v1 = uluaGetVector2Index( L, 1 ); + Vector2 v2 = uluaGetVector2Index( L, 2 ); uluaPushVector2( L, Vector2Subtract( v1, v2 ) ); @@ -263,14 +260,13 @@ Subtract vector by float value - Success return Vector2 */ int lmathVector2SubtractValue( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector2SubtractValue( Vector2 v, float sub )" ); lua_pushboolean( L, false ); return 1; } - float sub = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - Vector2 v = uluaGetVector2( L ); + Vector2 v = uluaGetVector2Index( L, 1 ); + float sub = lua_tonumber( L, 2 ); uluaPushVector2( L, Vector2SubtractValue( v, sub ) ); @@ -286,12 +282,12 @@ Calculate vector length - Success return float */ int lmathVector2Length( lua_State *L ) { - if ( !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector2Length( vector2 v )" ); lua_pushboolean( L, false ); return 1; } - Vector2 v = uluaGetVector2( L ); + Vector2 v = uluaGetVector2Index( L, 1 ); lua_pushnumber( L, Vector2Length( v ) ); @@ -307,12 +303,12 @@ Calculate vector square length - Success return float */ int lmathVector2LengthSqr( lua_State *L ) { - if ( !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector2LengthSqr( vector2 v )" ); lua_pushboolean( L, false ); return 1; } - Vector2 v = uluaGetVector2( L ); + Vector2 v = uluaGetVector2Index( L, 1 ); lua_pushnumber( L, Vector2LengthSqr( v ) ); @@ -328,14 +324,13 @@ Calculate two vectors dot product - Success return float */ int lmathVector2DotProduct( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector2DotProduct( Vector2 v1, Vector2 v2 )" ); lua_pushboolean( L, false ); return 1; } - Vector2 v2 = uluaGetVector2( L ); - lua_pop( L, 1 ); - Vector2 v1 = uluaGetVector2( L ); + Vector2 v1 = uluaGetVector2Index( L, 1 ); + Vector2 v2 = uluaGetVector2Index( L, 2 ); lua_pushnumber( L, Vector2DotProduct( v1, v2 ) ); @@ -351,14 +346,13 @@ Calculate distance between two vectors - Success return float */ int lmathVector2Distance( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector2Distance( Vector2 v1, Vector2 v2 )" ); lua_pushboolean( L, false ); return 1; } - Vector2 v2 = uluaGetVector2( L ); - lua_pop( L, 1 ); - Vector2 v1 = uluaGetVector2( L ); + Vector2 v1 = uluaGetVector2Index( L, 1 ); + Vector2 v2 = uluaGetVector2Index( L, 2 ); lua_pushnumber( L, Vector2Distance( v1, v2 ) ); @@ -374,14 +368,13 @@ Calculate square distance between two vectors - Success return float */ int lmathVector2DistanceSqr( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector2DistanceSqr( Vector2 v1, Vector2 v2 )" ); lua_pushboolean( L, false ); return 1; } - Vector2 v2 = uluaGetVector2( L ); - lua_pop( L, 1 ); - Vector2 v1 = uluaGetVector2( L ); + Vector2 v1 = uluaGetVector2Index( L, 1 ); + Vector2 v2 = uluaGetVector2Index( L, 2 ); lua_pushnumber( L, Vector2DistanceSqr( v1, v2 ) ); @@ -397,14 +390,13 @@ Calculate angle from two vectors - Success return float */ int lmathVector2Angle( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector2Angle( Vector2 v1, Vector2 v2 )" ); lua_pushboolean( L, false ); return 1; } - Vector2 v2 = uluaGetVector2( L ); - lua_pop( L, 1 ); - Vector2 v1 = uluaGetVector2( L ); + Vector2 v1 = uluaGetVector2Index( L, 1 ); + Vector2 v2 = uluaGetVector2Index( L, 2 ); lua_pushnumber( L, Vector2Angle( v1, v2 ) ); @@ -422,14 +414,13 @@ Current implementation should be aligned with glm::angle. - Success return float */ int lmathVector2LineAngle( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector2LineAngle( Vector2 start, Vector2 end )" ); lua_pushboolean( L, false ); return 1; } - Vector2 end = uluaGetVector2( L ); - lua_pop( L, 1 ); - Vector2 start = uluaGetVector2( L ); + Vector2 start = uluaGetVector2Index( L, 1 ); + Vector2 end = uluaGetVector2Index( L, 2 ); lua_pushnumber( L, Vector2LineAngle( start, end ) ); @@ -445,14 +436,13 @@ Scale vector ( multiply by value ) - Success return Vector2 */ int lmathVector2Scale( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector2Scale( Vector2 v, float scale )" ); lua_pushboolean( L, false ); return 1; } - float scale = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - Vector2 v = uluaGetVector2( L ); + Vector2 v = uluaGetVector2Index( L, 1 ); + float scale = lua_tonumber( L, 2 ); uluaPushVector2( L, Vector2Scale( v, scale ) ); @@ -468,14 +458,13 @@ Multiply vector by vector - Success return Vector2 */ int lmathVector2Multiply( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector2Multiply( Vector2 v1, Vector2 v2 )" ); lua_pushboolean( L, false ); return 1; } - Vector2 v2 = uluaGetVector2( L ); - lua_pop( L, 1 ); - Vector2 v1 = uluaGetVector2( L ); + Vector2 v1 = uluaGetVector2Index( L, 1 ); + Vector2 v2 = uluaGetVector2Index( L, 2 ); uluaPushVector2( L, Vector2Multiply( v1, v2 ) ); @@ -491,12 +480,12 @@ Negate vector - Success return Vector2 */ int lmathVector2Negate( lua_State *L ) { - if ( !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector2Negate( Vector2 v )" ); lua_pushboolean( L, false ); return 1; } - Vector2 v = uluaGetVector2( L ); + Vector2 v = uluaGetVector2Index( L, 1 ); uluaPushVector2( L, Vector2Negate( v ) ); @@ -512,14 +501,13 @@ Divide vector by vector - Success return Vector2 */ int lmathVector2Divide( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector2Divide( Vector2 v1, Vector2 v2 )" ); lua_pushboolean( L, false ); return 1; } - Vector2 v2 = uluaGetVector2( L ); - lua_pop( L, 1 ); - Vector2 v1 = uluaGetVector2( L ); + Vector2 v1 = uluaGetVector2Index( L, 1 ); + Vector2 v2 = uluaGetVector2Index( L, 2 ); uluaPushVector2( L, Vector2Divide( v1, v2 ) ); @@ -535,12 +523,12 @@ Normalize provided vector - Success return Vector2 */ int lmathVector2Normalize( lua_State *L ) { - if ( !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector2Normalize( Vector2 v )" ); lua_pushboolean( L, false ); return 1; } - Vector2 v = uluaGetVector2( L ); + Vector2 v = uluaGetVector2Index( L, 1 ); uluaPushVector2( L, Vector2Normalize( v ) ); @@ -556,14 +544,13 @@ Transforms a Vector2 by a given Matrix - Success return Vector2 */ int lmathVector2Transform( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector2Transform( Vector2 v, Matrix mat )" ); lua_pushboolean( L, false ); return 1; } - Matrix mat = uluaGetMatrix( L ); - lua_pop( L, 1 ); - Vector2 v = uluaGetVector2( L ); + Vector2 v = uluaGetVector2Index( L, 1 ); + Matrix mat = uluaGetMatrixIndex( L, 2 ); uluaPushVector2( L, Vector2Transform( v, mat ) ); @@ -579,16 +566,14 @@ Calculate linear interpolation between two vectors - Success return Vector2 */ int lmathVector2Lerp( lua_State *L ) { - if ( !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector2Lerp( Vector2 v1, Vector2 v2, float amount )" ); lua_pushboolean( L, false ); return 1; } - float amount = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - Vector2 v2 = uluaGetVector2( L ); - lua_pop( L, 1 ); - Vector2 v1 = uluaGetVector2( L ); + Vector2 v1 = uluaGetVector2Index( L, 1 ); + Vector2 v2 = uluaGetVector2Index( L, 2 ); + float amount = lua_tonumber( L, 3 ); uluaPushVector2( L, Vector2Lerp( v1, v2, amount ) ); @@ -604,14 +589,13 @@ Calculate reflected vector to normal - Success return Vector2 */ int lmathVector2Reflect( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector2Reflect( Vector2 v, Vector2 normal )" ); lua_pushboolean( L, false ); return 1; } - Vector2 v2 = uluaGetVector2( L ); - lua_pop( L, 1 ); - Vector2 v1 = uluaGetVector2( L ); + Vector2 v1 = uluaGetVector2Index( L, 1 ); + Vector2 v2 = uluaGetVector2Index( L, 2 ); uluaPushVector2( L, Vector2Reflect( v1, v2 ) ); @@ -627,14 +611,13 @@ Rotate vector by angle - Success return Vector2 */ int lmathVector2Rotate( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector2Rotate( Vector2 v, float angle )" ); lua_pushboolean( L, false ); return 1; } - float degs = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - Vector2 v = uluaGetVector2( L ); + Vector2 v = uluaGetVector2Index( L, 1 ); + float degs = lua_tonumber( L, 2 ); uluaPushVector2( L, Vector2Rotate( v, degs ) ); @@ -650,16 +633,14 @@ Move Vector towards target - Success return Vector2 */ int lmathVector2MoveTowards( lua_State *L ) { - if ( !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector2MoveTowards( Vector2 v, Vector2 target, float maxDistance )" ); lua_pushboolean( L, false ); return 1; } - float maxDistance = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - Vector2 v2 = uluaGetVector2( L ); - lua_pop( L, 1 ); - Vector2 v1 = uluaGetVector2( L ); + Vector2 v1 = uluaGetVector2Index( L, 1 ); + Vector2 v2 = uluaGetVector2Index( L, 2 ); + float maxDistance = lua_tonumber( L, 3 ); uluaPushVector2( L, Vector2MoveTowards( v1, v2, maxDistance ) ); @@ -675,12 +656,12 @@ Invert the given vector - Success return Vector2 */ int lmathVector2Invert( lua_State *L ) { - if ( !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector2Invert( Vector2 v )" ); lua_pushboolean( L, false ); return 1; } - Vector2 v = uluaGetVector2( L ); + Vector2 v = uluaGetVector2Index( L, 1 ); uluaPushVector2( L, Vector2Invert( v ) ); @@ -697,16 +678,14 @@ min and max values specified by the given vectors - Success return Vector2 */ int lmathVector2Clamp( lua_State *L ) { - if ( !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector2Clamp( Vector2 v, Vector2 min, Vector2 max )" ); lua_pushboolean( L, false ); return 1; } - Vector2 max = uluaGetVector2( L ); - lua_pop( L, 1 ); - Vector2 min = uluaGetVector2( L ); - lua_pop( L, 1 ); - Vector2 v = uluaGetVector2( L ); + Vector2 v = uluaGetVector2Index( L, 1 ); + Vector2 min = uluaGetVector2Index( L, 2 ); + Vector2 max = uluaGetVector2Index( L, 3 ); uluaPushVector2( L, Vector2Clamp( v, min, max ) ); @@ -722,16 +701,14 @@ Clamp the magnitude of the vector between two min and max values - Success return Vector2 */ int lmathVector2ClampValue( lua_State *L ) { - if ( !lua_istable( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector2ClampValue( Vector2 v, float min, float max )" ); lua_pushboolean( L, false ); return 1; } - float max = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - float min = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - Vector2 v = uluaGetVector2( L ); + Vector2 v = uluaGetVector2Index( L, 1 ); + float min = lua_tonumber( L, 2 ); + float max = lua_tonumber( L, 3 ); uluaPushVector2( L, Vector2ClampValue( v, min, max ) ); @@ -747,14 +724,13 @@ Check whether two given vectors are almost equal - Success return int */ int lmathVector2Equals( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector2Equals( Vector2 v1, Vector2 v2 )" ); lua_pushboolean( L, false ); return 1; } - Vector2 v2 = uluaGetVector2( L ); - lua_pop( L, 1 ); - Vector2 v1 = uluaGetVector2( L ); + Vector2 v1 = uluaGetVector2Index( L, 1 ); + Vector2 v2 = uluaGetVector2Index( L, 2 ); lua_pushinteger( L, Vector2Equals( v1, v2 ) ); @@ -800,14 +776,13 @@ Add two vectors - Success return Vector3 */ int lmathVector3Add( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3Add( Vector3 v1, Vector3 v2 )" ); lua_pushboolean( L, false ); return 1; } - Vector3 v2 = uluaGetVector3( L ); - lua_pop( L, 1 ); - Vector3 v1 = uluaGetVector3( L ); + Vector3 v1 = uluaGetVector3Index( L, 1 ); + Vector3 v2 = uluaGetVector3Index( L, 2 ); uluaPushVector3( L, Vector3Add( v1, v2 ) ); @@ -823,14 +798,13 @@ Add vector and float value - Success return Vector3 */ int lmathVector3AddValue( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3AddValue( Vector3 v, float add )" ); lua_pushboolean( L, false ); return 1; } - float add = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - Vector3 v = uluaGetVector3( L ); + Vector3 v = uluaGetVector3Index( L, 1 ); + float add = lua_tonumber( L, 2 ); uluaPushVector3( L, Vector3AddValue( v, add ) ); @@ -846,14 +820,13 @@ Subtract two vectors - Success return Vector3 */ int lmathVector3Subtract( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3Subtract( Vector3 v1, Vector3 v2 )" ); lua_pushboolean( L, false ); return 1; } - Vector3 v2 = uluaGetVector3( L ); - lua_pop( L, 1 ); - Vector3 v1 = uluaGetVector3( L ); + Vector3 v1 = uluaGetVector3Index( L, 1 ); + Vector3 v2 = uluaGetVector3Index( L, 2 ); uluaPushVector3( L, Vector3Subtract( v1, v2 ) ); @@ -869,14 +842,13 @@ Subtract vector by float value - Success return Vector3 */ int lmathVector3SubtractValue( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3SubtractValue( Vector3 v, float sub )" ); lua_pushboolean( L, false ); return 1; } - float sub = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - Vector3 v = uluaGetVector3( L ); + Vector3 v = uluaGetVector3Index( L, 1 ); + float sub = lua_tonumber( L, 2 ); uluaPushVector3( L, Vector3SubtractValue( v, sub ) ); @@ -892,14 +864,13 @@ Multiply vector by scalar - Success return Vector3 */ int lmathVector3Scale( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3Scale( Vector3 v, float scalar )" ); lua_pushboolean( L, false ); return 1; } - float scalar = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - Vector3 v = uluaGetVector3( L ); + Vector3 v = uluaGetVector3Index( L, 1 ); + float scalar = lua_tonumber( L, 2 ); uluaPushVector3( L, Vector3Scale( v, scalar ) ); @@ -915,14 +886,13 @@ Multiply vector by vector - Success return Vector3 */ int lmathVector3Multiply( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3Multiply( Vector3 v1, Vector3 v2 )" ); lua_pushboolean( L, false ); return 1; } - Vector3 v2 = uluaGetVector3( L ); - lua_pop( L, 1 ); - Vector3 v1 = uluaGetVector3( L ); + Vector3 v1 = uluaGetVector3Index( L, 1 ); + Vector3 v2 = uluaGetVector3Index( L, 2 ); uluaPushVector3( L, Vector3Multiply( v1, v2 ) ); @@ -938,14 +908,13 @@ Calculate two vectors cross product - Success return Vector3 */ int lmathVector3CrossProduct( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3CrossProduct( Vector3 v1, Vector3 v2 )" ); lua_pushboolean( L, false ); return 1; } - Vector3 v2 = uluaGetVector3( L ); - lua_pop( L, 1 ); - Vector3 v1 = uluaGetVector3( L ); + Vector3 v1 = uluaGetVector3Index( L, 1 ); + Vector3 v2 = uluaGetVector3Index( L, 2 ); uluaPushVector3( L, Vector3CrossProduct( v1, v2 ) ); @@ -961,12 +930,12 @@ Calculate one vector perpendicular vector - Success return Vector3 */ int lmathVector3Perpendicular( lua_State *L ) { - if ( !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3Perpendicular( Vector3 v )" ); lua_pushboolean( L, false ); return 1; } - Vector3 v = uluaGetVector3( L ); + Vector3 v = uluaGetVector3Index( L, 1 ); uluaPushVector3( L, Vector3Perpendicular( v ) ); @@ -982,12 +951,12 @@ Calculate vector length - Success return float */ int lmathVector3Length( lua_State *L ) { - if ( !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3Length( Vector3 v )" ); lua_pushboolean( L, false ); return 1; } - Vector3 v = uluaGetVector3( L ); + Vector3 v = uluaGetVector3Index( L, 1 ); lua_pushnumber( L, Vector3Length( v ) ); @@ -1003,12 +972,12 @@ Calculate vector square length - Success return float */ int lmathVector3LengthSqr( lua_State *L ) { - if ( !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3LengthSqr( Vector3 v )" ); lua_pushboolean( L, false ); return 1; } - Vector3 v = uluaGetVector3( L ); + Vector3 v = uluaGetVector3Index( L, 1 ); lua_pushnumber( L, Vector3LengthSqr( v ) ); @@ -1024,14 +993,13 @@ Calculate two vectors dot product - Success return float */ int lmathVector3DotProduct( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3DotProduct( Vector3 v1, Vector3 v2 )" ); lua_pushboolean( L, false ); return 1; } - Vector3 v2 = uluaGetVector3( L ); - lua_pop( L, 1 ); - Vector3 v1 = uluaGetVector3( L ); + Vector3 v1 = uluaGetVector3Index( L, 1 ); + Vector3 v2 = uluaGetVector3Index( L, 2 ); lua_pushnumber( L, Vector3DotProduct( v1, v2 ) ); @@ -1047,14 +1015,13 @@ Calculate distance between two vectors - Success return float */ int lmathVector3Distance( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3Distance( Vector3 v1, Vector3 v2 )" ); lua_pushboolean( L, false ); return 1; } - Vector3 v2 = uluaGetVector3( L ); - lua_pop( L, 1 ); - Vector3 v1 = uluaGetVector3( L ); + Vector3 v1 = uluaGetVector3Index( L, 1 ); + Vector3 v2 = uluaGetVector3Index( L, 2 ); lua_pushnumber( L, Vector3Distance( v1, v2 ) ); @@ -1070,14 +1037,13 @@ Calculate square distance between two vectors - Success return float */ int lmathVector3DistanceSqr( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3DistanceSqr( Vector3 v1, Vector3 v2 )" ); lua_pushboolean( L, false ); return 1; } - Vector3 v2 = uluaGetVector3( L ); - lua_pop( L, 1 ); - Vector3 v1 = uluaGetVector3( L ); + Vector3 v1 = uluaGetVector3Index( L, 1 ); + Vector3 v2 = uluaGetVector3Index( L, 2 ); lua_pushnumber( L, Vector3DistanceSqr( v1, v2 ) ); @@ -1093,14 +1059,13 @@ Calculate angle between two vectors - Success return float */ int lmathVector3Angle( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3Angle( Vector3 v1, Vector3 v2 )" ); lua_pushboolean( L, false ); return 1; } - Vector3 v2 = uluaGetVector3( L ); - lua_pop( L, 1 ); - Vector3 v1 = uluaGetVector3( L ); + Vector3 v1 = uluaGetVector3Index( L, 1 ); + Vector3 v2 = uluaGetVector3Index( L, 2 ); lua_pushnumber( L, Vector3Angle( v1, v2 ) ); @@ -1116,12 +1081,12 @@ Negate provided vector ( invert direction ) - Success return Vector3 */ int lmathVector3Negate( lua_State *L ) { - if ( !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3Negate( Vector3 v )" ); lua_pushboolean( L, false ); return 1; } - Vector3 v = uluaGetVector3( L ); + Vector3 v = uluaGetVector3Index( L, 1 ); uluaPushVector3( L, Vector3Negate( v ) ); @@ -1137,14 +1102,13 @@ Divide vector by vector - Success return Vector3 */ int lmathVector3Divide( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3Divide( Vector3 v1, Vector3 v2 )" ); lua_pushboolean( L, false ); return 1; } - Vector3 v2 = uluaGetVector3( L ); - lua_pop( L, 1 ); - Vector3 v1 = uluaGetVector3( L ); + Vector3 v1 = uluaGetVector3Index( L, 1 ); + Vector3 v2 = uluaGetVector3Index( L, 2 ); uluaPushVector3( L, Vector3Divide( v1, v2 ) ); @@ -1160,12 +1124,12 @@ Normalize provided vector - Success return Vector3 */ int lmathVector3Normalize( lua_State *L ) { - if ( !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3Normalize( Vector3 v )" ); lua_pushboolean( L, false ); return 1; } - Vector3 v = uluaGetVector3( L ); + Vector3 v = uluaGetVector3Index( L, 1 ); uluaPushVector3( L, Vector3Normalize( v ) ); @@ -1182,14 +1146,13 @@ Gram-Schmidt function implementation - Success return Vector3, Vector3 */ int lmathVector3OrthoNormalize( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3OrthoNormalize( Vector3 v1, Vector3 v2 )" ); lua_pushboolean( L, false ); return 1; } - Vector3 v2 = uluaGetVector3( L ); - lua_pop( L, 1 ); - Vector3 v1 = uluaGetVector3( L ); + Vector3 v1 = uluaGetVector3Index( L, 1 ); + Vector3 v2 = uluaGetVector3Index( L, 2 ); Vector3OrthoNormalize( &v1, &v2 ); @@ -1208,14 +1171,13 @@ Transforms a Vector3 by a given Matrix - Success return Vector3 */ int lmathVector3Transform( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3Transform( Vector3 v, Matrix mat )" ); lua_pushboolean( L, false ); return 1; } - Matrix mat = uluaGetMatrix( L ); - lua_pop( L, 1 ); - Vector3 v = uluaGetVector3( L ); + Vector3 v = uluaGetVector3Index( L, 1 ); + Matrix mat = uluaGetMatrixIndex( L, 2 ); uluaPushVector3( L, Vector3Transform( v, mat ) ); @@ -1231,14 +1193,13 @@ Transform a vector by quaternion rotation - Success return Vector3 */ int lmathVector3RotateByQuaternion( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3RotateByQuaternion( Vector3 v, Quaternion q )" ); lua_pushboolean( L, false ); return 1; } - Quaternion q = uluaGetQuaternion( L ); - lua_pop( L, 1 ); - Vector3 v = uluaGetVector3( L ); + Vector3 v = uluaGetVector3Index( L, 1 ); + Quaternion q = uluaGetQuaternionIndex( L, 2 ); uluaPushVector3( L, Vector3RotateByQuaternion( v, q ) ); @@ -1254,16 +1215,14 @@ Rotates a vector around an axis - Success return Vector3 */ int lmathVector3RotateByAxisAngle( lua_State *L ) { - if ( !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3RotateByAxisAngle( Vector3 v, Vector3 axis, float angle )" ); lua_pushboolean( L, false ); return 1; } - float angle = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - Vector3 axis = uluaGetVector3( L ); - lua_pop( L, 1 ); - Vector3 v = uluaGetVector3( L ); + Vector3 v = uluaGetVector3Index( L, 1 ); + Vector3 axis = uluaGetVector3Index( L, 2 ); + float angle = lua_tonumber( L, 3 ); uluaPushVector3( L, Vector3RotateByAxisAngle( v, axis, angle ) ); @@ -1279,16 +1238,14 @@ Calculate linear interpolation between two vectors - Success return Vector3 */ int lmathVector3Lerp( lua_State *L ) { - if ( !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3Lerp( Vector3 v1, Vector3 v2, float amount )" ); lua_pushboolean( L, false ); return 1; } - float amount = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - Vector3 v2 = uluaGetVector3( L ); - lua_pop( L, 1 ); - Vector3 v1 = uluaGetVector3( L ); + Vector3 v1 = uluaGetVector3Index( L, 1 ); + Vector3 v2 = uluaGetVector3Index( L, 2 ); + float amount = lua_tonumber( L, 3 ); uluaPushVector3( L, Vector3Lerp( v1, v2, amount ) ); @@ -1304,16 +1261,15 @@ Calculate reflected vector to normal - Success return Vector3 */ int lmathVector3Reflect( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3Reflect( Vector3 v, Vector3 normal )" ); lua_pushboolean( L, false ); return 1; } - Vector3 normal = uluaGetVector3( L ); - lua_pop( L, 1 ); - Vector3 v1 = uluaGetVector3( L ); + Vector3 v = uluaGetVector3Index( L, 1 ); + Vector3 normal = uluaGetVector3Index( L, 2 ); - uluaPushVector3( L, Vector3Reflect( v1, normal ) ); + uluaPushVector3( L, Vector3Reflect( v, normal ) ); return 1; } @@ -1327,14 +1283,13 @@ Get min value for each pair of components - Success return Vector3 */ int lmathVector3Min( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3Min( Vector3 v1, Vector3 v2 )" ); lua_pushboolean( L, false ); return 1; } - Vector3 v2 = uluaGetVector3( L ); - lua_pop( L, 1 ); - Vector3 v1 = uluaGetVector3( L ); + Vector3 v1 = uluaGetVector3Index( L, 1 ); + Vector3 v2 = uluaGetVector3Index( L, 2 ); uluaPushVector3( L, Vector3Min( v1, v2 ) ); @@ -1350,14 +1305,13 @@ Get max value for each pair of components - Success return Vector3 */ int lmathVector3Max( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3Max( Vector3 v1, Vector3 v2 )" ); lua_pushboolean( L, false ); return 1; } - Vector3 v2 = uluaGetVector3( L ); - lua_pop( L, 1 ); - Vector3 v1 = uluaGetVector3( L ); + Vector3 v1 = uluaGetVector3Index( L, 1 ); + Vector3 v2 = uluaGetVector3Index( L, 2 ); uluaPushVector3( L, Vector3Max( v1, v2 ) ); @@ -1374,18 +1328,15 @@ NOTE: Assumes P is on the plane of the triangle - Success return Vector3 */ int lmathVector3Barycenter( lua_State *L ) { - if ( !lua_istable( L, -4 ) || !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) || !lua_istable( L, 4 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3Barycenter( Vector3 p, Vector3 a, Vector3 b, Vector3 c )" ); lua_pushboolean( L, false ); return 1; } - Vector3 c = uluaGetVector3( L ); - lua_pop( L, 1 ); - Vector3 b = uluaGetVector3( L ); - lua_pop( L, 1 ); - Vector3 a = uluaGetVector3( L ); - lua_pop( L, 1 ); - Vector3 p = uluaGetVector3( L ); + Vector3 p = uluaGetVector3Index( L, 1 ); + Vector3 a = uluaGetVector3Index( L, 2 ); + Vector3 b = uluaGetVector3Index( L, 3 ); + Vector3 c = uluaGetVector3Index( L, 4 ); uluaPushVector3( L, Vector3Barycenter( p, a, b, c ) ); @@ -1402,16 +1353,14 @@ NOTE: We are avoiding calling other raymath functions despite available - Success return Vector3 */ int lmathVector3Unproject( lua_State *L ) { - if ( !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3Unproject( Vector3 source, Matrix projection, Matrix view )" ); lua_pushboolean( L, false ); return 1; } - Matrix view = uluaGetMatrix( L ); - lua_pop( L, 1 ); - Matrix projection = uluaGetMatrix( L ); - lua_pop( L, 1 ); - Vector3 source = uluaGetVector3( L ); + Vector3 source = uluaGetVector3Index( L, 1 ); + Matrix projection = uluaGetMatrixIndex( L, 2 ); + Matrix view = uluaGetMatrixIndex( L, 3 ); uluaPushVector3( L, Vector3Unproject( source, projection, view ) ); @@ -1427,12 +1376,12 @@ Invert the given vector - Success return Vector3 */ int lmathVector3Invert( lua_State *L ) { - if ( !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3Invert( Vector3 v )" ); lua_pushboolean( L, false ); return 1; } - Vector3 v = uluaGetVector3( L ); + Vector3 v = uluaGetVector3Index( L, 1 ); uluaPushVector3( L, Vector3Invert( v ) ); @@ -1449,16 +1398,14 @@ min and max values specified by the given vectors - Success return Vector3 */ int lmathVector3Clamp( lua_State *L ) { - if ( !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3Clamp( Vector3 v, Vector3 min, Vector3 max )" ); lua_pushboolean( L, false ); return 1; } - Vector3 max = uluaGetVector3( L ); - lua_pop( L, 1 ); - Vector3 min = uluaGetVector3( L ); - lua_pop( L, 1 ); - Vector3 v = uluaGetVector3( L ); + Vector3 v = uluaGetVector3Index( L, 1 ); + Vector3 min = uluaGetVector3Index( L, 2 ); + Vector3 max = uluaGetVector3Index( L, 3 ); uluaPushVector3( L, Vector3Clamp( v, min, max ) ); @@ -1474,16 +1421,14 @@ Clamp the magnitude of the vector between two values - Success return Vector3 */ int lmathVector3ClampValue( lua_State *L ) { - if ( !lua_istable( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3ClampValue( Vector3 v, float min, float max )" ); lua_pushboolean( L, false ); return 1; } - float max = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - float min = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - Vector3 v = uluaGetVector3( L ); + Vector3 v = uluaGetVector3Index( L, 1 ); + float min = lua_tonumber( L, 2 ); + float max = lua_tonumber( L, 3 ); uluaPushVector3( L, Vector3ClampValue( v, min, max ) ); @@ -1499,14 +1444,13 @@ Check whether two given vectors are almost equal - Success return int */ int lmathVector3Equals( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3Equals( Vector3 v1, Vector3 v2 )" ); lua_pushboolean( L, false ); return 1; } - Vector3 v2 = uluaGetVector3( L ); - lua_pop( L, 1 ); - Vector3 v1 = uluaGetVector3( L ); + Vector3 v1 = uluaGetVector3Index( L, 1 ); + Vector3 v2 = uluaGetVector3Index( L, 2 ); lua_pushinteger( L, Vector3Equals( v1, v2 ) ); @@ -1527,16 +1471,14 @@ on the other side of the surface - Success return Vector3 */ int lmathVector3Refract( lua_State *L ) { - if ( !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.Vector3Refract( Vector3 v, Vector3 n, float r )" ); lua_pushboolean( L, false ); return 1; } - float r = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - Vector3 n = uluaGetVector3( L ); - lua_pop( L, 1 ); - Vector3 v = uluaGetVector3( L ); + Vector3 v = uluaGetVector3Index( L, 1 ); + Vector3 n = uluaGetVector3Index( L, 2 ); + float r = lua_tonumber( L, 3 ); uluaPushVector3( L, Vector3Refract( v, n, r ) ); @@ -1556,12 +1498,12 @@ Compute matrix determinant - Success return float */ int lmathMatrixDeterminant( lua_State *L ) { - if ( !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.MatrixDeterminant( Matrix mat )" ); lua_pushboolean( L, false ); return 1; } - Matrix mat = uluaGetMatrix( L ); + Matrix mat = uluaGetMatrixIndex( L, 1 ); lua_pushnumber( L, MatrixDeterminant( mat ) ); @@ -1577,12 +1519,12 @@ Get the trace of the matrix ( sum of the values along the diagonal ) - Success return float */ int lmathMatrixTrace( lua_State *L ) { - if ( !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.MatrixTrace( Matrix mat )" ); lua_pushboolean( L, false ); return 1; } - Matrix mat = uluaGetMatrix( L ); + Matrix mat = uluaGetMatrixIndex( L, 1 ); lua_pushnumber( L, MatrixTrace( mat ) ); @@ -1598,12 +1540,12 @@ Transposes provided matrix - Success return Matrix */ int lmathMatrixTranspose( lua_State *L ) { - if ( !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.MatrixTranspose( Matrix mat )" ); lua_pushboolean( L, false ); return 1; } - Matrix mat = uluaGetMatrix( L ); + Matrix mat = uluaGetMatrixIndex( L, 1 ); uluaPushMatrix( L, MatrixTranspose( mat ) ); @@ -1619,12 +1561,12 @@ Invert provided matrix - Success return Matrix */ int lmathMatrixInvert( lua_State *L ) { - if ( !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.MatrixInvert( Matrix mat )" ); lua_pushboolean( L, false ); return 1; } - Matrix mat = uluaGetMatrix( L ); + Matrix mat = uluaGetMatrixIndex( L, 1 ); uluaPushMatrix( L, MatrixInvert( mat ) ); @@ -1653,14 +1595,13 @@ Add two matrices - Success return Matrix */ int lmathMatrixAdd( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.MatrixAdd( Matrix left, Matrix right )" ); lua_pushboolean( L, false ); return 1; } - Matrix mat2 = uluaGetMatrix( L ); - lua_pop( L, 1 ); - Matrix mat1 = uluaGetMatrix( L ); + Matrix mat1 = uluaGetMatrixIndex( L, 1 ); + Matrix mat2 = uluaGetMatrixIndex( L, 2 ); uluaPushMatrix( L, MatrixAdd( mat1, mat2 ) ); @@ -1676,14 +1617,13 @@ Subtract two matrices (left - right) - Success return Matrix */ int lmathMatrixSubtract( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.MatrixSubtract( Matrix left, Matrix right )" ); lua_pushboolean( L, false ); return 1; } - Matrix mat2 = uluaGetMatrix( L ); - lua_pop( L, 1 ); - Matrix mat1 = uluaGetMatrix( L ); + Matrix mat1 = uluaGetMatrixIndex( L, 1 ); + Matrix mat2 = uluaGetMatrixIndex( L, 2 ); uluaPushMatrix( L, MatrixSubtract( mat1, mat2 ) ); @@ -1699,14 +1639,13 @@ Get two matrix multiplication - Success return Matrix */ int lmathMatrixMultiply( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.MatrixMultiply( Matrix left, Matrix right )" ); lua_pushboolean( L, false ); return 1; } - Matrix mat2 = uluaGetMatrix( L ); - lua_pop( L, 1 ); - Matrix mat1 = uluaGetMatrix( L ); + Matrix mat1 = uluaGetMatrixIndex( L, 1 ); + Matrix mat2 = uluaGetMatrixIndex( L, 2 ); uluaPushMatrix( L, MatrixMultiply( mat1, mat2 ) ); @@ -1722,12 +1661,12 @@ Get translation matrix - Success return Matrix */ int lmathMatrixTranslate( lua_State *L ) { - if ( !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.MatrixTranslate( Vector3 translate )" ); lua_pushboolean( L, false ); return 1; } - Vector3 v = uluaGetVector3( L ); + Vector3 v = uluaGetVector3Index( L, 1 ); uluaPushMatrix( L, MatrixTranslate( v.x, v.y, v.z ) ); @@ -1743,14 +1682,13 @@ Create rotation matrix from axis and angle. NOTE: Angle should be provided in ra - Success return Matrix */ int lmathMatrixRotate( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.MatrixRotate( Vector3 axis, float angle )" ); lua_pushboolean( L, false ); return 1; } - float angle = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - Vector3 axis = uluaGetVector3( L ); + Vector3 axis = uluaGetVector3Index( L, 1 ); + float angle = lua_tonumber( L, 2 ); uluaPushMatrix( L, MatrixRotate( axis, angle ) ); @@ -1766,12 +1704,12 @@ Get x-rotation matrix ( angle in radians ) - Success return Matrix */ int lmathMatrixRotateX( lua_State *L ) { - if ( !lua_isnumber( L, -1 ) ) { + if ( !lua_isnumber( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.MatrixRotateX( float angle )" ); lua_pushboolean( L, false ); return 1; } - float angle = lua_tonumber( L, -1 ); + float angle = lua_tonumber( L, 1 ); uluaPushMatrix( L, MatrixRotateX( angle ) ); @@ -1787,12 +1725,12 @@ Get y-rotation matrix ( angle in radians ) - Success return Matrix */ int lmathMatrixRotateY( lua_State *L ) { - if ( !lua_isnumber( L, -1 ) ) { + if ( !lua_isnumber( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.MatrixRotateY( float angle )" ); lua_pushboolean( L, false ); return 1; } - float angle = lua_tonumber( L, -1 ); + float angle = lua_tonumber( L, 1 ); uluaPushMatrix( L, MatrixRotateY( angle ) ); @@ -1808,12 +1746,12 @@ Get z-rotation matrix ( angle in radians ) - Success return Matrix */ int lmathMatrixRotateZ( lua_State *L ) { - if ( !lua_isnumber( L, -1 ) ) { + if ( !lua_isnumber( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.MatrixRotateZ( float angle )" ); lua_pushboolean( L, false ); return 1; } - float angle = lua_tonumber( L, -1 ); + float angle = lua_tonumber( L, 1 ); uluaPushMatrix( L, MatrixRotateZ( angle ) ); @@ -1829,12 +1767,12 @@ Get xyz-rotation matrix ( angles in radians ) - Success return Matrix */ int lmathMatrixRotateXYZ( lua_State *L ) { - if ( !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.MatrixRotateXYZ( Vector3 angle )" ); lua_pushboolean( L, false ); return 1; } - Vector3 angle = uluaGetVector3( L ); + Vector3 angle = uluaGetVector3Index( L, 1 ); uluaPushMatrix( L, MatrixRotateXYZ( angle ) ); @@ -1850,12 +1788,12 @@ Get zyx-rotation matrix ( angles in radians ) - Success return Matrix */ int lmathMatrixRotateZYX( lua_State *L ) { - if ( !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.MatrixRotateZYX( Vector3 angle )" ); lua_pushboolean( L, false ); return 1; } - Vector3 angle = uluaGetVector3( L ); + Vector3 angle = uluaGetVector3Index( L, 1 ); uluaPushMatrix( L, MatrixRotateZYX( angle ) ); @@ -1871,12 +1809,12 @@ Get scaling matrix - Success return Matrix */ int lmathMatrixScale( lua_State *L ) { - if ( !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.MatrixScale( Vector3 scale )" ); lua_pushboolean( L, false ); return 1; } - Vector3 v = uluaGetVector3( L ); + Vector3 v = uluaGetVector3Index( L, 1 ); uluaPushMatrix( L, MatrixScale( v.x, v.y, v.z ) ); @@ -1892,18 +1830,18 @@ Get perspective projection matrix - Success return Matrix */ int lmathMatrixFrustum( lua_State *L ) { - if ( !lua_isnumber( L, -6 ) || !lua_isnumber( L, -5 ) || !lua_isnumber( L, -4 ) - || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) + || !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_isnumber( L, 6 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.MatrixFrustum( double left, double right, double bottom, double top, double near, double far )" ); lua_pushboolean( L, false ); return 1; } - float far = lua_tonumber( L, -1 ); - float near = lua_tonumber( L, -2 ); - float top = lua_tonumber( L, -3 ); - float bottom = lua_tonumber( L, -4 ); - float right = lua_tonumber( L, -5 ); - float left = lua_tonumber( L, -6 ); + float left = lua_tonumber( L, 1 ); + float right = lua_tonumber( L, 2); + float bottom = lua_tonumber( L, 3 ); + float top = lua_tonumber( L, 4 ); + float near = lua_tonumber( L, 5 ); + float far = lua_tonumber( L, 6 ); uluaPushMatrix( L, MatrixFrustum( left, right, bottom, top, near, far ) ); @@ -1919,15 +1857,15 @@ Get perspective projection matrix - Success return Matrix */ int lmathMatrixPerspective( lua_State *L ) { - if ( !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.MatrixPerspective( double fovy, double aspect, double near, double far )" ); lua_pushboolean( L, false ); return 1; } - float far = lua_tonumber( L, -1 ); - float near = lua_tonumber( L, -2 ); - float aspect = lua_tonumber( L, -3 ); - float fovy = lua_tonumber( L, -4 ); + float fovy = lua_tonumber( L, 1 ); + float aspect = lua_tonumber( L, 2 ); + float near = lua_tonumber( L, 3 ); + float far = lua_tonumber( L, 4 ); uluaPushMatrix( L, MatrixPerspective( fovy, aspect, near, far ) ); @@ -1943,18 +1881,18 @@ Get orthographic projection matrix - Success return Matrix */ int lmathMatrixOrtho( lua_State *L ) { - if ( !lua_isnumber( L, -6 ) || !lua_isnumber( L, -5 ) || !lua_isnumber( L, -4 ) - || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) + || !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_isnumber( L, 6 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.MatrixOrtho( double left, double right, double bottom, double top, double near, double far )" ); lua_pushboolean( L, false ); return 1; } - float far = lua_tonumber( L, -1 ); - float near = lua_tonumber( L, -2 ); - float top = lua_tonumber( L, -3 ); - float bottom = lua_tonumber( L, -4 ); - float right = lua_tonumber( L, -5 ); - float left = lua_tonumber( L, -6 ); + float left = lua_tonumber( L, 1 ); + float right = lua_tonumber( L, 2 ); + float bottom = lua_tonumber( L, 3 ); + float top = lua_tonumber( L, 4 ); + float near = lua_tonumber( L, 5 ); + float far = lua_tonumber( L, 6 ); uluaPushMatrix( L, MatrixOrtho( left, right, bottom, top, near, far ) ); @@ -1970,16 +1908,14 @@ Get camera look-at matrix ( View matrix ) - Success return Matrix */ int lmathMatrixLookAt( lua_State *L ) { - if ( !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.MatrixLookAt( Vector3 eye, Vector3 target, Vector3 up )" ); lua_pushboolean( L, false ); return 1; } - Vector3 up = uluaGetVector3( L ); - lua_pop( L, 1 ); - Vector3 target = uluaGetVector3( L ); - lua_pop( L, 1 ); - Vector3 eye = uluaGetVector3( L ); + Vector3 eye = uluaGetVector3Index( L, 1 ); + Vector3 target = uluaGetVector3Index( L, 2 ); + Vector3 up = uluaGetVector3Index( L, 3 ); uluaPushMatrix( L, MatrixLookAt( eye, target, up ) ); @@ -1999,14 +1935,13 @@ Add two quaternions - Success return Quaternion */ int lmathQuaternionAdd( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.QuaternionAdd( Quaternion q1, Quaternion q2 )" ); lua_pushboolean( L, false ); return 1; } - Quaternion q2 = uluaGetQuaternion( L ); - lua_pop( L, 1 ); - Quaternion q1 = uluaGetQuaternion( L ); + Quaternion q1 = uluaGetQuaternionIndex( L, 1 ); + Quaternion q2 = uluaGetQuaternionIndex( L, 2 ); uluaPushQuaternion( L, QuaternionAdd( q1, q2 ) ); @@ -2022,14 +1957,13 @@ Add quaternion and float value - Success return Quaternion */ int lmathQuaternionAddValue( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.QuaternionAddValue( Quaternion q, float add )" ); lua_pushboolean( L, false ); return 1; } - float add = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - Quaternion q = uluaGetQuaternion( L ); + Quaternion q = uluaGetQuaternionIndex( L, 1 ); + float add = lua_tonumber( L, 2 ); uluaPushQuaternion( L, QuaternionAddValue( q, add ) ); @@ -2045,14 +1979,13 @@ Subtract two quaternions - Success return Quaternion */ int lmathQuaternionSubtract( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.QuaternionSubtract( Quaternion q1, Quaternion q2 )" ); lua_pushboolean( L, false ); return 1; } - Quaternion q2 = uluaGetQuaternion( L ); - lua_pop( L, 1 ); - Quaternion q1 = uluaGetQuaternion( L ); + Quaternion q1 = uluaGetQuaternionIndex( L, 1 ); + Quaternion q2 = uluaGetQuaternionIndex( L, 2 ); uluaPushQuaternion( L, QuaternionSubtract( q1, q2 ) ); @@ -2068,14 +2001,13 @@ Subtract quaternion and float value - Success return Quaternion */ int lmathQuaternionSubtractValue( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.QuaternionSubtractValue( Quaternion q, float sub )" ); lua_pushboolean( L, false ); return 1; } - float sub = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - Quaternion q = uluaGetQuaternion( L ); + Quaternion q = uluaGetQuaternionIndex( L, 1 ); + float sub = lua_tonumber( L, 2 ); uluaPushQuaternion( L, QuaternionSubtractValue( q, sub ) ); @@ -2104,12 +2036,12 @@ Computes the length of a quaternion - Success return float */ int lmathQuaternionLength( lua_State *L ) { - if ( !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.QuaternionLength( Quaternion q )" ); lua_pushboolean( L, false ); return 1; } - Quaternion q = uluaGetQuaternion( L ); + Quaternion q = uluaGetQuaternionIndex( L, 1 ); lua_pushnumber( L, QuaternionLength( q ) ); @@ -2125,12 +2057,12 @@ Normalize provided quaternion - Success return Quaternion */ int lmathQuaternionNormalize( lua_State *L ) { - if ( !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.QuaternionNormalize( Quaternion q )" ); lua_pushboolean( L, false ); return 1; } - Quaternion q = uluaGetQuaternion( L ); + Quaternion q = uluaGetQuaternionIndex( L, 1 ); uluaPushQuaternion( L, QuaternionNormalize( q ) ); @@ -2146,12 +2078,12 @@ Invert provided quaternion - Success return Quaternion */ int lmathQuaternionInvert( lua_State *L ) { - if ( !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.QuaternionInvert( Quaternion q )" ); lua_pushboolean( L, false ); return 1; } - Quaternion q = uluaGetQuaternion( L ); + Quaternion q = uluaGetQuaternionIndex( L, 1 ); uluaPushQuaternion( L, QuaternionInvert( q ) ); @@ -2167,14 +2099,13 @@ Calculate two quaternion multiplication - Success return Quaternion */ int lmathQuaternionMultiply( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.QuaternionMultiply( Quaternion q1, Quaternion q2 )" ); lua_pushboolean( L, false ); return 1; } - Quaternion q2 = uluaGetQuaternion( L ); - lua_pop( L, 1 ); - Quaternion q1 = uluaGetQuaternion( L ); + Quaternion q1 = uluaGetQuaternionIndex( L, 1 ); + Quaternion q2 = uluaGetQuaternionIndex( L, 2 ); uluaPushQuaternion( L, QuaternionMultiply( q1, q2 ) ); @@ -2190,14 +2121,13 @@ Scale quaternion by float value - Success return Quaternion */ int lmathQuaternionScale( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.QuaternionScale( Quaternion q, float mul )" ); lua_pushboolean( L, false ); return 1; } - float mul = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - Quaternion q = uluaGetQuaternion( L ); + Quaternion q = uluaGetQuaternionIndex( L, 1 ); + float mul = lua_tonumber( L, 2 ); uluaPushQuaternion( L, QuaternionScale( q, mul ) ); @@ -2213,14 +2143,13 @@ Divide two quaternions - Success return Quaternion */ int lmathQuaternionDivide( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.QuaternionDivide( Quaternion q1, Quaternion q2 )" ); lua_pushboolean( L, false ); return 1; } - Quaternion q2 = uluaGetQuaternion( L ); - lua_pop( L, 1 ); - Quaternion q1 = uluaGetQuaternion( L ); + Quaternion q1 = uluaGetQuaternionIndex( L, 1 ); + Quaternion q2 = uluaGetQuaternionIndex( L, 2 ); uluaPushQuaternion( L, QuaternionDivide( q1, q2 ) ); @@ -2236,16 +2165,14 @@ Calculate linear interpolation between two quaternions - Success return Quaternion */ int lmathQuaternionLerp( lua_State *L ) { - if ( !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.QuaternionLerp( Quaternion q1, Quaternion q2, float amount )" ); lua_pushboolean( L, false ); return 1; } - float amount = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - Quaternion q2 = uluaGetQuaternion( L ); - lua_pop( L, 1 ); - Quaternion q1 = uluaGetQuaternion( L ); + Quaternion q1 = uluaGetQuaternionIndex( L, 1 ); + Quaternion q2 = uluaGetQuaternionIndex( L, 2 ); + float amount = lua_tonumber( L, 3 ); uluaPushQuaternion( L, QuaternionLerp( q1, q2, amount ) ); @@ -2261,16 +2188,14 @@ Calculate slerp-optimized interpolation between two quaternions - Success return Quaternion */ int lmathQuaternionNlerp( lua_State *L ) { - if ( !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.QuaternionNlerp( Quaternion q1, Quaternion q2, float amount )" ); lua_pushboolean( L, false ); return 1; } - float amount = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - Quaternion q2 = uluaGetQuaternion( L ); - lua_pop( L, 1 ); - Quaternion q1 = uluaGetQuaternion( L ); + Quaternion q1 = uluaGetQuaternionIndex( L, 1 ); + Quaternion q2 = uluaGetQuaternionIndex( L, 2 ); + float amount = lua_tonumber( L, 3 ); uluaPushQuaternion( L, QuaternionNlerp( q1, q2, amount ) ); @@ -2286,16 +2211,14 @@ Calculates spherical linear interpolation between two quaternions - Success return Quaternion */ int lmathQuaternionSlerp( lua_State *L ) { - if ( !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.QuaternionSlerp( Quaternion q1, Quaternion q2, float amount )" ); lua_pushboolean( L, false ); return 1; } - float amount = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - Quaternion q2 = uluaGetQuaternion( L ); - lua_pop( L, 1 ); - Quaternion q1 = uluaGetQuaternion( L ); + Quaternion q1 = uluaGetQuaternionIndex( L, 1 ); + Quaternion q2 = uluaGetQuaternionIndex( L, 2 ); + float amount = lua_tonumber( L, 3 ); uluaPushQuaternion( L, QuaternionSlerp( q1, q2, amount ) ); @@ -2311,14 +2234,13 @@ Calculate quaternion based on the rotation from one vector to another - Success return Quaternion */ int lmathQuaternionFromVector3ToVector3( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.QuaternionFromVector3ToVector3( Vector3 from, Vector3 to )" ); lua_pushboolean( L, false ); return 1; } - Vector3 to = uluaGetVector3( L ); - lua_pop( L, 1 ); - Vector3 from = uluaGetVector3( L ); + Vector3 from = uluaGetVector3Index( L, 1 ); + Vector3 to = uluaGetVector3Index( L, 2 ); uluaPushQuaternion( L, QuaternionFromVector3ToVector3( from, to ) ); @@ -2334,12 +2256,12 @@ Get a quaternion for a given rotation matrix - Success return Quaternion */ int lmathQuaternionFromMatrix( lua_State *L ) { - if ( !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.QuaternionFromMatrix( Matrix mat )" ); lua_pushboolean( L, false ); return 1; } - Matrix mat = uluaGetMatrix( L ); + Matrix mat = uluaGetMatrixIndex( L, 1 ); uluaPushQuaternion( L, QuaternionFromMatrix( mat ) ); @@ -2355,12 +2277,12 @@ Get a quaternion for a given rotation matrix - Success return Matrix */ int lmathQuaternionToMatrix( lua_State *L ) { - if ( !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.QuaternionToMatrix( Quaternion q )" ); lua_pushboolean( L, false ); return 1; } - Quaternion q = uluaGetQuaternion( L ); + Quaternion q = uluaGetQuaternionIndex( L, 1 ); uluaPushMatrix( L, QuaternionToMatrix( q ) ); @@ -2377,14 +2299,13 @@ NOTE: angle must be provided in radians - Success return Quaternion */ int lmathQuaternionFromAxisAngle( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.QuaternionFromAxisAngle( Vector3 axis, float angle )" ); lua_pushboolean( L, false ); return 1; } - float angle = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - Vector3 axis = uluaGetVector3( L ); + Vector3 axis = uluaGetVector3Index( L, 1 ); + float angle = lua_tonumber( L, 2 ); uluaPushQuaternion( L, QuaternionFromAxisAngle( axis, angle ) ); @@ -2400,12 +2321,12 @@ Get the rotation angle and axis for a given quaternion - Success return Vector3, float */ int lmathQuaternionToAxisAngle( lua_State *L ) { - if ( !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.QuaternionToAxisAngle( Quaternion q )" ); lua_pushboolean( L, false ); return 1; } - Quaternion q = uluaGetQuaternion( L ); + Quaternion q = uluaGetQuaternionIndex( L, 1 ); float angle = 0.0; Vector3 axis = { 0.0 }; @@ -2427,14 +2348,14 @@ NOTE: Rotation order is ZYX - Success return Quaternion */ int lmathQuaternionFromEuler( lua_State *L ) { - if ( !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.QuaternionFromEuler( float pitch, float yaw, float roll )" ); lua_pushboolean( L, false ); return 1; } - float roll = lua_tonumber( L, -1 ); - float yaw = lua_tonumber( L, -2 ); - float pitch = lua_tonumber( L, -3 ); + float pitch = lua_tonumber( L, 1 ); + float yaw = lua_tonumber( L, 2 ); + float roll = lua_tonumber( L, 3 ); uluaPushQuaternion( L, QuaternionFromEuler( pitch, yaw, roll ) ); @@ -2451,12 +2372,12 @@ NOTE: Angles are returned in a Vector3 struct in radians - Success return Vector3 */ int lmathQuaternionToEuler( lua_State *L ) { - if ( !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.QuaternionToEuler( Quaternion q )" ); lua_pushboolean( L, false ); return 1; } - Quaternion q = uluaGetQuaternion( L ); + Quaternion q = uluaGetQuaternionIndex( L, 1 ); uluaPushVector3( L, QuaternionToEuler( q ) ); @@ -2472,14 +2393,13 @@ Transform a quaternion given a transformation matrix - Success return Quaternion */ int lmathQuaternionTransform( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.QuaternionTransform( Quaternion q, Matrix mat )" ); lua_pushboolean( L, false ); return 1; } - Matrix mat = uluaGetMatrix( L ); - lua_pop( L, 1 ); - Quaternion q = uluaGetQuaternion( L ); + Quaternion q = uluaGetQuaternionIndex( L, 1 ); + Matrix mat = uluaGetMatrixIndex( L, 2 ); uluaPushQuaternion( L, QuaternionTransform( q, mat ) ); @@ -2495,14 +2415,13 @@ Check whether two given quaternions are almost equal - Success return int */ int lmathQuaternionEquals( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.QuaternionEquals( Quaternion q1, Quaternion q2 )" ); lua_pushboolean( L, false ); return 1; } - Quaternion q2 = uluaGetQuaternion( L ); - lua_pop( L, 1 ); - Quaternion q1 = uluaGetQuaternion( L ); + Quaternion q1 = uluaGetQuaternionIndex( L, 1 ); + Quaternion q2 = uluaGetQuaternionIndex( L, 2 ); lua_pushinteger( L, QuaternionEquals( q1, q2 ) ); @@ -29,6 +29,20 @@ bool validFont( size_t id ) { } } +static int newFont() { + int i = 0; + + for ( i = 0; i < state->fontCount; i++ ) { + if ( state->fonts[i] == NULL ) { + break; + } + } + state->fonts[i] = malloc( sizeof( Font ) ); + checkFontRealloc( i ); + + return i; +} + /* ## Text - Loading */ @@ -42,22 +56,21 @@ Load font from file into GPU memory ( VRAM ) - Success return int */ int ltextLoadFont( lua_State *L ) { - if ( !lua_isstring( L, -1 ) ) { + if ( !lua_isstring( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.LoadFont( string fileName )" ); lua_pushinteger( L, -1 ); return 1; } - int i = 0; - - for ( i = 0; i < state->fontCount; i++ ) { - if ( state->fonts[i] == NULL ) { - break; - } + if ( FileExists( lua_tostring( L, 1 ) ) ) { + int i = newFont(); + *state->fonts[i] = LoadFont( lua_tostring( L, 1 ) ); + lua_pushinteger( L, i ); + return 1; + } + else { + lua_pushinteger( L, -1 ); + return 1; } - state->fonts[i] = malloc( sizeof( Font ) ); - *state->fonts[i] = LoadFont( lua_tostring( L, -1 ) ); - lua_pushinteger( L, i ); - checkFontRealloc( i ); return 1; } @@ -71,22 +84,23 @@ Load font from file with extended parameters. Loading the default character set - Success return int */ int ltextLoadFontEx( lua_State *L ) { - if ( !lua_isstring( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_isstring( L, 1 ) || !lua_isnumber( L, 2 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.LoadFontEx( string fileName, int fontSize )" ); lua_pushinteger( L, -1 ); return 1; } - int i = 0; + int fontSize = lua_tointeger( L, 2 ); - for ( i = 0; i < state->fontCount; i++ ) { - if ( state->fonts[i] == NULL ) { - break; - } + if ( FileExists( lua_tostring( L, 1 ) ) ) { + int i = newFont(); + *state->fonts[i] = LoadFontEx( lua_tostring( L, 1 ), fontSize, NULL, 0 ); + lua_pushinteger( L, i ); + return 1; + } + else { + lua_pushinteger( L, -1 ); + return 1; } - state->fonts[i] = malloc( sizeof( Font ) ); - *state->fonts[i] = LoadFontEx( lua_tostring( L, -2 ), lua_tointeger( L, - 1 ), NULL, 0 ); - lua_pushinteger( L, i ); - checkFontRealloc( i ); return 1; } @@ -100,34 +114,23 @@ Load font from Image ( XNA style ) - Success return int */ int ltextLoadFontFromImage( lua_State *L ) { - if ( !lua_isnumber( L, -3 ) || !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_isnumber( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.LoadFontFromImage( Image image, Color key, int firstChar )" ); lua_pushinteger( L, -1 ); return 1; } - int i = 0; - - for ( i = 0; i < state->fontCount; i++ ) { - if ( state->fonts[i] == NULL ) { - break; - } - } - - int firstChar = lua_tointeger( L, -1 ); - lua_pop( L, 1 ); - Color key = uluaGetColor( L ); - lua_pop( L, 1 ); - size_t imageId = lua_tointeger( L, -1 ); + size_t imageId = lua_tointeger( L, 1 ); + Color key = uluaGetColorIndex( L, 2 ); + int firstChar = lua_tointeger( L, 3 ); if ( !validImage( imageId ) ) { lua_pushboolean( L, false ); return 1; } - state->fonts[i] = malloc( sizeof( Font ) ); + int i = newFont(); *state->fonts[i] = LoadFontFromImage( *state->images[ imageId ], key, firstChar ); lua_pushinteger( L, i ); - checkFontRealloc( i ); return 1; } @@ -141,19 +144,19 @@ Unload Font from GPU memory ( VRAM ) - Success return true */ int ltextUnloadFont( lua_State *L ) { - if ( !lua_isnumber( L, -1 ) ) { + if ( !lua_isnumber( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.UnloadFont( Font font )" ); lua_pushboolean( L, false ); return 1; } - size_t id = lua_tointeger( L, -1 ); + size_t FontId = lua_tointeger( L, 1 ); - if ( !validFont( id ) ) { + if ( !validFont( FontId ) ) { lua_pushboolean( L, false ); return 1; } - UnloadFont( *state->fonts[ id ] ); - state->fonts[ id ] = NULL; + UnloadFont( *state->fonts[ FontId ] ); + state->fonts[ FontId ] = NULL; lua_pushboolean( L, true ); return 1; @@ -172,12 +175,12 @@ Draw current FPS - Success return true */ int ltextDrawFPS( lua_State *L ) { - if ( !lua_istable( L, -1 ) ) { + if ( !lua_istable( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawFPS( Vector2 pos )" ); lua_pushboolean( L, false ); return 1; } - Vector2 pos = uluaGetVector2( L ); + Vector2 pos = uluaGetVector2Index( L, 1 ); DrawFPS( pos.x, pos.y ); lua_pushboolean( L, true ); @@ -194,27 +197,23 @@ Draw text using font and additional parameters - Success return true */ int ltextDrawText( lua_State *L ) { - if ( !lua_isnumber( L, -6 ) || !lua_isstring( L, -5 ) || !lua_istable( L, -4 ) - || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_isnumber( L, 1 ) || !lua_isstring( L, 2 ) || !lua_istable( L, 3 ) + || !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_istable( L, 6 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawText( Font font, string text, Vector2 position, float fontSize, float spacing, Color tint )" ); lua_pushboolean( L, false ); return 1; } - Color color = uluaGetColor( L ); - lua_pop( L, 1 ); - float spacing = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - float fontSize = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - Vector2 position = uluaGetVector2( L ); - lua_pop( L, 1 ); - size_t fontId = lua_tointeger( L, -2 ); + size_t fontId = lua_tointeger( L, 1 ); + Vector2 position = uluaGetVector2Index( L, 3 ); + float fontSize = lua_tonumber( L, 4 ); + float spacing = lua_tonumber( L, 5 ); + Color tint = uluaGetColorIndex( L, 6 ); if ( !validFont( fontId ) ) { lua_pushboolean( L, false ); return 1; } - DrawTextEx( *state->fonts[ fontId ], lua_tostring( L, -1 ), position, fontSize, spacing, color ); + DrawTextEx( *state->fonts[ fontId ], lua_tostring( L, 2 ), position, fontSize, spacing, tint ); lua_pushboolean( L, true ); return 1; @@ -229,31 +228,25 @@ Draw text using Font and pro parameters ( rotation ) - Success return true */ int ltextDrawTextPro( lua_State *L ) { - if ( !lua_isnumber( L, -8 ) || !lua_isstring( L, -7 ) || !lua_istable( L, -6 ) || !lua_istable( L, -5 ) - || !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_istable( L, -1 ) ) { + if ( !lua_isnumber( L, 1 ) || !lua_isstring( L, 2 ) || !lua_istable( L, 3 ) || !lua_istable( L, 4 ) + || !lua_isnumber( L, 5 ) || !lua_isnumber( L, 6 ) || !lua_isnumber( L, 7 ) || !lua_istable( L, 8 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawTextPro( Font font, string text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, Color tint )" ); lua_pushboolean( L, false ); return 1; } - Color color = uluaGetColor( L ); - lua_pop( L, 1 ); - float spacing = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - float fontSize = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - float rotation = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - Vector2 origin = uluaGetVector2( L ); - lua_pop( L, 1 ); - Vector2 position = uluaGetVector2( L ); - lua_pop( L, 1 ); - size_t fontId = lua_tointeger( L, -2 ); + size_t fontId = lua_tointeger( L, 1 ); + Vector2 position = uluaGetVector2Index( L, 3 ); + Vector2 origin = uluaGetVector2Index( L, 4 ); + float rotation = lua_tonumber( L, 5 ); + float fontSize = lua_tonumber( L, 6 ); + float spacing = lua_tonumber( L, 7 ); + Color tint = uluaGetColorIndex( L, 8 ); if ( !validFont( fontId ) ) { lua_pushboolean( L, false ); return 1; } - DrawTextPro( *state->fonts[ fontId ], lua_tostring( L, -1 ), position, origin, rotation, fontSize, spacing, color ); + DrawTextPro( *state->fonts[ fontId ], lua_tostring( L, 2 ), position, origin, rotation, fontSize, spacing, tint ); lua_pushboolean( L, true ); return 1; @@ -272,22 +265,20 @@ Measure string size for Font - Success return Vector2 */ int ltextMeasureText( lua_State *L ) { - if ( !lua_isnumber( L, -4 ) || !lua_isstring( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) { + if ( !lua_isnumber( L, 1 ) || !lua_isstring( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.MeasureText( Font font, string text, float fontSize, float spacing )" ); lua_pushboolean( L, false ); return 1; } - float spacing = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - float fontSize = lua_tonumber( L, -1 ); - lua_pop( L, 1 ); - size_t fontId = lua_tointeger( L, -2 ); + size_t fontId = lua_tointeger( L, 1 ); + float fontSize = lua_tonumber( L, 3 ); + float spacing = lua_tonumber( L, 4 ); if ( !validFont( fontId ) ) { lua_pushboolean( L, false ); return 1; } - uluaPushVector2( L, MeasureTextEx( *state->fonts[ fontId ], lua_tostring( L, -1 ), fontSize, spacing ) ); + uluaPushVector2( L, MeasureTextEx( *state->fonts[ fontId ], lua_tostring( L, 2 ), fontSize, spacing ) ); return 1; } @@ -301,12 +292,12 @@ Get font baseSize - Success return int */ int ltextGetFontBaseSize( lua_State *L ) { - if ( !lua_isnumber( L, -1 ) ) { + if ( !lua_isnumber( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.GetFontBaseSize( Font font )" ); lua_pushboolean( L, false ); return 1; } - size_t fontId = lua_tointeger( L, -1 ); + size_t fontId = lua_tointeger( L, 1 ); if ( !validFont( fontId ) ) { lua_pushboolean( L, false ); @@ -326,12 +317,12 @@ Get font glyphCount - Success return int */ int ltextGetFontGlyphCount( lua_State *L ) { - if ( !lua_isnumber( L, -1 ) ) { + if ( !lua_isnumber( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.GetFontGlyphCount( Font font )" ); lua_pushboolean( L, false ); return 1; } - size_t fontId = lua_tointeger( L, -1 ); + size_t fontId = lua_tointeger( L, 1 ); if ( !validFont( fontId ) ) { lua_pushboolean( L, false ); @@ -351,12 +342,12 @@ Get font glyphPadding - Success return int */ int ltextGetFontGlyphPadding( lua_State *L ) { - if ( !lua_isnumber( L, -1 ) ) { + if ( !lua_isnumber( L, 1 ) ) { TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.GetFontGlyphPadding( Font font )" ); lua_pushboolean( L, false ); return 1; } - size_t fontId = lua_tointeger( L, -1 ); + size_t fontId = lua_tointeger( L, 1 ); if ( !validFont( fontId ) ) { lua_pushboolean( L, false ); |
