diff options
| author | jussi | 2023-10-29 15:21:10 +0200 |
|---|---|---|
| committer | jussi | 2023-10-29 15:21:10 +0200 |
| commit | 0df40e2ac080364bcebd4fe0445b814230545477 (patch) | |
| tree | 36be0ab558d6642352c0bb3034b6e6b32471716d | |
| parent | 76911d45a879838047b2845cd6124e9ca3af083a (diff) | |
| download | reilua-enhanced-0df40e2ac080364bcebd4fe0445b814230545477.tar.gz reilua-enhanced-0df40e2ac080364bcebd4fe0445b814230545477.tar.bz2 reilua-enhanced-0df40e2ac080364bcebd4fe0445b814230545477.zip | |
Shapes, RLGL, Math, Gui and Easings to new style.
| -rw-r--r-- | API.md | 768 | ||||
| -rw-r--r-- | ReiLua_API.lua | 867 | ||||
| -rw-r--r-- | src/core.c | 2 | ||||
| -rw-r--r-- | src/easings.c | 350 | ||||
| -rw-r--r-- | src/gl.c | 14 | ||||
| -rw-r--r-- | src/lua_core.c | 73 | ||||
| -rw-r--r-- | src/rgui.c | 559 | ||||
| -rw-r--r-- | src/rlgl.c | 979 | ||||
| -rw-r--r-- | src/rmath.c | 777 | ||||
| -rw-r--r-- | src/shapes.c | 588 | ||||
| -rw-r--r-- | src/textures.c | 29 |
11 files changed, 1065 insertions, 3941 deletions
@@ -2771,283 +2771,190 @@ defining a font char white rectangle would allow drawing everything in a single --- -> success = RL.DrawPixel( Vector2 pos, Color color ) +> RL.DrawPixel( Vector2 pos, Color color ) Draw a pixel -- Failure return false -- Success return true - --- -> success = RL.DrawLine( Vector2 startPos, Vector2 endPos, float thickness, Color color ) +> RL.DrawLine( Vector2 startPos, Vector2 endPos, float thickness, Color color ) Draw a line defining thickness -- Failure return false -- Success return true - --- -> success = RL.DrawLineBezier( Vector2 startPos, Vector2 endPos, float thickness, Color color ) +> RL.DrawLineBezier( Vector2 startPos, Vector2 endPos, float thickness, Color color ) Draw a line using cubic-bezier curves in-out -- Failure return false -- Success return true - --- -> success = RL.DrawLineBezierQuad( Vector2 startPos, Vector2 endPos, Vector2 controlPos, float thickness, Color color ) +> RL.DrawLineBezierQuad( Vector2 startPos, Vector2 endPos, Vector2 controlPos, float thickness, Color color ) Draw line using quadratic bezier curves with a control point -- Failure return false -- Success return true - --- -> success = RL.DrawLineBezierCubic( Vector2 startPos, Vector2 endPos, Vector2 startControlPos, Vector2 endControlPos, float thickness, Color color ) +> RL.DrawLineBezierCubic( Vector2 startPos, Vector2 endPos, Vector2 startControlPos, Vector2 endControlPos, float thickness, Color color ) Draw line using quadratic bezier curves with a control point -- Failure return false -- Success return true - --- -> success = RL.DrawLineStrip( Vector2{} points, Color color ) +> RL.DrawLineStrip( Vector2{} points, Color color ) Draw lines sequence -- Failure return false -- Success return true - --- -> success = RL.DrawCircle( Vector2 center, float radius, Color color ) +> RL.DrawCircle( Vector2 center, float radius, Color color ) Draw a color-filled circle -- Failure return false -- Success return true - --- -> success = RL.DrawCircleSector( Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color ) +> RL.DrawCircleSector( Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color ) Draw a piece of a circle -- Failure return false -- Success return true - --- -> success = RL.DrawCircleSectorLines( Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color ) +> RL.DrawCircleSectorLines( Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color ) Draw circle sector outline -- Failure return false -- Success return true - --- -> success = RL.DrawCircleGradient( Vector2 center, float radius, Color color1, Color color2 ) +> RL.DrawCircleGradient( Vector2 center, float radius, Color color1, Color color2 ) Draw a gradient-filled circle -- Failure return false -- Success return true - --- -> success = RL.DrawCircleLines( Vector2 center, float radius, Color color ) +> RL.DrawCircleLines( Vector2 center, float radius, Color color ) Draw circle outline -- Failure return false -- Success return true - --- -> success = RL.DrawEllipse( Vector2 center, float radiusH, float radiusV, Color color ) +> RL.DrawEllipse( Vector2 center, float radiusH, float radiusV, Color color ) Draw ellipse -- Failure return false -- Success return true - --- -> success = RL.DrawEllipseLines( Vector2 center, float radiusH, float radiusV, Color color ) +> RL.DrawEllipseLines( Vector2 center, float radiusH, float radiusV, Color color ) Draw ellipse outline -- Failure return false -- Success return true - --- -> success = RL.DrawRing( Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color ) +> RL.DrawRing( Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color ) Draw ring -- Failure return false -- Success return true - --- -> success = RL.DrawRingLines( Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color ) +> RL.DrawRingLines( Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color ) Draw ring outline -- Failure return false -- Success return true - --- -> success = RL.DrawRectangle( Rectangle rec, Color color ) +> RL.DrawRectangle( Rectangle rec, Color color ) Draw a color-filled rectangle -- Failure return false -- Success return true - --- -> success = RL.DrawRectanglePro( Rectangle rec, Vector2 origin, float rotation, Color color ) +> RL.DrawRectanglePro( Rectangle rec, Vector2 origin, float rotation, Color color ) Draw a color-filled rectangle with pro parameters -- Failure return false -- Success return true - --- -> success = RL.DrawRectangleGradientV( Rectangle rectangle, Color color1, Color color2 ) +> RL.DrawRectangleGradientV( Rectangle rectangle, Color color1, Color color2 ) Draw a vertical-gradient-filled rectangle -- Failure return false -- Success return true - --- -> success = RL.DrawRectangleGradientH( Rectangle rectangle, Color color1, Color color2 ) +> RL.DrawRectangleGradientH( Rectangle rectangle, Color color1, Color color2 ) Draw a horizontal-gradient-filled rectangle -- Failure return false -- Success return true - --- -> success = RL.DrawRectangleGradientEx( Rectangle rectangle, Color col1, Color col2, Color col3, Color col4 ) +> RL.DrawRectangleGradientEx( Rectangle rectangle, Color col1, Color col2, Color col3, Color col4 ) Draw a gradient-filled rectangle with custom vertex colors -- Failure return false -- Success return true - --- -> success = RL.DrawRectangleLines( Rectangle rec, Color color ) +> RL.DrawRectangleLines( Rectangle rec, Color color ) Draw rectangle outline -- Failure return false -- Success return true - --- -> success = RL.DrawRectangleLinesEx( Rectangle rec, int lineThick, Color color ) +> RL.DrawRectangleLinesEx( Rectangle rec, int lineThick, Color color ) Draw rectangle outline with extended parameters -- Failure return false -- Success return true - --- -> success = RL.DrawRectangleRounded( Rectangle rec, float roundness, int segments, Color color ) +> RL.DrawRectangleRounded( Rectangle rec, float roundness, int segments, Color color ) Draw rectangle with rounded edges -- Failure return false -- Success return true - --- -> success = RL.DrawRectangleRoundedLines( Rectangle rec, float roundness, int segments, int lineThick, Color color ) +> RL.DrawRectangleRoundedLines( Rectangle rec, float roundness, int segments, int lineThick, Color color ) Draw rectangle with rounded edges outline -- Failure return false -- Success return true - --- -> success = RL.DrawTriangle( Vector2 v1, Vector2 v2, Vector2 v3, Color color ) - -Draw a color-filled triangle ( Vertex in counter-clockwise order! ) +> RL.DrawTriangle( Vector2 v1, Vector2 v2, Vector2 v3, Color color ) -- Failure return false -- Success return true +Draw a color-filled triangle (Vertex in counter-clockwise order!) --- -> success = RL.DrawTriangleLines( Vector2 v1, Vector2 v2, Vector2 v3, Color color ) +> RL.DrawTriangleLines( Vector2 v1, Vector2 v2, Vector2 v3, Color color ) -Draw triangle outline ( Vertex in counter-clockwise order! ) - -- Failure return false -- Success return true +Draw triangle outline (Vertex in counter-clockwise order!) --- -> success = RL.DrawTriangleFan( Vector2{} points, Color color ) - -Draw a triangle fan defined by points ( first vertex is the center ) +> RL.DrawTriangleFan( Vector2{} points, Color color ) -- Failure return false -- Success return true +Draw a triangle fan defined by points (first vertex is the center) --- -> success = RL.DrawTriangleStrip( Vector2{} points, Color color ) +> RL.DrawTriangleStrip( Vector2{} points, Color color ) Draw a triangle strip defined by points -- Failure return false -- Success return true - --- -> success = RL.DrawPoly( Vector2 center, int sides, float radius, float rotation, Color color ) +> RL.DrawPoly( Vector2 center, int sides, float radius, float rotation, Color color ) -Draw a regular polygon ( Vector version ) - -- Failure return false -- Success return true +Draw a regular polygon (Vector version) --- -> success = RL.DrawPolyLines( Vector2 center, int sides, float radius, float rotation, Color color ) +> RL.DrawPolyLines( Vector2 center, int sides, float radius, float rotation, Color color ) Draw a polygon outline of n sides -- Failure return false -- Success return true - --- -> success = RL.DrawPolyLinesEx( Vector2 center, int sides, float radius, float rotation, float lineThick, Color color ) +> RL.DrawPolyLinesEx( Vector2 center, int sides, float radius, float rotation, float lineThick, Color color ) Draw a polygon outline of n sides with extended parameters -- Failure return false -- Success return true - --- ## Shapes - Collision @@ -3058,7 +2965,6 @@ Draw a polygon outline of n sides with extended parameters Check collision between two rectangles -- Failure return nil - Success return bool --- @@ -3067,7 +2973,6 @@ Check collision between two rectangles Check collision between two circles -- Failure return nil - Success return bool --- @@ -3076,7 +2981,6 @@ Check collision between two circles Check collision between circle and rectangle -- Failure return nil - Success return bool --- @@ -3085,7 +2989,6 @@ Check collision between circle and rectangle Check if point is inside rectangle -- Failure return nil - Success return bool --- @@ -3094,7 +2997,6 @@ Check if point is inside rectangle Check if point is inside circle -- Failure return nil - Success return bool --- @@ -3103,7 +3005,6 @@ Check if point is inside circle Check if point is inside a triangle -- Failure return nil - Success return bool --- @@ -3112,7 +3013,6 @@ Check if point is inside a triangle Check if point is within a polygon described by array of vertices -- Failure return nil - Success return bool --- @@ -3121,7 +3021,6 @@ Check if point is within a polygon described by array of vertices Check the collision between two lines defined by two points each, returns collision point by reference -- Failure return nil - Success return bool, Vector2 --- @@ -3130,7 +3029,6 @@ Check the collision between two lines defined by two points each, returns collis Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold] -- Failure return nil - Success return bool --- @@ -3139,7 +3037,6 @@ Check if point belongs to line created between two points [p1] and [p2] with def Get collision rectangle for two rectangles collision -- Failure return nil - Success return Rectangle --- @@ -3288,8 +3185,7 @@ Create an image from another image piece Create an image from text (custom sprite font) -- Failure return -1 -- Success return int +- Success return Image --- @@ -4721,7 +4617,6 @@ Get current music time played (in seconds) Clamp float value -- Failure return false - Success return float --- @@ -4730,7 +4625,6 @@ Clamp float value Calculate linear interpolation between two floats -- Failure return false - Success return float --- @@ -4739,7 +4633,6 @@ Calculate linear interpolation between two floats Normalize input value within input range -- Failure return false - Success return float --- @@ -4748,7 +4641,6 @@ Normalize input value within input range Remap input value within input range to output range -- Failure return false - Success return float --- @@ -4757,7 +4649,6 @@ Remap input value within input range to output range Wrap input value from min to max -- Failure return false - Success return float --- @@ -4766,7 +4657,6 @@ Wrap input value from min to max Check whether two given floats are almost equal -- Failure return false - Success return int --- @@ -4795,7 +4685,6 @@ Vector with components value 1.0f Add two vectors (v1 + v2) -- Failure return false - Success return Vector2 --- @@ -4804,7 +4693,6 @@ Add two vectors (v1 + v2) Add vector and float value -- Failure return false - Success return Vector2 --- @@ -4813,7 +4701,6 @@ Add vector and float value Subtract two vectors (v1 - v2) -- Failure return false - Success return Vector2 --- @@ -4822,7 +4709,6 @@ Subtract two vectors (v1 - v2) Subtract vector by float value -- Failure return false - Success return Vector2 --- @@ -4831,7 +4717,6 @@ Subtract vector by float value Calculate vector length -- Failure return false - Success return float --- @@ -4840,7 +4725,6 @@ Calculate vector length Calculate vector square length -- Failure return false - Success return float --- @@ -4849,7 +4733,6 @@ Calculate vector square length Calculate two vectors dot product -- Failure return false - Success return float --- @@ -4858,7 +4741,6 @@ Calculate two vectors dot product Calculate distance between two vectors -- Failure return false - Success return float --- @@ -4867,7 +4749,6 @@ Calculate distance between two vectors Calculate square distance between two vectors -- Failure return false - Success return float --- @@ -4876,7 +4757,6 @@ Calculate square distance between two vectors Calculate angle from two vectors -- Failure return false - Success return float --- @@ -4887,16 +4767,14 @@ Calculate angle defined by a two vectors line. NOTE: Parameters need to be normalized. Current implementation should be aligned with glm::angle. -- Failure return false - Success return float --- > result = RL.Vector2Scale( Vector2 v, float scale ) -Scale vector ( multiply by value ) +Scale vector (multiply by value) -- Failure return false - Success return Vector2 --- @@ -4905,7 +4783,6 @@ Scale vector ( multiply by value ) Multiply vector by vector -- Failure return false - Success return Vector2 --- @@ -4914,7 +4791,6 @@ Multiply vector by vector Negate vector -- Failure return false - Success return Vector2 --- @@ -4923,7 +4799,6 @@ Negate vector Divide vector by vector -- Failure return false - Success return Vector2 --- @@ -4932,7 +4807,6 @@ Divide vector by vector Normalize provided vector -- Failure return false - Success return Vector2 --- @@ -4941,7 +4815,6 @@ Normalize provided vector Transforms a Vector2 by a given Matrix -- Failure return false - Success return Vector2 --- @@ -4950,7 +4823,6 @@ Transforms a Vector2 by a given Matrix Calculate linear interpolation between two vectors -- Failure return false - Success return Vector2 --- @@ -4959,7 +4831,6 @@ Calculate linear interpolation between two vectors Calculate reflected vector to normal -- Failure return false - Success return Vector2 --- @@ -4968,7 +4839,6 @@ Calculate reflected vector to normal Rotate vector by angle -- Failure return false - Success return Vector2 --- @@ -4977,7 +4847,6 @@ Rotate vector by angle Move Vector towards target -- Failure return false - Success return Vector2 --- @@ -4986,7 +4855,6 @@ Move Vector towards target Invert the given vector -- Failure return false - Success return Vector2 --- @@ -4996,7 +4864,6 @@ Invert the given vector Clamp the components of the vector between min and max values specified by the given vectors -- Failure return false - Success return Vector2 --- @@ -5005,7 +4872,6 @@ min and max values specified by the given vectors Clamp the magnitude of the vector between two min and max values -- Failure return false - Success return Vector2 --- @@ -5014,7 +4880,6 @@ Clamp the magnitude of the vector between two min and max values Check whether two given vectors are almost equal -- Failure return false - Success return int --- @@ -5043,7 +4908,6 @@ Vector with components value 1.0f Add two vectors -- Failure return false - Success return Vector3 --- @@ -5052,7 +4916,6 @@ Add two vectors Add vector and float value -- Failure return false - Success return Vector3 --- @@ -5061,7 +4924,6 @@ Add vector and float value Subtract two vectors -- Failure return false - Success return Vector3 --- @@ -5070,7 +4932,6 @@ Subtract two vectors Subtract vector by float value -- Failure return false - Success return Vector3 --- @@ -5079,7 +4940,6 @@ Subtract vector by float value Multiply vector by scalar -- Failure return false - Success return Vector3 --- @@ -5088,7 +4948,6 @@ Multiply vector by scalar Multiply vector by vector -- Failure return false - Success return Vector3 --- @@ -5097,7 +4956,6 @@ Multiply vector by vector Calculate two vectors cross product -- Failure return false - Success return Vector3 --- @@ -5106,7 +4964,6 @@ Calculate two vectors cross product Calculate one vector perpendicular vector -- Failure return false - Success return Vector3 --- @@ -5115,7 +4972,6 @@ Calculate one vector perpendicular vector Calculate vector length -- Failure return false - Success return float --- @@ -5124,7 +4980,6 @@ Calculate vector length Calculate vector square length -- Failure return false - Success return float --- @@ -5133,7 +4988,6 @@ Calculate vector square length Calculate two vectors dot product -- Failure return false - Success return float --- @@ -5142,7 +4996,6 @@ Calculate two vectors dot product Calculate distance between two vectors -- Failure return false - Success return float --- @@ -5151,7 +5004,6 @@ Calculate distance between two vectors Calculate square distance between two vectors -- Failure return false - Success return float --- @@ -5160,16 +5012,14 @@ Calculate square distance between two vectors Calculate angle between two vectors -- Failure return false - Success return float --- > result = RL.Vector3Negate( Vector3 v ) -Negate provided vector ( invert direction ) +Negate provided vector (invert direction) -- Failure return false - Success return Vector3 --- @@ -5178,7 +5028,6 @@ Negate provided vector ( invert direction ) Divide vector by vector -- Failure return false - Success return Vector3 --- @@ -5187,7 +5036,6 @@ Divide vector by vector Normalize provided vector -- Failure return false - Success return Vector3 --- @@ -5197,7 +5045,6 @@ Normalize provided vector Orthonormalize provided vectors. Makes vectors normalized and orthogonal to each other. Gram-Schmidt function implementation -- Failure return false - Success return Vector3, Vector3 --- @@ -5206,7 +5053,6 @@ Gram-Schmidt function implementation Transforms a Vector3 by a given Matrix -- Failure return false - Success return Vector3 --- @@ -5215,7 +5061,6 @@ Transforms a Vector3 by a given Matrix Transform a vector by quaternion rotation -- Failure return false - Success return Vector3 --- @@ -5224,7 +5069,6 @@ Transform a vector by quaternion rotation Rotates a vector around an axis -- Failure return false - Success return Vector3 --- @@ -5233,7 +5077,6 @@ Rotates a vector around an axis Calculate linear interpolation between two vectors -- Failure return false - Success return Vector3 --- @@ -5242,7 +5085,6 @@ Calculate linear interpolation between two vectors Calculate reflected vector to normal -- Failure return false - Success return Vector3 --- @@ -5251,7 +5093,6 @@ Calculate reflected vector to normal Get min value for each pair of components -- Failure return false - Success return Vector3 --- @@ -5260,17 +5101,15 @@ Get min value for each pair of components Get max value for each pair of components -- Failure return false - Success return Vector3 --- > result = RL.Vector3Barycenter( Vector3 p, Vector3 a, Vector3 b, Vector3 c ) -Compute barycenter coordinates ( u, v, w ) for point p with respect to triangle ( a, b, c ) +Compute barycenter coordinates (u, v, w) for point p with respect to triangle (a, b, c) NOTE: Assumes P is on the plane of the triangle -- Failure return false - Success return Vector3 --- @@ -5280,7 +5119,6 @@ NOTE: Assumes P is on the plane of the triangle Projects a Vector3 from screen space into object space NOTE: We are avoiding calling other raymath functions despite available -- Failure return false - Success return Vector3 --- @@ -5289,7 +5127,6 @@ NOTE: We are avoiding calling other raymath functions despite available Invert the given vector -- Failure return false - Success return Vector3 --- @@ -5299,7 +5136,6 @@ Invert the given vector Clamp the components of the vector between min and max values specified by the given vectors -- Failure return false - Success return Vector3 --- @@ -5308,7 +5144,6 @@ min and max values specified by the given vectors Clamp the magnitude of the vector between two values -- Failure return false - Success return Vector3 --- @@ -5317,7 +5152,6 @@ Clamp the magnitude of the vector between two values Check whether two given vectors are almost equal -- Failure return false - Success return int --- @@ -5331,7 +5165,6 @@ and r specifies the ratio of the refractive index of the medium from where the ray comes to the refractive index of the medium on the other side of the surface -- Failure return false - Success return Vector3 --- @@ -5344,16 +5177,14 @@ on the other side of the surface Compute matrix determinant -- Failure return false - Success return float --- > result = RL.MatrixTrace( Matrix mat ) -Get the trace of the matrix ( sum of the values along the diagonal ) +Get the trace of the matrix (sum of the values along the diagonal) -- Failure return false - Success return float --- @@ -5362,7 +5193,6 @@ Get the trace of the matrix ( sum of the values along the diagonal ) Transposes provided matrix -- Failure return false - Success return Matrix --- @@ -5371,7 +5201,6 @@ Transposes provided matrix Invert provided matrix -- Failure return false - Success return Matrix --- @@ -5388,7 +5217,6 @@ Get identity matrix Add two matrices -- Failure return false - Success return Matrix --- @@ -5397,7 +5225,6 @@ Add two matrices Subtract two matrices (left - right) -- Failure return false - Success return Matrix --- @@ -5406,7 +5233,6 @@ Subtract two matrices (left - right) Get two matrix multiplication -- Failure return false - Success return Matrix --- @@ -5415,7 +5241,6 @@ Get two matrix multiplication Get translation matrix -- Failure return false - Success return Matrix --- @@ -5424,52 +5249,46 @@ Get translation matrix Create rotation matrix from axis and angle. NOTE: Angle should be provided in radians -- Failure return false - Success return Matrix --- > result = RL.MatrixRotateX( float angle ) -Get x-rotation matrix ( angle in radians ) +Get x-rotation matrix (angle in radians) -- Failure return false - Success return Matrix --- > result = RL.MatrixRotateY( float angle ) -Get y-rotation matrix ( angle in radians ) +Get y-rotation matrix (angle in radians) -- Failure return false - Success return Matrix --- > result = RL.MatrixRotateZ( float angle ) -Get z-rotation matrix ( angle in radians ) +Get z-rotation matrix (angle in radians) -- Failure return false - Success return Matrix --- > result = RL.MatrixRotateXYZ( Vector3 angle ) -Get xyz-rotation matrix ( angles in radians ) +Get xyz-rotation matrix (angles in radians) -- Failure return false - Success return Matrix --- > result = RL.MatrixRotateZYX( Vector3 angle ) -Get zyx-rotation matrix ( angles in radians ) +Get zyx-rotation matrix (angles in radians) -- Failure return false - Success return Matrix --- @@ -5478,7 +5297,6 @@ Get zyx-rotation matrix ( angles in radians ) Get scaling matrix -- Failure return false - Success return Matrix --- @@ -5487,7 +5305,6 @@ Get scaling matrix Get perspective projection matrix -- Failure return false - Success return Matrix --- @@ -5496,7 +5313,6 @@ Get perspective projection matrix Get perspective projection matrix -- Failure return false - Success return Matrix --- @@ -5505,16 +5321,14 @@ Get perspective projection matrix Get orthographic projection matrix -- Failure return false - Success return Matrix --- > result = RL.MatrixLookAt( Vector3 eye, Vector3 target, Vector3 up ) -Get camera look-at matrix ( View matrix ) +Get camera look-at matrix (View matrix) -- Failure return false - Success return Matrix --- @@ -5527,7 +5341,6 @@ Get camera look-at matrix ( View matrix ) Add two quaternions -- Failure return false - Success return Quaternion --- @@ -5536,7 +5349,6 @@ Add two quaternions Add quaternion and float value -- Failure return false - Success return Quaternion --- @@ -5545,7 +5357,6 @@ Add quaternion and float value Subtract two quaternions -- Failure return false - Success return Quaternion --- @@ -5554,7 +5365,6 @@ Subtract two quaternions Subtract quaternion and float value -- Failure return false - Success return Quaternion --- @@ -5571,7 +5381,6 @@ Get identity quaternion Computes the length of a quaternion -- Failure return false - Success return float --- @@ -5580,7 +5389,6 @@ Computes the length of a quaternion Normalize provided quaternion -- Failure return false - Success return Quaternion --- @@ -5589,7 +5397,6 @@ Normalize provided quaternion Invert provided quaternion -- Failure return false - Success return Quaternion --- @@ -5598,7 +5405,6 @@ Invert provided quaternion Calculate two quaternion multiplication -- Failure return false - Success return Quaternion --- @@ -5607,7 +5413,6 @@ Calculate two quaternion multiplication Scale quaternion by float value -- Failure return false - Success return Quaternion --- @@ -5616,7 +5421,6 @@ Scale quaternion by float value Divide two quaternions -- Failure return false - Success return Quaternion --- @@ -5625,7 +5429,6 @@ Divide two quaternions Calculate linear interpolation between two quaternions -- Failure return false - Success return Quaternion --- @@ -5634,7 +5437,6 @@ Calculate linear interpolation between two quaternions Calculate slerp-optimized interpolation between two quaternions -- Failure return false - Success return Quaternion --- @@ -5643,7 +5445,6 @@ Calculate slerp-optimized interpolation between two quaternions Calculates spherical linear interpolation between two quaternions -- Failure return false - Success return Quaternion --- @@ -5652,7 +5453,6 @@ Calculates spherical linear interpolation between two quaternions Calculate quaternion based on the rotation from one vector to another -- Failure return false - Success return Quaternion --- @@ -5661,7 +5461,6 @@ Calculate quaternion based on the rotation from one vector to another Get a quaternion for a given rotation matrix -- Failure return false - Success return Quaternion --- @@ -5670,7 +5469,6 @@ Get a quaternion for a given rotation matrix Get a quaternion for a given rotation matrix -- Failure return false - Success return Matrix --- @@ -5680,7 +5478,6 @@ Get a quaternion for a given rotation matrix Get rotation quaternion for an angle and axis NOTE: angle must be provided in radians -- Failure return false - Success return Quaternion --- @@ -5689,7 +5486,6 @@ NOTE: angle must be provided in radians Get the rotation angle and axis for a given quaternion -- Failure return false - Success return Vector3, float --- @@ -5699,7 +5495,6 @@ Get the rotation angle and axis for a given quaternion Get the quaternion equivalent to Euler angles NOTE: Rotation order is ZYX -- Failure return false - Success return Quaternion --- @@ -5709,7 +5504,6 @@ NOTE: Rotation order is ZYX Get the Euler angles equivalent to quaternion (roll, pitch, yaw) NOTE: Angles are returned in a Vector3 struct in radians -- Failure return false - Success return Vector3 --- @@ -5718,7 +5512,6 @@ NOTE: Angles are returned in a Vector3 struct in radians Transform a quaternion given a transformation matrix -- Failure return false - Success return Quaternion --- @@ -5727,7 +5520,6 @@ Transform a quaternion given a transformation matrix Check whether two given quaternions are almost equal -- Failure return false - Success return int --- @@ -5738,57 +5530,51 @@ Check whether two given quaternions are almost equal > RL.GuiEnable() -Enable gui controls ( global state ) +Enable gui controls (global state) --- > RL.GuiDisable() -Disable gui controls ( global state ) +Disable gui controls (global state) --- > RL.GuiLock() -Lock gui controls ( global state ) +Lock gui controls (global state) --- > RL.GuiUnlock() -Unlock gui controls ( global state ) +Unlock gui controls (global state) --- > locked = RL.GuiIsLocked() -Check if gui is locked ( global state ) +Check if gui is locked (global state) - Success return bool --- -> success = RL.GuiFade( float alpha ) +> RL.GuiFade( float alpha ) -Set gui controls alpha ( global state ), alpha goes from 0.0f to 1.0f - -- Failure return false -- Success return true +Set gui controls alpha (global state), alpha goes from 0.0f to 1.0f --- -> success = RL.GuiSetState( int state ) +> RL.GuiSetState( int state ) -Set gui state ( global state ) - -- Failure return false -- Success return true +Set gui state (global state) --- > state = RL.GuiGetState() -Get gui state ( global state ) +Get gui state (global state) - Success return int @@ -5806,9 +5592,9 @@ Set gui custom font (global state) > font = RL.GuiGetFont() -Get gui custom font ( global state ) +Get gui custom font (global state) -- Success return int +- Success return Font --- @@ -5816,27 +5602,23 @@ Get gui custom font ( global state ) --- -> success = RL.GuiSetStyle( int control, int property, int value ) +> RL.GuiSetStyle( int control, int property, int value ) Set one style property -- Failure return false -- Success return true - --- > value = RL.GuiGetStyle( int control, int property ) Get one style property -- Failure return false - Success return int --- > success = RL.GuiLoadStyle( string fileName ) -Load style file over global style variable ( .rgs ) +Load style file over global style variable (.rgs) - Failure return false - Success return true @@ -5857,43 +5639,32 @@ Load style default over global style Window Box control, shows a window that can be closed -- Failure return nil - Success return bool --- -> success = RL.GuiGroupBox( Rectangle bounds, string text ) +> RL.GuiGroupBox( Rectangle bounds, string text ) Group Box control with text name -- Failure return false -- Success return true - --- -> success = RL.GuiLine( Rectangle bounds, string text ) +> RL.GuiLine( Rectangle bounds, string text ) Line separator control, could contain text -- Failure return false -- Success return true - --- -> success = RL.GuiPanel( Rectangle bounds, string text ) +> RL.GuiPanel( Rectangle bounds, string text ) Panel control, useful to group controls -- Failure return false -- Success return true - --- > view, scroll = RL.GuiScrollPanel( Rectangle bounds, string text, Rectangle content, Vector2 scroll ) Scroll Panel control -- Failure return false - Success return Rectangle, Vector2 --- @@ -5902,20 +5673,16 @@ Scroll Panel control --- -> success = RL.GuiLabel( Rectangle bounds, string text ) +> RL.GuiLabel( Rectangle bounds, string text ) Label control, shows text -- Failure return false -- Success return true - --- > clicked = RL.GuiButton( Rectangle bounds, string text ) Button control, returns true when clicked -- Failure return nil - Success return boolean --- @@ -5924,7 +5691,6 @@ Button control, returns true when clicked Label button control, show true when clicked -- Failure return nil - Success return boolean --- @@ -5933,7 +5699,6 @@ Label button control, show true when clicked Toggle Button control, returns true when active -- Failure return nil - Success return boolean --- @@ -5942,7 +5707,6 @@ Toggle Button control, returns true when active Toggle Group control, returns active toggle index -- Failure return false - Success return int --- @@ -5951,7 +5715,6 @@ Toggle Group control, returns active toggle index Check Box control, returns true when active -- Failure return nil - Success return boolean --- @@ -5960,7 +5723,6 @@ Check Box control, returns true when active Combo Box control, returns selected item index -- Failure return nil - Success return int --- @@ -5969,7 +5731,6 @@ Combo Box control, returns selected item index Text Box control, updates input text -- Failure return nil - Success return boolean, string --- @@ -5978,7 +5739,6 @@ Text Box control, updates input text Text Box control with multiple lines -- Failure return nil - Success return boolean, string --- @@ -5987,7 +5747,6 @@ Text Box control with multiple lines Spinner control, returns selected value -- Failure return nil - Success return boolean, int --- @@ -5996,7 +5755,6 @@ Spinner control, returns selected value Value Box control, updates input text with numbers -- Failure return nil - Success return boolean, int --- @@ -6005,7 +5763,6 @@ Value Box control, updates input text with numbers Slider control, returns selected value -- Failure return nil - Success return float --- @@ -6014,7 +5771,6 @@ Slider control, returns selected value Slider Bar control, returns selected value -- Failure return nil - Success return float --- @@ -6023,7 +5779,6 @@ Slider Bar control, returns selected value Progress Bar control, shows current progress value -- Failure return nil - Success return float --- @@ -6032,7 +5787,6 @@ Progress Bar control, shows current progress value Scroll Bar control -- Failure return nil - Success return int --- @@ -6041,34 +5795,26 @@ Scroll Bar control Dropdown Box control, returns selected item -- Failure return nil - Success return bool, int --- -> success = RL.GuiStatusBar( Rectangle bounds, string text ) +> RL.GuiStatusBar( Rectangle bounds, string text ) Status Bar control, shows info text -- Failure return false -- Success return true - --- -> success = RL.GuiDummyRec( Rectangle bounds, string text ) +> RL.GuiDummyRec( Rectangle bounds, string text ) Dummy control for placeholders -- Failure return false -- Success return true - --- > cell = RL.GuiGrid( Rectangle bounds, string text, float spacing, int subdivs ) Grid control, returns mouse cell position -- Failure return false - Success return Vector2 --- @@ -6081,7 +5827,6 @@ Grid control, returns mouse cell position List View control, returns selected list item index and scroll index -- Failure return nil - Success return int, int --- @@ -6090,16 +5835,14 @@ List View control, returns selected list item index and scroll index List View with extended parameters, returns selected list item index, scroll index and focus -- Failure return nil - Success return int, int, int --- > buttonIndex = RL.GuiMessageBox( Rectangle bounds, string title, string message, string buttons ) -Message Box control, displays a message, returns button index ( 0 is x button ) +Message Box control, displays a message, returns button index (0 is x button) -- Failure return false - Success return int --- @@ -6108,16 +5851,14 @@ Message Box control, displays a message, returns button index ( 0 is x button ) Text Input Box control, ask for text, supports secret -- Failure return false - Success return int, string, int --- > color = RL.GuiColorPicker( Rectangle bounds, string text, Color color ) -Color Picker control ( multiple color controls ) +Color Picker control (multiple color controls) -- Failure return false - Success return Color --- @@ -6126,7 +5867,6 @@ Color Picker control ( multiple color controls ) Color Panel control -- Failure return false - Success return Color --- @@ -6135,7 +5875,6 @@ Color Panel control Color Bar Alpha control -- Failure return false - Success return float --- @@ -6144,7 +5883,6 @@ Color Bar Alpha control Color Bar Hue control -- Failure return false - Success return float --- @@ -6155,54 +5893,40 @@ Color Bar Hue control > text = RL.GuiIconText( int iconId, string text ) -Get text with icon id prepended ( if supported ) +Get text with icon id prepended (if supported) -- Failure return false - Success return string --- -> success = RL.GuiDrawIcon( int iconId, Vector2 pos, int pixelSize, Color color ) +> RL.GuiDrawIcon( int iconId, Vector2 pos, int pixelSize, Color color ) Draw icon -- Failure return false -- Success return true - --- -> success = RL.GuiSetIconScale( int scale ) - -Set icon scale ( 1 by default ) +> RL.GuiSetIconScale( int scale ) -- Failure return false -- Success return true +Set icon scale (1 by default) --- -> success = RL.GuiSetIconPixel( int iconId, Vector2 pos ) +> RL.GuiSetIconPixel( int iconId, Vector2 pos ) Set icon pixel value -- Failure return false -- Success return true - --- -> success = RL.GuiClearIconPixel( int iconId, Vector2 pos ) +> RL.GuiClearIconPixel( int iconId, Vector2 pos ) Clear icon pixel value -- Failure return false -- Success return true - --- > value = RL.GuiCheckIconPixel( int iconId, Vector2 pos ) Check icon pixel value -- Failure return nil - Success return bool --- @@ -6299,13 +6023,10 @@ Get light enabled --- -> success = RL.rlMatrixMode( int mode ) +> RL.rlMatrixMode( int mode ) Choose the current matrix to be transformed -- Failure return false -- Success return true - --- > RL.rlPushMatrix() @@ -6326,80 +6047,56 @@ Reset current matrix to identity matrix --- -> success = RL.rlTranslatef( Vector3 translation ) +> RL.rlTranslatef( Vector3 translation ) Multiply the current matrix by a translation matrix -- Failure return false -- Success return true - --- -> success = RL.rlRotatef( float angle, Vector3 rotation ) +> RL.rlRotatef( float angle, Vector3 rotation ) Multiply the current matrix by a rotation matrix -- Failure return false -- Success return true - --- -> success = RL.rlScalef( Vector3 scale ) +> RL.rlScalef( Vector3 scale ) Multiply the current matrix by a scaling matrix -- Failure return false -- Success return true - --- -> success = RL.rlMultMatrixf( Matrix matrix ) +> RL.rlMultMatrixf( Matrix matrix ) Multiply the current matrix by another matrix -- Failure return false -- Success return true - --- -> success = RL.rlFrustum( float left, float right, float bottom, float top, float znear, float zfar ) +> RL.rlFrustum( float left, float right, float bottom, float top, float znear, float zfar ) Multiply the current matrix by a perspective matrix generated by parameters -- Failure return false -- Success return true - --- -> success = RL.rlOrtho( float left, float right, float bottom, float top, float znear, float zfar ) +> RL.rlOrtho( float left, float right, float bottom, float top, float znear, float zfar ) Multiply the current matrix by an orthographic matrix generated by parameters -- Failure return false -- Success return true - --- -> success = RL.rlViewport( Rectangle viewport ) +> RL.rlViewport( Rectangle viewport ) -Set the viewport area ( transformation from normalized device coordinates to window coordinates ) +Set the viewport area (transformation from normalized device coordinates to window coordinates) NOTE: We store current viewport dimensions -- Failure return false -- Success return true - --- ## RLGL - Vertex level operations --- -> success = RL.rlBegin( int mode ) +> RL.rlBegin( int mode ) -Initialize drawing mode ( how to organize vertex ) - -- Failure return false -- Success return true +Initialize drawing mode (how to organize vertex) --- @@ -6409,66 +6106,45 @@ Finish vertex providing --- -> success = RL.rlVertex2f( Vector2 position ) +> RL.rlVertex2f( Vector2 position ) -Define one vertex ( position ) - -- Failure return false -- Success return true +Define one vertex (position) --- -> success = RL.rlVertex3f( Vector3 position ) - -Define one vertex ( position ) +> RL.rlVertex3f( Vector3 position ) -- Failure return false -- Success return true +Define one vertex (position) --- -> success = RL.rlTexCoord2f( Vector2 texCoord ) +> RL.rlTexCoord2f( Vector2 texCoord ) -Define one vertex ( texture coordinate ) - 2 float - -- Failure return false -- Success return true +Define one vertex (texture coordinate) - 2 float --- -> success = RL.rlNormal3f( Vector3 normal ) +> RL.rlNormal3f( Vector3 normal ) -Define one vertex ( normal ) - 3 float - -- Failure return false -- Success return true +Define one vertex (normal) - 3 float --- -> success = RL.rlColor4ub( Color color ) +> RL.rlColor4ub( Color color ) -Define one vertex ( color ) - 4 byte - -- Failure return false -- Success return true +Define one vertex (color) - 4 byte --- -> success = RL.rlColor3f( Vector3 color ) - -Define one vertex ( color ) - 3 float +> RL.rlColor3f( Vector3 color ) -- Failure return false -- Success return true +Define one vertex (color) - 3 float --- -> success = RL.rlColor4f( Vector4 color ) +> RL.rlColor4f( Vector4 color ) -Define one vertex ( color ) - 4 float - -- Failure return false -- Success return true +Define one vertex (color) - 4 float --- @@ -6478,22 +6154,21 @@ Define one vertex ( color ) - 4 float > supported = RL.rlEnableVertexArray( int vaoId ) -Enable vertex array ( VAO, if supported ) +Enable vertex array (VAO, if supported) -- Failure return nil - Success return bool --- > RL.rlDisableVertexArray() -Disable vertex array ( VAO, if supported ) +Disable vertex array (VAO, if supported) --- -> success = RL.rlEnableVertexBuffer( int id ) +> RL.rlEnableVertexBuffer( int id ) -Enable vertex buffer ( VBO ) +Enable vertex buffer (VBO) - Failure return false - Success return true @@ -6502,63 +6177,48 @@ Enable vertex buffer ( VBO ) > RL.rlDisableVertexBuffer() -Disable vertex buffer ( VBO ) +Disable vertex buffer (VBO) --- -> success = RL.rlEnableVertexBufferElement( int id ) +> RL.rlEnableVertexBufferElement( int id ) -Enable vertex buffer element ( VBO element ) - -- Failure return false -- Success return true +Enable vertex buffer element (VBO element) --- > RL.rlDisableVertexBufferElement() -Disable vertex buffer element ( VBO element ) +Disable vertex buffer element (VBO element) --- -> success = RL.rlEnableVertexAttribute( int index ) +> RL.rlEnableVertexAttribute( int index ) Enable vertex attribute index -- Failure return false -- Success return true - --- -> success = RL.rlDisableVertexAttribute( int index ) +> RL.rlDisableVertexAttribute( int index ) Disable vertex attribute index -- Failure return false -- Success return true - --- ## RLGL - Textures state --- -> success = RL.rlActiveTextureSlot( int slot ) +> RL.rlActiveTextureSlot( int slot ) Select and active a texture slot -- Failure return false -- Success return true - --- -> success = RL.rlEnableTexture( int id ) +> RL.rlEnableTexture( int id ) Enable texture -- Failure return false -- Success return true - --- > RL.rlDisableTexture() @@ -6567,13 +6227,10 @@ Disable texture --- -> success = RL.rlEnableTextureCubemap( int id ) +> RL.rlEnableTextureCubemap( int id ) Enable texture cubemap -- Failure return false -- Success return true - --- > RL.rlDisableTextureCubemap() @@ -6582,21 +6239,15 @@ Disable texture cubemap --- -> success = RL.rlTextureParameters( int id, int param, int value ) +> RL.rlTextureParameters( int id, int param, int value ) -Set texture parameters ( filter, wrap ) - -- Failure return false -- Success return true +Set texture parameters (filter, wrap) --- -> success = RL.rlCubemapParameters( int id, int param, int value ) - -Set cubemap parameters ( filter, wrap ) +> RL.rlCubemapParameters( int id, int param, int value ) -- Failure return false -- Success return true +Set cubemap parameters (filter, wrap) --- @@ -6604,13 +6255,10 @@ Set cubemap parameters ( filter, wrap ) --- -> success = RL.rlEnableShader( int id ) +> RL.rlEnableShader( int id ) Enable shader program -- Failure return false -- Success return true - --- > RL.rlDisableShader() @@ -6623,13 +6271,10 @@ Disable shader program --- -> success = RL.rlEnableFramebuffer( int id ) +> RL.rlEnableFramebuffer( int id ) Enable render texture (fbo) -- Failure return false -- Success return true - --- > RL.rlDisableFramebuffer() @@ -6638,13 +6283,10 @@ Disable render texture (fbo), return to default framebuffer --- -> success = RL.rlActiveDrawBuffers( int count ) +> RL.rlActiveDrawBuffers( int count ) Activate multiple draw color buffers -- Failure return false -- Success return true - --- ## RLGL - General render state @@ -6699,13 +6341,10 @@ Disable backface culling --- -> success = RL.rlSetCullFace( int mode ) +> RL.rlSetCullFace( int mode ) Set face culling mode -- Failure return false -- Success return true - --- > RL.rlEnableScissorTest() @@ -6720,13 +6359,10 @@ Disable scissor test --- -> success = RL.rlScissor( Rectangle area ) +> RL.rlScissor( Rectangle area ) Scissor test -- Failure return false -- Success return true - --- > RL.rlEnableWireMode() @@ -6741,13 +6377,10 @@ Disable wire mode --- -> success = RL.rlSetLineWidth( float width ) +> RL.rlSetLineWidth( float width ) Set the line drawing width -- Failure return false -- Success return true - --- > width = RL.rlGetLineWidth() @@ -6790,18 +6423,15 @@ Check if stereo render is enabled --- -> success = RL.rlClearColor( Color color ) +> RL.rlClearColor( Color color ) Clear color buffer with color -- Failure return false -- Success return true - --- > RL.rlClearScreenBuffers() -Clear used screen buffers ( color and depth ) +Clear used screen buffers (color and depth) --- @@ -6811,30 +6441,21 @@ Check and log OpenGL error codes --- -> success = RL.rlSetBlendMode( int mode ) +> RL.rlSetBlendMode( int mode ) Set blending mode -- Failure return false -- Success return true - --- -> success = RL.rlSetBlendFactors( int glSrcFactor, int glDstFactor, int glEquation ) +> RL.rlSetBlendFactors( int glSrcFactor, int glDstFactor, int glEquation ) -Set blending mode factor and equation ( using OpenGL factors ) - -- Failure return false -- Success return true +Set blending mode factor and equation (using OpenGL factors) --- -> success = RL.rlSetBlendFactorsSeparate( int glSrcRGB, int glDstRGB, int glSrcAlpha, int glDstAlpha, int glEqRGB, int glEqAlpha ) +> RL.rlSetBlendFactorsSeparate( int glSrcRGB, int glDstRGB, int glSrcAlpha, int glDstAlpha, int glEqRGB, int glEqAlpha ) -Set blending mode factors and equations separately ( using OpenGL factors ) - -- Failure return false -- Success return true +Set blending mode factors and equations separately (using OpenGL factors) --- @@ -6864,18 +6485,14 @@ Update and draw internal render batch Check internal buffer overflow for a given number of vertex and force a rlRenderBatch draw call if required -- Failure return nil - Success return bool --- -> success = RL.rlSetTexture( int id ) +> RL.rlSetTexture( int id ) Set current texture for render batch and check buffers limits -- Failure return false -- Success return true - --- ## RLGL - Vertex buffers management @@ -6894,7 +6511,6 @@ Load vertex array (vao) if supported Load a vertex buffer attribute -- Failure return -1 - Success return int --- @@ -6903,108 +6519,74 @@ Load a vertex buffer attribute Load a new attributes element buffer -- Failure return -1 - Success return int --- -> success = RL.rlUpdateVertexBuffer( int bufferId, Buffer buffer, int offset ) +> RL.rlUpdateVertexBuffer( int bufferId, Buffer buffer, int offset ) Update GPU buffer with new data -- Failure return false -- Success return true - --- -> success = RL.rlUpdateVertexBufferElements( int id, Buffer buffer, int offset ) +> RL.rlUpdateVertexBufferElements( int id, Buffer buffer, int offset ) Update vertex buffer elements with new data -- Failure return false -- Success return true - --- -> success = RL.rlUnloadVertexArray( int vaoId ) +> RL.rlUnloadVertexArray( int vaoId ) Unload vertex array object (VAO) -- Failure return false -- Success return true - --- -> success = RL.rlUnloadVertexBuffer( int vboId ) +> RL.rlUnloadVertexBuffer( int vboId ) Unload vertex buffer (VBO) -- Failure return false -- Success return true - --- -> success = RL.rlSetVertexAttribute( int index, int compSize, int type, bool normalized, int stride, int pointer ) +> RL.rlSetVertexAttribute( int index, int compSize, int type, bool normalized, int stride, int pointer ) Set vertex attribute -- Failure return false -- Success return true - --- -> success = RL.rlSetVertexAttributeDivisor( int index, int divisor ) +> RL.rlSetVertexAttributeDivisor( int index, int divisor ) Set vertex attribute divisor -- Failure return false -- Success return true - --- -> success = RL.rlSetVertexAttributeDefault( int locIndex, float{} value, int attribType ) +> RL.rlSetVertexAttributeDefault( int locIndex, float{} value, int attribType ) Set vertex attribute default value -- Failure return false -- Success return true - --- -> success = RL.rlDrawVertexArray( int offset, int count ) +> RL.rlDrawVertexArray( int offset, int count ) Draw vertex array -- Failure return false -- Success return true - --- -> success = RL.rlDrawVertexArrayElements( int offset, int count, Buffer buffer ) +> RL.rlDrawVertexArrayElements( int offset, int count, Buffer buffer ) Draw vertex array elements -- Failure return false -- Success return true - --- -> success = RL.rlDrawVertexArrayInstanced( int offset, int count, int instances ) +> RL.rlDrawVertexArrayInstanced( int offset, int count, int instances ) Draw vertex array instanced -- Failure return false -- Success return true - --- -> success = RL.rlDrawVertexArrayElementsInstanced( int offset, int count, Buffer buffer, int instances ) +> RL.rlDrawVertexArrayElementsInstanced( int offset, int count, Buffer buffer, int instances ) Draw vertex array elements instanced -- Failure return false -- Success return true - --- ## RLGL - Textures management @@ -7015,27 +6597,22 @@ Draw vertex array elements instanced Load texture in GPU -- Failure return -1 - Success return int --- > id = RL.rlLoadTextureDepth( Vector2 size, bool useRenderBuffer ) -Load depth texture/renderbuffer ( to be attached to fbo ) +Load depth texture/renderbuffer (to be attached to fbo) -- Failure return -1 - Success return int --- -> success = RL.rlUnloadTexture( int id ) +> RL.rlUnloadTexture( int id ) Unload texture from GPU memory -- Failure return false -- Success return true - --- ## RLGL - Framebuffer management (fbo) @@ -7046,36 +6623,28 @@ Unload texture from GPU memory Load an empty framebuffer -- Failure return -1 - Success return int --- -> success = RL.rlFramebufferAttach( int fboId, int texId, int attachType, int texType, int mipLevel ) +> RL.rlFramebufferAttach( int fboId, int texId, int attachType, int texType, int mipLevel ) Attach texture/renderbuffer to a framebuffer -- Failure return false -- Success return true - --- > isComplete = RL.rlFramebufferComplete( int id ) Verify framebuffer is complete -- Failure return nil - Success return bool --- -> success = RL.rlUnloadFramebuffer( int id ) +> RL.rlUnloadFramebuffer( int id ) Delete framebuffer from GPU -- Failure return nil -- Success return bool - --- ## RLGL - Shaders management @@ -7123,7 +6692,6 @@ Get internal accumulated transform matrix Get internal projection matrix for stereo render (selected eye) -- Failure return false - Success return Matrix --- @@ -7132,45 +6700,32 @@ Get internal projection matrix for stereo render (selected eye) Get internal view offset matrix for stereo render (selected eye) -- Failure return false - Success return Matrix --- -> success = RL.rlSetMatrixProjection( Matrix proj ) +> RL.rlSetMatrixProjection( Matrix proj ) Set a custom projection matrix (replaces internal projection matrix) -- Failure return false -- Success return true - --- -> success = RL.rlSetMatrixModelview( Matrix view ) +> RL.rlSetMatrixModelview( Matrix view ) Set a custom modelview matrix (replaces internal modelview matrix) -- Failure return false -- Success return true - --- -> success = RL.rlSetMatrixProjectionStereo( Matrix right, Matrix left ) +> RL.rlSetMatrixProjectionStereo( Matrix right, Matrix left ) Set eyes projection matrices for stereo rendering -- Failure return false -- Success return true - --- -> success = RL.rlSetMatrixViewOffsetStereo( Matrix right, Matrix left ) +> RL.rlSetMatrixViewOffsetStereo( Matrix right, Matrix left ) Set eyes view offsets matrices for stereo rendering -- Failure return false -- Success return true - --- ## OpenGL - Framebuffer management @@ -7192,7 +6747,6 @@ Use -1 RenderTexture for window framebuffer. Ease linear -- Failure return false - Success return float --- @@ -7205,7 +6759,6 @@ Ease linear Ease sine in -- Failure return false - Success return float --- @@ -7214,7 +6767,6 @@ Ease sine in Ease sine out -- Failure return false - Success return float --- @@ -7223,7 +6775,6 @@ Ease sine out Ease sine in out -- Failure return false - Success return float --- @@ -7236,7 +6787,6 @@ Ease sine in out Ease circle in -- Failure return false - Success return float --- @@ -7245,7 +6795,6 @@ Ease circle in Ease circle out -- Failure return false - Success return float --- @@ -7254,7 +6803,6 @@ Ease circle out Ease circle in out -- Failure return false - Success return float --- @@ -7267,7 +6815,6 @@ Ease circle in out Ease cubic in -- Failure return false - Success return float --- @@ -7276,7 +6823,6 @@ Ease cubic in Ease cubic out -- Failure return false - Success return float --- @@ -7285,7 +6831,6 @@ Ease cubic out Ease cubic in out -- Failure return false - Success return float --- @@ -7298,7 +6843,6 @@ Ease cubic in out Ease quadratic in -- Failure return false - Success return float --- @@ -7307,7 +6851,6 @@ Ease quadratic in Ease quadratic out -- Failure return false - Success return float --- @@ -7316,7 +6859,6 @@ Ease quadratic out Ease quadratic in out -- Failure return false - Success return float --- @@ -7329,7 +6871,6 @@ Ease quadratic in out Ease exponential in -- Failure return false - Success return float --- @@ -7338,7 +6879,6 @@ Ease exponential in Ease exponential out -- Failure return false - Success return float --- @@ -7347,7 +6887,6 @@ Ease exponential out Ease exponential in out -- Failure return false - Success return float --- @@ -7360,7 +6899,6 @@ Ease exponential in out Ease back in -- Failure return false - Success return float --- @@ -7369,7 +6907,6 @@ Ease back in Ease back out -- Failure return false - Success return float --- @@ -7378,7 +6915,6 @@ Ease back out Ease back in out -- Failure return false - Success return float --- @@ -7391,7 +6927,6 @@ Ease back in out Ease bounce in -- Failure return false - Success return float --- @@ -7400,7 +6935,6 @@ Ease bounce in Ease bounce out -- Failure return false - Success return float --- @@ -7409,7 +6943,6 @@ Ease bounce out Ease bounce in out -- Failure return false - Success return float --- @@ -7422,7 +6955,6 @@ Ease bounce in out Ease elastic in -- Failure return false - Success return float --- @@ -7431,7 +6963,6 @@ Ease elastic in Ease elastic out -- Failure return false - Success return float --- @@ -7440,7 +6971,6 @@ Ease elastic out Ease elastic in out -- Failure return false - Success return float --- diff --git a/ReiLua_API.lua b/ReiLua_API.lua index f9e6038..3c67219 100644 --- a/ReiLua_API.lua +++ b/ReiLua_API.lua @@ -1744,139 +1744,111 @@ function RL.GetScreenToWorld2D( position, camera ) end function RL.SetShapesTexture( texture, source ) end ---Draw a pixel ----- Failure return false ----- Success return true ---@param pos table ---@param color table ----@return any success -function RL.DrawPixel( pos, color ) end +---@return any RL.DrawPixel +function RL.DrawPixel( pos, color ) end ---Draw a line defining thickness ----- Failure return false ----- Success return true ---@param startPos table ---@param endPos table ---@param thickness number ---@param color table ----@return any success -function RL.DrawLine( startPos, endPos, thickness, color ) end +---@return any RL.DrawLine +function RL.DrawLine( startPos, endPos, thickness, color ) end ---Draw a line using cubic-bezier curves in-out ----- Failure return false ----- Success return true ---@param startPos table ---@param endPos table ---@param thickness number ---@param color table ----@return any success -function RL.DrawLineBezier( startPos, endPos, thickness, color ) end +---@return any RL.DrawLineBezier +function RL.DrawLineBezier( startPos, endPos, thickness, color ) end ---Draw line using quadratic bezier curves with a control point ----- Failure return false ----- Success return true ---@param startPos table ---@param endPos table ---@param controlPos table ---@param thickness number ---@param color table ----@return any success -function RL.DrawLineBezierQuad( startPos, endPos, controlPos, thickness, color ) end +---@return any RL.DrawLineBezierQuad +function RL.DrawLineBezierQuad( startPos, endPos, controlPos, thickness, color ) end ---Draw line using quadratic bezier curves with a control point ----- Failure return false ----- Success return true ---@param startPos table ---@param endPos table ---@param startControlPos table ---@param endControlPos table ---@param thickness number ---@param color table ----@return any success -function RL.DrawLineBezierCubic( startPos, endPos, startControlPos, endControlPos, thickness, color ) end +---@return any RL.DrawLineBezierCubic +function RL.DrawLineBezierCubic( startPos, endPos, startControlPos, endControlPos, thickness, color ) end ---Draw lines sequence ----- Failure return false ----- Success return true ---@param points any ---@param color table ----@return any success -function RL.DrawLineStrip( points, color ) end +---@return any RL.DrawLineStrip +function RL.DrawLineStrip( points, color ) end ---Draw a color-filled circle ----- Failure return false ----- Success return true ---@param center table ---@param radius number ---@param color table ----@return any success -function RL.DrawCircle( center, radius, color ) end +---@return any RL.DrawCircle +function RL.DrawCircle( center, radius, color ) end ---Draw a piece of a circle ----- Failure return false ----- Success return true ---@param center table ---@param radius number ---@param startAngle number ---@param endAngle number ---@param segments integer ---@param color table ----@return any success -function RL.DrawCircleSector( center, radius, startAngle, endAngle, segments, color ) end +---@return any RL.DrawCircleSector +function RL.DrawCircleSector( center, radius, startAngle, endAngle, segments, color ) end ---Draw circle sector outline ----- Failure return false ----- Success return true ---@param center table ---@param radius number ---@param startAngle number ---@param endAngle number ---@param segments integer ---@param color table ----@return any success -function RL.DrawCircleSectorLines( center, radius, startAngle, endAngle, segments, color ) end +---@return any RL.DrawCircleSectorLines +function RL.DrawCircleSectorLines( center, radius, startAngle, endAngle, segments, color ) end ---Draw a gradient-filled circle ----- Failure return false ----- Success return true ---@param center table ---@param radius number ---@param color1 table ---@param color2 table ----@return any success -function RL.DrawCircleGradient( center, radius, color1, color2 ) end +---@return any RL.DrawCircleGradient +function RL.DrawCircleGradient( center, radius, color1, color2 ) end ---Draw circle outline ----- Failure return false ----- Success return true ---@param center table ---@param radius number ---@param color table ----@return any success -function RL.DrawCircleLines( center, radius, color ) end +---@return any RL.DrawCircleLines +function RL.DrawCircleLines( center, radius, color ) end ---Draw ellipse ----- Failure return false ----- Success return true ---@param center table ---@param radiusH number ---@param radiusV number ---@param color table ----@return any success -function RL.DrawEllipse( center, radiusH, radiusV, color ) end +---@return any RL.DrawEllipse +function RL.DrawEllipse( center, radiusH, radiusV, color ) end ---Draw ellipse outline ----- Failure return false ----- Success return true ---@param center table ---@param radiusH number ---@param radiusV number ---@param color table ----@return any success -function RL.DrawEllipseLines( center, radiusH, radiusV, color ) end +---@return any RL.DrawEllipseLines +function RL.DrawEllipseLines( center, radiusH, radiusV, color ) end ---Draw ring ----- Failure return false ----- Success return true ---@param center table ---@param innerRadius number ---@param outerRadius number @@ -1884,12 +1856,10 @@ function RL.DrawEllipseLines( center, radiusH, radiusV, color ) end ---@param endAngle number ---@param segments integer ---@param color table ----@return any success -function RL.DrawRing( center, innerRadius, outerRadius, startAngle, endAngle, segments, color ) end +---@return any RL.DrawRing +function RL.DrawRing( center, innerRadius, outerRadius, startAngle, endAngle, segments, color ) end ---Draw ring outline ----- Failure return false ----- Success return true ---@param center table ---@param innerRadius number ---@param outerRadius number @@ -1897,168 +1867,135 @@ function RL.DrawRing( center, innerRadius, outerRadius, startAngle, endAngle, se ---@param endAngle number ---@param segments integer ---@param color table ----@return any success -function RL.DrawRingLines( center, innerRadius, outerRadius, startAngle, endAngle, segments, color ) end +---@return any RL.DrawRingLines +function RL.DrawRingLines( center, innerRadius, outerRadius, startAngle, endAngle, segments, color ) end ---Draw a color-filled rectangle ----- Failure return false ----- Success return true ---@param rec table ---@param color table ----@return any success -function RL.DrawRectangle( rec, color ) end +---@return any RL.DrawRectangle +function RL.DrawRectangle( rec, color ) end ---Draw a color-filled rectangle with pro parameters ----- Failure return false ----- Success return true ---@param rec table ---@param origin table ---@param rotation number ---@param color table ----@return any success -function RL.DrawRectanglePro( rec, origin, rotation, color ) end +---@return any RL.DrawRectanglePro +function RL.DrawRectanglePro( rec, origin, rotation, color ) end ---Draw a vertical-gradient-filled rectangle ----- Failure return false ----- Success return true ---@param rectangle table ---@param color1 table ---@param color2 table ----@return any success -function RL.DrawRectangleGradientV( rectangle, color1, color2 ) end +---@return any RL.DrawRectangleGradientV +function RL.DrawRectangleGradientV( rectangle, color1, color2 ) end ---Draw a horizontal-gradient-filled rectangle ----- Failure return false ----- Success return true ---@param rectangle table ---@param color1 table ---@param color2 table ----@return any success -function RL.DrawRectangleGradientH( rectangle, color1, color2 ) end +---@return any RL.DrawRectangleGradientH +function RL.DrawRectangleGradientH( rectangle, color1, color2 ) end ---Draw a gradient-filled rectangle with custom vertex colors ----- Failure return false ----- Success return true ---@param rectangle table ---@param col1 table ---@param col2 table ---@param col3 table ---@param col4 table ----@return any success -function RL.DrawRectangleGradientEx( rectangle, col1, col2, col3, col4 ) end +---@return any RL.DrawRectangleGradientEx +function RL.DrawRectangleGradientEx( rectangle, col1, col2, col3, col4 ) end ---Draw rectangle outline ----- Failure return false ----- Success return true ---@param rec table ---@param color table ----@return any success -function RL.DrawRectangleLines( rec, color ) end +---@return any RL.DrawRectangleLines +function RL.DrawRectangleLines( rec, color ) end ---Draw rectangle outline with extended parameters ----- Failure return false ----- Success return true ---@param rec table ---@param lineThick integer ---@param color table ----@return any success -function RL.DrawRectangleLinesEx( rec, lineThick, color ) end +---@return any RL.DrawRectangleLinesEx +function RL.DrawRectangleLinesEx( rec, lineThick, color ) end ---Draw rectangle with rounded edges ----- Failure return false ----- Success return true ---@param rec table ---@param roundness number ---@param segments integer ---@param color table ----@return any success -function RL.DrawRectangleRounded( rec, roundness, segments, color ) end +---@return any RL.DrawRectangleRounded +function RL.DrawRectangleRounded( rec, roundness, segments, color ) end ---Draw rectangle with rounded edges outline ----- Failure return false ----- Success return true ---@param rec table ---@param roundness number ---@param segments integer ---@param lineThick integer ---@param color table ----@return any success -function RL.DrawRectangleRoundedLines( rec, roundness, segments, lineThick, color ) end +---@return any RL.DrawRectangleRoundedLines +function RL.DrawRectangleRoundedLines( rec, roundness, segments, lineThick, color ) end ----Draw a color-filled triangle ( Vertex in counter-clockwise order! ) ----- Failure return false ----- Success return true +---Draw a color-filled triangle (Vertex in counter-clockwise order!) ---@param v1 table ---@param v2 table ---@param v3 table ---@param color table ----@return any success -function RL.DrawTriangle( v1, v2, v3, color ) end +---@return any RL.DrawTriangle +function RL.DrawTriangle( v1, v2, v3, color ) end ----Draw triangle outline ( Vertex in counter-clockwise order! ) ----- Failure return false ----- Success return true +---Draw triangle outline (Vertex in counter-clockwise order!) ---@param v1 table ---@param v2 table ---@param v3 table ---@param color table ----@return any success -function RL.DrawTriangleLines( v1, v2, v3, color ) end +---@return any RL.DrawTriangleLines +function RL.DrawTriangleLines( v1, v2, v3, color ) end ----Draw a triangle fan defined by points ( first vertex is the center ) ----- Failure return false ----- Success return true +---Draw a triangle fan defined by points (first vertex is the center) ---@param points any ---@param color table ----@return any success -function RL.DrawTriangleFan( points, color ) end +---@return any RL.DrawTriangleFan +function RL.DrawTriangleFan( points, color ) end ---Draw a triangle strip defined by points ----- Failure return false ----- Success return true ---@param points any ---@param color table ----@return any success -function RL.DrawTriangleStrip( points, color ) end +---@return any RL.DrawTriangleStrip +function RL.DrawTriangleStrip( points, color ) end ----Draw a regular polygon ( Vector version ) ----- Failure return false ----- Success return true +---Draw a regular polygon (Vector version) ---@param center table ---@param sides integer ---@param radius number ---@param rotation number ---@param color table ----@return any success -function RL.DrawPoly( center, sides, radius, rotation, color ) end +---@return any RL.DrawPoly +function RL.DrawPoly( center, sides, radius, rotation, color ) end ---Draw a polygon outline of n sides ----- Failure return false ----- Success return true ---@param center table ---@param sides integer ---@param radius number ---@param rotation number ---@param color table ----@return any success -function RL.DrawPolyLines( center, sides, radius, rotation, color ) end +---@return any RL.DrawPolyLines +function RL.DrawPolyLines( center, sides, radius, rotation, color ) end ---Draw a polygon outline of n sides with extended parameters ----- Failure return false ----- Success return true ---@param center table ---@param sides integer ---@param radius number ---@param rotation number ---@param lineThick number ---@param color table ----@return any success -function RL.DrawPolyLinesEx( center, sides, radius, rotation, lineThick, color ) end +---@return any RL.DrawPolyLinesEx +function RL.DrawPolyLinesEx( center, sides, radius, rotation, lineThick, color ) end -- Shapes - Collision ---Check collision between two rectangles ----- Failure return nil ---- Success return bool ---@param rec1 table ---@param rec2 table @@ -2066,7 +2003,6 @@ function RL.DrawPolyLinesEx( center, sides, radius, rotation, lineThick, color ) function RL.CheckCollisionRecs( rec1, rec2 ) end ---Check collision between two circles ----- Failure return nil ---- Success return bool ---@param center1 table ---@param radius1 number @@ -2076,7 +2012,6 @@ function RL.CheckCollisionRecs( rec1, rec2 ) end function RL.CheckCollisionCircles( center1, radius1, center2, radius2 ) end ---Check collision between circle and rectangle ----- Failure return nil ---- Success return bool ---@param center table ---@param radius number @@ -2085,7 +2020,6 @@ function RL.CheckCollisionCircles( center1, radius1, center2, radius2 ) end function RL.CheckCollisionCircleRec( center, radius, rec ) end ---Check if point is inside rectangle ----- Failure return nil ---- Success return bool ---@param point table ---@param rec table @@ -2093,7 +2027,6 @@ function RL.CheckCollisionCircleRec( center, radius, rec ) end function RL.CheckCollisionPointRec( point, rec ) end ---Check if point is inside circle ----- Failure return nil ---- Success return bool ---@param point table ---@param center table @@ -2102,7 +2035,6 @@ function RL.CheckCollisionPointRec( point, rec ) end function RL.CheckCollisionPointCircle( point, center, radius ) end ---Check if point is inside a triangle ----- Failure return nil ---- Success return bool ---@param point table ---@param p1 table @@ -2112,7 +2044,6 @@ function RL.CheckCollisionPointCircle( point, center, radius ) end function RL.CheckCollisionPointTriangle( point, p1, p2, p3 ) end ---Check if point is within a polygon described by array of vertices ----- Failure return nil ---- Success return bool ---@param point table ---@param points any @@ -2120,7 +2051,6 @@ function RL.CheckCollisionPointTriangle( point, p1, p2, p3 ) end function RL.CheckCollisionPointPoly( point, points ) end ---Check the collision between two lines defined by two points each, returns collision point by reference ----- Failure return nil ---- Success return bool, Vector2 ---@param startPos1 table ---@param endPos1 table @@ -2131,7 +2061,6 @@ function RL.CheckCollisionPointPoly( point, points ) end function RL.CheckCollisionLines( startPos1, endPos1, startPos2, endPos2 ) end ---Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold] ----- Failure return nil ---- Success return bool ---@param point table ---@param p1 table @@ -2141,7 +2070,6 @@ function RL.CheckCollisionLines( startPos1, endPos1, startPos2, endPos2 ) end function RL.CheckCollisionPointLine( point, p1, p2, threshold ) end ---Get collision rectangle for two rectangles collision ----- Failure return nil ---- Success return Rectangle ---@param rec1 table ---@param rec2 table @@ -2269,8 +2197,7 @@ function RL.ImageCopy( image ) end function RL.ImageFromImage( image, rec ) end ---Create an image from text (custom sprite font) ----- Failure return -1 ----- Success return int +---- Success return Image ---@param font any ---@param text string ---@param fontSize number @@ -3644,7 +3571,6 @@ function RL.GetMusicTimePlayed( music ) end -- Math - Utils ---Clamp float value ----- Failure return false ---- Success return float ---@param value number ---@param min number @@ -3653,7 +3579,6 @@ function RL.GetMusicTimePlayed( music ) end function RL.Clamp( value, min, max ) end ---Calculate linear interpolation between two floats ----- Failure return false ---- Success return float ---@param a number ---@param b number @@ -3662,7 +3587,6 @@ function RL.Clamp( value, min, max ) end function RL.Lerp( a, b, amount ) end ---Normalize input value within input range ----- Failure return false ---- Success return float ---@param value number ---@param a number @@ -3671,7 +3595,6 @@ function RL.Lerp( a, b, amount ) end function RL.Normalize( value, a, b ) end ---Remap input value within input range to output range ----- Failure return false ---- Success return float ---@param value number ---@param inputStart number @@ -3682,7 +3605,6 @@ function RL.Normalize( value, a, b ) end function RL.Remap( value, inputStart, inputEnd, outputStart, outputEnd ) end ---Wrap input value from min to max ----- Failure return false ---- Success return float ---@param value number ---@param min number @@ -3691,7 +3613,6 @@ function RL.Remap( value, inputStart, inputEnd, outputStart, outputEnd ) end function RL.Wrap( value, min, max ) end ---Check whether two given floats are almost equal ----- Failure return false ---- Success return int ---@param x number ---@param y number @@ -3711,7 +3632,6 @@ function RL.Vector2Zero() end function RL.Vector2One() end ---Add two vectors (v1 + v2) ----- Failure return false ---- Success return Vector2 ---@param v1 table ---@param v2 table @@ -3719,7 +3639,6 @@ function RL.Vector2One() end function RL.Vector2Add( v1, v2 ) end ---Add vector and float value ----- Failure return false ---- Success return Vector2 ---@param v table ---@param add number @@ -3727,7 +3646,6 @@ function RL.Vector2Add( v1, v2 ) end function RL.Vector2AddValue( v, add ) end ---Subtract two vectors (v1 - v2) ----- Failure return false ---- Success return Vector2 ---@param v1 table ---@param v2 table @@ -3735,7 +3653,6 @@ function RL.Vector2AddValue( v, add ) end function RL.Vector2Subtract( v1, v2 ) end ---Subtract vector by float value ----- Failure return false ---- Success return Vector2 ---@param v table ---@param sub number @@ -3743,21 +3660,18 @@ function RL.Vector2Subtract( v1, v2 ) end function RL.Vector2SubtractValue( v, sub ) end ---Calculate vector length ----- Failure return false ---- Success return float ---@param v any ---@return any result function RL.Vector2Length( v ) end ---Calculate vector square length ----- Failure return false ---- Success return float ---@param v any ---@return any result function RL.Vector2LengthSqr( v ) end ---Calculate two vectors dot product ----- Failure return false ---- Success return float ---@param v1 table ---@param v2 table @@ -3765,7 +3679,6 @@ function RL.Vector2LengthSqr( v ) end function RL.Vector2DotProduct( v1, v2 ) end ---Calculate distance between two vectors ----- Failure return false ---- Success return float ---@param v1 table ---@param v2 table @@ -3773,7 +3686,6 @@ function RL.Vector2DotProduct( v1, v2 ) end function RL.Vector2Distance( v1, v2 ) end ---Calculate square distance between two vectors ----- Failure return false ---- Success return float ---@param v1 table ---@param v2 table @@ -3781,7 +3693,6 @@ function RL.Vector2Distance( v1, v2 ) end function RL.Vector2DistanceSqr( v1, v2 ) end ---Calculate angle from two vectors ----- Failure return false ---- Success return float ---@param v1 table ---@param v2 table @@ -3791,15 +3702,13 @@ function RL.Vector2Angle( v1, v2 ) end ---Calculate angle defined by a two vectors line. ---NOTE: Parameters need to be normalized. ---Current implementation should be aligned with glm::angle. ----- Failure return false ---- Success return float ---@param a table ---@param b table ---@return any result function RL.Vector2LineAngle( a, b ) end ----Scale vector ( multiply by value ) ----- Failure return false +---Scale vector (multiply by value) ---- Success return Vector2 ---@param v table ---@param scale number @@ -3807,7 +3716,6 @@ function RL.Vector2LineAngle( a, b ) end function RL.Vector2Scale( v, scale ) end ---Multiply vector by vector ----- Failure return false ---- Success return Vector2 ---@param v1 table ---@param v2 table @@ -3815,14 +3723,12 @@ function RL.Vector2Scale( v, scale ) end function RL.Vector2Multiply( v1, v2 ) end ---Negate vector ----- Failure return false ---- Success return Vector2 ---@param v table ---@return any result function RL.Vector2Negate( v ) end ---Divide vector by vector ----- Failure return false ---- Success return Vector2 ---@param v1 table ---@param v2 table @@ -3830,14 +3736,12 @@ function RL.Vector2Negate( v ) end function RL.Vector2Divide( v1, v2 ) end ---Normalize provided vector ----- Failure return false ---- Success return Vector2 ---@param v table ---@return any result function RL.Vector2Normalize( v ) end ---Transforms a Vector2 by a given Matrix ----- Failure return false ---- Success return Vector2 ---@param v table ---@param mat table @@ -3845,7 +3749,6 @@ function RL.Vector2Normalize( v ) end function RL.Vector2Transform( v, mat ) end ---Calculate linear interpolation between two vectors ----- Failure return false ---- Success return Vector2 ---@param v1 table ---@param v2 table @@ -3854,7 +3757,6 @@ function RL.Vector2Transform( v, mat ) end function RL.Vector2Lerp( v1, v2, amount ) end ---Calculate reflected vector to normal ----- Failure return false ---- Success return Vector2 ---@param v table ---@param normal table @@ -3862,7 +3764,6 @@ function RL.Vector2Lerp( v1, v2, amount ) end function RL.Vector2Reflect( v, normal ) end ---Rotate vector by angle ----- Failure return false ---- Success return Vector2 ---@param v table ---@param angle number @@ -3870,7 +3771,6 @@ function RL.Vector2Reflect( v, normal ) end function RL.Vector2Rotate( v, angle ) end ---Move Vector towards target ----- Failure return false ---- Success return Vector2 ---@param v table ---@param target table @@ -3879,7 +3779,6 @@ function RL.Vector2Rotate( v, angle ) end function RL.Vector2MoveTowards( v, target, maxDistance ) end ---Invert the given vector ----- Failure return false ---- Success return Vector2 ---@param v table ---@return any result @@ -3887,7 +3786,6 @@ function RL.Vector2Invert( v ) end ---Clamp the components of the vector between ---min and max values specified by the given vectors ----- Failure return false ---- Success return Vector2 ---@param v table ---@param min table @@ -3896,7 +3794,6 @@ function RL.Vector2Invert( v ) end function RL.Vector2Clamp( v, min, max ) end ---Clamp the magnitude of the vector between two min and max values ----- Failure return false ---- Success return Vector2 ---@param v table ---@param min number @@ -3905,7 +3802,6 @@ function RL.Vector2Clamp( v, min, max ) end function RL.Vector2ClampValue( v, min, max ) end ---Check whether two given vectors are almost equal ----- Failure return false ---- Success return int ---@param v1 table ---@param v2 table @@ -3925,7 +3821,6 @@ function RL.Vector3Zero() end function RL.Vector3One() end ---Add two vectors ----- Failure return false ---- Success return Vector3 ---@param v1 table ---@param v2 table @@ -3933,7 +3828,6 @@ function RL.Vector3One() end function RL.Vector3Add( v1, v2 ) end ---Add vector and float value ----- Failure return false ---- Success return Vector3 ---@param v table ---@param add number @@ -3941,7 +3835,6 @@ function RL.Vector3Add( v1, v2 ) end function RL.Vector3AddValue( v, add ) end ---Subtract two vectors ----- Failure return false ---- Success return Vector3 ---@param v1 table ---@param v2 table @@ -3949,7 +3842,6 @@ function RL.Vector3AddValue( v, add ) end function RL.Vector3Subtract( v1, v2 ) end ---Subtract vector by float value ----- Failure return false ---- Success return Vector3 ---@param v table ---@param sub number @@ -3957,7 +3849,6 @@ function RL.Vector3Subtract( v1, v2 ) end function RL.Vector3SubtractValue( v, sub ) end ---Multiply vector by scalar ----- Failure return false ---- Success return Vector3 ---@param v table ---@param scalar number @@ -3965,7 +3856,6 @@ function RL.Vector3SubtractValue( v, sub ) end function RL.Vector3Scale( v, scalar ) end ---Multiply vector by vector ----- Failure return false ---- Success return Vector3 ---@param v1 table ---@param v2 table @@ -3973,7 +3863,6 @@ function RL.Vector3Scale( v, scalar ) end function RL.Vector3Multiply( v1, v2 ) end ---Calculate two vectors cross product ----- Failure return false ---- Success return Vector3 ---@param v1 table ---@param v2 table @@ -3981,28 +3870,24 @@ function RL.Vector3Multiply( v1, v2 ) end function RL.Vector3CrossProduct( v1, v2 ) end ---Calculate one vector perpendicular vector ----- Failure return false ---- Success return Vector3 ---@param v table ---@return any result function RL.Vector3Perpendicular( v ) end ---Calculate vector length ----- Failure return false ---- Success return float ---@param v table ---@return any result function RL.Vector3Length( v ) end ---Calculate vector square length ----- Failure return false ---- Success return float ---@param v table ---@return any result function RL.Vector3LengthSqr( v ) end ---Calculate two vectors dot product ----- Failure return false ---- Success return float ---@param v1 table ---@param v2 table @@ -4010,7 +3895,6 @@ function RL.Vector3LengthSqr( v ) end function RL.Vector3DotProduct( v1, v2 ) end ---Calculate distance between two vectors ----- Failure return false ---- Success return float ---@param v1 table ---@param v2 table @@ -4018,7 +3902,6 @@ function RL.Vector3DotProduct( v1, v2 ) end function RL.Vector3Distance( v1, v2 ) end ---Calculate square distance between two vectors ----- Failure return false ---- Success return float ---@param v1 table ---@param v2 table @@ -4026,22 +3909,19 @@ function RL.Vector3Distance( v1, v2 ) end function RL.Vector3DistanceSqr( v1, v2 ) end ---Calculate angle between two vectors ----- Failure return false ---- Success return float ---@param v1 table ---@param v2 table ---@return any result function RL.Vector3Angle( v1, v2 ) end ----Negate provided vector ( invert direction ) ----- Failure return false +---Negate provided vector (invert direction) ---- Success return Vector3 ---@param v table ---@return any result function RL.Vector3Negate( v ) end ---Divide vector by vector ----- Failure return false ---- Success return Vector3 ---@param v1 table ---@param v2 table @@ -4049,7 +3929,6 @@ function RL.Vector3Negate( v ) end function RL.Vector3Divide( v1, v2 ) end ---Normalize provided vector ----- Failure return false ---- Success return Vector3 ---@param v table ---@return any result @@ -4057,7 +3936,6 @@ function RL.Vector3Normalize( v ) end ---Orthonormalize provided vectors. Makes vectors normalized and orthogonal to each other. ---Gram-Schmidt function implementation ----- Failure return false ---- Success return Vector3, Vector3 ---@param v1 table ---@param v2 table @@ -4066,7 +3944,6 @@ function RL.Vector3Normalize( v ) end function RL.Vector3OrthoNormalize( v1, v2 ) end ---Transforms a Vector3 by a given Matrix ----- Failure return false ---- Success return Vector3 ---@param v table ---@param mat table @@ -4074,7 +3951,6 @@ function RL.Vector3OrthoNormalize( v1, v2 ) end function RL.Vector3Transform( v, mat ) end ---Transform a vector by quaternion rotation ----- Failure return false ---- Success return Vector3 ---@param v table ---@param q table @@ -4082,7 +3958,6 @@ function RL.Vector3Transform( v, mat ) end function RL.Vector3RotateByQuaternion( v, q ) end ---Rotates a vector around an axis ----- Failure return false ---- Success return Vector3 ---@param v table ---@param axis table @@ -4091,7 +3966,6 @@ function RL.Vector3RotateByQuaternion( v, q ) end function RL.Vector3RotateByAxisAngle( v, axis, angle ) end ---Calculate linear interpolation between two vectors ----- Failure return false ---- Success return Vector3 ---@param v1 table ---@param v2 table @@ -4100,7 +3974,6 @@ function RL.Vector3RotateByAxisAngle( v, axis, angle ) end function RL.Vector3Lerp( v1, v2, amount ) end ---Calculate reflected vector to normal ----- Failure return false ---- Success return Vector3 ---@param v table ---@param normal table @@ -4108,7 +3981,6 @@ function RL.Vector3Lerp( v1, v2, amount ) end function RL.Vector3Reflect( v, normal ) end ---Get min value for each pair of components ----- Failure return false ---- Success return Vector3 ---@param v1 table ---@param v2 table @@ -4116,16 +3988,14 @@ function RL.Vector3Reflect( v, normal ) end function RL.Vector3Min( v1, v2 ) end ---Get max value for each pair of components ----- Failure return false ---- Success return Vector3 ---@param v1 table ---@param v2 table ---@return any result function RL.Vector3Max( v1, v2 ) end ----Compute barycenter coordinates ( u, v, w ) for point p with respect to triangle ( a, b, c ) +---Compute barycenter coordinates (u, v, w) for point p with respect to triangle (a, b, c) ---NOTE: Assumes P is on the plane of the triangle ----- Failure return false ---- Success return Vector3 ---@param p table ---@param a table @@ -4136,7 +4006,6 @@ function RL.Vector3Barycenter( p, a, b, c ) end ---Projects a Vector3 from screen space into object space ---NOTE: We are avoiding calling other raymath functions despite available ----- Failure return false ---- Success return Vector3 ---@param source table ---@param projection table @@ -4145,7 +4014,6 @@ function RL.Vector3Barycenter( p, a, b, c ) end function RL.Vector3Unproject( source, projection, view ) end ---Invert the given vector ----- Failure return false ---- Success return Vector3 ---@param v table ---@return any result @@ -4153,7 +4021,6 @@ function RL.Vector3Invert( v ) end ---Clamp the components of the vector between ---min and max values specified by the given vectors ----- Failure return false ---- Success return Vector3 ---@param v table ---@param min table @@ -4162,7 +4029,6 @@ function RL.Vector3Invert( v ) end function RL.Vector3Clamp( v, min, max ) end ---Clamp the magnitude of the vector between two values ----- Failure return false ---- Success return Vector3 ---@param v table ---@param min number @@ -4171,7 +4037,6 @@ function RL.Vector3Clamp( v, min, max ) end function RL.Vector3ClampValue( v, min, max ) end ---Check whether two given vectors are almost equal ----- Failure return false ---- Success return int ---@param v1 table ---@param v2 table @@ -4184,7 +4049,6 @@ function RL.Vector3Equals( v1, v2 ) end ---and r specifies the ratio of the refractive index of the medium ---from where the ray comes to the refractive index of the medium ---on the other side of the surface ----- Failure return false ---- Success return Vector3 ---@param v table ---@param n table @@ -4195,28 +4059,24 @@ function RL.Vector3Refract( v, n, r ) end -- Math - Matrix ---Compute matrix determinant ----- Failure return false ---- Success return float ---@param mat table ---@return any result function RL.MatrixDeterminant( mat ) end ----Get the trace of the matrix ( sum of the values along the diagonal ) ----- Failure return false +---Get the trace of the matrix (sum of the values along the diagonal) ---- Success return float ---@param mat table ---@return any result function RL.MatrixTrace( mat ) end ---Transposes provided matrix ----- Failure return false ---- Success return Matrix ---@param mat table ---@return any result function RL.MatrixTranspose( mat ) end ---Invert provided matrix ----- Failure return false ---- Success return Matrix ---@param mat table ---@return any result @@ -4228,7 +4088,6 @@ function RL.MatrixInvert( mat ) end function RL.MatrixIdentity() end ---Add two matrices ----- Failure return false ---- Success return Matrix ---@param left table ---@param right table @@ -4236,7 +4095,6 @@ function RL.MatrixIdentity() end function RL.MatrixAdd( left, right ) end ---Subtract two matrices (left - right) ----- Failure return false ---- Success return Matrix ---@param left table ---@param right table @@ -4244,7 +4102,6 @@ function RL.MatrixAdd( left, right ) end function RL.MatrixSubtract( left, right ) end ---Get two matrix multiplication ----- Failure return false ---- Success return Matrix ---@param left table ---@param right table @@ -4252,64 +4109,55 @@ function RL.MatrixSubtract( left, right ) end function RL.MatrixMultiply( left, right ) end ---Get translation matrix ----- Failure return false ---- Success return Matrix ---@param translate table ---@return any result function RL.MatrixTranslate( translate ) end ---Create rotation matrix from axis and angle. NOTE: Angle should be provided in radians ----- Failure return false ---- Success return Matrix ---@param axis table ---@param angle number ---@return any result function RL.MatrixRotate( axis, angle ) end ----Get x-rotation matrix ( angle in radians ) ----- Failure return false +---Get x-rotation matrix (angle in radians) ---- Success return Matrix ---@param angle number ---@return any result function RL.MatrixRotateX( angle ) end ----Get y-rotation matrix ( angle in radians ) ----- Failure return false +---Get y-rotation matrix (angle in radians) ---- Success return Matrix ---@param angle number ---@return any result function RL.MatrixRotateY( angle ) end ----Get z-rotation matrix ( angle in radians ) ----- Failure return false +---Get z-rotation matrix (angle in radians) ---- Success return Matrix ---@param angle number ---@return any result function RL.MatrixRotateZ( angle ) end ----Get xyz-rotation matrix ( angles in radians ) ----- Failure return false +---Get xyz-rotation matrix (angles in radians) ---- Success return Matrix ---@param angle table ---@return any result function RL.MatrixRotateXYZ( angle ) end ----Get zyx-rotation matrix ( angles in radians ) ----- Failure return false +---Get zyx-rotation matrix (angles in radians) ---- Success return Matrix ---@param angle table ---@return any result function RL.MatrixRotateZYX( angle ) end ---Get scaling matrix ----- Failure return false ---- Success return Matrix ---@param scale table ---@return any result function RL.MatrixScale( scale ) end ---Get perspective projection matrix ----- Failure return false ---- Success return Matrix ---@param left any ---@param right any @@ -4321,7 +4169,6 @@ function RL.MatrixScale( scale ) end function RL.MatrixFrustum( left, right, bottom, top, near, far ) end ---Get perspective projection matrix ----- Failure return false ---- Success return Matrix ---@param fovy any ---@param aspect any @@ -4331,7 +4178,6 @@ function RL.MatrixFrustum( left, right, bottom, top, near, far ) end function RL.MatrixPerspective( fovy, aspect, near, far ) end ---Get orthographic projection matrix ----- Failure return false ---- Success return Matrix ---@param left any ---@param right any @@ -4342,8 +4188,7 @@ function RL.MatrixPerspective( fovy, aspect, near, far ) end ---@return any result function RL.MatrixOrtho( left, right, bottom, top, near, far ) end ----Get camera look-at matrix ( View matrix ) ----- Failure return false +---Get camera look-at matrix (View matrix) ---- Success return Matrix ---@param eye table ---@param target table @@ -4354,7 +4199,6 @@ function RL.MatrixLookAt( eye, target, up ) end -- Math - Quaternion ---Add two quaternions ----- Failure return false ---- Success return Quaternion ---@param q1 table ---@param q2 table @@ -4362,7 +4206,6 @@ function RL.MatrixLookAt( eye, target, up ) end function RL.QuaternionAdd( q1, q2 ) end ---Add quaternion and float value ----- Failure return false ---- Success return Quaternion ---@param q table ---@param add number @@ -4370,7 +4213,6 @@ function RL.QuaternionAdd( q1, q2 ) end function RL.QuaternionAddValue( q, add ) end ---Subtract two quaternions ----- Failure return false ---- Success return Quaternion ---@param q1 table ---@param q2 table @@ -4378,7 +4220,6 @@ function RL.QuaternionAddValue( q, add ) end function RL.QuaternionSubtract( q1, q2 ) end ---Subtract quaternion and float value ----- Failure return false ---- Success return Quaternion ---@param q table ---@param sub number @@ -4391,28 +4232,24 @@ function RL.QuaternionSubtractValue( q, sub ) end function RL.QuaternionIdentity() end ---Computes the length of a quaternion ----- Failure return false ---- Success return float ---@param q table ---@return any result function RL.QuaternionLength( q ) end ---Normalize provided quaternion ----- Failure return false ---- Success return Quaternion ---@param q table ---@return any result function RL.QuaternionNormalize( q ) end ---Invert provided quaternion ----- Failure return false ---- Success return Quaternion ---@param q table ---@return any result function RL.QuaternionInvert( q ) end ---Calculate two quaternion multiplication ----- Failure return false ---- Success return Quaternion ---@param q1 table ---@param q2 table @@ -4420,7 +4257,6 @@ function RL.QuaternionInvert( q ) end function RL.QuaternionMultiply( q1, q2 ) end ---Scale quaternion by float value ----- Failure return false ---- Success return Quaternion ---@param q table ---@param mul number @@ -4428,7 +4264,6 @@ function RL.QuaternionMultiply( q1, q2 ) end function RL.QuaternionScale( q, mul ) end ---Divide two quaternions ----- Failure return false ---- Success return Quaternion ---@param q1 table ---@param q2 table @@ -4436,7 +4271,6 @@ function RL.QuaternionScale( q, mul ) end function RL.QuaternionDivide( q1, q2 ) end ---Calculate linear interpolation between two quaternions ----- Failure return false ---- Success return Quaternion ---@param q1 table ---@param q2 table @@ -4445,7 +4279,6 @@ function RL.QuaternionDivide( q1, q2 ) end function RL.QuaternionLerp( q1, q2, amount ) end ---Calculate slerp-optimized interpolation between two quaternions ----- Failure return false ---- Success return Quaternion ---@param q1 table ---@param q2 table @@ -4454,7 +4287,6 @@ function RL.QuaternionLerp( q1, q2, amount ) end function RL.QuaternionNlerp( q1, q2, amount ) end ---Calculates spherical linear interpolation between two quaternions ----- Failure return false ---- Success return Quaternion ---@param q1 table ---@param q2 table @@ -4463,7 +4295,6 @@ function RL.QuaternionNlerp( q1, q2, amount ) end function RL.QuaternionSlerp( q1, q2, amount ) end ---Calculate quaternion based on the rotation from one vector to another ----- Failure return false ---- Success return Quaternion ---@param from table ---@param to table @@ -4471,14 +4302,12 @@ function RL.QuaternionSlerp( q1, q2, amount ) end function RL.QuaternionFromVector3ToVector3( from, to ) end ---Get a quaternion for a given rotation matrix ----- Failure return false ---- Success return Quaternion ---@param mat table ---@return any result function RL.QuaternionFromMatrix( mat ) end ---Get a quaternion for a given rotation matrix ----- Failure return false ---- Success return Matrix ---@param q table ---@return any result @@ -4486,7 +4315,6 @@ function RL.QuaternionToMatrix( q ) end ---Get rotation quaternion for an angle and axis ---NOTE: angle must be provided in radians ----- Failure return false ---- Success return Quaternion ---@param axis table ---@param angle number @@ -4494,7 +4322,6 @@ function RL.QuaternionToMatrix( q ) end function RL.QuaternionFromAxisAngle( axis, angle ) end ---Get the rotation angle and axis for a given quaternion ----- Failure return false ---- Success return Vector3, float ---@param q table ---@return any axis @@ -4503,7 +4330,6 @@ function RL.QuaternionToAxisAngle( q ) end ---Get the quaternion equivalent to Euler angles ---NOTE: Rotation order is ZYX ----- Failure return false ---- Success return Quaternion ---@param pitch number ---@param yaw number @@ -4513,14 +4339,12 @@ function RL.QuaternionFromEuler( pitch, yaw, roll ) end ---Get the Euler angles equivalent to quaternion (roll, pitch, yaw) ---NOTE: Angles are returned in a Vector3 struct in radians ----- Failure return false ---- Success return Vector3 ---@param q table ---@return any result function RL.QuaternionToEuler( q ) end ---Transform a quaternion given a transformation matrix ----- Failure return false ---- Success return Quaternion ---@param q table ---@param mat table @@ -4528,7 +4352,6 @@ function RL.QuaternionToEuler( q ) end function RL.QuaternionTransform( q, mat ) end ---Check whether two given quaternions are almost equal ----- Failure return false ---- Success return int ---@param q1 table ---@param q2 table @@ -4537,42 +4360,38 @@ function RL.QuaternionEquals( q1, q2 ) end -- Gui - Global ----Enable gui controls ( global state ) +---Enable gui controls (global state) ---@return any RL.GuiEnable function RL.GuiEnable() end ----Disable gui controls ( global state ) +---Disable gui controls (global state) ---@return any RL.GuiDisable function RL.GuiDisable() end ----Lock gui controls ( global state ) +---Lock gui controls (global state) ---@return any RL.GuiLock function RL.GuiLock() end ----Unlock gui controls ( global state ) +---Unlock gui controls (global state) ---@return any RL.GuiUnlock function RL.GuiUnlock() end ----Check if gui is locked ( global state ) +---Check if gui is locked (global state) ---- Success return bool ---@return any locked function RL.GuiIsLocked() end ----Set gui controls alpha ( global state ), alpha goes from 0.0f to 1.0f ----- Failure return false ----- Success return true +---Set gui controls alpha (global state), alpha goes from 0.0f to 1.0f ---@param alpha number ----@return any success -function RL.GuiFade( alpha ) end +---@return any RL.GuiFade +function RL.GuiFade( alpha ) end ----Set gui state ( global state ) ----- Failure return false ----- Success return true +---Set gui state (global state) ---@param state integer ----@return any success -function RL.GuiSetState( state ) end +---@return any RL.GuiSetState +function RL.GuiSetState( state ) end ----Get gui state ( global state ) +---Get gui state (global state) ---- Success return int ---@return any state function RL.GuiGetState() end @@ -4584,31 +4403,28 @@ function RL.GuiGetState() end ---@return any RL.GuiSetFont function RL.GuiSetFont( font ) end ----Get gui custom font ( global state ) ----- Success return int +---Get gui custom font (global state) +---- Success return Font ---@return any font function RL.GuiGetFont() end -- Gui - Style ---Set one style property ----- Failure return false ----- Success return true ---@param control integer ---@param property integer ---@param value integer ----@return any success -function RL.GuiSetStyle( control, property, value ) end +---@return any RL.GuiSetStyle +function RL.GuiSetStyle( control, property, value ) end ---Get one style property ----- Failure return false ---- Success return int ---@param control integer ---@param property integer ---@return any value function RL.GuiGetStyle( control, property ) end ----Load style file over global style variable ( .rgs ) +---Load style file over global style variable (.rgs) ---- Failure return false ---- Success return true ---@param fileName string @@ -4622,7 +4438,6 @@ function RL.GuiLoadStyleDefault() end -- Gui - Container ---Window Box control, shows a window that can be closed ----- Failure return nil ---- Success return bool ---@param bounds table ---@param title string @@ -4630,31 +4445,24 @@ function RL.GuiLoadStyleDefault() end function RL.GuiWindowBox( bounds, title ) end ---Group Box control with text name ----- Failure return false ----- Success return true ---@param bounds table ---@param text string ----@return any success -function RL.GuiGroupBox( bounds, text ) end +---@return any RL.GuiGroupBox +function RL.GuiGroupBox( bounds, text ) end ---Line separator control, could contain text ----- Failure return false ----- Success return true ---@param bounds table ---@param text string ----@return any success -function RL.GuiLine( bounds, text ) end +---@return any RL.GuiLine +function RL.GuiLine( bounds, text ) end ---Panel control, useful to group controls ----- Failure return false ----- Success return true ---@param bounds table ---@param text string ----@return any success -function RL.GuiPanel( bounds, text ) end +---@return any RL.GuiPanel +function RL.GuiPanel( bounds, text ) end ---Scroll Panel control ----- Failure return false ---- Success return Rectangle, Vector2 ---@param bounds table ---@param text string @@ -4667,15 +4475,12 @@ function RL.GuiScrollPanel( bounds, text, content, scroll ) end -- Gui - Basic ---Label control, shows text ----- Failure return false ----- Success return true ---@param bounds table ---@param text string ----@return any success -function RL.GuiLabel( bounds, text ) end +---@return any RL.GuiLabel +function RL.GuiLabel( bounds, text ) end ---Button control, returns true when clicked ----- Failure return nil ---- Success return boolean ---@param bounds table ---@param text string @@ -4683,7 +4488,6 @@ function RL.GuiLabel( bounds, text ) end function RL.GuiButton( bounds, text ) end ---Label button control, show true when clicked ----- Failure return nil ---- Success return boolean ---@param bounds table ---@param text string @@ -4691,7 +4495,6 @@ function RL.GuiButton( bounds, text ) end function RL.GuiLabelButton( bounds, text ) end ---Toggle Button control, returns true when active ----- Failure return nil ---- Success return boolean ---@param bounds table ---@param text string @@ -4700,7 +4503,6 @@ function RL.GuiLabelButton( bounds, text ) end function RL.GuiToggle( bounds, text, active ) end ---Toggle Group control, returns active toggle index ----- Failure return false ---- Success return int ---@param bounds table ---@param text string @@ -4709,7 +4511,6 @@ function RL.GuiToggle( bounds, text, active ) end function RL.GuiToggleGroup( bounds, text, active ) end ---Check Box control, returns true when active ----- Failure return nil ---- Success return boolean ---@param bounds table ---@param text string @@ -4718,7 +4519,6 @@ function RL.GuiToggleGroup( bounds, text, active ) end function RL.GuiCheckBox( bounds, text, checked ) end ---Combo Box control, returns selected item index ----- Failure return nil ---- Success return int ---@param bounds table ---@param text string @@ -4727,7 +4527,6 @@ function RL.GuiCheckBox( bounds, text, checked ) end function RL.GuiComboBox( bounds, text, active ) end ---Text Box control, updates input text ----- Failure return nil ---- Success return boolean, string ---@param bounds table ---@param text string @@ -4738,7 +4537,6 @@ function RL.GuiComboBox( bounds, text, active ) end function RL.GuiTextBox( bounds, text, textSize, editMode ) end ---Text Box control with multiple lines ----- Failure return nil ---- Success return boolean, string ---@param bounds table ---@param text string @@ -4749,7 +4547,6 @@ function RL.GuiTextBox( bounds, text, textSize, editMode ) end function RL.GuiTextBoxMulti( bounds, text, textSize, editMode ) end ---Spinner control, returns selected value ----- Failure return nil ---- Success return boolean, int ---@param bounds table ---@param text string @@ -4762,7 +4559,6 @@ function RL.GuiTextBoxMulti( bounds, text, textSize, editMode ) end function RL.GuiSpinner( bounds, text, value, minValue, maxValue, editMode ) end ---Value Box control, updates input text with numbers ----- Failure return nil ---- Success return boolean, int ---@param bounds table ---@param text string @@ -4775,7 +4571,6 @@ function RL.GuiSpinner( bounds, text, value, minValue, maxValue, editMode ) end function RL.GuiValueBox( bounds, text, value, minValue, maxValue, editMode ) end ---Slider control, returns selected value ----- Failure return nil ---- Success return float ---@param bounds table ---@param textLeft string @@ -4787,7 +4582,6 @@ function RL.GuiValueBox( bounds, text, value, minValue, maxValue, editMode ) end function RL.GuiSlider( bounds, textLeft, textRight, value, minValue, maxValue ) end ---Slider Bar control, returns selected value ----- Failure return nil ---- Success return float ---@param bounds table ---@param textLeft string @@ -4799,7 +4593,6 @@ function RL.GuiSlider( bounds, textLeft, textRight, value, minValue, maxValue ) function RL.GuiSliderBar( bounds, textLeft, textRight, value, minValue, maxValue ) end ---Progress Bar control, shows current progress value ----- Failure return nil ---- Success return float ---@param bounds table ---@param textLeft string @@ -4811,7 +4604,6 @@ function RL.GuiSliderBar( bounds, textLeft, textRight, value, minValue, maxValue function RL.GuiProgressBar( bounds, textLeft, textRight, value, minValue, maxValue ) end ---Scroll Bar control ----- Failure return nil ---- Success return int ---@param bounds table ---@param value integer @@ -4821,7 +4613,6 @@ function RL.GuiProgressBar( bounds, textLeft, textRight, value, minValue, maxVal function RL.GuiScrollBar( bounds, value, minValue, maxValue ) end ---Dropdown Box control, returns selected item ----- Failure return nil ---- Success return bool, int ---@param bounds table ---@param text string @@ -4832,23 +4623,18 @@ function RL.GuiScrollBar( bounds, value, minValue, maxValue ) end function RL.GuiDropdownBox( bounds, text, active, editMode ) end ---Status Bar control, shows info text ----- Failure return false ----- Success return true ---@param bounds table ---@param text string ----@return any success -function RL.GuiStatusBar( bounds, text ) end +---@return any RL.GuiStatusBar +function RL.GuiStatusBar( bounds, text ) end ---Dummy control for placeholders ----- Failure return false ----- Success return true ---@param bounds table ---@param text string ----@return any success -function RL.GuiDummyRec( bounds, text ) end +---@return any RL.GuiDummyRec +function RL.GuiDummyRec( bounds, text ) end ---Grid control, returns mouse cell position ----- Failure return false ---- Success return Vector2 ---@param bounds table ---@param text string @@ -4860,7 +4646,6 @@ function RL.GuiGrid( bounds, text, spacing, subdivs ) end -- Gui - Advanced ---List View control, returns selected list item index and scroll index ----- Failure return nil ---- Success return int, int ---@param bounds table ---@param text string @@ -4871,7 +4656,6 @@ function RL.GuiGrid( bounds, text, spacing, subdivs ) end function RL.GuiListView( bounds, text, scrollIndex, active ) end ---List View with extended parameters, returns selected list item index, scroll index and focus ----- Failure return nil ---- Success return int, int, int ---@param bounds table ---@param text string @@ -4883,8 +4667,7 @@ function RL.GuiListView( bounds, text, scrollIndex, active ) end ---@return any focus function RL.GuiListViewEx( bounds, text, focus, scrollIndex, active ) end ----Message Box control, displays a message, returns button index ( 0 is x button ) ----- Failure return false +---Message Box control, displays a message, returns button index (0 is x button) ---- Success return int ---@param bounds table ---@param title string @@ -4894,7 +4677,6 @@ function RL.GuiListViewEx( bounds, text, focus, scrollIndex, active ) end function RL.GuiMessageBox( bounds, title, message, buttons ) end ---Text Input Box control, ask for text, supports secret ----- Failure return false ---- Success return int, string, int ---@param bounds table ---@param title string @@ -4908,8 +4690,7 @@ function RL.GuiMessageBox( bounds, title, message, buttons ) end ---@return any secretViewActive function RL.GuiTextInputBox( bounds, title, message, buttons, text, textMaxSize, secretViewActive ) end ----Color Picker control ( multiple color controls ) ----- Failure return false +---Color Picker control (multiple color controls) ---- Success return Color ---@param bounds table ---@param text string @@ -4918,7 +4699,6 @@ function RL.GuiTextInputBox( bounds, title, message, buttons, text, textMaxSize, function RL.GuiColorPicker( bounds, text, color ) end ---Color Panel control ----- Failure return false ---- Success return Color ---@param bounds table ---@param text string @@ -4927,7 +4707,6 @@ function RL.GuiColorPicker( bounds, text, color ) end function RL.GuiColorPanel( bounds, text, color ) end ---Color Bar Alpha control ----- Failure return false ---- Success return float ---@param bounds table ---@param text string @@ -4936,7 +4715,6 @@ function RL.GuiColorPanel( bounds, text, color ) end function RL.GuiColorBarAlpha( bounds, text, alpha ) end ---Color Bar Hue control ----- Failure return false ---- Success return float ---@param bounds table ---@param text string @@ -4946,8 +4724,7 @@ function RL.GuiColorBarHue( bounds, text, value ) end -- Gui - Icons ----Get text with icon id prepended ( if supported ) ----- Failure return false +---Get text with icon id prepended (if supported) ---- Success return string ---@param iconId integer ---@param text string @@ -4955,40 +4732,31 @@ function RL.GuiColorBarHue( bounds, text, value ) end function RL.GuiIconText( iconId, text ) end ---Draw icon ----- Failure return false ----- Success return true ---@param iconId integer ---@param pos table ---@param pixelSize integer ---@param color table ----@return any success -function RL.GuiDrawIcon( iconId, pos, pixelSize, color ) end +---@return any RL.GuiDrawIcon +function RL.GuiDrawIcon( iconId, pos, pixelSize, color ) end ----Set icon scale ( 1 by default ) ----- Failure return false ----- Success return true +---Set icon scale (1 by default) ---@param scale integer ----@return any success -function RL.GuiSetIconScale( scale ) end +---@return any RL.GuiSetIconScale +function RL.GuiSetIconScale( scale ) end ---Set icon pixel value ----- Failure return false ----- Success return true ---@param iconId integer ---@param pos table ----@return any success -function RL.GuiSetIconPixel( iconId, pos ) end +---@return any RL.GuiSetIconPixel +function RL.GuiSetIconPixel( iconId, pos ) end ---Clear icon pixel value ----- Failure return false ----- Success return true ---@param iconId integer ---@param pos table ----@return any success -function RL.GuiClearIconPixel( iconId, pos ) end +---@return any RL.GuiClearIconPixel +function RL.GuiClearIconPixel( iconId, pos ) end ---Check icon pixel value ----- Failure return nil ---- Success return bool ---@param iconId integer ---@param pos table @@ -5076,11 +4844,9 @@ function RL.IsLightEnabled( light ) end -- RLGL - Matrix operations ---Choose the current matrix to be transformed ----- Failure return false ----- Success return true ---@param mode integer ----@return any success -function RL.rlMatrixMode( mode ) end +---@return any RL.rlMatrixMode +function RL.rlMatrixMode( mode ) end ---Push the current matrix to stack ---@return any RL.rlPushMatrix @@ -5095,234 +4861,185 @@ function RL.rlPopMatrix() end function RL.rlLoadIdentity() end ---Multiply the current matrix by a translation matrix ----- Failure return false ----- Success return true ---@param translation table ----@return any success -function RL.rlTranslatef( translation ) end +---@return any RL.rlTranslatef +function RL.rlTranslatef( translation ) end ---Multiply the current matrix by a rotation matrix ----- Failure return false ----- Success return true ---@param angle number ---@param rotation table ----@return any success -function RL.rlRotatef( angle, rotation ) end +---@return any RL.rlRotatef +function RL.rlRotatef( angle, rotation ) end ---Multiply the current matrix by a scaling matrix ----- Failure return false ----- Success return true ---@param scale table ----@return any success -function RL.rlScalef( scale ) end +---@return any RL.rlScalef +function RL.rlScalef( scale ) end ---Multiply the current matrix by another matrix ----- Failure return false ----- Success return true ---@param matrix table ----@return any success -function RL.rlMultMatrixf( matrix ) end +---@return any RL.rlMultMatrixf +function RL.rlMultMatrixf( matrix ) end ---Multiply the current matrix by a perspective matrix generated by parameters ----- Failure return false ----- Success return true ---@param left number ---@param right number ---@param bottom number ---@param top number ---@param znear number ---@param zfar number ----@return any success -function RL.rlFrustum( left, right, bottom, top, znear, zfar ) end +---@return any RL.rlFrustum +function RL.rlFrustum( left, right, bottom, top, znear, zfar ) end ---Multiply the current matrix by an orthographic matrix generated by parameters ----- Failure return false ----- Success return true ---@param left number ---@param right number ---@param bottom number ---@param top number ---@param znear number ---@param zfar number ----@return any success -function RL.rlOrtho( left, right, bottom, top, znear, zfar ) end +---@return any RL.rlOrtho +function RL.rlOrtho( left, right, bottom, top, znear, zfar ) end ----Set the viewport area ( transformation from normalized device coordinates to window coordinates ) +---Set the viewport area (transformation from normalized device coordinates to window coordinates) ---NOTE: We store current viewport dimensions ----- Failure return false ----- Success return true ---@param viewport table ----@return any success -function RL.rlViewport( viewport ) end +---@return any RL.rlViewport +function RL.rlViewport( viewport ) end -- RLGL - Vertex level operations ----Initialize drawing mode ( how to organize vertex ) ----- Failure return false ----- Success return true +---Initialize drawing mode (how to organize vertex) ---@param mode integer ----@return any success -function RL.rlBegin( mode ) end +---@return any RL.rlBegin +function RL.rlBegin( mode ) end ---Finish vertex providing ---@return any RL.rlEnd function RL.rlEnd() end ----Define one vertex ( position ) ----- Failure return false ----- Success return true +---Define one vertex (position) ---@param position table ----@return any success -function RL.rlVertex2f( position ) end +---@return any RL.rlVertex2f +function RL.rlVertex2f( position ) end ----Define one vertex ( position ) ----- Failure return false ----- Success return true +---Define one vertex (position) ---@param position table ----@return any success -function RL.rlVertex3f( position ) end +---@return any RL.rlVertex3f +function RL.rlVertex3f( position ) end ----Define one vertex ( texture coordinate ) - 2 float ----- Failure return false ----- Success return true +---Define one vertex (texture coordinate) - 2 float ---@param texCoord table ----@return any success -function RL.rlTexCoord2f( texCoord ) end +---@return any RL.rlTexCoord2f +function RL.rlTexCoord2f( texCoord ) end ----Define one vertex ( normal ) - 3 float ----- Failure return false ----- Success return true +---Define one vertex (normal) - 3 float ---@param normal table ----@return any success -function RL.rlNormal3f( normal ) end +---@return any RL.rlNormal3f +function RL.rlNormal3f( normal ) end ----Define one vertex ( color ) - 4 byte ----- Failure return false ----- Success return true +---Define one vertex (color) - 4 byte ---@param color table ----@return any success -function RL.rlColor4ub( color ) end +---@return any RL.rlColor4ub +function RL.rlColor4ub( color ) end ----Define one vertex ( color ) - 3 float ----- Failure return false ----- Success return true +---Define one vertex (color) - 3 float ---@param color table ----@return any success -function RL.rlColor3f( color ) end +---@return any RL.rlColor3f +function RL.rlColor3f( color ) end ----Define one vertex ( color ) - 4 float ----- Failure return false ----- Success return true +---Define one vertex (color) - 4 float ---@param color table ----@return any success -function RL.rlColor4f( color ) end +---@return any RL.rlColor4f +function RL.rlColor4f( color ) end -- RLGL - Vertex buffers state ----Enable vertex array ( VAO, if supported ) ----- Failure return nil +---Enable vertex array (VAO, if supported) ---- Success return bool ---@param vaoId integer ---@return any supported function RL.rlEnableVertexArray( vaoId ) end ----Disable vertex array ( VAO, if supported ) +---Disable vertex array (VAO, if supported) ---@return any RL.rlDisableVertexArray function RL.rlDisableVertexArray() end ----Enable vertex buffer ( VBO ) +---Enable vertex buffer (VBO) ---- Failure return false ---- Success return true ---@param id integer ----@return any success -function RL.rlEnableVertexBuffer( id ) end +---@return any RL.rlEnableVertexBuffer +function RL.rlEnableVertexBuffer( id ) end ----Disable vertex buffer ( VBO ) +---Disable vertex buffer (VBO) ---@return any RL.rlDisableVertexBuffer function RL.rlDisableVertexBuffer() end ----Enable vertex buffer element ( VBO element ) ----- Failure return false ----- Success return true +---Enable vertex buffer element (VBO element) ---@param id integer ----@return any success -function RL.rlEnableVertexBufferElement( id ) end +---@return any RL.rlEnableVertexBufferElement +function RL.rlEnableVertexBufferElement( id ) end ----Disable vertex buffer element ( VBO element ) +---Disable vertex buffer element (VBO element) ---@return any RL.rlDisableVertexBufferElement function RL.rlDisableVertexBufferElement() end ---Enable vertex attribute index ----- Failure return false ----- Success return true ---@param index integer ----@return any success -function RL.rlEnableVertexAttribute( index ) end +---@return any RL.rlEnableVertexAttribute +function RL.rlEnableVertexAttribute( index ) end ---Disable vertex attribute index ----- Failure return false ----- Success return true ---@param index integer ----@return any success -function RL.rlDisableVertexAttribute( index ) end +---@return any RL.rlDisableVertexAttribute +function RL.rlDisableVertexAttribute( index ) end -- RLGL - Textures state ---Select and active a texture slot ----- Failure return false ----- Success return true ---@param slot integer ----@return any success -function RL.rlActiveTextureSlot( slot ) end +---@return any RL.rlActiveTextureSlot +function RL.rlActiveTextureSlot( slot ) end ---Enable texture ----- Failure return false ----- Success return true ---@param id integer ----@return any success -function RL.rlEnableTexture( id ) end +---@return any RL.rlEnableTexture +function RL.rlEnableTexture( id ) end ---Disable texture ---@return any RL.rlDisableTexture function RL.rlDisableTexture() end ---Enable texture cubemap ----- Failure return false ----- Success return true ---@param id integer ----@return any success -function RL.rlEnableTextureCubemap( id ) end +---@return any RL.rlEnableTextureCubemap +function RL.rlEnableTextureCubemap( id ) end ---Disable texture cubemap ---@return any RL.rlDisableTextureCubemap function RL.rlDisableTextureCubemap() end ----Set texture parameters ( filter, wrap ) ----- Failure return false ----- Success return true +---Set texture parameters (filter, wrap) ---@param id integer ---@param param integer ---@param value integer ----@return any success -function RL.rlTextureParameters( id, param, value ) end +---@return any RL.rlTextureParameters +function RL.rlTextureParameters( id, param, value ) end ----Set cubemap parameters ( filter, wrap ) ----- Failure return false ----- Success return true +---Set cubemap parameters (filter, wrap) ---@param id integer ---@param param integer ---@param value integer ----@return any success -function RL.rlCubemapParameters( id, param, value ) end +---@return any RL.rlCubemapParameters +function RL.rlCubemapParameters( id, param, value ) end -- RLGL - Shader state ---Enable shader program ----- Failure return false ----- Success return true ---@param id integer ----@return any success -function RL.rlEnableShader( id ) end +---@return any RL.rlEnableShader +function RL.rlEnableShader( id ) end ---Disable shader program ---@return any RL.rlDisableShader @@ -5331,22 +5048,18 @@ function RL.rlDisableShader() end -- RLGL - Framebuffer state ---Enable render texture (fbo) ----- Failure return false ----- Success return true ---@param id integer ----@return any success -function RL.rlEnableFramebuffer( id ) end +---@return any RL.rlEnableFramebuffer +function RL.rlEnableFramebuffer( id ) end ---Disable render texture (fbo), return to default framebuffer ---@return any RL.rlDisableFramebuffer function RL.rlDisableFramebuffer() end ---Activate multiple draw color buffers ----- Failure return false ----- Success return true ---@param count integer ----@return any success -function RL.rlActiveDrawBuffers( count ) end +---@return any RL.rlActiveDrawBuffers +function RL.rlActiveDrawBuffers( count ) end -- RLGL - General render state @@ -5383,11 +5096,9 @@ function RL.rlEnableBackfaceCulling() end function RL.rlDisableBackfaceCulling() end ---Set face culling mode ----- Failure return false ----- Success return true ---@param mode integer ----@return any success -function RL.rlSetCullFace( mode ) end +---@return any RL.rlSetCullFace +function RL.rlSetCullFace( mode ) end ---Enable scissor test ---@return any RL.rlEnableScissorTest @@ -5398,11 +5109,9 @@ function RL.rlEnableScissorTest() end function RL.rlDisableScissorTest() end ---Scissor test ----- Failure return false ----- Success return true ---@param area table ----@return any success -function RL.rlScissor( area ) end +---@return any RL.rlScissor +function RL.rlScissor( area ) end ---Enable wire mode ---@return any RL.rlEnableWireMode @@ -5413,11 +5122,9 @@ function RL.rlEnableWireMode() end function RL.rlDisableWireMode() end ---Set the line drawing width ----- Failure return false ----- Success return true ---@param width number ----@return any success -function RL.rlSetLineWidth( width ) end +---@return any RL.rlSetLineWidth +function RL.rlSetLineWidth( width ) end ---Get the line drawing width ---- Success return float @@ -5446,13 +5153,11 @@ function RL.rlDisableStereoRender() end function RL.rlIsStereoRenderEnabled() end ---Clear color buffer with color ----- Failure return false ----- Success return true ---@param color table ----@return any success -function RL.rlClearColor( color ) end +---@return any RL.rlClearColor +function RL.rlClearColor( color ) end ----Clear used screen buffers ( color and depth ) +---Clear used screen buffers (color and depth) ---@return any RL.rlClearScreenBuffers function RL.rlClearScreenBuffers() end @@ -5461,32 +5166,26 @@ function RL.rlClearScreenBuffers() end function RL.rlCheckErrors() end ---Set blending mode ----- Failure return false ----- Success return true ---@param mode integer ----@return any success -function RL.rlSetBlendMode( mode ) end +---@return any RL.rlSetBlendMode +function RL.rlSetBlendMode( mode ) end ----Set blending mode factor and equation ( using OpenGL factors ) ----- Failure return false ----- Success return true +---Set blending mode factor and equation (using OpenGL factors) ---@param glSrcFactor integer ---@param glDstFactor integer ---@param glEquation integer ----@return any success -function RL.rlSetBlendFactors( glSrcFactor, glDstFactor, glEquation ) end +---@return any RL.rlSetBlendFactors +function RL.rlSetBlendFactors( glSrcFactor, glDstFactor, glEquation ) end ----Set blending mode factors and equations separately ( using OpenGL factors ) ----- Failure return false ----- Success return true +---Set blending mode factors and equations separately (using OpenGL factors) ---@param glSrcRGB integer ---@param glDstRGB integer ---@param glSrcAlpha integer ---@param glDstAlpha integer ---@param glEqRGB integer ---@param glEqAlpha integer ----@return any success -function RL.rlSetBlendFactorsSeparate( glSrcRGB, glDstRGB, glSrcAlpha, glDstAlpha, glEqRGB, glEqAlpha ) end +---@return any RL.rlSetBlendFactorsSeparate +function RL.rlSetBlendFactorsSeparate( glSrcRGB, glDstRGB, glSrcAlpha, glDstAlpha, glEqRGB, glEqAlpha ) end -- RLGL - Initialization functions @@ -5502,18 +5201,15 @@ function RL.rlGetVersion() end function RL.rlDrawRenderBatchActive() end ---Check internal buffer overflow for a given number of vertex and force a rlRenderBatch draw call if required ----- Failure return nil ---- Success return bool ---@param vCount integer ---@return any overflow function RL.rlCheckRenderBatchLimit( vCount ) end ---Set current texture for render batch and check buffers limits ----- Failure return false ----- Success return true ---@param id integer ----@return any success -function RL.rlSetTexture( id ) end +---@return any RL.rlSetTexture +function RL.rlSetTexture( id ) end -- RLGL - Vertex buffers management @@ -5523,7 +5219,6 @@ function RL.rlSetTexture( id ) end function RL.rlLoadVertexArray() end ---Load a vertex buffer attribute ----- Failure return -1 ---- Success return int ---@param buffer any ---@param dynamic boolean @@ -5531,7 +5226,6 @@ function RL.rlLoadVertexArray() end function RL.rlLoadVertexBuffer( buffer, dynamic ) end ---Load a new attributes element buffer ----- Failure return -1 ---- Success return int ---@param buffer any ---@param dynamic boolean @@ -5539,106 +5233,83 @@ function RL.rlLoadVertexBuffer( buffer, dynamic ) end function RL.rlLoadVertexBufferElement( buffer, dynamic ) end ---Update GPU buffer with new data ----- Failure return false ----- Success return true ---@param bufferId integer ---@param buffer any ---@param offset integer ----@return any success -function RL.rlUpdateVertexBuffer( bufferId, buffer, offset ) end +---@return any RL.rlUpdateVertexBuffer +function RL.rlUpdateVertexBuffer( bufferId, buffer, offset ) end ---Update vertex buffer elements with new data ----- Failure return false ----- Success return true ---@param id integer ---@param buffer any ---@param offset integer ----@return any success -function RL.rlUpdateVertexBufferElements( id, buffer, offset ) end +---@return any RL.rlUpdateVertexBufferElements +function RL.rlUpdateVertexBufferElements( id, buffer, offset ) end ---Unload vertex array object (VAO) ----- Failure return false ----- Success return true ---@param vaoId integer ----@return any success -function RL.rlUnloadVertexArray( vaoId ) end +---@return any RL.rlUnloadVertexArray +function RL.rlUnloadVertexArray( vaoId ) end ---Unload vertex buffer (VBO) ----- Failure return false ----- Success return true ---@param vboId integer ----@return any success -function RL.rlUnloadVertexBuffer( vboId ) end +---@return any RL.rlUnloadVertexBuffer +function RL.rlUnloadVertexBuffer( vboId ) end ---Set vertex attribute ----- Failure return false ----- Success return true ---@param index integer ---@param compSize integer ---@param type integer ---@param normalized boolean ---@param stride integer ---@param pointer integer ----@return any success -function RL.rlSetVertexAttribute( index, compSize, type, normalized, stride, pointer ) end +---@return any RL.rlSetVertexAttribute +function RL.rlSetVertexAttribute( index, compSize, type, normalized, stride, pointer ) end ---Set vertex attribute divisor ----- Failure return false ----- Success return true ---@param index integer ---@param divisor integer ----@return any success -function RL.rlSetVertexAttributeDivisor( index, divisor ) end +---@return any RL.rlSetVertexAttributeDivisor +function RL.rlSetVertexAttributeDivisor( index, divisor ) end ---Set vertex attribute default value ----- Failure return false ----- Success return true ---@param locIndex integer ---@param value any ---@param attribType integer ----@return any success -function RL.rlSetVertexAttributeDefault( locIndex, value, attribType ) end +---@return any RL.rlSetVertexAttributeDefault +function RL.rlSetVertexAttributeDefault( locIndex, value, attribType ) end ---Draw vertex array ----- Failure return false ----- Success return true ---@param offset integer ---@param count integer ----@return any success -function RL.rlDrawVertexArray( offset, count ) end +---@return any RL.rlDrawVertexArray +function RL.rlDrawVertexArray( offset, count ) end ---Draw vertex array elements ----- Failure return false ----- Success return true ---@param offset integer ---@param count integer ---@param buffer any ----@return any success -function RL.rlDrawVertexArrayElements( offset, count, buffer ) end +---@return any RL.rlDrawVertexArrayElements +function RL.rlDrawVertexArrayElements( offset, count, buffer ) end ---Draw vertex array instanced ----- Failure return false ----- Success return true ---@param offset integer ---@param count integer ---@param instances integer ----@return any success -function RL.rlDrawVertexArrayInstanced( offset, count, instances ) end +---@return any RL.rlDrawVertexArrayInstanced +function RL.rlDrawVertexArrayInstanced( offset, count, instances ) end ---Draw vertex array elements instanced ----- Failure return false ----- Success return true ---@param offset integer ---@param count integer ---@param buffer any ---@param instances integer ----@return any success -function RL.rlDrawVertexArrayElementsInstanced( offset, count, buffer, instances ) end +---@return any RL.rlDrawVertexArrayElementsInstanced +function RL.rlDrawVertexArrayElementsInstanced( offset, count, buffer, instances ) end -- RLGL - Textures management ---Load texture in GPU ----- Failure return -1 ---- Success return int ---@param size table ---@param format integer @@ -5646,8 +5317,7 @@ function RL.rlDrawVertexArrayElementsInstanced( offset, count, buffer, instances ---@return any id function RL.rlLoadTexture( size, format, mipmapCount ) end ----Load depth texture/renderbuffer ( to be attached to fbo ) ----- Failure return -1 +---Load depth texture/renderbuffer (to be attached to fbo) ---- Success return int ---@param size table ---@param useRenderBuffer boolean @@ -5655,45 +5325,37 @@ function RL.rlLoadTexture( size, format, mipmapCount ) end function RL.rlLoadTextureDepth( size, useRenderBuffer ) end ---Unload texture from GPU memory ----- Failure return false ----- Success return true ---@param id integer ----@return any success -function RL.rlUnloadTexture( id ) end +---@return any RL.rlUnloadTexture +function RL.rlUnloadTexture( id ) end -- RLGL - Framebuffer management (fbo) ---Load an empty framebuffer ----- Failure return -1 ---- Success return int ---@param size table ---@return any fboId function RL.rlLoadFramebuffer( size ) end ---Attach texture/renderbuffer to a framebuffer ----- Failure return false ----- Success return true ---@param fboId integer ---@param texId integer ---@param attachType integer ---@param texType integer ---@param mipLevel integer ----@return any success -function RL.rlFramebufferAttach( fboId, texId, attachType, texType, mipLevel ) end +---@return any RL.rlFramebufferAttach +function RL.rlFramebufferAttach( fboId, texId, attachType, texType, mipLevel ) end ---Verify framebuffer is complete ----- Failure return nil ---- Success return bool ---@param id integer ---@return any isComplete function RL.rlFramebufferComplete( id ) end ---Delete framebuffer from GPU ----- Failure return nil ----- Success return bool ---@param id integer ----@return any success -function RL.rlUnloadFramebuffer( id ) end +---@return any RL.rlUnloadFramebuffer +function RL.rlUnloadFramebuffer( id ) end -- RLGL - Shaders management @@ -5723,48 +5385,38 @@ function RL.rlGetMatrixProjection() end function RL.rlGetMatrixTransform() end ---Get internal projection matrix for stereo render (selected eye) ----- Failure return false ---- Success return Matrix ---@param eye integer ---@return any projection function RL.rlGetMatrixProjectionStereo( eye ) end ---Get internal view offset matrix for stereo render (selected eye) ----- Failure return false ---- Success return Matrix ---@param eye integer ---@return any viewOffset function RL.rlGetMatrixViewOffsetStereo( eye ) end ---Set a custom projection matrix (replaces internal projection matrix) ----- Failure return false ----- Success return true ---@param proj table ----@return any success -function RL.rlSetMatrixProjection( proj ) end +---@return any RL.rlSetMatrixProjection +function RL.rlSetMatrixProjection( proj ) end ---Set a custom modelview matrix (replaces internal modelview matrix) ----- Failure return false ----- Success return true ---@param view table ----@return any success -function RL.rlSetMatrixModelview( view ) end +---@return any RL.rlSetMatrixModelview +function RL.rlSetMatrixModelview( view ) end ---Set eyes projection matrices for stereo rendering ----- Failure return false ----- Success return true ---@param right table ---@param left table ----@return any success -function RL.rlSetMatrixProjectionStereo( right, left ) end +---@return any RL.rlSetMatrixProjectionStereo +function RL.rlSetMatrixProjectionStereo( right, left ) end ---Set eyes view offsets matrices for stereo rendering ----- Failure return false ----- Success return true ---@param right table ---@param left table ----@return any success -function RL.rlSetMatrixViewOffsetStereo( right, left ) end +---@return any RL.rlSetMatrixViewOffsetStereo +function RL.rlSetMatrixViewOffsetStereo( right, left ) end -- OpenGL - Framebuffer management @@ -5782,7 +5434,6 @@ function RL.glBlitFramebuffer( srcTex, dstTex, srcRect, dstRect, mask, filter ) -- Easings - Linear Easing functions ---Ease linear ----- Failure return false ---- Success return float ---@param t number ---@param b number @@ -5794,7 +5445,6 @@ function RL.EaseLinear( t, b, c, d ) end -- Easings - Sine Easing functions ---Ease sine in ----- Failure return false ---- Success return float ---@param t number ---@param b number @@ -5804,7 +5454,6 @@ function RL.EaseLinear( t, b, c, d ) end function RL.EaseSineIn( t, b, c, d ) end ---Ease sine out ----- Failure return false ---- Success return float ---@param t number ---@param b number @@ -5814,7 +5463,6 @@ function RL.EaseSineIn( t, b, c, d ) end function RL.EaseSineOut( t, b, c, d ) end ---Ease sine in out ----- Failure return false ---- Success return float ---@param t number ---@param b number @@ -5826,7 +5474,6 @@ function RL.EaseSineInOut( t, b, c, d ) end -- Easings - Circular Easing functions ---Ease circle in ----- Failure return false ---- Success return float ---@param t number ---@param b number @@ -5836,7 +5483,6 @@ function RL.EaseSineInOut( t, b, c, d ) end function RL.EaseCircIn( t, b, c, d ) end ---Ease circle out ----- Failure return false ---- Success return float ---@param t number ---@param b number @@ -5846,7 +5492,6 @@ function RL.EaseCircIn( t, b, c, d ) end function RL.EaseCircOut( t, b, c, d ) end ---Ease circle in out ----- Failure return false ---- Success return float ---@param t number ---@param b number @@ -5858,7 +5503,6 @@ function RL.EaseCircInOut( t, b, c, d ) end -- Easings - Cubic Easing functions ---Ease cubic in ----- Failure return false ---- Success return float ---@param t number ---@param b number @@ -5868,7 +5512,6 @@ function RL.EaseCircInOut( t, b, c, d ) end function RL.EaseCubicIn( t, b, c, d ) end ---Ease cubic out ----- Failure return false ---- Success return float ---@param t number ---@param b number @@ -5878,7 +5521,6 @@ function RL.EaseCubicIn( t, b, c, d ) end function RL.EaseCubicOut( t, b, c, d ) end ---Ease cubic in out ----- Failure return false ---- Success return float ---@param t number ---@param b number @@ -5890,7 +5532,6 @@ function RL.EaseCubicInOut( t, b, c, d ) end -- Easings - Quadratic Easing functions ---Ease quadratic in ----- Failure return false ---- Success return float ---@param t number ---@param b number @@ -5900,7 +5541,6 @@ function RL.EaseCubicInOut( t, b, c, d ) end function RL.EaseQuadIn( t, b, c, d ) end ---Ease quadratic out ----- Failure return false ---- Success return float ---@param t number ---@param b number @@ -5910,7 +5550,6 @@ function RL.EaseQuadIn( t, b, c, d ) end function RL.EaseQuadOut( t, b, c, d ) end ---Ease quadratic in out ----- Failure return false ---- Success return float ---@param t number ---@param b number @@ -5922,7 +5561,6 @@ function RL.EaseQuadInOut( t, b, c, d ) end -- Easings - Exponential Easing functions ---Ease exponential in ----- Failure return false ---- Success return float ---@param t number ---@param b number @@ -5932,7 +5570,6 @@ function RL.EaseQuadInOut( t, b, c, d ) end function RL.EaseExpoIn( t, b, c, d ) end ---Ease exponential out ----- Failure return false ---- Success return float ---@param t number ---@param b number @@ -5942,7 +5579,6 @@ function RL.EaseExpoIn( t, b, c, d ) end function RL.EaseExpoOut( t, b, c, d ) end ---Ease exponential in out ----- Failure return false ---- Success return float ---@param t number ---@param b number @@ -5954,7 +5590,6 @@ function RL.EaseExpoInOut( t, b, c, d ) end -- Easings - Back Easing functions ---Ease back in ----- Failure return false ---- Success return float ---@param t number ---@param b number @@ -5964,7 +5599,6 @@ function RL.EaseExpoInOut( t, b, c, d ) end function RL.EaseBackIn( t, b, c, d ) end ---Ease back out ----- Failure return false ---- Success return float ---@param t number ---@param b number @@ -5974,7 +5608,6 @@ function RL.EaseBackIn( t, b, c, d ) end function RL.EaseBackOut( t, b, c, d ) end ---Ease back in out ----- Failure return false ---- Success return float ---@param t number ---@param b number @@ -5986,7 +5619,6 @@ function RL.EaseBackInOut( t, b, c, d ) end -- Easings - Bounce Easing functions ---Ease bounce in ----- Failure return false ---- Success return float ---@param t number ---@param b number @@ -5996,7 +5628,6 @@ function RL.EaseBackInOut( t, b, c, d ) end function RL.EaseBounceIn( t, b, c, d ) end ---Ease bounce out ----- Failure return false ---- Success return float ---@param t number ---@param b number @@ -6006,7 +5637,6 @@ function RL.EaseBounceIn( t, b, c, d ) end function RL.EaseBounceOut( t, b, c, d ) end ---Ease bounce in out ----- Failure return false ---- Success return float ---@param t number ---@param b number @@ -6018,7 +5648,6 @@ function RL.EaseBounceInOut( t, b, c, d ) end -- Easings - Elastic Easing functions ---Ease elastic in ----- Failure return false ---- Success return float ---@param t number ---@param b number @@ -6028,7 +5657,6 @@ function RL.EaseBounceInOut( t, b, c, d ) end function RL.EaseElasticIn( t, b, c, d ) end ---Ease elastic out ----- Failure return false ---- Success return float ---@param t number ---@param b number @@ -6038,7 +5666,6 @@ function RL.EaseElasticIn( t, b, c, d ) end function RL.EaseElasticOut( t, b, c, d ) end ---Ease elastic in out ----- Failure return false ---- Success return float ---@param t number ---@param b number @@ -787,7 +787,7 @@ NOTE: Set nil if no shader */ int lcoreLoadShader( lua_State *L ) { if ( !( lua_isstring( L, 1 ) || lua_isnil( L, 1 ) ) || !( lua_isstring( L, 2 ) || lua_isnil( L, 2 ) ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.LoadShader( string vsFileName, string fsFileName )" ); + TraceLog( state->logLevelInvalid, "%s", "Argument needs to be string or nil" ); lua_pushnil( L ); return 1; } diff --git a/src/easings.c b/src/easings.c index f4092f0..cae349c 100644 --- a/src/easings.c +++ b/src/easings.c @@ -13,19 +13,13 @@ Ease linear -- Failure return false - Success return float */ int leasingsEaseLinear( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.EaseLinear( float t, float b, float c, float d )" ); - lua_pushboolean( L, false ); - return 1; - } - float t = lua_tonumber( L, 1 ); - float b = lua_tonumber( L, 2 ); - float c = lua_tonumber( L, 3 ); - float d = lua_tonumber( L, 4 ); + float t = luaL_checknumber( L, 1 ); + float b = luaL_checknumber( L, 2 ); + float c = luaL_checknumber( L, 3 ); + float d = luaL_checknumber( L, 4 ); lua_pushnumber( L, EaseLinearNone( t, b, c, d ) ); @@ -41,19 +35,13 @@ int leasingsEaseLinear( lua_State *L ) { Ease sine in -- Failure return false - Success return float */ int leasingsEaseSineIn( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.EaseSineIn( float t, float b, float c, float d )" ); - lua_pushboolean( L, false ); - return 1; - } - float t = lua_tonumber( L, 1 ); - float b = lua_tonumber( L, 2 ); - float c = lua_tonumber( L, 3 ); - float d = lua_tonumber( L, 4 ); + float t = luaL_checknumber( L, 1 ); + float b = luaL_checknumber( L, 2 ); + float c = luaL_checknumber( L, 3 ); + float d = luaL_checknumber( L, 4 ); lua_pushnumber( L, EaseSineIn( t, b, c, d ) ); @@ -65,19 +53,13 @@ int leasingsEaseSineIn( lua_State *L ) { Ease sine out -- Failure return false - Success return float */ int leasingsEaseSineOut( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.EaseSineOut( float t, float b, float c, float d )" ); - lua_pushboolean( L, false ); - return 1; - } - float t = lua_tonumber( L, 1 ); - float b = lua_tonumber( L, 2 ); - float c = lua_tonumber( L, 3 ); - float d = lua_tonumber( L, 4 ); + float t = luaL_checknumber( L, 1 ); + float b = luaL_checknumber( L, 2 ); + float c = luaL_checknumber( L, 3 ); + float d = luaL_checknumber( L, 4 ); lua_pushnumber( L, EaseSineOut( t, b, c, d ) ); @@ -89,19 +71,13 @@ int leasingsEaseSineOut( lua_State *L ) { Ease sine in out -- Failure return false - Success return float */ int leasingsEaseSineInOut( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.EaseSineInOut( float t, float b, float c, float d )" ); - lua_pushboolean( L, false ); - return 1; - } - float t = lua_tonumber( L, 1 ); - float b = lua_tonumber( L, 2 ); - float c = lua_tonumber( L, 3 ); - float d = lua_tonumber( L, 4 ); + float t = luaL_checknumber( L, 1 ); + float b = luaL_checknumber( L, 2 ); + float c = luaL_checknumber( L, 3 ); + float d = luaL_checknumber( L, 4 ); lua_pushnumber( L, EaseSineInOut( t, b, c, d ) ); @@ -117,19 +93,13 @@ int leasingsEaseSineInOut( lua_State *L ) { Ease circle in -- Failure return false - Success return float */ int leasingsEaseCircIn( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.EaseCircIn( float t, float b, float c, float d )" ); - lua_pushboolean( L, false ); - return 1; - } - float t = lua_tonumber( L, 1 ); - float b = lua_tonumber( L, 2 ); - float c = lua_tonumber( L, 3 ); - float d = lua_tonumber( L, 4 ); + float t = luaL_checknumber( L, 1 ); + float b = luaL_checknumber( L, 2 ); + float c = luaL_checknumber( L, 3 ); + float d = luaL_checknumber( L, 4 ); lua_pushnumber( L, EaseCircIn( t, b, c, d ) ); @@ -141,19 +111,13 @@ int leasingsEaseCircIn( lua_State *L ) { Ease circle out -- Failure return false - Success return float */ int leasingsEaseCircOut( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.EaseCircOut( float t, float b, float c, float d )" ); - lua_pushboolean( L, false ); - return 1; - } - float t = lua_tonumber( L, 1 ); - float b = lua_tonumber( L, 2 ); - float c = lua_tonumber( L, 3 ); - float d = lua_tonumber( L, 4 ); + float t = luaL_checknumber( L, 1 ); + float b = luaL_checknumber( L, 2 ); + float c = luaL_checknumber( L, 3 ); + float d = luaL_checknumber( L, 4 ); lua_pushnumber( L, EaseCircOut( t, b, c, d ) ); @@ -165,19 +129,13 @@ int leasingsEaseCircOut( lua_State *L ) { Ease circle in out -- Failure return false - Success return float */ int leasingsEaseCircInOut( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.EaseCircInOut( float t, float b, float c, float d )" ); - lua_pushboolean( L, false ); - return 1; - } - float t = lua_tonumber( L, 1 ); - float b = lua_tonumber( L, 2 ); - float c = lua_tonumber( L, 3 ); - float d = lua_tonumber( L, 4 ); + float t = luaL_checknumber( L, 1 ); + float b = luaL_checknumber( L, 2 ); + float c = luaL_checknumber( L, 3 ); + float d = luaL_checknumber( L, 4 ); lua_pushnumber( L, EaseCircInOut( t, b, c, d ) ); @@ -193,19 +151,13 @@ int leasingsEaseCircInOut( lua_State *L ) { Ease cubic in -- Failure return false - Success return float */ int leasingsEaseCubicIn( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.EaseCubicIn( float t, float b, float c, float d )" ); - lua_pushboolean( L, false ); - return 1; - } - float t = lua_tonumber( L, 1 ); - float b = lua_tonumber( L, 2 ); - float c = lua_tonumber( L, 3 ); - float d = lua_tonumber( L, 4 ); + float t = luaL_checknumber( L, 1 ); + float b = luaL_checknumber( L, 2 ); + float c = luaL_checknumber( L, 3 ); + float d = luaL_checknumber( L, 4 ); lua_pushnumber( L, EaseCubicIn( t, b, c, d ) ); @@ -217,19 +169,13 @@ int leasingsEaseCubicIn( lua_State *L ) { Ease cubic out -- Failure return false - Success return float */ int leasingsEaseCubicOut( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.EaseCubicOut( float t, float b, float c, float d )" ); - lua_pushboolean( L, false ); - return 1; - } - float t = lua_tonumber( L, 1 ); - float b = lua_tonumber( L, 2 ); - float c = lua_tonumber( L, 3 ); - float d = lua_tonumber( L, 4 ); + float t = luaL_checknumber( L, 1 ); + float b = luaL_checknumber( L, 2 ); + float c = luaL_checknumber( L, 3 ); + float d = luaL_checknumber( L, 4 ); lua_pushnumber( L, EaseCubicOut( t, b, c, d ) ); @@ -241,19 +187,13 @@ int leasingsEaseCubicOut( lua_State *L ) { Ease cubic in out -- Failure return false - Success return float */ int leasingsEaseCubicInOut( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.EaseCubicInOut( float t, float b, float c, float d )" ); - lua_pushboolean( L, false ); - return 1; - } - float t = lua_tonumber( L, 1 ); - float b = lua_tonumber( L, 2 ); - float c = lua_tonumber( L, 3 ); - float d = lua_tonumber( L, 4 ); + float t = luaL_checknumber( L, 1 ); + float b = luaL_checknumber( L, 2 ); + float c = luaL_checknumber( L, 3 ); + float d = luaL_checknumber( L, 4 ); lua_pushnumber( L, EaseCubicInOut( t, b, c, d ) ); @@ -269,19 +209,13 @@ int leasingsEaseCubicInOut( lua_State *L ) { Ease quadratic in -- Failure return false - Success return float */ int leasingsEaseQuadIn( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.EaseQuadIn( float t, float b, float c, float d )" ); - lua_pushboolean( L, false ); - return 1; - } - float t = lua_tonumber( L, 1 ); - float b = lua_tonumber( L, 2 ); - float c = lua_tonumber( L, 3 ); - float d = lua_tonumber( L, 4 ); + float t = luaL_checknumber( L, 1 ); + float b = luaL_checknumber( L, 2 ); + float c = luaL_checknumber( L, 3 ); + float d = luaL_checknumber( L, 4 ); lua_pushnumber( L, EaseQuadIn( t, b, c, d ) ); @@ -293,19 +227,13 @@ int leasingsEaseQuadIn( lua_State *L ) { Ease quadratic out -- Failure return false - Success return float */ int leasingsEaseQuadOut( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.EaseQuadOut( float t, float b, float c, float d )" ); - lua_pushboolean( L, false ); - return 1; - } - float t = lua_tonumber( L, 1 ); - float b = lua_tonumber( L, 2 ); - float c = lua_tonumber( L, 3 ); - float d = lua_tonumber( L, 4 ); + float t = luaL_checknumber( L, 1 ); + float b = luaL_checknumber( L, 2 ); + float c = luaL_checknumber( L, 3 ); + float d = luaL_checknumber( L, 4 ); lua_pushnumber( L, EaseQuadOut( t, b, c, d ) ); @@ -317,19 +245,13 @@ int leasingsEaseQuadOut( lua_State *L ) { Ease quadratic in out -- Failure return false - Success return float */ int leasingsEaseQuadInOut( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.EaseQuadInOut( float t, float b, float c, float d )" ); - lua_pushboolean( L, false ); - return 1; - } - float t = lua_tonumber( L, 1 ); - float b = lua_tonumber( L, 2 ); - float c = lua_tonumber( L, 3 ); - float d = lua_tonumber( L, 4 ); + float t = luaL_checknumber( L, 1 ); + float b = luaL_checknumber( L, 2 ); + float c = luaL_checknumber( L, 3 ); + float d = luaL_checknumber( L, 4 ); lua_pushnumber( L, EaseQuadInOut( t, b, c, d ) ); @@ -345,19 +267,13 @@ int leasingsEaseQuadInOut( lua_State *L ) { Ease exponential in -- Failure return false - Success return float */ int leasingsEaseExpoIn( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.EaseExpoIn( float t, float b, float c, float d )" ); - lua_pushboolean( L, false ); - return 1; - } - float t = lua_tonumber( L, 1 ); - float b = lua_tonumber( L, 2 ); - float c = lua_tonumber( L, 3 ); - float d = lua_tonumber( L, 4 ); + float t = luaL_checknumber( L, 1 ); + float b = luaL_checknumber( L, 2 ); + float c = luaL_checknumber( L, 3 ); + float d = luaL_checknumber( L, 4 ); lua_pushnumber( L, EaseExpoIn( t, b, c, d ) ); @@ -369,19 +285,13 @@ int leasingsEaseExpoIn( lua_State *L ) { Ease exponential out -- Failure return false - Success return float */ int leasingsEaseExpoOut( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.EaseExpoOut( float t, float b, float c, float d )" ); - lua_pushboolean( L, false ); - return 1; - } - float t = lua_tonumber( L, 1 ); - float b = lua_tonumber( L, 2 ); - float c = lua_tonumber( L, 3 ); - float d = lua_tonumber( L, 4 ); + float t = luaL_checknumber( L, 1 ); + float b = luaL_checknumber( L, 2 ); + float c = luaL_checknumber( L, 3 ); + float d = luaL_checknumber( L, 4 ); lua_pushnumber( L, EaseExpoOut( t, b, c, d ) ); @@ -393,19 +303,13 @@ int leasingsEaseExpoOut( lua_State *L ) { Ease exponential in out -- Failure return false - Success return float */ int leasingsEaseExpoInOut( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.EaseExpoInOut( float t, float b, float c, float d )" ); - lua_pushboolean( L, false ); - return 1; - } - float t = lua_tonumber( L, 1 ); - float b = lua_tonumber( L, 2 ); - float c = lua_tonumber( L, 3 ); - float d = lua_tonumber( L, 4 ); + float t = luaL_checknumber( L, 1 ); + float b = luaL_checknumber( L, 2 ); + float c = luaL_checknumber( L, 3 ); + float d = luaL_checknumber( L, 4 ); lua_pushnumber( L, EaseExpoInOut( t, b, c, d ) ); @@ -421,19 +325,13 @@ int leasingsEaseExpoInOut( lua_State *L ) { Ease back in -- Failure return false - Success return float */ int leasingsEaseBackIn( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.EaseBackIn( float t, float b, float c, float d )" ); - lua_pushboolean( L, false ); - return 1; - } - float t = lua_tonumber( L, 1 ); - float b = lua_tonumber( L, 2 ); - float c = lua_tonumber( L, 3 ); - float d = lua_tonumber( L, 4 ); + float t = luaL_checknumber( L, 1 ); + float b = luaL_checknumber( L, 2 ); + float c = luaL_checknumber( L, 3 ); + float d = luaL_checknumber( L, 4 ); lua_pushnumber( L, EaseBackIn( t, b, c, d ) ); @@ -445,19 +343,13 @@ int leasingsEaseBackIn( lua_State *L ) { Ease back out -- Failure return false - Success return float */ int leasingsEaseBackOut( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.EaseBackOut( float t, float b, float c, float d )" ); - lua_pushboolean( L, false ); - return 1; - } - float t = lua_tonumber( L, 1 ); - float b = lua_tonumber( L, 2 ); - float c = lua_tonumber( L, 3 ); - float d = lua_tonumber( L, 4 ); + float t = luaL_checknumber( L, 1 ); + float b = luaL_checknumber( L, 2 ); + float c = luaL_checknumber( L, 3 ); + float d = luaL_checknumber( L, 4 ); lua_pushnumber( L, EaseBackOut( t, b, c, d ) ); @@ -469,19 +361,13 @@ int leasingsEaseBackOut( lua_State *L ) { Ease back in out -- Failure return false - Success return float */ int leasingsEaseBackInOut( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.EaseBackInOut( float t, float b, float c, float d )" ); - lua_pushboolean( L, false ); - return 1; - } - float t = lua_tonumber( L, 1 ); - float b = lua_tonumber( L, 2 ); - float c = lua_tonumber( L, 3 ); - float d = lua_tonumber( L, 4 ); + float t = luaL_checknumber( L, 1 ); + float b = luaL_checknumber( L, 2 ); + float c = luaL_checknumber( L, 3 ); + float d = luaL_checknumber( L, 4 ); lua_pushnumber( L, EaseBackInOut( t, b, c, d ) ); @@ -497,19 +383,13 @@ int leasingsEaseBackInOut( lua_State *L ) { Ease bounce in -- Failure return false - Success return float */ int leasingsEaseBounceIn( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.EaseBounceIn( float t, float b, float c, float d )" ); - lua_pushboolean( L, false ); - return 1; - } - float t = lua_tonumber( L, 1 ); - float b = lua_tonumber( L, 2 ); - float c = lua_tonumber( L, 3 ); - float d = lua_tonumber( L, 4 ); + float t = luaL_checknumber( L, 1 ); + float b = luaL_checknumber( L, 2 ); + float c = luaL_checknumber( L, 3 ); + float d = luaL_checknumber( L, 4 ); lua_pushnumber( L, EaseBounceIn( t, b, c, d ) ); @@ -521,19 +401,13 @@ int leasingsEaseBounceIn( lua_State *L ) { Ease bounce out -- Failure return false - Success return float */ int leasingsEaseBounceOut( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.EaseBounceOut( float t, float b, float c, float d )" ); - lua_pushboolean( L, false ); - return 1; - } - float t = lua_tonumber( L, 1 ); - float b = lua_tonumber( L, 2 ); - float c = lua_tonumber( L, 3 ); - float d = lua_tonumber( L, 4 ); + float t = luaL_checknumber( L, 1 ); + float b = luaL_checknumber( L, 2 ); + float c = luaL_checknumber( L, 3 ); + float d = luaL_checknumber( L, 4 ); lua_pushnumber( L, EaseBounceOut( t, b, c, d ) ); @@ -545,19 +419,13 @@ int leasingsEaseBounceOut( lua_State *L ) { Ease bounce in out -- Failure return false - Success return float */ int leasingsEaseBounceInOut( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.EaseBounceInOut( float t, float b, float c, float d )" ); - lua_pushboolean( L, false ); - return 1; - } - float t = lua_tonumber( L, 1 ); - float b = lua_tonumber( L, 2 ); - float c = lua_tonumber( L, 3 ); - float d = lua_tonumber( L, 4 ); + float t = luaL_checknumber( L, 1 ); + float b = luaL_checknumber( L, 2 ); + float c = luaL_checknumber( L, 3 ); + float d = luaL_checknumber( L, 4 ); lua_pushnumber( L, EaseBounceInOut( t, b, c, d ) ); @@ -573,19 +441,13 @@ int leasingsEaseBounceInOut( lua_State *L ) { Ease elastic in -- Failure return false - Success return float */ int leasingsEaseElasticIn( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.EaseElasticIn( float t, float b, float c, float d )" ); - lua_pushboolean( L, false ); - return 1; - } - float t = lua_tonumber( L, 1 ); - float b = lua_tonumber( L, 2 ); - float c = lua_tonumber( L, 3 ); - float d = lua_tonumber( L, 4 ); + float t = luaL_checknumber( L, 1 ); + float b = luaL_checknumber( L, 2 ); + float c = luaL_checknumber( L, 3 ); + float d = luaL_checknumber( L, 4 ); lua_pushnumber( L, EaseElasticIn( t, b, c, d ) ); @@ -597,19 +459,13 @@ int leasingsEaseElasticIn( lua_State *L ) { Ease elastic out -- Failure return false - Success return float */ int leasingsEaseElasticOut( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.EaseElasticOut( float t, float b, float c, float d )" ); - lua_pushboolean( L, false ); - return 1; - } - float t = lua_tonumber( L, 1 ); - float b = lua_tonumber( L, 2 ); - float c = lua_tonumber( L, 3 ); - float d = lua_tonumber( L, 4 ); + float t = luaL_checknumber( L, 1 ); + float b = luaL_checknumber( L, 2 ); + float c = luaL_checknumber( L, 3 ); + float d = luaL_checknumber( L, 4 ); lua_pushnumber( L, EaseElasticOut( t, b, c, d ) ); @@ -621,19 +477,13 @@ int leasingsEaseElasticOut( lua_State *L ) { Ease elastic in out -- Failure return false - Success return float */ int leasingsEaseElasticInOut( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.EaseElasticInOut( float t, float b, float c, float d )" ); - lua_pushboolean( L, false ); - return 1; - } - float t = lua_tonumber( L, 1 ); - float b = lua_tonumber( L, 2 ); - float c = lua_tonumber( L, 3 ); - float d = lua_tonumber( L, 4 ); + float t = luaL_checknumber( L, 1 ); + float b = luaL_checknumber( L, 2 ); + float c = luaL_checknumber( L, 3 ); + float d = luaL_checknumber( L, 4 ); lua_pushnumber( L, EaseElasticInOut( t, b, c, d ) ); @@ -15,25 +15,29 @@ Copy a block of pixels from one framebuffer object to another. Use -1 RenderTexture for window framebuffer. */ int lglBlitFramebuffer( lua_State *L ) { - // TODO Currently doesn't support setting window render target because of luaL_checkudata. - RenderTexture *srcTex = luaL_checkudata( L, 1, "RenderTexture" ); - RenderTexture *dstTex = luaL_checkudata( L, 2, "RenderTexture" ); + if ( !( lua_isuserdata( L, 1 ) || lua_isnil( L, 1 ) ) || !( lua_isuserdata( L, 2 ) || lua_isnil( L, 2 ) ) ) { + TraceLog( state->logLevelInvalid, "%s", "Argument needs to be RenderTexture or nil" ); + lua_pushnil( L ); + return 1; + } Rectangle srcRect = uluaGetRectangleIndex( L, 3 ); Rectangle dstRect = uluaGetRectangleIndex( L, 4 ); int mask = luaL_checkinteger( L, 5 ); int filter = luaL_checkinteger( L, 6 ); - if ( lua_tointeger( L, 1 ) == -1 ) { + if ( lua_isnil( L, 1 ) ) { glBindFramebuffer( GL_READ_FRAMEBUFFER, 0 ); } else { + RenderTexture *srcTex = luaL_checkudata( L, 1, "RenderTexture" ); glBindFramebuffer( GL_READ_FRAMEBUFFER, srcTex->id ); } - if ( lua_tointeger( L, 2 ) == -1 ) { + if ( lua_isnil( L, 2 ) ) { glBindFramebuffer( GL_DRAW_FRAMEBUFFER, 0 ); } else { + RenderTexture *dstTex = luaL_checkudata( L, 2, "RenderTexture" ); glBindFramebuffer( GL_DRAW_FRAMEBUFFER, dstTex->id ); } diff --git a/src/lua_core.c b/src/lua_core.c index fa60517..659cf56 100644 --- a/src/lua_core.c +++ b/src/lua_core.c @@ -16,7 +16,7 @@ /* Define types. */ -/* Buffer. */ + /* Buffer. */ static int gcBuffer( lua_State *L ) { Buffer *buffer = luaL_checkudata ( L, 1, "Buffer" ); free( buffer->data ); @@ -32,7 +32,7 @@ static void defineBuffer() { lua_setfield( L, -2, "__gc" ); } -/* Image */ + /* Image */ static int gcImage( lua_State *L ) { Image *image = luaL_checkudata ( L, 1, "Image" ); printf( "gcImage\n" ); @@ -50,7 +50,7 @@ static void defineImage() { lua_setfield( L, -2, "__gc" ); } -/* Texture */ + /* Texture */ static int gcTexture( lua_State *L ) { Texture *texture = luaL_checkudata ( L, 1, "Texture" ); printf( "gcTexture\n" ); @@ -68,7 +68,7 @@ static void defineTexture() { lua_setfield( L, -2, "__gc" ); } -/* RenderRexture. */ + /* RenderRexture. */ static int gcRenderTexture( lua_State *L ) { RenderTexture *renderTexture = luaL_checkudata ( L, 1, "RenderTexture" ); printf( "gcRenderTexture\n" ); @@ -86,7 +86,7 @@ static void defineRenderTexture() { lua_setfield( L, -2, "__gc" ); } -/* Camera2D. */ + /* Camera2D. */ static void defineCamera2D() { lua_State *L = state->luaState; @@ -95,7 +95,7 @@ static void defineCamera2D() { lua_setfield( L, -2, "__index" ); } -/* Camera3D. */ + /* Camera3D. */ static void defineCamera3D() { lua_State *L = state->luaState; @@ -104,7 +104,7 @@ static void defineCamera3D() { lua_setfield( L, -2, "__index" ); } -/* Shader. */ + /* Shader. */ static int gcShader( lua_State *L ) { Shader *shader = luaL_checkudata ( L, 1, "Shader" ); printf( "gcShader\n" ); @@ -122,7 +122,7 @@ static void defineShader() { lua_setfield( L, -2, "__gc" ); } -/* Font. */ + /* Font. */ static int gcFont( lua_State *L ) { Font *font = luaL_checkudata ( L, 1, "Font" ); printf( "gcFont\n" ); @@ -140,7 +140,7 @@ static void defineFont() { lua_setfield( L, -2, "__gc" ); } -/* Wave. */ + /* Wave. */ static int gcWave( lua_State *L ) { Wave *wave = luaL_checkudata ( L, 1, "Wave" ); printf( "gcWave\n" ); @@ -158,7 +158,7 @@ static void defineWave() { lua_setfield( L, -2, "__gc" ); } -/* Sound. */ + /* Sound. */ static int gcSound( lua_State *L ) { Sound *sound = luaL_checkudata ( L, 1, "Sound" ); printf( "gcSound\n" ); @@ -176,7 +176,7 @@ static void defineSound() { lua_setfield( L, -2, "__gc" ); } -/* Music. */ + /* Music. */ static int gcMusic( lua_State *L ) { Music *music = luaL_checkudata ( L, 1, "Music" ); printf( "gcMusic\n" ); @@ -194,7 +194,7 @@ static void defineMusic() { lua_setfield( L, -2, "__gc" ); } -/* Light. */ + /* Light. */ static void defineLight() { lua_State *L = state->luaState; @@ -203,7 +203,7 @@ static void defineLight() { lua_setfield( L, -2, "__index" ); } -/* Material. */ + /* Material. */ static int gcMaterial( lua_State *L ) { Material *material = luaL_checkudata ( L, 1, "Material" ); printf( "gcMaterial\n" ); @@ -235,7 +235,7 @@ static void defineMaterial() { lua_setfield( L, -2, "__gc" ); } -/* Mesh. */ + /* Mesh. */ static int gcMesh( lua_State *L ) { Mesh *mesh = luaL_checkudata ( L, 1, "Mesh" ); printf( "gcMesh\n" ); @@ -253,7 +253,7 @@ static void defineMesh() { lua_setfield( L, -2, "__gc" ); } -/* Model. */ + /* Model. */ static int gcModel( lua_State *L ) { Model *model = luaL_checkudata ( L, 1, "Model" ); printf( "gcModel\n" ); @@ -272,7 +272,7 @@ static void defineModel() { lua_setfield( L, -2, "__gc" ); } -/* ModelAnimation. */ + /* ModelAnimation. */ static int gcModelAnimation( lua_State *L ) { ModelAnimation *modelAnimation = luaL_checkudata ( L, 1, "ModelAnimation" ); printf( "gcModelAnimation\n" ); @@ -2332,10 +2332,6 @@ Color uluaGetColorIndex( lua_State *L, int index ) { luaL_checktype( L, index, LUA_TTABLE ); Color color = { 0, 0, 0, 255 }; - if ( !lua_istable( L, index ) ) { - TraceLog( state->logLevelInvalid, "%s", "Error. Wrong color value. Returning { 0, 0, 0, 255 }" ); - return color; - } int t = index, i = 0; lua_pushnil( L ); @@ -2388,10 +2384,6 @@ Vector2 uluaGetVector2Index( lua_State *L, int index ) { luaL_checktype( L, index, LUA_TTABLE ); Vector2 vector = { 0.0f, 0.0f }; - if ( !lua_istable( L, index ) ) { - TraceLog( state->logLevelInvalid, "%s", "Error. Wrong vector2 value. Returning { 0, 0 }" ); - return vector; - } int t = index, i = 0; lua_pushnil( L ); @@ -2432,10 +2424,6 @@ Vector3 uluaGetVector3Index( lua_State *L, int index ) { luaL_checktype( L, index, LUA_TTABLE ); Vector3 vector = { 0.0f, 0.0f, 0.0f }; - if ( !lua_istable( L, index ) ) { - TraceLog( state->logLevelInvalid, "%s", "Error. Wrong vector3 value. Returning { 0, 0, 0 }" ); - return vector; - } int t = index, i = 0; lua_pushnil( L ); @@ -2482,10 +2470,6 @@ Vector4 uluaGetVector4Index( lua_State *L, int index ) { luaL_checktype( L, index, LUA_TTABLE ); Vector4 vector = { 0.0f, 0.0f, 0.0f, 0.0f }; - if ( !lua_istable( L, index ) ) { - TraceLog( state->logLevelInvalid, "%s", "Error. Wrong vector4 value. Returning { 0, 0, 0, 0 }" ); - return vector; - } int t = index, i = 0; lua_pushnil( L ); @@ -2538,11 +2522,6 @@ Rectangle uluaGetRectangleIndex( lua_State *L, int index ) { luaL_checktype( L, index, LUA_TTABLE ); Rectangle rect = { 0.0f, 0.0f, 0.0f, 0.0f }; - if ( !lua_istable( L, index ) ) { - TraceLog( state->logLevelInvalid, "%s", "Error. Wrong rectangle value. Returning { 0, 0, 0, 0 }" ); - return rect; - } - int t = index, i = 0; lua_pushnil( L ); @@ -2595,10 +2574,6 @@ Quaternion uluaGetQuaternionIndex( lua_State *L, int index ) { luaL_checktype( L, index, LUA_TTABLE ); Quaternion quaternion = { 0.0f, 0.0f, 0.0f, 0.0f }; - if ( !lua_istable( L, index ) ) { - TraceLog( state->logLevelInvalid, "%s", "Error. Wrong quaternion value. Returning { 0, 0, 0, 0 }" ); - return quaternion; - } int t = index, i = 0; lua_pushnil( L ); @@ -2652,10 +2627,6 @@ Matrix uluaGetMatrixIndex( lua_State *L, int index ) { Matrix matrix = { 0.0f }; float m[4][4]; - if ( !lua_istable( L, index ) ) { - TraceLog( state->logLevelInvalid, "%s", "Error. Wrong matrix value. Returning MatrixIdentity." ); - return MatrixIdentity(); - } int t = index, i = 0; lua_pushnil( L ); @@ -2691,10 +2662,6 @@ BoundingBox uluaGetBoundingBoxIndex( lua_State *L, int index ) { luaL_checktype( L, index, LUA_TTABLE ); BoundingBox box = { .min = { 0.0, 0.0, 0.0 }, .max = { 0.0, 0.0, 0.0 } }; - if ( !lua_istable( L, index ) ) { - TraceLog( state->logLevelInvalid, "%s", "Error. Wrong boundingbox value. Returning { min{ 0, 0, 0 }, max{ 0, 0, 0 } }." ); - return box; - } int t = index, i = 0; lua_pushnil( L ); @@ -2736,10 +2703,6 @@ Ray uluaGetRayIndex( lua_State *L, int index ) { luaL_checktype( L, index, LUA_TTABLE ); Ray ray = { .position = { 0.0, 0.0, 0.0 }, .direction = { 0.0, 0.0, 0.0 } }; - if ( !lua_istable( L, index ) ) { - TraceLog( state->logLevelInvalid, "%s", "Error. Wrong ray value. Returning { position{ 0, 0, 0 }, direction{ 0, 0, 0 } }." ); - return ray; - } int t = index, i = 0; lua_pushnil( L ); @@ -2781,10 +2744,6 @@ NPatchInfo uluaGetNPatchInfoIndex( lua_State *L, int index ) { luaL_checktype( L, index, LUA_TTABLE ); NPatchInfo npatch = { .source = { 0.0, 0.0, 0.0, 0.0 }, .left = 0, .top = 0, .right = 0, .bottom = 0, .layout = NPATCH_NINE_PATCH }; - if ( !lua_istable( L, index ) ) { - TraceLog( state->logLevelInvalid, "%s", "Error. Wrong ray value. Returning { source = { 0.0, 0.0, 0.0, 0.0 }, left = 0, top = 0, right = 0, bottom = 0, layout = NPATCH_NINE_PATCH }." ); - return npatch; - } int t = index, i = 0; lua_pushnil( L ); @@ -13,7 +13,7 @@ /* > RL.GuiEnable() -Enable gui controls ( global state ) +Enable gui controls (global state) */ int lguiGuiEnable( lua_State *L ) { GuiEnable(); @@ -24,7 +24,7 @@ int lguiGuiEnable( lua_State *L ) { /* > RL.GuiDisable() -Disable gui controls ( global state ) +Disable gui controls (global state) */ int lguiGuiDisable( lua_State *L ) { GuiDisable(); @@ -35,7 +35,7 @@ int lguiGuiDisable( lua_State *L ) { /* > RL.GuiLock() -Lock gui controls ( global state ) +Lock gui controls (global state) */ int lguiGuiLock( lua_State *L ) { GuiLock(); @@ -46,7 +46,7 @@ int lguiGuiLock( lua_State *L ) { /* > RL.GuiUnlock() -Unlock gui controls ( global state ) +Unlock gui controls (global state) */ int lguiGuiUnlock( lua_State *L ) { GuiUnlock(); @@ -57,7 +57,7 @@ int lguiGuiUnlock( lua_State *L ) { /* > locked = RL.GuiIsLocked() -Check if gui is locked ( global state ) +Check if gui is locked (global state) - Success return bool */ @@ -68,53 +68,35 @@ int lguiGuiIsLocked( lua_State *L ) { } /* -> success = RL.GuiFade( float alpha ) +> RL.GuiFade( float alpha ) -Set gui controls alpha ( global state ), alpha goes from 0.0f to 1.0f - -- Failure return false -- Success return true +Set gui controls alpha (global state), alpha goes from 0.0f to 1.0f */ int lguiGuiFade( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiFade( float alpha )" ); - lua_pushboolean( L, false ); - return 1; - } - float alpha = lua_tonumber( L, 1 ); + float alpha = luaL_checknumber( L, 1 ); GuiFade( alpha ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.GuiSetState( int state ) - -Set gui state ( global state ) +> RL.GuiSetState( int state ) -- Failure return false -- Success return true +Set gui state (global state) */ int lguiGuiSetState( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiSetState( int state )" ); - lua_pushboolean( L, false ); - return 1; - } - int state = lua_tointeger( L, 1 ); + int state = luaL_checkinteger( L, 1 ); GuiSetState( state ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* > state = RL.GuiGetState() -Get gui state ( global state ) +Get gui state (global state) - Success return int */ @@ -144,9 +126,9 @@ int lguiGuiSetFont( lua_State *L ) { /* > font = RL.GuiGetFont() -Get gui custom font ( global state ) +Get gui custom font (global state) -- Success return int +- Success return Font */ int lguiGuiGetFont( lua_State *L ) { uluaPushFont( L, GuiGetFont() ); @@ -159,27 +141,18 @@ int lguiGuiGetFont( lua_State *L ) { */ /* -> success = RL.GuiSetStyle( int control, int property, int value ) +> RL.GuiSetStyle( int control, int property, int value ) Set one style property - -- Failure return false -- Success return true */ int lguiGuiSetStyle( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiSetStyle( int control, int property, int value )" ); - lua_pushboolean( L, false ); - return 1; - } - int control = lua_tointeger( L, 1 ); - int property = lua_tointeger( L, 2 ); - int value = lua_tointeger( L, 3 ); + int control = luaL_checkinteger( L, 1 ); + int property = luaL_checkinteger( L, 2 ); + int value = luaL_checkinteger( L, 3 ); GuiSetStyle( control, property, value ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* @@ -187,17 +160,11 @@ int lguiGuiSetStyle( lua_State *L ) { Get one style property -- Failure return false - Success return int */ int lguiGuiGetStyle( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiGetStyle( int control, int property )" ); - lua_pushboolean( L, false ); - return 1; - } - int control = lua_tointeger( L, 1 ); - int property = lua_tointeger( L, 2 ); + int control = luaL_checkinteger( L, 1 ); + int property = luaL_checkinteger( L, 2 ); lua_pushinteger( L, GuiGetStyle( control, property ) ); @@ -207,27 +174,20 @@ int lguiGuiGetStyle( lua_State *L ) { /* > success = RL.GuiLoadStyle( string fileName ) -Load style file over global style variable ( .rgs ) +Load style file over global style variable (.rgs) - Failure return false - Success return true */ int lguiGuiLoadStyle( lua_State *L ) { - if ( !lua_isstring( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiLoadStyle( string fileName )" ); - lua_pushboolean( L, false ); - return 1; - } - - if ( FileExists( lua_tostring( L, 1 ) ) ) { + if ( FileExists( luaL_checkstring( L, 1 ) ) ) { GuiLoadStyle( lua_tostring( L, 1 ) ); lua_pushboolean( L, true ); + return 1; } - else { - lua_pushboolean( L, false ); - return 1; - } + TraceLog( state->logLevelInvalid, "Invalid file '%s'", lua_tostring( L, 1 ) ); + lua_pushboolean( L, false ); return 1; } @@ -252,86 +212,53 @@ int lguiGuiLoadStyleDefault( lua_State *L ) { Window Box control, shows a window that can be closed -- Failure return nil - Success return bool */ int lguiGuiWindowBox( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiWindowBox( Rectangle bounds, string title )" ); - lua_pushnil( L ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); - lua_pushboolean( L, GuiWindowBox( bounds, lua_tostring( L, 2 ) ) ); + lua_pushboolean( L, GuiWindowBox( bounds, luaL_checkstring( L, 2 ) ) ); return 1; } /* -> success = RL.GuiGroupBox( Rectangle bounds, string text ) +> RL.GuiGroupBox( Rectangle bounds, string text ) Group Box control with text name - -- Failure return false -- Success return true */ int lguiGuiGroupBox( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiGroupBox( Rectangle bounds, string text )" ); - lua_pushboolean( L, false ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); - GuiGroupBox( bounds, lua_tostring( L, 2 ) ); - lua_pushboolean( L, true ); + GuiGroupBox( bounds, luaL_checkstring( L, 2 ) ); - return 1; + return 0; } /* -> success = RL.GuiLine( Rectangle bounds, string text ) +> RL.GuiLine( Rectangle bounds, string text ) Line separator control, could contain text - -- Failure return false -- Success return true */ int lguiGuiLine( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiLine( Rectangle bounds, string text )" ); - lua_pushboolean( L, false ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); - GuiLine( bounds, lua_tostring( L, 2 ) ); - lua_pushboolean( L, true ); + GuiLine( bounds, luaL_checkstring( L, 2 ) ); - return 1; + return 0; } /* -> success = RL.GuiPanel( Rectangle bounds, string text ) +> RL.GuiPanel( Rectangle bounds, string text ) Panel control, useful to group controls - -- Failure return false -- Success return true */ int lguiGuiPanel( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiPanel( Rectangle bounds, string text )" ); - lua_pushboolean( L, false ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); - GuiPanel( bounds, lua_tostring( L, 2 ) ); - lua_pushboolean( L, true ); + GuiPanel( bounds, luaL_checkstring( L, 2 ) ); - return 1; + return 0; } /* @@ -339,20 +266,14 @@ int lguiGuiPanel( lua_State *L ) { Scroll Panel control -- Failure return false - Success return Rectangle, Vector2 */ int lguiGuiScrollPanel( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) || !lua_istable( L, 3 ) || !lua_istable( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiScrollPanel( Rectangle bounds, string text, Rectangle content, Vector2 scroll )" ); - lua_pushboolean( L, false ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); Rectangle content = uluaGetRectangleIndex( L, 3 ); Vector2 scroll = uluaGetVector2Index( L, 4 ); - uluaPushRectangle( L, GuiScrollPanel( bounds, lua_tostring( L, 2 ), content, &scroll ) ); + uluaPushRectangle( L, GuiScrollPanel( bounds, luaL_checkstring( L, 2 ), content, &scroll ) ); uluaPushVector2( L, scroll ); return 2; @@ -363,25 +284,16 @@ int lguiGuiScrollPanel( lua_State *L ) { */ /* -> success = RL.GuiLabel( Rectangle bounds, string text ) +> RL.GuiLabel( Rectangle bounds, string text ) Label control, shows text - -- Failure return false -- Success return true */ int lguiGuiLabel( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiLabel( Rectangle bounds, string text )" ); - lua_pushboolean( L, false ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); - GuiLabel( bounds, lua_tostring( L, 2 ) ); - lua_pushboolean( L, true ); + GuiLabel( bounds, luaL_checkstring( L, 2 ) ); - return 1; + return 0; } /* @@ -389,18 +301,12 @@ int lguiGuiLabel( lua_State *L ) { Button control, returns true when clicked -- Failure return nil - Success return boolean */ int lguiGuiButton( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiButton( Rectangle bounds, string text )" ); - lua_pushnil( L ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); - lua_pushboolean( L, GuiButton( bounds, lua_tostring( L, 2 ) ) ); + lua_pushboolean( L, GuiButton( bounds, luaL_checkstring( L, 2 ) ) ); return 1; } @@ -410,18 +316,12 @@ int lguiGuiButton( lua_State *L ) { Label button control, show true when clicked -- Failure return nil - Success return boolean */ int lguiGuiLabelButton( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiLabelButton( Rectangle bounds, string text )" ); - lua_pushnil( L ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); - lua_pushboolean( L, GuiLabelButton( bounds, lua_tostring( L, 2 ) ) ); + lua_pushboolean( L, GuiLabelButton( bounds, luaL_checkstring( L, 2 ) ) ); return 1; } @@ -431,19 +331,13 @@ int lguiGuiLabelButton( lua_State *L ) { Toggle Button control, returns true when active -- Failure return nil - Success return boolean */ int lguiGuiToggle( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) || !lua_isboolean( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiToggle( Rectangle bounds, string text, bool active )" ); - lua_pushnil( L ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); bool checked = lua_toboolean( L, 3 ); - lua_pushboolean( L, GuiToggle( bounds, lua_tostring( L, 2 ), checked ) ); + lua_pushboolean( L, GuiToggle( bounds, luaL_checkstring( L, 2 ), checked ) ); return 1; } @@ -453,19 +347,13 @@ int lguiGuiToggle( lua_State *L ) { Toggle Group control, returns active toggle index -- Failure return false - Success return int */ int lguiGuiToggleGroup( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiToggleGroup( Rectangle bounds, string text, bool active )" ); - lua_pushboolean( L, false ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); - int active = lua_tointeger( L, 3 ); + int active = luaL_checkinteger( L, 3 ); - lua_pushinteger( L, GuiToggleGroup( bounds, lua_tostring( L, 2 ), active ) ); + lua_pushinteger( L, GuiToggleGroup( bounds, luaL_checkstring( L, 2 ), active ) ); return 1; } @@ -475,19 +363,13 @@ int lguiGuiToggleGroup( lua_State *L ) { Check Box control, returns true when active -- Failure return nil - Success return boolean */ int lguiGuiCheckBox( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) || !lua_isboolean( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiCheckBox( Rectangle bounds, string text, bool checked )" ); - lua_pushnil( L ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); bool checked = lua_toboolean( L, 3 ); - lua_pushboolean( L, GuiCheckBox( bounds, lua_tostring( L, 2 ), checked ) ); + lua_pushboolean( L, GuiCheckBox( bounds, luaL_checkstring( L, 2 ), checked ) ); return 1; } @@ -497,19 +379,13 @@ int lguiGuiCheckBox( lua_State *L ) { Combo Box control, returns selected item index -- Failure return nil - Success return int */ int lguiGuiComboBox( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiComboBox( Rectangle bounds, string text, int active )" ); - lua_pushnil( L ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); - int active = lua_tointeger( L, 3 ); + int active = luaL_checkinteger( L, 3 ); - lua_pushinteger( L, GuiComboBox( bounds, lua_tostring( L, 2 ), active ) ); + lua_pushinteger( L, GuiComboBox( bounds, luaL_checkstring( L, 2 ), active ) ); return 1; } @@ -519,20 +395,14 @@ int lguiGuiComboBox( lua_State *L ) { Text Box control, updates input text -- Failure return nil - Success return boolean, string */ int lguiGuiTextBox( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isboolean( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiTextBox( Rectangle bounds, string text, int textSize, bool editMode )" ); - lua_pushnil( L ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); - int textSize = lua_tointeger( L, 3 ); + int textSize = luaL_checkinteger( L, 3 ); // char text[ STRING_LEN ] = { '\0' }; char text[ textSize + 1 ]; - strcpy( text, lua_tostring( L, 2 ) ); + strcpy( text, luaL_checkstring( L, 2 ) ); bool editMode = lua_toboolean( L, 4 ); lua_pushboolean( L, GuiTextBox( bounds, text, textSize, editMode ) ); @@ -546,20 +416,14 @@ int lguiGuiTextBox( lua_State *L ) { Text Box control with multiple lines -- Failure return nil - Success return boolean, string */ int lguiGuiTextBoxMulti( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isboolean( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiTextBoxMulti( Rectangle bounds, string text, int textSize, bool editMode )" ); - lua_pushnil( L ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); - int textSize = lua_tointeger( L, 3 ); + int textSize = luaL_checkinteger( L, 3 ); // char text[ STRING_LEN ] = { '\0' }; char text[ textSize + 1 ]; - strcpy( text, lua_tostring( L, 2 ) ); + strcpy( text, luaL_checkstring( L, 2 ) ); bool editMode = lua_toboolean( L, 4 ); lua_pushboolean( L, GuiTextBoxMulti( bounds, text, textSize, editMode ) ); @@ -573,23 +437,16 @@ int lguiGuiTextBoxMulti( lua_State *L ) { Spinner control, returns selected value -- Failure return nil - Success return boolean, int */ int lguiGuiSpinner( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) || !lua_isnumber( L, 3 ) - || !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_isboolean( L, 6 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiSpinner( Rectangle bounds, string text, int value, int minValue, int maxValue, bool editMode )" ); - lua_pushnil( L ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); - int value = lua_tointeger( L, 3 ); - int minValue = lua_tointeger( L, 4 ); - int maxValue = lua_tointeger( L, 5 ); + int value = luaL_checkinteger( L, 3 ); + int minValue = luaL_checkinteger( L, 4 ); + int maxValue = luaL_checkinteger( L, 5 ); bool editMode = lua_toboolean( L, 6 ); - lua_pushboolean( L, GuiSpinner( bounds, lua_tostring( L, 2 ), &value, minValue, maxValue, editMode ) ); + lua_pushboolean( L, GuiSpinner( bounds, luaL_checkstring( L, 2 ), &value, minValue, maxValue, editMode ) ); lua_pushinteger( L, value ); return 2; @@ -600,23 +457,16 @@ int lguiGuiSpinner( lua_State *L ) { Value Box control, updates input text with numbers -- Failure return nil - Success return boolean, int */ int lguiGuiValueBox( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) || !lua_isnumber( L, 3 ) - || !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_isboolean( L, 6 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiValueBox( Rectangle bounds, string text, int value, int minValue, int maxValue, bool editMode )" ); - lua_pushnil( L ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); - int value = lua_tointeger( L, 3 ); - int minValue = lua_tointeger( L, 4 ); - int maxValue = lua_tointeger( L, 5 ); + int value = luaL_checkinteger( L, 3 ); + int minValue = luaL_checkinteger( L, 4 ); + int maxValue = luaL_checkinteger( L, 5 ); bool editMode = lua_toboolean( L, 6 ); - lua_pushboolean( L, GuiValueBox( bounds, lua_tostring( L, 2 ), &value, minValue, maxValue, editMode ) ); + lua_pushboolean( L, GuiValueBox( bounds, luaL_checkstring( L, 2 ), &value, minValue, maxValue, editMode ) ); lua_pushinteger( L, value ); return 2; @@ -627,22 +477,15 @@ int lguiGuiValueBox( lua_State *L ) { Slider control, returns selected value -- Failure return nil - Success return float */ int lguiGuiSlider( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) || !lua_isstring( L, 3 ) - || !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_isnumber( L, 6 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiSlider( Rectangle bounds, string textLeft, string textRight, float value, float minValue, float maxValue )" ); - lua_pushnil( L ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); - float value = lua_tonumber( L, 4 ); - float minValue = lua_tonumber( L, 5 ); - float maxValue = lua_tonumber( L, 6 ); + float value = luaL_checknumber( L, 4 ); + float minValue = luaL_checknumber( L, 5 ); + float maxValue = luaL_checknumber( L, 6 ); - lua_pushnumber( L, GuiSlider( bounds, lua_tostring( L, 2 ), lua_tostring( L, 3 ), value, minValue, maxValue ) ); + lua_pushnumber( L, GuiSlider( bounds, luaL_checkstring( L, 2 ), luaL_checkstring( L, 3 ), value, minValue, maxValue ) ); return 1; } @@ -652,22 +495,15 @@ int lguiGuiSlider( lua_State *L ) { Slider Bar control, returns selected value -- Failure return nil - Success return float */ int lguiGuiSliderBar( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) || !lua_isstring( L, 3 ) - || !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_isnumber( L, 6 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiSliderBar( Rectangle bounds, string textLeft, string textRight, float value, float minValue, float maxValue )" ); - lua_pushnil( L ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); - float value = lua_tonumber( L, 4 ); - float minValue = lua_tonumber( L, 5 ); - float maxValue = lua_tonumber( L, 6 ); + float value = luaL_checknumber( L, 4 ); + float minValue = luaL_checknumber( L, 5 ); + float maxValue = luaL_checknumber( L, 6 ); - lua_pushnumber( L, GuiSliderBar( bounds, lua_tostring( L, 2 ), lua_tostring( L, 3 ), value, minValue, maxValue ) ); + lua_pushnumber( L, GuiSliderBar( bounds, luaL_checkstring( L, 2 ), luaL_checkstring( L, 3 ), value, minValue, maxValue ) ); return 1; } @@ -677,22 +513,15 @@ int lguiGuiSliderBar( lua_State *L ) { Progress Bar control, shows current progress value -- Failure return nil - Success return float */ int lguiGuiProgressBar( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) || !lua_isstring( L, 3 ) - || !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_isnumber( L, 6 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiProgressBar( Rectangle bounds, string textLeft, string textRight, float value, float minValue, float maxValue )" ); - lua_pushnil( L ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); - float value = lua_tonumber( L, 4 ); - float minValue = lua_tonumber( L, 5 ); - float maxValue = lua_tonumber( L, 6 ); + float value = luaL_checknumber( L, 4 ); + float minValue = luaL_checknumber( L, 5 ); + float maxValue = luaL_checknumber( L, 6 ); - lua_pushnumber( L, GuiProgressBar( bounds, lua_tostring( L, 2 ), lua_tostring( L, 3 ), value, minValue, maxValue ) ); + lua_pushnumber( L, GuiProgressBar( bounds, luaL_checkstring( L, 2 ), luaL_checkstring( L, 3 ), value, minValue, maxValue ) ); return 1; } @@ -702,19 +531,13 @@ int lguiGuiProgressBar( lua_State *L ) { Scroll Bar control -- Failure return nil - Success return int */ int lguiGuiScrollBar( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiScrollBar( Rectangle bounds, int value, int minValue, int maxValue )" ); - lua_pushnil( L ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); - int value = lua_tointeger( L, 2 ); - int minValue = lua_tointeger( L, 3 ); - int maxValue = lua_tointeger( L, 4 ); + int value = luaL_checkinteger( L, 2 ); + int minValue = luaL_checkinteger( L, 3 ); + int maxValue = luaL_checkinteger( L, 4 ); lua_pushinteger( L, GuiScrollBar( bounds, value, minValue, maxValue ) ); @@ -726,67 +549,43 @@ int lguiGuiScrollBar( lua_State *L ) { Dropdown Box control, returns selected item -- Failure return nil - Success return bool, int */ int lguiGuiDropdownBox( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isboolean( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiDropdownBox( Rectangle bounds, string text, int active, bool editMode )" ); - lua_pushnil( L ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); - int active = lua_tointeger( L, 3 ); + int active = luaL_checkinteger( L, 3 ); bool editMode = lua_toboolean( L, 4 ); - lua_pushboolean( L, GuiDropdownBox( bounds, lua_tostring( L, 2 ), &active, editMode ) ); + lua_pushboolean( L, GuiDropdownBox( bounds, luaL_checkstring( L, 2 ), &active, editMode ) ); lua_pushinteger( L, active ); return 2; } /* -> success = RL.GuiStatusBar( Rectangle bounds, string text ) +> RL.GuiStatusBar( Rectangle bounds, string text ) Status Bar control, shows info text - -- Failure return false -- Success return true */ int lguiGuiStatusBar( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiStatusBar( Rectangle bounds, string text )" ); - lua_pushboolean( L, false ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); - GuiStatusBar( bounds, lua_tostring( L, 2 ) ); - lua_pushboolean( L, true ); + GuiStatusBar( bounds, luaL_checkstring( L, 2 ) ); - return 1; + return 0; } /* -> success = RL.GuiDummyRec( Rectangle bounds, string text ) +> RL.GuiDummyRec( Rectangle bounds, string text ) Dummy control for placeholders - -- Failure return false -- Success return true */ int lguiGuiDummyRec( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiDummyRec( Rectangle bounds, string text )" ); - lua_pushboolean( L, false ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); - GuiDummyRec( bounds, lua_tostring( L, 2 ) ); - lua_pushboolean( L, true ); + GuiDummyRec( bounds, luaL_checkstring( L, 2 ) ); - return 1; + return 0; } /* @@ -794,20 +593,14 @@ int lguiGuiDummyRec( lua_State *L ) { Grid control, returns mouse cell position -- Failure return false - Success return Vector2 */ int lguiGuiGrid( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiGrid( Rectangle bounds, string text, float spacing, int subdivs )" ); - lua_pushboolean( L, false ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); - float spacing = lua_tonumber( L, 3 ); - int subdivs = lua_tointeger( L, 4 ); + float spacing = luaL_checknumber( L, 3 ); + int subdivs = luaL_checkinteger( L, 4 ); - uluaPushVector2( L, GuiGrid( bounds, lua_tostring( L, 2 ), spacing, subdivs ) ); + uluaPushVector2( L, GuiGrid( bounds, luaL_checkstring( L, 2 ), spacing, subdivs ) ); return 1; } @@ -821,20 +614,14 @@ int lguiGuiGrid( lua_State *L ) { List View control, returns selected list item index and scroll index -- Failure return nil - Success return int, int */ int lguiGuiListView( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiListView( Rectangle bounds, string text, int scrollIndex, int active )" ); - lua_pushnil( L ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); - int scrollIndex = lua_tointeger( L, 3 ); - int active = lua_tointeger( L, 4 ); + int scrollIndex = luaL_checkinteger( L, 3 ); + int active = luaL_checkinteger( L, 4 ); - lua_pushinteger( L, GuiListView( bounds, lua_tostring( L, 2 ), &scrollIndex, active ) ); + lua_pushinteger( L, GuiListView( bounds, luaL_checkstring( L, 2 ), &scrollIndex, active ) ); lua_pushinteger( L, scrollIndex ); return 2; @@ -845,22 +632,15 @@ int lguiGuiListView( lua_State *L ) { List View with extended parameters, returns selected list item index, scroll index and focus -- Failure return nil - Success return int, int, int */ int lguiGuiListViewEx( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) || !lua_isnumber( L, 3 ) - || !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiListViewEx( Rectangle bounds, string text, int focus, int scrollIndex, int active )" ); - lua_pushnil( L ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); - int focus = lua_tointeger( L, 3 ); - int scrollIndex = lua_tointeger( L, 4 ); - int active = lua_tointeger( L, 5 ); + int focus = luaL_checkinteger( L, 3 ); + int scrollIndex = luaL_checkinteger( L, 4 ); + int active = luaL_checkinteger( L, 5 ); int count = 0; - const char **text = GuiTextSplit( lua_tostring( L, 2 ), &count, NULL ); + const char **text = GuiTextSplit( luaL_checkstring( L, 2 ), &count, NULL ); lua_pushinteger( L, GuiListViewEx( bounds, text, count, &focus, &scrollIndex, active ) ); lua_pushinteger( L, scrollIndex ); @@ -872,20 +652,14 @@ int lguiGuiListViewEx( lua_State *L ) { /* > buttonIndex = RL.GuiMessageBox( Rectangle bounds, string title, string message, string buttons ) -Message Box control, displays a message, returns button index ( 0 is x button ) +Message Box control, displays a message, returns button index (0 is x button) -- Failure return false - Success return int */ int lguiGuiMessageBox( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) || !lua_isstring( L, 3 ) || !lua_isstring( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiMessageBox( Rectangle bounds, string title, string message, string buttons )" ); - lua_pushboolean( L, false ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); - lua_pushinteger( L, GuiMessageBox( bounds, lua_tostring( L, 2 ), lua_tostring( L, 3 ), lua_tostring( L, 4 ) ) ); + lua_pushinteger( L, GuiMessageBox( bounds, luaL_checkstring( L, 2 ), luaL_checkstring( L, 3 ), luaL_checkstring( L, 4 ) ) ); return 1; } @@ -895,23 +669,16 @@ int lguiGuiMessageBox( lua_State *L ) { Text Input Box control, ask for text, supports secret -- Failure return false - Success return int, string, int */ int lguiGuiTextInputBox( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) || !lua_isstring( L, 3 ) || !lua_isstring( L, 4 ) - || !lua_isstring( L, 5 ) || !lua_isnumber( L, 6 ) || !lua_isnumber( L, 7 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiTextInputBox( Rectangle bounds, string title, string message, string buttons, string text, int textMaxSize, int secretViewActive )" ); - lua_pushboolean( L, false ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); - int textMaxSize = lua_tointeger( L, 6 ); - int secretViewActive = lua_tointeger( L, 7 ); + int textMaxSize = luaL_checkinteger( L, 6 ); + int secretViewActive = luaL_checkinteger( L, 7 ); char text[ textMaxSize + 1 ]; - strcpy( text, lua_tostring( L, 5 ) ); + strcpy( text, luaL_checkstring( L, 5 ) ); - lua_pushinteger( L, GuiTextInputBox( bounds, lua_tostring( L, 2 ), lua_tostring( L, 3 ), lua_tostring( L, 4 ), text, textMaxSize, &secretViewActive ) ); + lua_pushinteger( L, GuiTextInputBox( bounds, luaL_checkstring( L, 2 ), luaL_checkstring( L, 3 ), luaL_checkstring( L, 4 ), text, textMaxSize, &secretViewActive ) ); lua_pushstring( L, text ); lua_pushinteger( L, secretViewActive ); @@ -921,21 +688,15 @@ int lguiGuiTextInputBox( lua_State *L ) { /* > color = RL.GuiColorPicker( Rectangle bounds, string text, Color color ) -Color Picker control ( multiple color controls ) +Color Picker control (multiple color controls) -- Failure return false - Success return Color */ int lguiGuiColorPicker( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) || !lua_istable( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiColorPicker( Rectangle bounds, string text, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); Color color = uluaGetColorIndex( L, 3 ); - uluaPushColor( L, GuiColorPicker( bounds, lua_tostring( L, 2 ), color ) ); + uluaPushColor( L, GuiColorPicker( bounds, luaL_checkstring( L, 2 ), color ) ); return 1; } @@ -945,19 +706,13 @@ int lguiGuiColorPicker( lua_State *L ) { Color Panel control -- Failure return false - Success return Color */ int lguiGuiColorPanel( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) || !lua_istable( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiColorPanel( Rectangle bounds, string text, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); Color color = uluaGetColorIndex( L, 3 ); - uluaPushColor( L, GuiColorPanel( bounds, lua_tostring( L, 2 ), color ) ); + uluaPushColor( L, GuiColorPanel( bounds, luaL_checkstring( L, 2 ), color ) ); return 1; } @@ -967,19 +722,13 @@ int lguiGuiColorPanel( lua_State *L ) { Color Bar Alpha control -- Failure return false - Success return float */ int lguiGuiColorBarAlpha( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiColorBarAlpha( Rectangle bounds, string text, float alpha )" ); - lua_pushboolean( L, false ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); - float alpha = lua_tonumber( L, 3 ); + float alpha = luaL_checknumber( L, 3 ); - lua_pushnumber( L, GuiColorBarAlpha( bounds, lua_tostring( L, 2 ), alpha ) ); + lua_pushnumber( L, GuiColorBarAlpha( bounds, luaL_checkstring( L, 2 ), alpha ) ); return 1; } @@ -989,19 +738,13 @@ int lguiGuiColorBarAlpha( lua_State *L ) { Color Bar Hue control -- Failure return false - Success return float */ int lguiGuiColorBarHue( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiColorBarHue( Rectangle bounds, string text, float value )" ); - lua_pushboolean( L, false ); - return 1; - } Rectangle bounds = uluaGetRectangleIndex( L, 1 ); - float value = lua_tonumber( L, 3 ); + float value = luaL_checknumber( L, 3 ); - lua_pushnumber( L, GuiColorBarHue( bounds, lua_tostring( L, 2 ), value ) ); + lua_pushnumber( L, GuiColorBarHue( bounds, luaL_checkstring( L, 2 ), value ) ); return 1; } @@ -1013,120 +756,78 @@ int lguiGuiColorBarHue( lua_State *L ) { /* > text = RL.GuiIconText( int iconId, string text ) -Get text with icon id prepended ( if supported ) +Get text with icon id prepended (if supported) -- Failure return false - Success return string */ int lguiGuiIconText( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isstring( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiIconText( int iconId, string text )" ); - lua_pushboolean( L, false ); - return 1; - } - int iconId = lua_tointeger( L, 1 ); + int iconId = luaL_checkinteger( L, 1 ); - if ( TextIsEqual( lua_tostring( L, 2 ), "" ) ) { + if ( TextIsEqual( luaL_checkstring( L, 2 ), "" ) ) { lua_pushstring( L, GuiIconText( iconId, NULL ) ); } else { - lua_pushstring( L, GuiIconText( iconId, lua_tostring( L, 2 ) ) ); + lua_pushstring( L, GuiIconText( iconId, luaL_checkstring( L, 2 ) ) ); } return 1; } /* -> success = RL.GuiDrawIcon( int iconId, Vector2 pos, int pixelSize, Color color ) +> RL.GuiDrawIcon( int iconId, Vector2 pos, int pixelSize, Color color ) Draw icon - -- Failure return false -- Success return true */ int lguiGuiDrawIcon( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_istable( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiDrawIcon( int iconId, Vector2 pos, int pixelSize, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } - int iconId = lua_tointeger( L, 1 ); + int iconId = luaL_checkinteger( L, 1 ); Vector2 pos = uluaGetVector2Index( L, 2 ); - int pixelSize = lua_tointeger( L, 3 ); + int pixelSize = luaL_checkinteger( L, 3 ); Color color = uluaGetColorIndex( L, 4 ); GuiDrawIcon( iconId, pos.x, pos.y, pixelSize, color ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.GuiSetIconScale( int scale ) +> RL.GuiSetIconScale( int scale ) -Set icon scale ( 1 by default ) - -- Failure return false -- Success return true +Set icon scale (1 by default) */ int lguiGuiSetIconScale( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiSetIconScale( int scale )" ); - lua_pushboolean( L, false ); - return 1; - } - unsigned int scale = lua_tointeger( L, 1 ); + unsigned int scale = luaL_checkinteger( L, 1 ); GuiSetIconScale( scale ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.GuiSetIconPixel( int iconId, Vector2 pos ) +> RL.GuiSetIconPixel( int iconId, Vector2 pos ) Set icon pixel value - -- Failure return false -- Success return true */ int lguiGuiSetIconPixel( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiSetIconPixel( int iconId, Vector2 pos )" ); - lua_pushboolean( L, false ); - return 1; - } - int iconId = lua_tointeger( L, 1 ); + int iconId = luaL_checkinteger( L, 1 ); Vector2 pos = uluaGetVector2Index( L, 2 ); GuiSetIconPixel( iconId, pos.x, pos.y ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.GuiClearIconPixel( int iconId, Vector2 pos ) +> RL.GuiClearIconPixel( int iconId, Vector2 pos ) Clear icon pixel value - -- Failure return false -- Success return true */ int lguiGuiClearIconPixel( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiClearIconPixel( int iconId, Vector2 pos )" ); - lua_pushboolean( L, false ); - return 1; - } - int iconId = lua_tointeger( L, 1 ); + int iconId = luaL_checkinteger( L, 1 ); Vector2 pos = uluaGetVector2Index( L, 2 ); GuiClearIconPixel( iconId, pos.x, pos.y ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* @@ -1134,16 +835,10 @@ int lguiGuiClearIconPixel( lua_State *L ) { Check icon pixel value -- Failure return nil - Success return bool */ int lguiGuiCheckIconPixel( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GuiCheckIconPixel( int iconId, Vector2 pos )" ); - lua_pushnil( L ); - return 1; - } - int iconId = lua_tointeger( L, 1 ); + int iconId = luaL_checkinteger( L, 1 ); Vector2 pos = uluaGetVector2Index( L, 2 ); lua_pushboolean( L, GuiCheckIconPixel( iconId, pos.x, pos.y ) ); @@ -8,23 +8,14 @@ */ /* -> success = RL.rlMatrixMode( int mode ) +> RL.rlMatrixMode( int mode ) Choose the current matrix to be transformed - -- Failure return false -- Success return true */ int lrlglMatrixMode( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlMatrixMode( int mode )" ); - lua_pushboolean( L, false ); - return 1; - } - rlMatrixMode( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlMatrixMode( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* @@ -61,87 +52,53 @@ int lrlglLoadIdentity( lua_State *L ) { } /* -> success = RL.rlTranslatef( Vector3 translation ) +> RL.rlTranslatef( Vector3 translation ) Multiply the current matrix by a translation matrix - -- Failure return false -- Success return true */ int lrlglTranslatef( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlTranslatef( Vector3 translation )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 translation = uluaGetVector3Index( L, 1 ); rlTranslatef( translation.x, translation.y, translation.z ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlRotatef( float angle, Vector3 rotation ) +> RL.rlRotatef( float angle, Vector3 rotation ) Multiply the current matrix by a rotation matrix - -- Failure return false -- Success return true */ int lrlglRotatef( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlRotatef( float angle, Vector3 rotation )" ); - lua_pushboolean( L, false ); - return 1; - } - float angle = lua_tonumber( L, 1 ); + float angle = luaL_checknumber( L, 1 ); Vector3 rotation = uluaGetVector3Index( L, 2 ); rlRotatef( angle, rotation.x, rotation.y, rotation.z ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlScalef( Vector3 scale ) +> RL.rlScalef( Vector3 scale ) Multiply the current matrix by a scaling matrix - -- Failure return false -- Success return true */ int lrlglScalef( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlScalef( Vector3 scale )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 scale = uluaGetVector3Index( L, 1 ); rlScalef( scale.x, scale.y, scale.z ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlMultMatrixf( Matrix matrix ) +> RL.rlMultMatrixf( Matrix matrix ) Multiply the current matrix by another matrix - -- Failure return false -- Success return true */ int lrlglMultMatrixf( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlMultMatrixf( Matrix matrix )" ); - lua_pushboolean( L, false ); - return 1; - } Matrix matrix = uluaGetMatrixIndex( L, 1 ); + float matf[16] = { matrix.m0, matrix.m4, matrix.m8, matrix.m12, matrix.m1, matrix.m5, matrix.m9, matrix.m13, @@ -149,88 +106,58 @@ int lrlglMultMatrixf( lua_State *L ) { matrix.m3, matrix.m7, matrix.m11, matrix.m15 }; rlMultMatrixf( matf ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlFrustum( float left, float right, float bottom, float top, float znear, float zfar ) +> RL.rlFrustum( float left, float right, float bottom, float top, float znear, float zfar ) Multiply the current matrix by a perspective matrix generated by parameters - -- Failure return false -- Success return true */ int lrlglFrustum( lua_State *L ) { - 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( state->logLevelInvalid, "%s", "Bad call of function. RL.rlFrustum( float left, float right, float bottom, float top, float znear, float zfar )" ); - lua_pushboolean( L, false ); - return 1; - } - double left = lua_tonumber( L, 1 ); - double right = lua_tonumber( L, 2 ); - double bottom = lua_tonumber( L, 3 ); - double top = lua_tonumber( L, 4 ); - double znear = lua_tonumber( L, 5 ); - double zfar = lua_tonumber( L, 6 ); + double left = luaL_checknumber( L, 1 ); + double right = luaL_checknumber( L, 2 ); + double bottom = luaL_checknumber( L, 3 ); + double top = luaL_checknumber( L, 4 ); + double znear = luaL_checknumber( L, 5 ); + double zfar = luaL_checknumber( L, 6 ); rlFrustum( left, right, bottom, top, znear, zfar ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlOrtho( float left, float right, float bottom, float top, float znear, float zfar ) +> RL.rlOrtho( float left, float right, float bottom, float top, float znear, float zfar ) Multiply the current matrix by an orthographic matrix generated by parameters - -- Failure return false -- Success return true */ int lrlglOrtho( lua_State *L ) { - 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( state->logLevelInvalid, "%s", "Bad call of function. RL.rlOrtho( float left, float right, float bottom, float top, float znear, float zfar )" ); - lua_pushboolean( L, false ); - return 1; - } - double left = lua_tonumber( L, 1 ); - double right = lua_tonumber( L, 2 ); - double bottom = lua_tonumber( L, 3 ); - double top = lua_tonumber( L, 4 ); - double znear = lua_tonumber( L, 5 ); - double zfar = lua_tonumber( L, 6 ); + double left = luaL_checknumber( L, 1 ); + double right = luaL_checknumber( L, 2 ); + double bottom = luaL_checknumber( L, 3 ); + double top = luaL_checknumber( L, 4 ); + double znear = luaL_checknumber( L, 5 ); + double zfar = luaL_checknumber( L, 6 ); rlOrtho( left, right, bottom, top, znear, zfar ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlViewport( Rectangle viewport ) +> RL.rlViewport( Rectangle viewport ) -Set the viewport area ( transformation from normalized device coordinates to window coordinates ) +Set the viewport area (transformation from normalized device coordinates to window coordinates) NOTE: We store current viewport dimensions - -- Failure return false -- Success return true */ int lrlglViewport( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlViewport( Rectangle viewport )" ); - lua_pushboolean( L, false ); - return 1; - } Rectangle rect = uluaGetRectangleIndex( L, 1 ); rlViewport( rect.x, rect.y, rect.width, rect.height ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* @@ -238,23 +165,14 @@ int lrlglViewport( lua_State *L ) { */ /* -> success = RL.rlBegin( int mode ) +> RL.rlBegin( int mode ) -Initialize drawing mode ( how to organize vertex ) - -- Failure return false -- Success return true +Initialize drawing mode (how to organize vertex) */ int lrlglBegin( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlBegin( int mode )" ); - lua_pushboolean( L, false ); - return 1; - } - rlBegin( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlBegin( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* @@ -269,157 +187,94 @@ int lrlglEnd( lua_State *L ) { } /* -> success = RL.rlVertex2f( Vector2 position ) - -Define one vertex ( position ) +> RL.rlVertex2f( Vector2 position ) -- Failure return false -- Success return true +Define one vertex (position) */ int lrlglVertex2f( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlVertex2f( Vector2 position )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 position = uluaGetVector2Index( L, 1 ); rlVertex2f( position.x, position.y ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlVertex3f( Vector3 position ) - -Define one vertex ( position ) +> RL.rlVertex3f( Vector3 position ) -- Failure return false -- Success return true +Define one vertex (position) */ int lrlglVertex3f( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlVertex3f( Vector3 position )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 position = uluaGetVector3Index( L, 1 ); rlVertex3f( position.x, position.y, position.z ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlTexCoord2f( Vector2 texCoord ) +> RL.rlTexCoord2f( Vector2 texCoord ) -Define one vertex ( texture coordinate ) - 2 float - -- Failure return false -- Success return true +Define one vertex (texture coordinate) - 2 float */ int lrlglTexCoord2f( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlTexCoord2f( Vector2 texCoord )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 texCoord = uluaGetVector2Index( L, 1 ); rlTexCoord2f( texCoord.x, texCoord.y ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlNormal3f( Vector3 normal ) +> RL.rlNormal3f( Vector3 normal ) -Define one vertex ( normal ) - 3 float - -- Failure return false -- Success return true +Define one vertex (normal) - 3 float */ int lrlglNormal3f( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlNormal3f( Vector3 normal )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 normal = uluaGetVector3Index( L, 1 ); rlNormal3f( normal.x, normal.y, normal.z ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlColor4ub( Color color ) - -Define one vertex ( color ) - 4 byte +> RL.rlColor4ub( Color color ) -- Failure return false -- Success return true +Define one vertex (color) - 4 byte */ int lrlglColor4ub( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlColor4ub( Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Color color = uluaGetColorIndex( L, 1 ); rlColor4ub( color.r, color.g, color.b, color.a ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlColor3f( Vector3 color ) +> RL.rlColor3f( Vector3 color ) -Define one vertex ( color ) - 3 float - -- Failure return false -- Success return true +Define one vertex (color) - 3 float */ int lrlglColor3f( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlColor3f( Vector3 color )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 color = uluaGetVector3Index( L, 1 ); rlColor3f( color.x, color.y, color.z ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlColor4f( Vector4 color ) +> RL.rlColor4f( Vector4 color ) -Define one vertex ( color ) - 4 float - -- Failure return false -- Success return true +Define one vertex (color) - 4 float */ int lrlglColor4f( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlColor4f( Vector4 color )" ); - lua_pushboolean( L, false ); - return 1; - } Vector4 color = uluaGetVector4Index( L, 1 ); rlColor4f( color.x, color.y, color.z, color.w ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* @@ -429,18 +284,12 @@ int lrlglColor4f( lua_State *L ) { /* > supported = RL.rlEnableVertexArray( int vaoId ) -Enable vertex array ( VAO, if supported ) +Enable vertex array (VAO, if supported) -- Failure return nil - Success return bool */ int lrlglEnableVertexArray( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlEnableVertexArray( int vaoId )" ); - lua_pushnil( L ); - return 1; - } - lua_pushboolean( L, rlEnableVertexArray( lua_tointeger( L, 1 ) ) ); + lua_pushboolean( L, rlEnableVertexArray( luaL_checkinteger( L, 1 ) ) ); return 1; } @@ -448,7 +297,7 @@ int lrlglEnableVertexArray( lua_State *L ) { /* > RL.rlDisableVertexArray() -Disable vertex array ( VAO, if supported ) +Disable vertex array (VAO, if supported) */ int lrlglDisableVertexArray( lua_State *L ) { rlDisableVertexArray(); @@ -457,29 +306,23 @@ int lrlglDisableVertexArray( lua_State *L ) { } /* -> success = RL.rlEnableVertexBuffer( int id ) +> RL.rlEnableVertexBuffer( int id ) -Enable vertex buffer ( VBO ) +Enable vertex buffer (VBO) - Failure return false - Success return true */ int lrlglEnableVertexBuffer( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlEnableVertexBuffer( int id )" ); - lua_pushboolean( L, false ); - return 1; - } - rlEnableVertexBuffer( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlEnableVertexBuffer( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* > RL.rlDisableVertexBuffer() -Disable vertex buffer ( VBO ) +Disable vertex buffer (VBO) */ int lrlglDisableVertexBuffer( lua_State *L ) { rlDisableVertexBuffer(); @@ -488,29 +331,20 @@ int lrlglDisableVertexBuffer( lua_State *L ) { } /* -> success = RL.rlEnableVertexBufferElement( int id ) - -Enable vertex buffer element ( VBO element ) +> RL.rlEnableVertexBufferElement( int id ) -- Failure return false -- Success return true +Enable vertex buffer element (VBO element) */ int lrlglEnableVertexBufferElement( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlEnableVertexBufferElement( int id )" ); - lua_pushboolean( L, false ); - return 1; - } - rlEnableVertexBufferElement( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlEnableVertexBufferElement( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* > RL.rlDisableVertexBufferElement() -Disable vertex buffer element ( VBO element ) +Disable vertex buffer element (VBO element) */ int lrlglDisableVertexBufferElement( lua_State *L ) { rlDisableVertexBufferElement(); @@ -519,43 +353,25 @@ int lrlglDisableVertexBufferElement( lua_State *L ) { } /* -> success = RL.rlEnableVertexAttribute( int index ) +> RL.rlEnableVertexAttribute( int index ) Enable vertex attribute index - -- Failure return false -- Success return true */ int lrlglEnableVertexAttribute( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlEnableVertexAttribute( int index )" ); - lua_pushboolean( L, false ); - return 1; - } - rlEnableVertexAttribute( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlEnableVertexAttribute( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* -> success = RL.rlDisableVertexAttribute( int index ) +> RL.rlDisableVertexAttribute( int index ) Disable vertex attribute index - -- Failure return false -- Success return true */ int lrlglDisableVertexAttribute( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlDisableVertexAttribute( int index )" ); - lua_pushboolean( L, false ); - return 1; - } - rlDisableVertexAttribute( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlDisableVertexAttribute( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* @@ -563,43 +379,25 @@ int lrlglDisableVertexAttribute( lua_State *L ) { */ /* -> success = RL.rlActiveTextureSlot( int slot ) +> RL.rlActiveTextureSlot( int slot ) Select and active a texture slot - -- Failure return false -- Success return true */ int lrlglActiveTextureSlot( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlActiveTextureSlot( int slot )" ); - lua_pushboolean( L, false ); - return 1; - } - rlActiveTextureSlot( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlActiveTextureSlot( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* -> success = RL.rlEnableTexture( int id ) +> RL.rlEnableTexture( int id ) Enable texture - -- Failure return false -- Success return true */ int lrlglEnableTexture( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlEnableTexture( int id )" ); - lua_pushboolean( L, false ); - return 1; - } - rlEnableTexture( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlEnableTexture( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* @@ -614,23 +412,14 @@ int lrlglDisableTexture( lua_State *L ) { } /* -> success = RL.rlEnableTextureCubemap( int id ) +> RL.rlEnableTextureCubemap( int id ) Enable texture cubemap - -- Failure return false -- Success return true */ int lrlglEnableTextureCubemap( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlEnableTextureCubemap( int id )" ); - lua_pushboolean( L, false ); - return 1; - } - rlEnableTextureCubemap( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlEnableTextureCubemap( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* @@ -645,51 +434,33 @@ int lrlglDisableTextureCubemap( lua_State *L ) { } /* -> success = RL.rlTextureParameters( int id, int param, int value ) +> RL.rlTextureParameters( int id, int param, int value ) -Set texture parameters ( filter, wrap ) - -- Failure return false -- Success return true +Set texture parameters (filter, wrap) */ int lrlglTextureParameters( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlTextureParameters( int id, int param, int value )" ); - lua_pushboolean( L, false ); - return 1; - } - unsigned int id = lua_tointeger( L, 1 ); - int param = lua_tointeger( L, 2 ); - int value = lua_tointeger( L, 3 ); + unsigned int id = luaL_checkinteger( L, 1 ); + int param = luaL_checkinteger( L, 2 ); + int value = luaL_checkinteger( L, 3 ); rlTextureParameters( id, param, value ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlCubemapParameters( int id, int param, int value ) - -Set cubemap parameters ( filter, wrap ) +> RL.rlCubemapParameters( int id, int param, int value ) -- Failure return false -- Success return true +Set cubemap parameters (filter, wrap) */ int lrlglCubemapParameters( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlCubemapParameters( int id, int param, int value )" ); - lua_pushboolean( L, false ); - return 1; - } - unsigned int id = lua_tointeger( L, 1 ); - int param = lua_tointeger( L, 2 ); - int value = lua_tointeger( L, 3 ); + unsigned int id = luaL_checkinteger( L, 1 ); + int param = luaL_checkinteger( L, 2 ); + int value = luaL_checkinteger( L, 3 ); rlCubemapParameters( id, param, value ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* @@ -697,23 +468,14 @@ int lrlglCubemapParameters( lua_State *L ) { */ /* -> success = RL.rlEnableShader( int id ) +> RL.rlEnableShader( int id ) Enable shader program - -- Failure return false -- Success return true */ int lrlglEnableShader( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlEnableShader( int id )" ); - lua_pushboolean( L, false ); - return 1; - } - rlEnableShader( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlEnableShader( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* @@ -732,23 +494,14 @@ int lrlglDisableShader( lua_State *L ) { */ /* -> success = RL.rlEnableFramebuffer( int id ) +> RL.rlEnableFramebuffer( int id ) Enable render texture (fbo) - -- Failure return false -- Success return true */ int lrlglEnableFramebuffer( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlEnableFramebuffer( int id )" ); - lua_pushboolean( L, false ); - return 1; - } - rlEnableFramebuffer( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlEnableFramebuffer( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* @@ -763,23 +516,14 @@ int lrlglDisableFramebuffer( lua_State *L ) { } /* -> success = RL.rlActiveDrawBuffers( int count ) +> RL.rlActiveDrawBuffers( int count ) Activate multiple draw color buffers - -- Failure return false -- Success return true */ int lrlglActiveDrawBuffers( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlActiveDrawBuffers( int count )" ); - lua_pushboolean( L, false ); - return 1; - } - rlActiveDrawBuffers( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlActiveDrawBuffers( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* @@ -875,23 +619,14 @@ int lrlglDisableBackfaceCulling( lua_State *L ) { } /* -> success = RL.rlSetCullFace( int mode ) +> RL.rlSetCullFace( int mode ) Set face culling mode - -- Failure return false -- Success return true */ int lrlglSetCullFace( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetCullFace( int mode )" ); - lua_pushboolean( L, false ); - return 1; - } - rlSetCullFace( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlSetCullFace( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* @@ -917,25 +652,16 @@ int lrlglDisableScissorTest( lua_State *L ) { } /* -> success = RL.rlScissor( Rectangle area ) +> RL.rlScissor( Rectangle area ) Scissor test - -- Failure return false -- Success return true */ int lrlglScissor( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlScissor( Rectangle area )" ); - lua_pushboolean( L, false ); - return 1; - } Rectangle area = uluaGetRectangleIndex( L, 1 ); rlScissor( area.x, area.y, area.width, area.height ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* @@ -961,23 +687,14 @@ int lrlglDisableWireMode( lua_State *L ) { } /* -> success = RL.rlSetLineWidth( float width ) +> RL.rlSetLineWidth( float width ) Set the line drawing width - -- Failure return false -- Success return true */ int lrlglSetLineWidth( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetLineWidth( float width )" ); - lua_pushboolean( L, false ); - return 1; - } - rlSetLineWidth( lua_tonumber( L, 1 ) ); - lua_pushboolean( L, true ); + rlSetLineWidth( luaL_checknumber( L, 1 ) ); - return 1; + return 0; } /* @@ -1051,31 +768,22 @@ int lrlglIsStereoRenderEnabled( lua_State *L ) { } /* -> success = RL.rlClearColor( Color color ) +> RL.rlClearColor( Color color ) Clear color buffer with color - -- Failure return false -- Success return true */ int lrlglClearColor( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlClearColor( Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Color color = uluaGetColorIndex( L, 1 ); rlClearColor( color.r, color.g, color.b, color.a ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* > RL.rlClearScreenBuffers() -Clear used screen buffers ( color and depth ) +Clear used screen buffers (color and depth) */ int lrlglClearScreenBuffers( lua_State *L ) { rlClearScreenBuffers(); @@ -1095,75 +803,47 @@ int lrlglCheckErrors( lua_State *L ) { } /* -> success = RL.rlSetBlendMode( int mode ) +> RL.rlSetBlendMode( int mode ) Set blending mode - -- Failure return false -- Success return true */ int lrlglSetBlendMode( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetBlendMode( int mode )" ); - lua_pushboolean( L, false ); - return 1; - } - rlSetBlendMode( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlSetBlendMode( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* -> success = RL.rlSetBlendFactors( int glSrcFactor, int glDstFactor, int glEquation ) - -Set blending mode factor and equation ( using OpenGL factors ) +> RL.rlSetBlendFactors( int glSrcFactor, int glDstFactor, int glEquation ) -- Failure return false -- Success return true +Set blending mode factor and equation (using OpenGL factors) */ int lrlglSetBlendFactors( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetBlendFactors( int glSrcFactor, int glDstFactor, int glEquation )" ); - lua_pushboolean( L, false ); - return 1; - } - int glSrcFactor = lua_tointeger( L, 1 ); - int glDstFactor = lua_tointeger( L, 2 ); - int glEquation = lua_tointeger( L, 3 ); + int glSrcFactor = luaL_checkinteger( L, 1 ); + int glDstFactor = luaL_checkinteger( L, 2 ); + int glEquation = luaL_checkinteger( L, 3 ); rlSetBlendFactors( glSrcFactor, glDstFactor, glEquation ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlSetBlendFactorsSeparate( int glSrcRGB, int glDstRGB, int glSrcAlpha, int glDstAlpha, int glEqRGB, int glEqAlpha ) +> RL.rlSetBlendFactorsSeparate( int glSrcRGB, int glDstRGB, int glSrcAlpha, int glDstAlpha, int glEqRGB, int glEqAlpha ) -Set blending mode factors and equations separately ( using OpenGL factors ) - -- Failure return false -- Success return true +Set blending mode factors and equations separately (using OpenGL factors) */ int lrlglSetBlendFactorsSeparate( lua_State *L ) { - 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( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetBlendFactorsSeparate( int glSrcRGB, int glDstRGB, int glSrcAlpha, int glDstAlpha, int glEqRGB, int glEqAlpha )" ); - lua_pushboolean( L, false ); - return 1; - } - int glSrcRGB = lua_tointeger( L, 1 ); - int glDstRGB = lua_tointeger( L, 2 ); - int glSrcAlpha = lua_tointeger( L, 3 ); - int glDstAlpha = lua_tointeger( L, 4 ); - int glEqRGB = lua_tointeger( L, 5 ); - int glEqAlpha = lua_tointeger( L, 6 ); + int glSrcRGB = luaL_checkinteger( L, 1 ); + int glDstRGB = luaL_checkinteger( L, 2 ); + int glSrcAlpha = luaL_checkinteger( L, 3 ); + int glDstAlpha = luaL_checkinteger( L, 4 ); + int glEqRGB = luaL_checkinteger( L, 5 ); + int glEqAlpha = luaL_checkinteger( L, 6 ); rlSetBlendFactorsSeparate( glSrcRGB, glDstRGB, glSrcAlpha, glDstAlpha, glEqRGB, glEqAlpha ); - lua_pushboolean( L, true ); - return 1; + return 0; } @@ -1204,38 +884,23 @@ int lrlglDrawRenderBatchActive( lua_State *L ) { Check internal buffer overflow for a given number of vertex and force a rlRenderBatch draw call if required -- Failure return nil - Success return bool */ int lrlglCheckRenderBatchLimit( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlCheckRenderBatchLimit( int vCount )" ); - lua_pushnil( L ); - return 1; - } - lua_pushboolean( L, rlCheckRenderBatchLimit( lua_tointeger( L, 1 ) ) ); + lua_pushboolean( L, rlCheckRenderBatchLimit( luaL_checkinteger( L, 1 ) ) ); return 1; } /* -> success = RL.rlSetTexture( int id ) +> RL.rlSetTexture( int id ) Set current texture for render batch and check buffers limits - -- Failure return false -- Success return true */ int lrlglSetTexture( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetTexture( int id )" ); - lua_pushboolean( L, false ); - return 1; - } - rlSetTexture( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlSetTexture( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* @@ -1260,17 +925,11 @@ int lrlglLoadVertexArray( lua_State *L ) { Load a vertex buffer attribute -- Failure return -1 - Success return int */ int lrlglLoadVertexBuffer( lua_State *L ) { - if ( !lua_isuserdata( L, 1 ) || !lua_isboolean( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlLoadVertexBuffer( Buffer buffer, bool dynamic )" ); - lua_pushinteger( L, -1 ); - return 1; - } Buffer *buffer = luaL_checkudata( L, 1, "Buffer" ); - bool dynamic = lua_tointeger( L, 2 ); + bool dynamic = luaL_checkinteger( L, 2 ); lua_pushinteger( L, rlLoadVertexBuffer( buffer->data, buffer->size, dynamic ) ); @@ -1282,17 +941,11 @@ int lrlglLoadVertexBuffer( lua_State *L ) { Load a new attributes element buffer -- Failure return -1 - Success return int */ int lrlglLoadVertexBufferElement( lua_State *L ) { - if ( !lua_isuserdata( L, 1 ) || !lua_isboolean( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlLoadVertexBufferElement( Buffer buffer, bool dynamic )" ); - lua_pushinteger( L, -1 ); - return 1; - } Buffer *buffer = luaL_checkudata( L, 1, "Buffer" ); - bool dynamic = lua_tointeger( L, 2 ); + bool dynamic = luaL_checkinteger( L, 2 ); lua_pushinteger( L, rlLoadVertexBufferElement( buffer->data, buffer->size, dynamic ) ); @@ -1300,160 +953,97 @@ int lrlglLoadVertexBufferElement( lua_State *L ) { } /* -> success = RL.rlUpdateVertexBuffer( int bufferId, Buffer buffer, int offset ) +> RL.rlUpdateVertexBuffer( int bufferId, Buffer buffer, int offset ) Update GPU buffer with new data - -- Failure return false -- Success return true */ int lrlglUpdateVertexBuffer( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isuserdata( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlUpdateVertexBuffer( int bufferId, Buffer buffer, int offset )" ); - lua_pushboolean( L, false ); - return 1; - } - int bufferId = lua_tointeger( L, 1 ); + int bufferId = luaL_checkinteger( L, 1 ); Buffer *buffer = luaL_checkudata( L, 2, "Buffer" ); - int offset = lua_tointeger( L, 3 ); + int offset = luaL_checkinteger( L, 3 ); rlUpdateVertexBuffer( bufferId, buffer->data, buffer->size, offset ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlUpdateVertexBufferElements( int id, Buffer buffer, int offset ) +> RL.rlUpdateVertexBufferElements( int id, Buffer buffer, int offset ) Update vertex buffer elements with new data - -- Failure return false -- Success return true */ int lrlglUpdateVertexBufferElements( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isuserdata( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlUpdateVertexBufferElements( int id, Buffer buffer, int offset )" ); - lua_pushboolean( L, false ); - return 1; - } - int bufferId = lua_tointeger( L, 1 ); + int bufferId = luaL_checkinteger( L, 1 ); Buffer *buffer = luaL_checkudata( L, 2, "Buffer" ); - int offset = lua_tointeger( L, 3 ); + int offset = luaL_checkinteger( L, 3 ); rlUpdateVertexBufferElements( bufferId, buffer->data, buffer->size, offset ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlUnloadVertexArray( int vaoId ) +> RL.rlUnloadVertexArray( int vaoId ) Unload vertex array object (VAO) - -- Failure return false -- Success return true */ int lrlglUnloadVertexArray( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlUnloadVertexArray( int vaoId )" ); - lua_pushboolean( L, false ); - return 1; - } - rlUnloadVertexArray( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlUnloadVertexArray( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* -> success = RL.rlUnloadVertexBuffer( int vboId ) +> RL.rlUnloadVertexBuffer( int vboId ) Unload vertex buffer (VBO) - -- Failure return false -- Success return true */ int lrlglUnloadVertexBuffer( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlUnloadVertexBuffer( int vboId )" ); - lua_pushboolean( L, false ); - return 1; - } - rlUnloadVertexBuffer( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlUnloadVertexBuffer( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* -> success = RL.rlSetVertexAttribute( int index, int compSize, int type, bool normalized, int stride, int pointer ) +> RL.rlSetVertexAttribute( int index, int compSize, int type, bool normalized, int stride, int pointer ) Set vertex attribute - -- Failure return false -- Success return true */ int lrlglSetVertexAttribute( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) - || !lua_isboolean( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_isnumber( L, 6 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetVertexAttribute( int index, int compSize, int type, bool normalized, int stride, int pointer )" ); - lua_pushboolean( L, false ); - return 1; - } - int index = lua_tointeger( L, 1 ); - int compSize = lua_tointeger( L, 2 ); - int type = lua_tointeger( L, 3 ); + int index = luaL_checkinteger( L, 1 ); + int compSize = luaL_checkinteger( L, 2 ); + int type = luaL_checkinteger( L, 3 ); bool normalized = lua_toboolean( L, 4 ); - int stride = lua_tointeger( L, 5 ); - int pointer = lua_tointeger( L, 6 ); + int stride = luaL_checkinteger( L, 5 ); + int pointer = luaL_checkinteger( L, 6 ); rlSetVertexAttribute( index, compSize, type, normalized, stride, &pointer ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlSetVertexAttributeDivisor( int index, int divisor ) +> RL.rlSetVertexAttributeDivisor( int index, int divisor ) Set vertex attribute divisor - -- Failure return false -- Success return true */ int lrlglSetVertexAttributeDivisor( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetVertexAttributeDivisor( int index, int divisor )" ); - lua_pushboolean( L, false ); - return 1; - } - unsigned int index = (unsigned int)lua_tointeger( L, 1 ); - int divisor = lua_tointeger( L, 2 ); + unsigned int index = (unsigned int)luaL_checkinteger( L, 1 ); + int divisor = luaL_checkinteger( L, 2 ); rlSetVertexAttributeDivisor( index, divisor ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlSetVertexAttributeDefault( int locIndex, float{} value, int attribType ) +> RL.rlSetVertexAttributeDefault( int locIndex, float{} value, int attribType ) Set vertex attribute default value - -- Failure return false -- Success return true */ int lrlglSetVertexAttributeDefault( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetVertexAttributeDefault( int locIndex, float{} value, int attribType )" ); - lua_pushboolean( L, false ); - return 1; - } - int locIndex = lua_tointeger( L, 1 ); - int attribType = lua_tointeger( L, 3 ); + int locIndex = luaL_checkinteger( L, 1 ); + int attribType = luaL_checkinteger( L, 3 ); int count = uluaGetTableLenIndex( L, 2 ); float value[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; @@ -1462,110 +1052,73 @@ int lrlglSetVertexAttributeDefault( lua_State *L ) { lua_pushnil( L ); while ( lua_next( L, t ) != 0 ) { - value[i] = lua_tonumber( L, -1 ); + value[i] = luaL_checknumber( L, -1 ); lua_pop( L, 1 ); i++; } rlSetVertexAttributeDefault( locIndex, value, attribType, count ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlDrawVertexArray( int offset, int count ) +> RL.rlDrawVertexArray( int offset, int count ) Draw vertex array - -- Failure return false -- Success return true */ int lrlglDrawVertexArray( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlDrawVertexArray( int offset, int count )" ); - lua_pushboolean( L, false ); - return 1; - } - int offset = lua_tointeger( L, 1 ); - int count = lua_tointeger( L, 2 ); + int offset = luaL_checkinteger( L, 1 ); + int count = luaL_checkinteger( L, 2 ); rlDrawVertexArray( offset, count ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlDrawVertexArrayElements( int offset, int count, Buffer buffer ) +> RL.rlDrawVertexArrayElements( int offset, int count, Buffer buffer ) Draw vertex array elements - -- Failure return false -- Success return true */ int lrlglDrawVertexArrayElements( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isuserdata( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlDrawVertexArrayElements( int offset, int count, Buffer buffer )" ); - lua_pushboolean( L, false ); - return 1; - } - int offset = lua_tointeger( L, 1 ); - int count = lua_tointeger( L, 2 ); + int offset = luaL_checkinteger( L, 1 ); + int count = luaL_checkinteger( L, 2 ); Buffer *buffer = luaL_checkudata( L, 3, "Buffer" ); rlDrawVertexArrayElements( offset, count, buffer->data ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlDrawVertexArrayInstanced( int offset, int count, int instances ) +> RL.rlDrawVertexArrayInstanced( int offset, int count, int instances ) Draw vertex array instanced - -- Failure return false -- Success return true */ int lrlglDrawVertexArrayInstanced( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlDrawVertexArrayInstanced( int offset, int count, int instances )" ); - lua_pushboolean( L, false ); - return 1; - } - int offset = lua_tointeger( L, 1 ); - int count = lua_tointeger( L, 2 ); - int instances = lua_tointeger( L, 3 ); + int offset = luaL_checkinteger( L, 1 ); + int count = luaL_checkinteger( L, 2 ); + int instances = luaL_checkinteger( L, 3 ); rlDrawVertexArrayInstanced( offset, count, instances ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlDrawVertexArrayElementsInstanced( int offset, int count, Buffer buffer, int instances ) +> RL.rlDrawVertexArrayElementsInstanced( int offset, int count, Buffer buffer, int instances ) Draw vertex array elements instanced - -- Failure return false -- Success return true */ int lrlglDrawVertexArrayElementsInstanced( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isuserdata( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlDrawVertexArrayElementsInstanced( int offset, int count, Buffer buffer, int instances )" ); - lua_pushboolean( L, false ); - return 1; - } - int offset = lua_tointeger( L, 1 ); - int count = lua_tointeger( L, 2 ); + int offset = luaL_checkinteger( L, 1 ); + int count = luaL_checkinteger( L, 2 ); Buffer *buffer = luaL_checkudata( L, 3, "Buffer" ); - int instances = lua_tointeger( L, 4 ); + int instances = luaL_checkinteger( L, 4 ); rlDrawVertexArrayElementsInstanced( offset, count, buffer->data, instances ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* @@ -1577,18 +1130,12 @@ int lrlglDrawVertexArrayElementsInstanced( lua_State *L ) { Load texture in GPU -- Failure return -1 - Success return int */ int lrlglLoadTexture( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlLoadTexture( Vector2 size, int format, int mipmapCount )" ); - lua_pushinteger( L, -1 ); - return 1; - } Vector2 size = uluaGetVector2Index( L, 1 ); - int format = lua_tointeger( L, 2 ); - int mipmapCount = lua_tointeger( L, 3 ); + int format = luaL_checkinteger( L, 2 ); + int mipmapCount = luaL_checkinteger( L, 3 ); lua_pushinteger( L, rlLoadTexture( NULL, size.x, size.y, format, mipmapCount ) ); @@ -1598,17 +1145,11 @@ int lrlglLoadTexture( lua_State *L ) { /* > id = RL.rlLoadTextureDepth( Vector2 size, bool useRenderBuffer ) -Load depth texture/renderbuffer ( to be attached to fbo ) +Load depth texture/renderbuffer (to be attached to fbo) -- Failure return -1 - Success return int */ int lrlglLoadTextureDepth( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isboolean( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlLoadTextureDepth( Vector2 size, bool useRenderBuffer )" ); - lua_pushinteger( L, -1 ); - return 1; - } Vector2 size = uluaGetVector2Index( L, 1 ); bool useRenderBuffer = lua_toboolean( L, 2 ); @@ -1618,23 +1159,14 @@ int lrlglLoadTextureDepth( lua_State *L ) { } /* -> success = RL.rlUnloadTexture( int id ) +> RL.rlUnloadTexture( int id ) Unload texture from GPU memory - -- Failure return false -- Success return true */ int lrlglUnloadTexture( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlUnloadTexture( int id )" ); - lua_pushboolean( L, false ); - return 1; - } - rlUnloadTexture( lua_tointeger( L, 1 ) ); - lua_pushboolean( L, true ); + rlUnloadTexture( luaL_checkinteger( L, 1 ) ); - return 1; + return 0; } /* @@ -1646,15 +1178,9 @@ int lrlglUnloadTexture( lua_State *L ) { Load an empty framebuffer -- Failure return -1 - Success return int */ int lrlglLoadFramebuffer( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlLoadFramebuffer( Vector2 size )" ); - lua_pushinteger( L, -1 ); - return 1; - } Vector2 size = uluaGetVector2Index( L, 1 ); lua_pushinteger( L, rlLoadFramebuffer( size.x, size.y ) ); @@ -1663,30 +1189,20 @@ int lrlglLoadFramebuffer( lua_State *L ) { } /* -> success = RL.rlFramebufferAttach( int fboId, int texId, int attachType, int texType, int mipLevel ) +> RL.rlFramebufferAttach( int fboId, int texId, int attachType, int texType, int mipLevel ) Attach texture/renderbuffer to a framebuffer - -- Failure return false -- Success return true */ int lrlglFramebufferAttach( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) - || !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlFramebufferAttach( int fboId, int texId, int attachType, int texType, int mipLevel )" ); - lua_pushboolean( L, false ); - return 1; - } - unsigned int fboId = lua_tointeger( L, 1 ); - unsigned int texId = lua_tointeger( L, 2 ); - int attachType = lua_tointeger( L, 3 ); - int texType = lua_tointeger( L, 4 ); - int mipLevel = lua_tointeger( L, 5 ); + unsigned int fboId = luaL_checkinteger( L, 1 ); + unsigned int texId = luaL_checkinteger( L, 2 ); + int attachType = luaL_checkinteger( L, 3 ); + int texType = luaL_checkinteger( L, 4 ); + int mipLevel = luaL_checkinteger( L, 5 ); rlFramebufferAttach( fboId, texId, attachType, texType, mipLevel ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* @@ -1694,16 +1210,10 @@ int lrlglFramebufferAttach( lua_State *L ) { Verify framebuffer is complete -- Failure return nil - Success return bool */ int lrlglFramebufferComplete( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlFramebufferComplete( int id )" ); - lua_pushnil( L ); - return 1; - } - unsigned int id = lua_tointeger( L, 1 ); + unsigned int id = luaL_checkinteger( L, 1 ); lua_pushboolean( L, rlFramebufferComplete( id ) ); @@ -1711,25 +1221,16 @@ int lrlglFramebufferComplete( lua_State *L ) { } /* -> success = RL.rlUnloadFramebuffer( int id ) +> RL.rlUnloadFramebuffer( int id ) Delete framebuffer from GPU - -- Failure return nil -- Success return bool */ int lrlglUnloadFramebuffer( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlUnloadFramebuffer( int id )" ); - lua_pushnil( L ); - return 1; - } - unsigned int id = lua_tointeger( L, 1 ); + unsigned int id = luaL_checkinteger( L, 1 ); rlUnloadFramebuffer( id ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* @@ -1803,16 +1304,10 @@ int lrlglGetMatrixTransform( lua_State *L ) { Get internal projection matrix for stereo render (selected eye) -- Failure return false - Success return Matrix */ int lrlglGetMatrixProjectionStereo( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlGetMatrixProjectionStereo( int eye )" ); - lua_pushboolean( L, false ); - return 1; - } - uluaPushMatrix( L, rlGetMatrixProjectionStereo( lua_tointeger( L, 1 ) ) ); + uluaPushMatrix( L, rlGetMatrixProjectionStereo( luaL_checkinteger( L, 1 ) ) ); return 1; } @@ -1822,96 +1317,54 @@ int lrlglGetMatrixProjectionStereo( lua_State *L ) { Get internal view offset matrix for stereo render (selected eye) -- Failure return false - Success return Matrix */ int lrlglGetMatrixViewOffsetStereo( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlGetMatrixViewOffsetStereo( int eye )" ); - lua_pushboolean( L, false ); - return 1; - } - uluaPushMatrix( L, rlGetMatrixViewOffsetStereo( lua_tointeger( L, 1 ) ) ); + uluaPushMatrix( L, rlGetMatrixViewOffsetStereo( luaL_checkinteger( L, 1 ) ) ); return 1; } /* -> success = RL.rlSetMatrixProjection( Matrix proj ) +> RL.rlSetMatrixProjection( Matrix proj ) Set a custom projection matrix (replaces internal projection matrix) - -- Failure return false -- Success return true */ int lrlglSetMatrixProjection( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetMatrixProjection( Matrix proj )" ); - lua_pushboolean( L, false ); - return 1; - } rlSetMatrixProjection( uluaGetMatrixIndex( L, 1 ) ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlSetMatrixModelview( Matrix view ) +> RL.rlSetMatrixModelview( Matrix view ) Set a custom modelview matrix (replaces internal modelview matrix) - -- Failure return false -- Success return true */ int lrlglSetMatrixModelview( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetMatrixModelview( Matrix view )" ); - lua_pushboolean( L, false ); - return 1; - } rlSetMatrixModelview( uluaGetMatrixIndex( L, 1 ) ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlSetMatrixProjectionStereo( Matrix right, Matrix left ) +> RL.rlSetMatrixProjectionStereo( Matrix right, Matrix left ) Set eyes projection matrices for stereo rendering - -- Failure return false -- Success return true */ int lrlglSetMatrixProjectionStereo( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetMatrixModelview( Matrix right, Matrix left )" ); - lua_pushboolean( L, false ); - return 1; - } rlSetMatrixProjectionStereo( uluaGetMatrixIndex( L, 1 ), uluaGetMatrixIndex( L, 2 ) ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.rlSetMatrixViewOffsetStereo( Matrix right, Matrix left ) +> RL.rlSetMatrixViewOffsetStereo( Matrix right, Matrix left ) Set eyes view offsets matrices for stereo rendering - -- Failure return false -- Success return true */ int lrlglSetMatrixViewOffsetStereo( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.rlSetMatrixViewOffsetStereo( Matrix right, Matrix left )" ); - lua_pushboolean( L, false ); - return 1; - } rlSetMatrixViewOffsetStereo( uluaGetMatrixIndex( L, 1 ), uluaGetMatrixIndex( L, 2 ) ); - lua_pushboolean( L, true ); - return 1; + return 0; } diff --git a/src/rmath.c b/src/rmath.c index 6effbd5..f1f4642 100644 --- a/src/rmath.c +++ b/src/rmath.c @@ -20,18 +20,12 @@ inline int imax( int a, int b ) { Clamp float value -- Failure return false - Success return float */ int lmathClamp( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Clamp( float value, float min, float max )" ); - lua_pushboolean( L, false ); - return 1; - } - float value = lua_tonumber( L, 1 ); - float min = lua_tonumber( L, 2 ); - float max = lua_tonumber( L, 3 ); + float value = luaL_checknumber( L, 1 ); + float min = luaL_checknumber( L, 2 ); + float max = luaL_checknumber( L, 3 ); lua_pushnumber( L, Clamp( value, min, max ) ); @@ -43,18 +37,12 @@ int lmathClamp( lua_State *L ) { Calculate linear interpolation between two floats -- Failure return false - Success return float */ int lmathLerp( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Lerp( float a, float b, float amount )" ); - lua_pushboolean( L, false ); - return 1; - } - float start = lua_tonumber( L, 1 ); - float end = lua_tonumber( L, 2 ); - float amount = lua_tonumber( L, 3 ); + float start = luaL_checknumber( L, 1 ); + float end = luaL_checknumber( L, 2 ); + float amount = luaL_checknumber( L, 3 ); lua_pushnumber( L, Lerp( start, end, amount ) ); @@ -66,18 +54,12 @@ int lmathLerp( lua_State *L ) { Normalize input value within input range -- Failure return false - Success return float */ int lmathNormalize( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Normalize( float value, float a, float b )" ); - lua_pushboolean( L, false ); - return 1; - } - float value = lua_tonumber( L, 1 ); - float start = lua_tonumber( L, 2 ); - float end = lua_tonumber( L, 3 ); + float value = luaL_checknumber( L, 1 ); + float start = luaL_checknumber( L, 2 ); + float end = luaL_checknumber( L, 3 ); lua_pushnumber( L, Normalize( value, start, end ) ); @@ -89,21 +71,14 @@ int lmathNormalize( lua_State *L ) { Remap input value within input range to output range -- Failure return false - Success return float */ int lmathRemap( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) - || !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Remap( float value, float inputStart, float inputEnd, float outputStart, float outputEnd )" ); - lua_pushboolean( L, false ); - return 1; - } - 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 ); + float value = luaL_checknumber( L, 1 ); + float inputStart = luaL_checknumber( L, 2 ); + float inputEnd = luaL_checknumber( L, 3 ); + float outputStart = luaL_checknumber( L, 4 ); + float outputEnd = luaL_checknumber( L, 5 ); lua_pushnumber( L, Remap( value, inputStart, inputEnd, outputStart, outputEnd ) ); @@ -115,18 +90,12 @@ int lmathRemap( lua_State *L ) { Wrap input value from min to max -- Failure return false - Success return float */ int lmathWrap( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Wrap( float value, float min, float max )" ); - lua_pushboolean( L, false ); - return 1; - } - float value = lua_tonumber( L, 1 ); - float min = lua_tonumber( L, 2 ); - float max = lua_tonumber( L, 3 ); + float value = luaL_checknumber( L, 1 ); + float min = luaL_checknumber( L, 2 ); + float max = luaL_checknumber( L, 3 ); lua_pushnumber( L, Wrap( value, min, max ) ); @@ -138,17 +107,11 @@ int lmathWrap( lua_State *L ) { Check whether two given floats are almost equal -- Failure return false - Success return int */ int lmathFloatEquals( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.FloatEquals( float x, float y )" ); - lua_pushboolean( L, false ); - return 1; - } - float x = lua_tonumber( L, 1 ); - float y = lua_tonumber( L, 2 ); + float x = luaL_checknumber( L, 1 ); + float y = luaL_checknumber( L, 2 ); lua_pushinteger( L, FloatEquals( x, y ) ); @@ -190,15 +153,9 @@ int lmathVector2One( lua_State *L ) { Add two vectors (v1 + v2) -- Failure return false - Success return Vector2 */ int lmathVector2Add( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Add( Vector2 v1, Vector2 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v1 = uluaGetVector2Index( L, 1 ); Vector2 v2 = uluaGetVector2Index( L, 2 ); @@ -212,17 +169,11 @@ int lmathVector2Add( lua_State *L ) { Add vector and float value -- Failure return false - Success return Vector2 */ int lmathVector2AddValue( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2AddValue( Vector2 v, float add )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v = uluaGetVector2Index( L, 1 ); - float add = lua_tonumber( L, 2 ); + float add = luaL_checknumber( L, 2 ); uluaPushVector2( L, Vector2AddValue( v, add ) ); @@ -234,15 +185,9 @@ int lmathVector2AddValue( lua_State *L ) { Subtract two vectors (v1 - v2) -- Failure return false - Success return Vector2 */ int lmathVector2Subtract( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Subtract( Vector2 v1, Vector2 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v1 = uluaGetVector2Index( L, 1 ); Vector2 v2 = uluaGetVector2Index( L, 2 ); @@ -256,17 +201,11 @@ int lmathVector2Subtract( lua_State *L ) { Subtract vector by float value -- Failure return false - Success return Vector2 */ int lmathVector2SubtractValue( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2SubtractValue( Vector2 v, float sub )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v = uluaGetVector2Index( L, 1 ); - float sub = lua_tonumber( L, 2 ); + float sub = luaL_checknumber( L, 2 ); uluaPushVector2( L, Vector2SubtractValue( v, sub ) ); @@ -278,15 +217,9 @@ int lmathVector2SubtractValue( lua_State *L ) { Calculate vector length -- Failure return false - Success return float */ int lmathVector2Length( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Length( vector2 v )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v = uluaGetVector2Index( L, 1 ); lua_pushnumber( L, Vector2Length( v ) ); @@ -299,15 +232,9 @@ int lmathVector2Length( lua_State *L ) { Calculate vector square length -- Failure return false - Success return float */ int lmathVector2LengthSqr( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2LengthSqr( vector2 v )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v = uluaGetVector2Index( L, 1 ); lua_pushnumber( L, Vector2LengthSqr( v ) ); @@ -320,15 +247,9 @@ int lmathVector2LengthSqr( lua_State *L ) { Calculate two vectors dot product -- Failure return false - Success return float */ int lmathVector2DotProduct( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2DotProduct( Vector2 v1, Vector2 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v1 = uluaGetVector2Index( L, 1 ); Vector2 v2 = uluaGetVector2Index( L, 2 ); @@ -342,15 +263,9 @@ int lmathVector2DotProduct( lua_State *L ) { Calculate distance between two vectors -- Failure return false - Success return float */ int lmathVector2Distance( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Distance( Vector2 v1, Vector2 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v1 = uluaGetVector2Index( L, 1 ); Vector2 v2 = uluaGetVector2Index( L, 2 ); @@ -364,15 +279,9 @@ int lmathVector2Distance( lua_State *L ) { Calculate square distance between two vectors -- Failure return false - Success return float */ int lmathVector2DistanceSqr( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2DistanceSqr( Vector2 v1, Vector2 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v1 = uluaGetVector2Index( L, 1 ); Vector2 v2 = uluaGetVector2Index( L, 2 ); @@ -386,15 +295,9 @@ int lmathVector2DistanceSqr( lua_State *L ) { Calculate angle from two vectors -- Failure return false - Success return float */ int lmathVector2Angle( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Angle( Vector2 v1, Vector2 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v1 = uluaGetVector2Index( L, 1 ); Vector2 v2 = uluaGetVector2Index( L, 2 ); @@ -410,15 +313,9 @@ Calculate angle defined by a two vectors line. NOTE: Parameters need to be normalized. Current implementation should be aligned with glm::angle. -- Failure return false - Success return float */ int lmathVector2LineAngle( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2LineAngle( Vector2 a, Vector2 b )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 start = uluaGetVector2Index( L, 1 ); Vector2 end = uluaGetVector2Index( L, 2 ); @@ -430,19 +327,13 @@ int lmathVector2LineAngle( lua_State *L ) { /* > result = RL.Vector2Scale( Vector2 v, float scale ) -Scale vector ( multiply by value ) +Scale vector (multiply by value) -- Failure return false - Success return Vector2 */ int lmathVector2Scale( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Scale( Vector2 v, float scale )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v = uluaGetVector2Index( L, 1 ); - float scale = lua_tonumber( L, 2 ); + float scale = luaL_checknumber( L, 2 ); uluaPushVector2( L, Vector2Scale( v, scale ) ); @@ -454,15 +345,9 @@ int lmathVector2Scale( lua_State *L ) { Multiply vector by vector -- Failure return false - Success return Vector2 */ int lmathVector2Multiply( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Multiply( Vector2 v1, Vector2 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v1 = uluaGetVector2Index( L, 1 ); Vector2 v2 = uluaGetVector2Index( L, 2 ); @@ -476,15 +361,9 @@ int lmathVector2Multiply( lua_State *L ) { Negate vector -- Failure return false - Success return Vector2 */ int lmathVector2Negate( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Negate( Vector2 v )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v = uluaGetVector2Index( L, 1 ); uluaPushVector2( L, Vector2Negate( v ) ); @@ -497,15 +376,9 @@ int lmathVector2Negate( lua_State *L ) { Divide vector by vector -- Failure return false - Success return Vector2 */ int lmathVector2Divide( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Divide( Vector2 v1, Vector2 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v1 = uluaGetVector2Index( L, 1 ); Vector2 v2 = uluaGetVector2Index( L, 2 ); @@ -519,15 +392,9 @@ int lmathVector2Divide( lua_State *L ) { Normalize provided vector -- Failure return false - Success return Vector2 */ int lmathVector2Normalize( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Normalize( Vector2 v )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v = uluaGetVector2Index( L, 1 ); uluaPushVector2( L, Vector2Normalize( v ) ); @@ -540,15 +407,9 @@ int lmathVector2Normalize( lua_State *L ) { Transforms a Vector2 by a given Matrix -- Failure return false - Success return Vector2 */ int lmathVector2Transform( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Transform( Vector2 v, Matrix mat )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v = uluaGetVector2Index( L, 1 ); Matrix mat = uluaGetMatrixIndex( L, 2 ); @@ -562,18 +423,12 @@ int lmathVector2Transform( lua_State *L ) { Calculate linear interpolation between two vectors -- Failure return false - Success return Vector2 */ int lmathVector2Lerp( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Lerp( Vector2 v1, Vector2 v2, float amount )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v1 = uluaGetVector2Index( L, 1 ); Vector2 v2 = uluaGetVector2Index( L, 2 ); - float amount = lua_tonumber( L, 3 ); + float amount = luaL_checknumber( L, 3 ); uluaPushVector2( L, Vector2Lerp( v1, v2, amount ) ); @@ -585,15 +440,9 @@ int lmathVector2Lerp( lua_State *L ) { Calculate reflected vector to normal -- Failure return false - Success return Vector2 */ int lmathVector2Reflect( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Reflect( Vector2 v, Vector2 normal )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v1 = uluaGetVector2Index( L, 1 ); Vector2 v2 = uluaGetVector2Index( L, 2 ); @@ -607,17 +456,11 @@ int lmathVector2Reflect( lua_State *L ) { Rotate vector by angle -- Failure return false - Success return Vector2 */ int lmathVector2Rotate( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Rotate( Vector2 v, float angle )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v = uluaGetVector2Index( L, 1 ); - float degs = lua_tonumber( L, 2 ); + float degs = luaL_checknumber( L, 2 ); uluaPushVector2( L, Vector2Rotate( v, degs ) ); @@ -629,18 +472,12 @@ int lmathVector2Rotate( lua_State *L ) { Move Vector towards target -- Failure return false - Success return Vector2 */ int lmathVector2MoveTowards( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2MoveTowards( Vector2 v, Vector2 target, float maxDistance )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v1 = uluaGetVector2Index( L, 1 ); Vector2 v2 = uluaGetVector2Index( L, 2 ); - float maxDistance = lua_tonumber( L, 3 ); + float maxDistance = luaL_checknumber( L, 3 ); uluaPushVector2( L, Vector2MoveTowards( v1, v2, maxDistance ) ); @@ -652,15 +489,9 @@ int lmathVector2MoveTowards( lua_State *L ) { Invert the given vector -- Failure return false - Success return Vector2 */ int lmathVector2Invert( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Invert( Vector2 v )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v = uluaGetVector2Index( L, 1 ); uluaPushVector2( L, Vector2Invert( v ) ); @@ -674,15 +505,9 @@ int lmathVector2Invert( lua_State *L ) { Clamp the components of the vector between min and max values specified by the given vectors -- Failure return false - Success return Vector2 */ int lmathVector2Clamp( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Clamp( Vector2 v, Vector2 min, Vector2 max )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v = uluaGetVector2Index( L, 1 ); Vector2 min = uluaGetVector2Index( L, 2 ); Vector2 max = uluaGetVector2Index( L, 3 ); @@ -697,18 +522,12 @@ int lmathVector2Clamp( lua_State *L ) { Clamp the magnitude of the vector between two min and max values -- Failure return false - Success return Vector2 */ int lmathVector2ClampValue( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2ClampValue( Vector2 v, float min, float max )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v = uluaGetVector2Index( L, 1 ); - float min = lua_tonumber( L, 2 ); - float max = lua_tonumber( L, 3 ); + float min = luaL_checknumber( L, 2 ); + float max = luaL_checknumber( L, 3 ); uluaPushVector2( L, Vector2ClampValue( v, min, max ) ); @@ -720,15 +539,9 @@ int lmathVector2ClampValue( lua_State *L ) { Check whether two given vectors are almost equal -- Failure return false - Success return int */ int lmathVector2Equals( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector2Equals( Vector2 v1, Vector2 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v1 = uluaGetVector2Index( L, 1 ); Vector2 v2 = uluaGetVector2Index( L, 2 ); @@ -772,15 +585,9 @@ int lmathVector3One( lua_State *L ) { Add two vectors -- Failure return false - Success return Vector3 */ int lmathVector3Add( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Add( Vector3 v1, Vector3 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v1 = uluaGetVector3Index( L, 1 ); Vector3 v2 = uluaGetVector3Index( L, 2 ); @@ -794,17 +601,11 @@ int lmathVector3Add( lua_State *L ) { Add vector and float value -- Failure return false - Success return Vector3 */ int lmathVector3AddValue( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3AddValue( Vector3 v, float add )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); - float add = lua_tonumber( L, 2 ); + float add = luaL_checknumber( L, 2 ); uluaPushVector3( L, Vector3AddValue( v, add ) ); @@ -816,15 +617,9 @@ int lmathVector3AddValue( lua_State *L ) { Subtract two vectors -- Failure return false - Success return Vector3 */ int lmathVector3Subtract( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Subtract( Vector3 v1, Vector3 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v1 = uluaGetVector3Index( L, 1 ); Vector3 v2 = uluaGetVector3Index( L, 2 ); @@ -838,17 +633,11 @@ int lmathVector3Subtract( lua_State *L ) { Subtract vector by float value -- Failure return false - Success return Vector3 */ int lmathVector3SubtractValue( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3SubtractValue( Vector3 v, float sub )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); - float sub = lua_tonumber( L, 2 ); + float sub = luaL_checknumber( L, 2 ); uluaPushVector3( L, Vector3SubtractValue( v, sub ) ); @@ -860,17 +649,11 @@ int lmathVector3SubtractValue( lua_State *L ) { Multiply vector by scalar -- Failure return false - Success return Vector3 */ int lmathVector3Scale( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Scale( Vector3 v, float scalar )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); - float scalar = lua_tonumber( L, 2 ); + float scalar = luaL_checknumber( L, 2 ); uluaPushVector3( L, Vector3Scale( v, scalar ) ); @@ -882,15 +665,9 @@ int lmathVector3Scale( lua_State *L ) { Multiply vector by vector -- Failure return false - Success return Vector3 */ int lmathVector3Multiply( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Multiply( Vector3 v1, Vector3 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v1 = uluaGetVector3Index( L, 1 ); Vector3 v2 = uluaGetVector3Index( L, 2 ); @@ -904,15 +681,9 @@ int lmathVector3Multiply( lua_State *L ) { Calculate two vectors cross product -- Failure return false - Success return Vector3 */ int lmathVector3CrossProduct( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3CrossProduct( Vector3 v1, Vector3 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v1 = uluaGetVector3Index( L, 1 ); Vector3 v2 = uluaGetVector3Index( L, 2 ); @@ -926,15 +697,9 @@ int lmathVector3CrossProduct( lua_State *L ) { Calculate one vector perpendicular vector -- Failure return false - Success return Vector3 */ int lmathVector3Perpendicular( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Perpendicular( Vector3 v )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); uluaPushVector3( L, Vector3Perpendicular( v ) ); @@ -947,15 +712,9 @@ int lmathVector3Perpendicular( lua_State *L ) { Calculate vector length -- Failure return false - Success return float */ int lmathVector3Length( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Length( Vector3 v )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); lua_pushnumber( L, Vector3Length( v ) ); @@ -968,15 +727,9 @@ int lmathVector3Length( lua_State *L ) { Calculate vector square length -- Failure return false - Success return float */ int lmathVector3LengthSqr( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3LengthSqr( Vector3 v )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); lua_pushnumber( L, Vector3LengthSqr( v ) ); @@ -989,15 +742,9 @@ int lmathVector3LengthSqr( lua_State *L ) { Calculate two vectors dot product -- Failure return false - Success return float */ int lmathVector3DotProduct( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3DotProduct( Vector3 v1, Vector3 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v1 = uluaGetVector3Index( L, 1 ); Vector3 v2 = uluaGetVector3Index( L, 2 ); @@ -1011,15 +758,9 @@ int lmathVector3DotProduct( lua_State *L ) { Calculate distance between two vectors -- Failure return false - Success return float */ int lmathVector3Distance( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Distance( Vector3 v1, Vector3 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v1 = uluaGetVector3Index( L, 1 ); Vector3 v2 = uluaGetVector3Index( L, 2 ); @@ -1033,15 +774,9 @@ int lmathVector3Distance( lua_State *L ) { Calculate square distance between two vectors -- Failure return false - Success return float */ int lmathVector3DistanceSqr( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3DistanceSqr( Vector3 v1, Vector3 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v1 = uluaGetVector3Index( L, 1 ); Vector3 v2 = uluaGetVector3Index( L, 2 ); @@ -1055,15 +790,9 @@ int lmathVector3DistanceSqr( lua_State *L ) { Calculate angle between two vectors -- Failure return false - Success return float */ int lmathVector3Angle( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Angle( Vector3 v1, Vector3 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v1 = uluaGetVector3Index( L, 1 ); Vector3 v2 = uluaGetVector3Index( L, 2 ); @@ -1075,17 +804,11 @@ int lmathVector3Angle( lua_State *L ) { /* > result = RL.Vector3Negate( Vector3 v ) -Negate provided vector ( invert direction ) +Negate provided vector (invert direction) -- Failure return false - Success return Vector3 */ int lmathVector3Negate( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Negate( Vector3 v )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); uluaPushVector3( L, Vector3Negate( v ) ); @@ -1098,15 +821,9 @@ int lmathVector3Negate( lua_State *L ) { Divide vector by vector -- Failure return false - Success return Vector3 */ int lmathVector3Divide( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Divide( Vector3 v1, Vector3 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v1 = uluaGetVector3Index( L, 1 ); Vector3 v2 = uluaGetVector3Index( L, 2 ); @@ -1120,15 +837,9 @@ int lmathVector3Divide( lua_State *L ) { Normalize provided vector -- Failure return false - Success return Vector3 */ int lmathVector3Normalize( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Normalize( Vector3 v )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); uluaPushVector3( L, Vector3Normalize( v ) ); @@ -1142,15 +853,9 @@ int lmathVector3Normalize( lua_State *L ) { Orthonormalize provided vectors. Makes vectors normalized and orthogonal to each other. Gram-Schmidt function implementation -- Failure return false - Success return Vector3, Vector3 */ int lmathVector3OrthoNormalize( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3OrthoNormalize( Vector3 v1, Vector3 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v1 = uluaGetVector3Index( L, 1 ); Vector3 v2 = uluaGetVector3Index( L, 2 ); @@ -1167,15 +872,9 @@ int lmathVector3OrthoNormalize( lua_State *L ) { Transforms a Vector3 by a given Matrix -- Failure return false - Success return Vector3 */ int lmathVector3Transform( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Transform( Vector3 v, Matrix mat )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); Matrix mat = uluaGetMatrixIndex( L, 2 ); @@ -1189,15 +888,9 @@ int lmathVector3Transform( lua_State *L ) { Transform a vector by quaternion rotation -- Failure return false - Success return Vector3 */ int lmathVector3RotateByQuaternion( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3RotateByQuaternion( Vector3 v, Quaternion q )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); Quaternion q = uluaGetQuaternionIndex( L, 2 ); @@ -1211,18 +904,12 @@ int lmathVector3RotateByQuaternion( lua_State *L ) { Rotates a vector around an axis -- Failure return false - Success return Vector3 */ int lmathVector3RotateByAxisAngle( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3RotateByAxisAngle( Vector3 v, Vector3 axis, float angle )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); Vector3 axis = uluaGetVector3Index( L, 2 ); - float angle = lua_tonumber( L, 3 ); + float angle = luaL_checknumber( L, 3 ); uluaPushVector3( L, Vector3RotateByAxisAngle( v, axis, angle ) ); @@ -1234,18 +921,12 @@ int lmathVector3RotateByAxisAngle( lua_State *L ) { Calculate linear interpolation between two vectors -- Failure return false - Success return Vector3 */ int lmathVector3Lerp( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Lerp( Vector3 v1, Vector3 v2, float amount )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v1 = uluaGetVector3Index( L, 1 ); Vector3 v2 = uluaGetVector3Index( L, 2 ); - float amount = lua_tonumber( L, 3 ); + float amount = luaL_checknumber( L, 3 ); uluaPushVector3( L, Vector3Lerp( v1, v2, amount ) ); @@ -1257,15 +938,9 @@ int lmathVector3Lerp( lua_State *L ) { Calculate reflected vector to normal -- Failure return false - Success return Vector3 */ int lmathVector3Reflect( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Reflect( Vector3 v, Vector3 normal )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); Vector3 normal = uluaGetVector3Index( L, 2 ); @@ -1279,15 +954,9 @@ int lmathVector3Reflect( lua_State *L ) { Get min value for each pair of components -- Failure return false - Success return Vector3 */ int lmathVector3Min( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Min( Vector3 v1, Vector3 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v1 = uluaGetVector3Index( L, 1 ); Vector3 v2 = uluaGetVector3Index( L, 2 ); @@ -1301,15 +970,9 @@ int lmathVector3Min( lua_State *L ) { Get max value for each pair of components -- Failure return false - Success return Vector3 */ int lmathVector3Max( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Max( Vector3 v1, Vector3 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v1 = uluaGetVector3Index( L, 1 ); Vector3 v2 = uluaGetVector3Index( L, 2 ); @@ -1321,18 +984,12 @@ int lmathVector3Max( lua_State *L ) { /* > result = RL.Vector3Barycenter( Vector3 p, Vector3 a, Vector3 b, Vector3 c ) -Compute barycenter coordinates ( u, v, w ) for point p with respect to triangle ( a, b, c ) +Compute barycenter coordinates (u, v, w) for point p with respect to triangle (a, b, c) NOTE: Assumes P is on the plane of the triangle -- Failure return false - Success return Vector3 */ int lmathVector3Barycenter( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) || !lua_istable( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Barycenter( Vector3 p, Vector3 a, Vector3 b, Vector3 c )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 p = uluaGetVector3Index( L, 1 ); Vector3 a = uluaGetVector3Index( L, 2 ); Vector3 b = uluaGetVector3Index( L, 3 ); @@ -1349,15 +1006,9 @@ int lmathVector3Barycenter( lua_State *L ) { Projects a Vector3 from screen space into object space NOTE: We are avoiding calling other raymath functions despite available -- Failure return false - Success return Vector3 */ int lmathVector3Unproject( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Unproject( Vector3 source, Matrix projection, Matrix view )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 source = uluaGetVector3Index( L, 1 ); Matrix projection = uluaGetMatrixIndex( L, 2 ); Matrix view = uluaGetMatrixIndex( L, 3 ); @@ -1372,15 +1023,9 @@ int lmathVector3Unproject( lua_State *L ) { Invert the given vector -- Failure return false - Success return Vector3 */ int lmathVector3Invert( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Invert( Vector3 v )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); uluaPushVector3( L, Vector3Invert( v ) ); @@ -1394,15 +1039,9 @@ int lmathVector3Invert( lua_State *L ) { Clamp the components of the vector between min and max values specified by the given vectors -- Failure return false - Success return Vector3 */ int lmathVector3Clamp( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Clamp( Vector3 v, Vector3 min, Vector3 max )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); Vector3 min = uluaGetVector3Index( L, 2 ); Vector3 max = uluaGetVector3Index( L, 3 ); @@ -1417,18 +1056,12 @@ int lmathVector3Clamp( lua_State *L ) { Clamp the magnitude of the vector between two values -- Failure return false - Success return Vector3 */ int lmathVector3ClampValue( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3ClampValue( Vector3 v, float min, float max )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); - float min = lua_tonumber( L, 2 ); - float max = lua_tonumber( L, 3 ); + float min = luaL_checknumber( L, 2 ); + float max = luaL_checknumber( L, 3 ); uluaPushVector3( L, Vector3ClampValue( v, min, max ) ); @@ -1440,15 +1073,9 @@ int lmathVector3ClampValue( lua_State *L ) { Check whether two given vectors are almost equal -- Failure return false - Success return int */ int lmathVector3Equals( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Equals( Vector3 v1, Vector3 v2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v1 = uluaGetVector3Index( L, 1 ); Vector3 v2 = uluaGetVector3Index( L, 2 ); @@ -1467,18 +1094,12 @@ and r specifies the ratio of the refractive index of the medium from where the ray comes to the refractive index of the medium on the other side of the surface -- Failure return false - Success return Vector3 */ int lmathVector3Refract( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.Vector3Refract( Vector3 v, Vector3 n, float r )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); Vector3 n = uluaGetVector3Index( L, 2 ); - float r = lua_tonumber( L, 3 ); + float r = luaL_checknumber( L, 3 ); uluaPushVector3( L, Vector3Refract( v, n, r ) ); @@ -1494,15 +1115,9 @@ int lmathVector3Refract( lua_State *L ) { Compute matrix determinant -- Failure return false - Success return float */ int lmathMatrixDeterminant( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixDeterminant( Matrix mat )" ); - lua_pushboolean( L, false ); - return 1; - } Matrix mat = uluaGetMatrixIndex( L, 1 ); lua_pushnumber( L, MatrixDeterminant( mat ) ); @@ -1513,17 +1128,11 @@ int lmathMatrixDeterminant( lua_State *L ) { /* > result = RL.MatrixTrace( Matrix mat ) -Get the trace of the matrix ( sum of the values along the diagonal ) +Get the trace of the matrix (sum of the values along the diagonal) -- Failure return false - Success return float */ int lmathMatrixTrace( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixTrace( Matrix mat )" ); - lua_pushboolean( L, false ); - return 1; - } Matrix mat = uluaGetMatrixIndex( L, 1 ); lua_pushnumber( L, MatrixTrace( mat ) ); @@ -1536,15 +1145,9 @@ int lmathMatrixTrace( lua_State *L ) { Transposes provided matrix -- Failure return false - Success return Matrix */ int lmathMatrixTranspose( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixTranspose( Matrix mat )" ); - lua_pushboolean( L, false ); - return 1; - } Matrix mat = uluaGetMatrixIndex( L, 1 ); uluaPushMatrix( L, MatrixTranspose( mat ) ); @@ -1557,15 +1160,9 @@ int lmathMatrixTranspose( lua_State *L ) { Invert provided matrix -- Failure return false - Success return Matrix */ int lmathMatrixInvert( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixInvert( Matrix mat )" ); - lua_pushboolean( L, false ); - return 1; - } Matrix mat = uluaGetMatrixIndex( L, 1 ); uluaPushMatrix( L, MatrixInvert( mat ) ); @@ -1591,15 +1188,9 @@ int lmathMatrixIdentity( lua_State *L ) { Add two matrices -- Failure return false - Success return Matrix */ int lmathMatrixAdd( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixAdd( Matrix left, Matrix right )" ); - lua_pushboolean( L, false ); - return 1; - } Matrix mat1 = uluaGetMatrixIndex( L, 1 ); Matrix mat2 = uluaGetMatrixIndex( L, 2 ); @@ -1613,15 +1204,9 @@ int lmathMatrixAdd( lua_State *L ) { Subtract two matrices (left - right) -- Failure return false - Success return Matrix */ int lmathMatrixSubtract( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixSubtract( Matrix left, Matrix right )" ); - lua_pushboolean( L, false ); - return 1; - } Matrix mat1 = uluaGetMatrixIndex( L, 1 ); Matrix mat2 = uluaGetMatrixIndex( L, 2 ); @@ -1635,15 +1220,9 @@ int lmathMatrixSubtract( lua_State *L ) { Get two matrix multiplication -- Failure return false - Success return Matrix */ int lmathMatrixMultiply( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixMultiply( Matrix left, Matrix right )" ); - lua_pushboolean( L, false ); - return 1; - } Matrix mat1 = uluaGetMatrixIndex( L, 1 ); Matrix mat2 = uluaGetMatrixIndex( L, 2 ); @@ -1657,15 +1236,9 @@ int lmathMatrixMultiply( lua_State *L ) { Get translation matrix -- Failure return false - Success return Matrix */ int lmathMatrixTranslate( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixTranslate( Vector3 translate )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); uluaPushMatrix( L, MatrixTranslate( v.x, v.y, v.z ) ); @@ -1678,17 +1251,11 @@ int lmathMatrixTranslate( lua_State *L ) { Create rotation matrix from axis and angle. NOTE: Angle should be provided in radians -- Failure return false - Success return Matrix */ int lmathMatrixRotate( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixRotate( Vector3 axis, float angle )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 axis = uluaGetVector3Index( L, 1 ); - float angle = lua_tonumber( L, 2 ); + float angle = luaL_checknumber( L, 2 ); uluaPushMatrix( L, MatrixRotate( axis, angle ) ); @@ -1698,18 +1265,12 @@ int lmathMatrixRotate( lua_State *L ) { /* > result = RL.MatrixRotateX( float angle ) -Get x-rotation matrix ( angle in radians ) +Get x-rotation matrix (angle in radians) -- Failure return false - Success return Matrix */ int lmathMatrixRotateX( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixRotateX( float angle )" ); - lua_pushboolean( L, false ); - return 1; - } - float angle = lua_tonumber( L, 1 ); + float angle = luaL_checknumber( L, 1 ); uluaPushMatrix( L, MatrixRotateX( angle ) ); @@ -1719,18 +1280,12 @@ int lmathMatrixRotateX( lua_State *L ) { /* > result = RL.MatrixRotateY( float angle ) -Get y-rotation matrix ( angle in radians ) +Get y-rotation matrix (angle in radians) -- Failure return false - Success return Matrix */ int lmathMatrixRotateY( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixRotateY( float angle )" ); - lua_pushboolean( L, false ); - return 1; - } - float angle = lua_tonumber( L, 1 ); + float angle = luaL_checknumber( L, 1 ); uluaPushMatrix( L, MatrixRotateY( angle ) ); @@ -1740,18 +1295,12 @@ int lmathMatrixRotateY( lua_State *L ) { /* > result = RL.MatrixRotateZ( float angle ) -Get z-rotation matrix ( angle in radians ) +Get z-rotation matrix (angle in radians) -- Failure return false - Success return Matrix */ int lmathMatrixRotateZ( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixRotateZ( float angle )" ); - lua_pushboolean( L, false ); - return 1; - } - float angle = lua_tonumber( L, 1 ); + float angle = luaL_checknumber( L, 1 ); uluaPushMatrix( L, MatrixRotateZ( angle ) ); @@ -1761,17 +1310,11 @@ int lmathMatrixRotateZ( lua_State *L ) { /* > result = RL.MatrixRotateXYZ( Vector3 angle ) -Get xyz-rotation matrix ( angles in radians ) +Get xyz-rotation matrix (angles in radians) -- Failure return false - Success return Matrix */ int lmathMatrixRotateXYZ( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixRotateXYZ( Vector3 angle )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 angle = uluaGetVector3Index( L, 1 ); uluaPushMatrix( L, MatrixRotateXYZ( angle ) ); @@ -1782,17 +1325,11 @@ int lmathMatrixRotateXYZ( lua_State *L ) { /* > result = RL.MatrixRotateZYX( Vector3 angle ) -Get zyx-rotation matrix ( angles in radians ) +Get zyx-rotation matrix (angles in radians) -- Failure return false - Success return Matrix */ int lmathMatrixRotateZYX( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixRotateZYX( Vector3 angle )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 angle = uluaGetVector3Index( L, 1 ); uluaPushMatrix( L, MatrixRotateZYX( angle ) ); @@ -1805,15 +1342,9 @@ int lmathMatrixRotateZYX( lua_State *L ) { Get scaling matrix -- Failure return false - Success return Matrix */ int lmathMatrixScale( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixScale( Vector3 scale )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 v = uluaGetVector3Index( L, 1 ); uluaPushMatrix( L, MatrixScale( v.x, v.y, v.z ) ); @@ -1826,22 +1357,15 @@ int lmathMatrixScale( lua_State *L ) { Get perspective projection matrix -- Failure return false - Success return Matrix */ int lmathMatrixFrustum( lua_State *L ) { - 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( state->logLevelInvalid, "%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 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 ); + float left = luaL_checknumber( L, 1 ); + float right = luaL_checknumber( L, 2); + float bottom = luaL_checknumber( L, 3 ); + float top = luaL_checknumber( L, 4 ); + float near = luaL_checknumber( L, 5 ); + float far = luaL_checknumber( L, 6 ); uluaPushMatrix( L, MatrixFrustum( left, right, bottom, top, near, far ) ); @@ -1853,19 +1377,13 @@ int lmathMatrixFrustum( lua_State *L ) { Get perspective projection matrix -- Failure return false - Success return Matrix */ int lmathMatrixPerspective( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixPerspective( double fovy, double aspect, double near, double far )" ); - lua_pushboolean( L, false ); - return 1; - } - float fovy = lua_tonumber( L, 1 ); - float aspect = lua_tonumber( L, 2 ); - float near = lua_tonumber( L, 3 ); - float far = lua_tonumber( L, 4 ); + float fovy = luaL_checknumber( L, 1 ); + float aspect = luaL_checknumber( L, 2 ); + float near = luaL_checknumber( L, 3 ); + float far = luaL_checknumber( L, 4 ); uluaPushMatrix( L, MatrixPerspective( fovy, aspect, near, far ) ); @@ -1877,22 +1395,15 @@ int lmathMatrixPerspective( lua_State *L ) { Get orthographic projection matrix -- Failure return false - Success return Matrix */ int lmathMatrixOrtho( lua_State *L ) { - 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( state->logLevelInvalid, "%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 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 ); + float left = luaL_checknumber( L, 1 ); + float right = luaL_checknumber( L, 2 ); + float bottom = luaL_checknumber( L, 3 ); + float top = luaL_checknumber( L, 4 ); + float near = luaL_checknumber( L, 5 ); + float far = luaL_checknumber( L, 6 ); uluaPushMatrix( L, MatrixOrtho( left, right, bottom, top, near, far ) ); @@ -1902,17 +1413,11 @@ int lmathMatrixOrtho( lua_State *L ) { /* > result = RL.MatrixLookAt( Vector3 eye, Vector3 target, Vector3 up ) -Get camera look-at matrix ( View matrix ) +Get camera look-at matrix (View matrix) -- Failure return false - Success return Matrix */ int lmathMatrixLookAt( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.MatrixLookAt( Vector3 eye, Vector3 target, Vector3 up )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 eye = uluaGetVector3Index( L, 1 ); Vector3 target = uluaGetVector3Index( L, 2 ); Vector3 up = uluaGetVector3Index( L, 3 ); @@ -1931,15 +1436,9 @@ int lmathMatrixLookAt( lua_State *L ) { Add two quaternions -- Failure return false - Success return Quaternion */ int lmathQuaternionAdd( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionAdd( Quaternion q1, Quaternion q2 )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q1 = uluaGetQuaternionIndex( L, 1 ); Quaternion q2 = uluaGetQuaternionIndex( L, 2 ); @@ -1953,17 +1452,11 @@ int lmathQuaternionAdd( lua_State *L ) { Add quaternion and float value -- Failure return false - Success return Quaternion */ int lmathQuaternionAddValue( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionAddValue( Quaternion q, float add )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q = uluaGetQuaternionIndex( L, 1 ); - float add = lua_tonumber( L, 2 ); + float add = luaL_checknumber( L, 2 ); uluaPushQuaternion( L, QuaternionAddValue( q, add ) ); @@ -1975,15 +1468,9 @@ int lmathQuaternionAddValue( lua_State *L ) { Subtract two quaternions -- Failure return false - Success return Quaternion */ int lmathQuaternionSubtract( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionSubtract( Quaternion q1, Quaternion q2 )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q1 = uluaGetQuaternionIndex( L, 1 ); Quaternion q2 = uluaGetQuaternionIndex( L, 2 ); @@ -1997,17 +1484,11 @@ int lmathQuaternionSubtract( lua_State *L ) { Subtract quaternion and float value -- Failure return false - Success return Quaternion */ int lmathQuaternionSubtractValue( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionSubtractValue( Quaternion q, float sub )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q = uluaGetQuaternionIndex( L, 1 ); - float sub = lua_tonumber( L, 2 ); + float sub = luaL_checknumber( L, 2 ); uluaPushQuaternion( L, QuaternionSubtractValue( q, sub ) ); @@ -2032,15 +1513,9 @@ int lmathQuaternionIdentity( lua_State *L ) { Computes the length of a quaternion -- Failure return false - Success return float */ int lmathQuaternionLength( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionLength( Quaternion q )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q = uluaGetQuaternionIndex( L, 1 ); lua_pushnumber( L, QuaternionLength( q ) ); @@ -2053,15 +1528,9 @@ int lmathQuaternionLength( lua_State *L ) { Normalize provided quaternion -- Failure return false - Success return Quaternion */ int lmathQuaternionNormalize( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionNormalize( Quaternion q )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q = uluaGetQuaternionIndex( L, 1 ); uluaPushQuaternion( L, QuaternionNormalize( q ) ); @@ -2074,15 +1543,9 @@ int lmathQuaternionNormalize( lua_State *L ) { Invert provided quaternion -- Failure return false - Success return Quaternion */ int lmathQuaternionInvert( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionInvert( Quaternion q )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q = uluaGetQuaternionIndex( L, 1 ); uluaPushQuaternion( L, QuaternionInvert( q ) ); @@ -2095,15 +1558,9 @@ int lmathQuaternionInvert( lua_State *L ) { Calculate two quaternion multiplication -- Failure return false - Success return Quaternion */ int lmathQuaternionMultiply( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionMultiply( Quaternion q1, Quaternion q2 )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q1 = uluaGetQuaternionIndex( L, 1 ); Quaternion q2 = uluaGetQuaternionIndex( L, 2 ); @@ -2117,17 +1574,11 @@ int lmathQuaternionMultiply( lua_State *L ) { Scale quaternion by float value -- Failure return false - Success return Quaternion */ int lmathQuaternionScale( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionScale( Quaternion q, float mul )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q = uluaGetQuaternionIndex( L, 1 ); - float mul = lua_tonumber( L, 2 ); + float mul = luaL_checknumber( L, 2 ); uluaPushQuaternion( L, QuaternionScale( q, mul ) ); @@ -2139,15 +1590,9 @@ int lmathQuaternionScale( lua_State *L ) { Divide two quaternions -- Failure return false - Success return Quaternion */ int lmathQuaternionDivide( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionDivide( Quaternion q1, Quaternion q2 )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q1 = uluaGetQuaternionIndex( L, 1 ); Quaternion q2 = uluaGetQuaternionIndex( L, 2 ); @@ -2161,18 +1606,12 @@ int lmathQuaternionDivide( lua_State *L ) { Calculate linear interpolation between two quaternions -- Failure return false - Success return Quaternion */ int lmathQuaternionLerp( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionLerp( Quaternion q1, Quaternion q2, float amount )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q1 = uluaGetQuaternionIndex( L, 1 ); Quaternion q2 = uluaGetQuaternionIndex( L, 2 ); - float amount = lua_tonumber( L, 3 ); + float amount = luaL_checknumber( L, 3 ); uluaPushQuaternion( L, QuaternionLerp( q1, q2, amount ) ); @@ -2184,18 +1623,12 @@ int lmathQuaternionLerp( lua_State *L ) { Calculate slerp-optimized interpolation between two quaternions -- Failure return false - Success return Quaternion */ int lmathQuaternionNlerp( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionNlerp( Quaternion q1, Quaternion q2, float amount )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q1 = uluaGetQuaternionIndex( L, 1 ); Quaternion q2 = uluaGetQuaternionIndex( L, 2 ); - float amount = lua_tonumber( L, 3 ); + float amount = luaL_checknumber( L, 3 ); uluaPushQuaternion( L, QuaternionNlerp( q1, q2, amount ) ); @@ -2207,18 +1640,12 @@ int lmathQuaternionNlerp( lua_State *L ) { Calculates spherical linear interpolation between two quaternions -- Failure return false - Success return Quaternion */ int lmathQuaternionSlerp( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionSlerp( Quaternion q1, Quaternion q2, float amount )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q1 = uluaGetQuaternionIndex( L, 1 ); Quaternion q2 = uluaGetQuaternionIndex( L, 2 ); - float amount = lua_tonumber( L, 3 ); + float amount = luaL_checknumber( L, 3 ); uluaPushQuaternion( L, QuaternionSlerp( q1, q2, amount ) ); @@ -2230,15 +1657,9 @@ int lmathQuaternionSlerp( lua_State *L ) { Calculate quaternion based on the rotation from one vector to another -- Failure return false - Success return Quaternion */ int lmathQuaternionFromVector3ToVector3( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionFromVector3ToVector3( Vector3 from, Vector3 to )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 from = uluaGetVector3Index( L, 1 ); Vector3 to = uluaGetVector3Index( L, 2 ); @@ -2252,15 +1673,9 @@ int lmathQuaternionFromVector3ToVector3( lua_State *L ) { Get a quaternion for a given rotation matrix -- Failure return false - Success return Quaternion */ int lmathQuaternionFromMatrix( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionFromMatrix( Matrix mat )" ); - lua_pushboolean( L, false ); - return 1; - } Matrix mat = uluaGetMatrixIndex( L, 1 ); uluaPushQuaternion( L, QuaternionFromMatrix( mat ) ); @@ -2273,15 +1688,9 @@ int lmathQuaternionFromMatrix( lua_State *L ) { Get a quaternion for a given rotation matrix -- Failure return false - Success return Matrix */ int lmathQuaternionToMatrix( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionToMatrix( Quaternion q )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q = uluaGetQuaternionIndex( L, 1 ); uluaPushMatrix( L, QuaternionToMatrix( q ) ); @@ -2295,17 +1704,11 @@ int lmathQuaternionToMatrix( lua_State *L ) { Get rotation quaternion for an angle and axis NOTE: angle must be provided in radians -- Failure return false - Success return Quaternion */ int lmathQuaternionFromAxisAngle( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionFromAxisAngle( Vector3 axis, float angle )" ); - lua_pushboolean( L, false ); - return 1; - } Vector3 axis = uluaGetVector3Index( L, 1 ); - float angle = lua_tonumber( L, 2 ); + float angle = luaL_checknumber( L, 2 ); uluaPushQuaternion( L, QuaternionFromAxisAngle( axis, angle ) ); @@ -2317,15 +1720,9 @@ int lmathQuaternionFromAxisAngle( lua_State *L ) { Get the rotation angle and axis for a given quaternion -- Failure return false - Success return Vector3, float */ int lmathQuaternionToAxisAngle( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionToAxisAngle( Quaternion q )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q = uluaGetQuaternionIndex( L, 1 ); float angle = 0.0; Vector3 axis = { 0.0 }; @@ -2344,18 +1741,12 @@ int lmathQuaternionToAxisAngle( lua_State *L ) { Get the quaternion equivalent to Euler angles NOTE: Rotation order is ZYX -- Failure return false - Success return Quaternion */ int lmathQuaternionFromEuler( lua_State *L ) { - if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionFromEuler( float pitch, float yaw, float roll )" ); - lua_pushboolean( L, false ); - return 1; - } - float pitch = lua_tonumber( L, 1 ); - float yaw = lua_tonumber( L, 2 ); - float roll = lua_tonumber( L, 3 ); + float pitch = luaL_checknumber( L, 1 ); + float yaw = luaL_checknumber( L, 2 ); + float roll = luaL_checknumber( L, 3 ); uluaPushQuaternion( L, QuaternionFromEuler( pitch, yaw, roll ) ); @@ -2368,15 +1759,9 @@ int lmathQuaternionFromEuler( lua_State *L ) { Get the Euler angles equivalent to quaternion (roll, pitch, yaw) NOTE: Angles are returned in a Vector3 struct in radians -- Failure return false - Success return Vector3 */ int lmathQuaternionToEuler( lua_State *L ) { - if ( !lua_istable( L, 1 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionToEuler( Quaternion q )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q = uluaGetQuaternionIndex( L, 1 ); uluaPushVector3( L, QuaternionToEuler( q ) ); @@ -2389,15 +1774,9 @@ int lmathQuaternionToEuler( lua_State *L ) { Transform a quaternion given a transformation matrix -- Failure return false - Success return Quaternion */ int lmathQuaternionTransform( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionTransform( Quaternion q, Matrix mat )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q = uluaGetQuaternionIndex( L, 1 ); Matrix mat = uluaGetMatrixIndex( L, 2 ); @@ -2411,15 +1790,9 @@ int lmathQuaternionTransform( lua_State *L ) { Check whether two given quaternions are almost equal -- Failure return false - Success return int */ int lmathQuaternionEquals( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.QuaternionEquals( Quaternion q1, Quaternion q2 )" ); - lua_pushboolean( L, false ); - return 1; - } Quaternion q1 = uluaGetQuaternionIndex( L, 1 ); Quaternion q2 = uluaGetQuaternionIndex( L, 2 ); diff --git a/src/shapes.c b/src/shapes.c index 876520a..ed2af7a 100644 --- a/src/shapes.c +++ b/src/shapes.c @@ -25,147 +25,92 @@ int lshapesSetShapesTexture( lua_State *L ) { } /* -> success = RL.DrawPixel( Vector2 pos, Color color ) +> RL.DrawPixel( Vector2 pos, Color color ) Draw a pixel - -- Failure return false -- Success return true */ int lshapesDrawPixel( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawPixel( Vector2 pos, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 pos = uluaGetVector2Index( L, 1 ); Color color = uluaGetColorIndex( L, 2 ); DrawPixelV( pos, color ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawLine( Vector2 startPos, Vector2 endPos, float thickness, Color color ) +> RL.DrawLine( Vector2 startPos, Vector2 endPos, float thickness, Color color ) Draw a line defining thickness - -- Failure return false -- Success return true */ int lshapesDrawLine( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_istable( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawLine( Vector2 startPos, Vector2 endPos, float thickness, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 startPos = uluaGetVector2Index( L, 1 ); Vector2 endPos = uluaGetVector2Index( L, 2 ); - float thickness = lua_tonumber( L, 3 ); + float thickness = luaL_checknumber( L, 3 ); Color color = uluaGetColorIndex( L, 4 ); DrawLineEx( startPos, endPos, thickness, color ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawLineBezier( Vector2 startPos, Vector2 endPos, float thickness, Color color ) +> RL.DrawLineBezier( Vector2 startPos, Vector2 endPos, float thickness, Color color ) Draw a line using cubic-bezier curves in-out - -- Failure return false -- Success return true */ int lshapesDrawLineBezier( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_istable( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawLineBezier( Vector2 startPos, Vector2 endPos, float thickness, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 startPos = uluaGetVector2Index( L, 1 ); Vector2 endPos = uluaGetVector2Index( L, 2 ); - float thickness = lua_tonumber( L, 3 ); + float thickness = luaL_checknumber( L, 3 ); Color color = uluaGetColorIndex( L, 4 ); DrawLineBezier( startPos, endPos, thickness, color ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawLineBezierQuad( Vector2 startPos, Vector2 endPos, Vector2 controlPos, float thickness, Color color ) +> RL.DrawLineBezierQuad( Vector2 startPos, Vector2 endPos, Vector2 controlPos, float thickness, Color color ) Draw line using quadratic bezier curves with a control point - -- Failure return false -- Success return true */ int lshapesDrawLineBezierQuad( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) - || !lua_isnumber( L, 4 ) || !lua_istable( L, 5 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawLineBezier( Vector2 startPos, Vector2 endPos, Vector2 controlPos, float thickness, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 startPos = uluaGetVector2Index( L, 1 ); Vector2 endPos = uluaGetVector2Index( L, 2 ); Vector2 controlPos = uluaGetVector2Index( L, 3 ); - float thickness = lua_tonumber( L, 4 ); + float thickness = luaL_checknumber( L, 4 ); Color color = uluaGetColorIndex( L, 5 ); DrawLineBezierQuad( startPos, endPos, controlPos, thickness, color ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawLineBezierCubic( Vector2 startPos, Vector2 endPos, Vector2 startControlPos, Vector2 endControlPos, float thickness, Color color ) +> RL.DrawLineBezierCubic( Vector2 startPos, Vector2 endPos, Vector2 startControlPos, Vector2 endControlPos, float thickness, Color color ) Draw line using quadratic bezier curves with a control point - -- Failure return false -- Success return true */ int lshapesDrawLineBezierCubic( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) || - !lua_istable( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_istable( L, 6 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawLineBezierCubic( Vector2 startPos, Vector2 endPos, Vector2 startControlPos, Vector2 endControlPos, float thickness, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 startPos = uluaGetVector2Index( L, 1 ); Vector2 endPos = uluaGetVector2Index( L, 2 ); Vector2 startControlPos = uluaGetVector2Index( L, 3 ); Vector2 endControlPos = uluaGetVector2Index( L, 4 ); - float thickness = lua_tonumber( L, 5 ); + float thickness = luaL_checknumber( L, 5 ); Color color = uluaGetColorIndex( L, 6 ); DrawLineBezierCubic( startPos, endPos, startControlPos, endControlPos, thickness, color ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawLineStrip( Vector2{} points, Color color ) +> RL.DrawLineStrip( Vector2{} points, Color color ) Draw lines sequence - -- Failure return false -- Success return true */ int lshapesDrawLineStrip( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawLineStrip( Vector2{} points, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } int pointsCount = uluaGetTableLenIndex( L, 1 ); Color color = uluaGetColorIndex( L, 2 ); @@ -180,361 +125,229 @@ int lshapesDrawLineStrip( lua_State *L ) { i++; lua_pop( L, 1 ); } - DrawLineStrip( points, pointsCount, color ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawCircle( Vector2 center, float radius, Color color ) +> RL.DrawCircle( Vector2 center, float radius, Color color ) Draw a color-filled circle - -- Failure return false -- Success return true */ int lshapesDrawCircle( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_istable( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawCircle( Vector2 center, float radius, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 center = uluaGetVector2Index( L, 1 ); - float radius = lua_tonumber( L, 2 ); + float radius = luaL_checknumber( L, 2 ); Color color = uluaGetColorIndex( L, 3 ); DrawCircleV( center, radius, color ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawCircleSector( Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color ) +> RL.DrawCircleSector( Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color ) Draw a piece of a circle - -- Failure return false -- Success return true */ int lshapesDrawCircleSector( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || - !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_istable( L, 6 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawCircleSector( Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 center = uluaGetVector2Index( L, 1 ); - float radius = lua_tonumber( L, 2 ); - float startAngle = lua_tonumber( L, 3 ); - float endAngle = lua_tonumber( L, 4 ); - int segments = lua_tointeger( L, 5 ); + float radius = luaL_checknumber( L, 2 ); + float startAngle = luaL_checknumber( L, 3 ); + float endAngle = luaL_checknumber( L, 4 ); + int segments = luaL_checkinteger( L, 5 ); Color color = uluaGetColorIndex( L, 6 ); DrawCircleSector( center, radius, startAngle, endAngle, segments, color ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawCircleSectorLines( Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color ) +> RL.DrawCircleSectorLines( Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color ) Draw circle sector outline - -- Failure return false -- Success return true */ int lshapesDrawCircleSectorLines( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || - !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_istable( L, 6 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawCircleSectorLines( Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 center = uluaGetVector2Index( L, 1 ); - float radius = lua_tonumber( L, 2 ); - float startAngle = lua_tonumber( L, 3 ); - float endAngle = lua_tonumber( L, 4 ); - int segments = lua_tointeger( L, 5 ); + float radius = luaL_checknumber( L, 2 ); + float startAngle = luaL_checknumber( L, 3 ); + float endAngle = luaL_checknumber( L, 4 ); + int segments = luaL_checkinteger( L, 5 ); Color color = uluaGetColorIndex( L, 6 ); DrawCircleSectorLines( center, radius, startAngle, endAngle, segments, color ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawCircleGradient( Vector2 center, float radius, Color color1, Color color2 ) +> RL.DrawCircleGradient( Vector2 center, float radius, Color color1, Color color2 ) Draw a gradient-filled circle - -- Failure return false -- Success return true */ int lshapesDrawCircleGradient( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_istable( L, 3 ) || !lua_istable( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawCircleGradient( Vector2 center, float radius, Color color1, Color color2 )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 center = uluaGetVector2Index( L, 1 ); - float radius = lua_tonumber( L, 2 ); + float radius = luaL_checknumber( L, 2 ); Color color1 = uluaGetColorIndex( L, 3 ); Color color2 = uluaGetColorIndex( L, 4 ); DrawCircleGradient( center.x, center.y, radius, color1, color2 ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawCircleLines( Vector2 center, float radius, Color color ) +> RL.DrawCircleLines( Vector2 center, float radius, Color color ) Draw circle outline - -- Failure return false -- Success return true */ int lshapesDrawCircleLines( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_istable( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawCircleLines( Vector2 center, float radius, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 center = uluaGetVector2Index( L, 1 ); - float radius = lua_tonumber( L, 2 ); + float radius = luaL_checknumber( L, 2 ); Color color = uluaGetColorIndex( L, 3 ); DrawCircleLines( center.x, center.y, radius, color ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawEllipse( Vector2 center, float radiusH, float radiusV, Color color ) +> RL.DrawEllipse( Vector2 center, float radiusH, float radiusV, Color color ) Draw ellipse - -- Failure return false -- Success return true */ int lshapesDrawEllipse( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_istable( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawEllipse( Vector2 center, float radiusH, float radiusV, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 center = uluaGetVector2Index( L, 1 ); - float radiusH = lua_tonumber( L, 2 ); - float radiusV = lua_tonumber( L, 3 ); + float radiusH = luaL_checknumber( L, 2 ); + float radiusV = luaL_checknumber( L, 3 ); Color color = uluaGetColorIndex( L, 4 ); DrawEllipse( center.x, center.y, radiusH, radiusV, color ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawEllipseLines( Vector2 center, float radiusH, float radiusV, Color color ) +> RL.DrawEllipseLines( Vector2 center, float radiusH, float radiusV, Color color ) Draw ellipse outline - -- Failure return false -- Success return true */ int lshapesDrawEllipseLines( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_istable( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawEllipseLines( Vector2 center, float radiusH, float radiusV, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 center = uluaGetVector2Index( L, 1 ); - float radiusH = lua_tonumber( L, 2 ); - float radiusV = lua_tonumber( L, 3 ); + float radiusH = luaL_checknumber( L, 2 ); + float radiusV = luaL_checknumber( L, 3 ); Color color = uluaGetColorIndex( L, 4 ); DrawEllipseLines( center.x, center.y, radiusH, radiusV, color ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawRing( Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color ) +> RL.DrawRing( Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color ) Draw ring - -- Failure return false -- Success return true */ int lshapesDrawRing( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) || - !lua_isnumber( L, 5 ) || !lua_isnumber( L, 6 ) || !lua_istable( L, 7 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawRing( Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 center = uluaGetVector2Index( L, 1 ); - float innerRadius = lua_tonumber( L, 2 ); - float outerRadius = lua_tonumber( L, 3 ); - float startAngle = lua_tonumber( L, 4 ); - float endAngle = lua_tonumber( L, 5 ); - int segments = lua_tointeger( L, 6 ); + float innerRadius = luaL_checknumber( L, 2 ); + float outerRadius = luaL_checknumber( L, 3 ); + float startAngle = luaL_checknumber( L, 4 ); + float endAngle = luaL_checknumber( L, 5 ); + int segments = luaL_checkinteger( L, 6 ); Color color = uluaGetColorIndex( L, 7 ); DrawRing( center, innerRadius, outerRadius, startAngle, endAngle, segments, color ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawRingLines( Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color ) +> RL.DrawRingLines( Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color ) Draw ring outline - -- Failure return false -- Success return true */ int lshapesDrawRingLines( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) || - !lua_isnumber( L, 5 ) || !lua_isnumber( L, 6 ) || !lua_istable( L, 7 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawRingLines( Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 center = uluaGetVector2Index( L, 1 ); - float innerRadius = lua_tonumber( L, 2 ); - float outerRadius = lua_tonumber( L, 3 ); - float startAngle = lua_tonumber( L, 4 ); - float endAngle = lua_tonumber( L, 5 ); - int segments = lua_tointeger( L, 6 ); + float innerRadius = luaL_checknumber( L, 2 ); + float outerRadius = luaL_checknumber( L, 3 ); + float startAngle = luaL_checknumber( L, 4 ); + float endAngle = luaL_checknumber( L, 5 ); + int segments = luaL_checkinteger( L, 6 ); Color color = uluaGetColorIndex( L, 7 ); DrawRingLines( center, innerRadius, outerRadius, startAngle, endAngle, segments, color ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawRectangle( Rectangle rec, Color color ) +> RL.DrawRectangle( Rectangle rec, Color color ) Draw a color-filled rectangle - -- Failure return false -- Success return true */ int lshapesDrawRectangle( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawRectangle( Rectangle rec, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Rectangle rect = uluaGetRectangleIndex( L, 1 ); Color color = uluaGetColorIndex( L, 2 ); DrawRectangleRec( rect, color ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawRectanglePro( Rectangle rec, Vector2 origin, float rotation, Color color ) +> RL.DrawRectanglePro( Rectangle rec, Vector2 origin, float rotation, Color color ) Draw a color-filled rectangle with pro parameters - -- Failure return false -- Success return true */ int lshapesDrawRectanglePro( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_istable( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawRectanglePro( Rectangle rec, Vector2 origin, float rotation, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Rectangle rec = uluaGetRectangleIndex( L, 1 ); Vector2 origin = uluaGetVector2Index( L, 2 ); - float rotation = lua_tonumber( L, 3 ); + float rotation = luaL_checknumber( L, 3 ); Color color = uluaGetColorIndex( L, 4 ); DrawRectanglePro( rec, origin, rotation, color ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawRectangleGradientV( Rectangle rectangle, Color color1, Color color2 ) +> RL.DrawRectangleGradientV( Rectangle rectangle, Color color1, Color color2 ) Draw a vertical-gradient-filled rectangle - -- Failure return false -- Success return true */ int lshapesDrawRectangleGradientV( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawRectangleGradientV( Rectangle rectangle, Color color1, Color color2 )" ); - lua_pushboolean( L, false ); - return 1; - } Rectangle rect = uluaGetRectangleIndex( L, 1 ); Color color1 = uluaGetColorIndex( L, 2 ); Color color2 = uluaGetColorIndex( L, 3 ); DrawRectangleGradientV( rect.x, rect.y, rect.width, rect.height, color1, color2 ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawRectangleGradientH( Rectangle rectangle, Color color1, Color color2 ) +> RL.DrawRectangleGradientH( Rectangle rectangle, Color color1, Color color2 ) Draw a horizontal-gradient-filled rectangle - -- Failure return false -- Success return true */ int lshapesDrawRectangleGradientH( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawRectangleGradientH( Rectangle rectangle, Color color1, Color color2 )" ); - lua_pushboolean( L, false ); - return 1; - } Rectangle rect = uluaGetRectangleIndex( L, 1 ); Color color1 = uluaGetColorIndex( L, 2 ); Color color2 = uluaGetColorIndex( L, 3 ); DrawRectangleGradientH( rect.x, rect.y, rect.width, rect.height, color1, color2 ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawRectangleGradientEx( Rectangle rectangle, Color col1, Color col2, Color col3, Color col4 ) +> RL.DrawRectangleGradientEx( Rectangle rectangle, Color col1, Color col2, Color col3, Color col4 ) Draw a gradient-filled rectangle with custom vertex colors - -- Failure return false -- Success return true */ int lshapesDrawRectangleGradientEx( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) - || !lua_istable( L, 4 ) || !lua_istable( L, 5 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawRectangleGradientEx( Rectangle rectangle, Color col1, Color col2, Color col3, Color col4 )" ); - lua_pushboolean( L, false ); - return 1; - } Rectangle rect = uluaGetRectangleIndex( L, 1 ); Color color1 = uluaGetColorIndex( L, 2 ); Color color2 = uluaGetColorIndex( L, 3 ); @@ -542,174 +355,110 @@ int lshapesDrawRectangleGradientEx( lua_State *L ) { Color color4 = uluaGetColorIndex( L, 5 ); DrawRectangleGradientEx( rect, color1, color2, color3, color4 ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawRectangleLines( Rectangle rec, Color color ) +> RL.DrawRectangleLines( Rectangle rec, Color color ) Draw rectangle outline - -- Failure return false -- Success return true */ int lshapesDrawRectangleLines( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawRectangleLines( Rectangle rec, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Rectangle rect = uluaGetRectangleIndex( L, 1 ); Color color = uluaGetColorIndex( L, 2 ); DrawRectangleLines( rect.x, rect.y, rect.width, rect.height, color ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawRectangleLinesEx( Rectangle rec, int lineThick, Color color ) +> RL.DrawRectangleLinesEx( Rectangle rec, int lineThick, Color color ) Draw rectangle outline with extended parameters - -- Failure return false -- Success return true */ int lshapesDrawRectangleLinesEx( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_istable( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawRectangleLinesEx( Rectangle rec, int lineThick, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Rectangle rect = uluaGetRectangleIndex( L, 1 ); - int lineThick = lua_tointeger( L, 2 ); + int lineThick = luaL_checkinteger( L, 2 ); Color color = uluaGetColorIndex( L, 3 ); DrawRectangleLinesEx( rect, lineThick, color ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawRectangleRounded( Rectangle rec, float roundness, int segments, Color color ) +> RL.DrawRectangleRounded( Rectangle rec, float roundness, int segments, Color color ) Draw rectangle with rounded edges - -- Failure return false -- Success return true */ int lshapesDrawRectangleRounded( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_istable( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawRectangleRounded( Rectangle rec, float roundness, int segments, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Rectangle rect = uluaGetRectangleIndex( L, 1 ); - float roundness = lua_tonumber( L, 2 ); - int segments = lua_tointeger( L, 3 ); + float roundness = luaL_checknumber( L, 2 ); + int segments = luaL_checkinteger( L, 3 ); Color color = uluaGetColorIndex( L, 4 ); DrawRectangleRounded( rect, roundness, segments, color ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawRectangleRoundedLines( Rectangle rec, float roundness, int segments, int lineThick, Color color ) +> RL.DrawRectangleRoundedLines( Rectangle rec, float roundness, int segments, int lineThick, Color color ) Draw rectangle with rounded edges outline - -- Failure return false -- Success return true */ int lshapesDrawRectangleRoundedLines( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) - || !lua_isnumber( L, 4 ) || !lua_istable( L, 5 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawRectangleRoundedLines( Rectangle rec, float roundness, int segments, int lineThick, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Rectangle rect = uluaGetRectangleIndex( L, 1 ); - float roundness = lua_tonumber( L, 2 ); - int segments = lua_tointeger( L, 3 ); - int lineThick = lua_tointeger( L, 4 ); + float roundness = luaL_checknumber( L, 2 ); + int segments = luaL_checkinteger( L, 3 ); + int lineThick = luaL_checkinteger( L, 4 ); Color color = uluaGetColorIndex( L, 5 ); DrawRectangleRoundedLines( rect, roundness, segments, lineThick, color ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawTriangle( Vector2 v1, Vector2 v2, Vector2 v3, Color color ) +> RL.DrawTriangle( Vector2 v1, Vector2 v2, Vector2 v3, Color color ) -Draw a color-filled triangle ( Vertex in counter-clockwise order! ) - -- Failure return false -- Success return true +Draw a color-filled triangle (Vertex in counter-clockwise order!) */ int lshapesDrawTriangle( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) || !lua_istable( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawTriangle( Vector2 v1, Vector2 v2, Vector2 v3, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v1 = uluaGetVector2Index( L, 1 ); Vector2 v2 = uluaGetVector2Index( L, 2 ); Vector2 v3 = uluaGetVector2Index( L, 3 ); Color color = uluaGetColorIndex( L, 4 ); DrawTriangle( v1, v2, v3, color ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawTriangleLines( Vector2 v1, Vector2 v2, Vector2 v3, Color color ) +> RL.DrawTriangleLines( Vector2 v1, Vector2 v2, Vector2 v3, Color color ) -Draw triangle outline ( Vertex in counter-clockwise order! ) - -- Failure return false -- Success return true +Draw triangle outline (Vertex in counter-clockwise order!) */ int lshapesDrawTriangleLines( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) || !lua_istable( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawTriangleLines( Vector2 v1, Vector2 v2, Vector2 v3, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 v1 = uluaGetVector2Index( L, 1 ); Vector2 v2 = uluaGetVector2Index( L, 2 ); Vector2 v3 = uluaGetVector2Index( L, 3 ); Color color = uluaGetColorIndex( L, 4 ); DrawTriangleLines( v1, v2, v3, color ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawTriangleFan( Vector2{} points, Color color ) - -Draw a triangle fan defined by points ( first vertex is the center ) +> RL.DrawTriangleFan( Vector2{} points, Color color ) -- Failure return false -- Success return true +Draw a triangle fan defined by points (first vertex is the center) */ int lshapesDrawTriangleFan( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawTriangleFan( Vector2{} points, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } int pointsCount = uluaGetTableLenIndex( L, 1 ); Color color = uluaGetColorIndex( L, 2 ); @@ -724,27 +473,17 @@ int lshapesDrawTriangleFan( lua_State *L ) { i++; lua_pop( L, 1 ); } - DrawTriangleFan( points, pointsCount, color ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawTriangleStrip( Vector2{} points, Color color ) +> RL.DrawTriangleStrip( Vector2{} points, Color color ) Draw a triangle strip defined by points - -- Failure return false -- Success return true */ int lshapesDrawTriangleStrip( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawTriangleStrip( Vector2{} points, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } int pointsCount = uluaGetTableLenIndex( L, 1 ); Color color = uluaGetColorIndex( L, 2 ); @@ -759,93 +498,61 @@ int lshapesDrawTriangleStrip( lua_State *L ) { i++; lua_pop( L, 1 ); } - DrawTriangleStrip( points, pointsCount, color ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawPoly( Vector2 center, int sides, float radius, float rotation, Color color ) - -Draw a regular polygon ( Vector version ) +> RL.DrawPoly( Vector2 center, int sides, float radius, float rotation, Color color ) -- Failure return false -- Success return true +Draw a regular polygon (Vector version) */ int lshapesDrawPoly( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) - || !lua_isnumber( L, 4 ) || !lua_istable( L, 5 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawPoly( Vector2 center, int sides, float radius, float rotation, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 center = uluaGetVector2Index( L, 1 ); - int sides = lua_tointeger( L, 2 ); - float radius = lua_tonumber( L, 3 ); - float rotation = lua_tonumber( L, 4 ); + int sides = luaL_checkinteger( L, 2 ); + float radius = luaL_checknumber( L, 3 ); + float rotation = luaL_checknumber( L, 4 ); Color color = uluaGetColorIndex( L, 5 ); DrawPoly( center, sides, radius, rotation, color ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawPolyLines( Vector2 center, int sides, float radius, float rotation, Color color ) +> RL.DrawPolyLines( Vector2 center, int sides, float radius, float rotation, Color color ) Draw a polygon outline of n sides - -- Failure return false -- Success return true */ int lshapesDrawPolyLines( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) - || !lua_isnumber( L, 4 ) || !lua_istable( L, 5 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawPolyLines( Vector2 center, int sides, float radius, float rotation, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 center = uluaGetVector2Index( L, 1 ); - int sides = lua_tointeger( L, 2 ); - float radius = lua_tonumber( L, 3 ); - float rotation = lua_tonumber( L, 4 ); + int sides = luaL_checkinteger( L, 2 ); + float radius = luaL_checknumber( L, 3 ); + float rotation = luaL_checknumber( L, 4 ); Color color = uluaGetColorIndex( L, 5 ); DrawPolyLines( center, sides, radius, rotation, color ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* -> success = RL.DrawPolyLinesEx( Vector2 center, int sides, float radius, float rotation, float lineThick, Color color ) +> RL.DrawPolyLinesEx( Vector2 center, int sides, float radius, float rotation, float lineThick, Color color ) Draw a polygon outline of n sides with extended parameters - -- Failure return false -- Success return true */ int lshapesDrawPolyLinesEx( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || - !lua_isnumber( L, 4 ) || !lua_isnumber( L, 5 ) || !lua_istable( L, 6 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.DrawPolyLinesEx( Vector2 center, int sides, float radius, float rotation, float lineThick, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } Vector2 center = uluaGetVector2Index( L, 1 ); - int sides = lua_tointeger( L, 2 ); - float radius = lua_tonumber( L, 3 ); - float rotation = lua_tonumber( L, 4 ); - float lineThick = lua_tonumber( L, 5 ); + int sides = luaL_checkinteger( L, 2 ); + float radius = luaL_checknumber( L, 3 ); + float rotation = luaL_checknumber( L, 4 ); + float lineThick = luaL_checknumber( L, 5 ); Color color = uluaGetColorIndex( L, 6 ); DrawPolyLinesEx( center, sides, radius, rotation, lineThick, color ); - lua_pushboolean( L, true ); - return 1; + return 0; } /* @@ -857,15 +564,9 @@ int lshapesDrawPolyLinesEx( lua_State *L ) { Check collision between two rectangles -- Failure return nil - Success return bool */ int lshapesCheckCollisionRecs( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.CheckCollisionRecs( Rectangle rec1, Rectangle rec2 )" ); - lua_pushnil( L ); - return 1; - } Rectangle rect1 = uluaGetRectangleIndex( L, 1 ); Rectangle rect2 = uluaGetRectangleIndex( L, 2 ); @@ -879,19 +580,13 @@ int lshapesCheckCollisionRecs( lua_State *L ) { Check collision between two circles -- Failure return nil - Success return bool */ int lshapesCheckCollisionCircles( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_istable( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.CheckCollisionCircles( Vector2 center1, float radius1, Vector2 center2, float radius2 )" ); - lua_pushnil( L ); - return 1; - } Vector2 center1 = uluaGetVector2Index( L, 1 ); - float radius1 = lua_tonumber( L, 2 ); + float radius1 = luaL_checknumber( L, 2 ); Vector2 center2 = uluaGetVector2Index( L, 3 ); - float radius2 = lua_tonumber( L, 4 ); + float radius2 = luaL_checknumber( L, 4 ); lua_pushboolean( L, CheckCollisionCircles( center1, radius1, center2, radius2 ) ); @@ -903,17 +598,11 @@ int lshapesCheckCollisionCircles( lua_State *L ) { Check collision between circle and rectangle -- Failure return nil - Success return bool */ int lshapesCheckCollisionCircleRec( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_istable( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.CheckCollisionCircleRec( Vector2 center, float radius, Rectangle rec )" ); - lua_pushnil( L ); - return 1; - } Vector2 center = uluaGetVector2Index( L, 1 ); - float radius = lua_tonumber( L, 2 ); + float radius = luaL_checknumber( L, 2 ); Rectangle rec = uluaGetRectangleIndex( L, 3 ); lua_pushboolean( L, CheckCollisionCircleRec( center, radius, rec ) ); @@ -926,15 +615,9 @@ int lshapesCheckCollisionCircleRec( lua_State *L ) { Check if point is inside rectangle -- Failure return nil - Success return bool */ int lshapesCheckCollisionPointRec( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.CheckCollisionPointRec( Vector2 point, Rectangle rec )" ); - lua_pushnil( L ); - return 1; - } Vector2 point = uluaGetVector2Index( L, 1 ); Rectangle rec = uluaGetRectangleIndex( L, 2 ); @@ -948,18 +631,12 @@ int lshapesCheckCollisionPointRec( lua_State *L ) { Check if point is inside circle -- Failure return nil - Success return bool */ int lshapesCheckCollisionPointCircle( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_isnumber( L, 3 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.CheckCollisionPointCircle( Vector2 point, Vector2 center, float radius )" ); - lua_pushnil( L ); - return 1; - } Vector2 point = uluaGetVector2Index( L, 1 ); Vector2 center = uluaGetVector2Index( L, 2 ); - float radius = lua_tonumber( L, 3 ); + float radius = luaL_checknumber( L, 3 ); lua_pushboolean( L, CheckCollisionPointCircle( point, center, radius ) ); @@ -971,15 +648,9 @@ int lshapesCheckCollisionPointCircle( lua_State *L ) { Check if point is inside a triangle -- Failure return nil - Success return bool */ int lshapesCheckCollisionPointTriangle( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) || !lua_istable( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.CheckCollisionPointTriangle( Vector2 point, Vector2 p1, Vector2 p2, Vector2 p3 )" ); - lua_pushnil( L ); - return 1; - } Vector2 point = uluaGetVector2Index( L, 1 ); Vector2 p1 = uluaGetVector2Index( L, 2 ); Vector2 p2 = uluaGetVector2Index( L, 3 ); @@ -995,15 +666,9 @@ int lshapesCheckCollisionPointTriangle( lua_State *L ) { Check if point is within a polygon described by array of vertices -- Failure return nil - Success return bool */ int lshapesCheckCollisionPointPoly( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.CheckCollisionPointPoly( Vector2 point, Vector2{} points )" ); - lua_pushnil( L ); - return 1; - } Vector2 point = uluaGetVector2Index( L, 1 ); int pointCount = uluaGetTableLenIndex( L, 2 ); Vector2 points[ pointCount ]; @@ -1017,7 +682,6 @@ int lshapesCheckCollisionPointPoly( lua_State *L ) { i++; lua_pop( L, 1 ); } - lua_pushboolean( L, CheckCollisionPointPoly( point, points, pointCount ) ); return 1; @@ -1028,15 +692,9 @@ int lshapesCheckCollisionPointPoly( lua_State *L ) { Check the collision between two lines defined by two points each, returns collision point by reference -- Failure return nil - Success return bool, Vector2 */ int lshapesCheckCollisionLines( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) || !lua_istable( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.CheckCollisionLines( Vector2 startPos1, Vector2 endPos1, Vector2 startPos2, Vector2 endPos2 )" ); - lua_pushnil( L ); - return 1; - } Vector2 startPos1 = uluaGetVector2Index( L, 1 ); Vector2 endPos1 = uluaGetVector2Index( L, 2 ); Vector2 startPos2 = uluaGetVector2Index( L, 3 ); @@ -1055,19 +713,13 @@ int lshapesCheckCollisionLines( lua_State *L ) { Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold] -- Failure return nil - Success return bool */ int lshapesCheckCollisionPointLine( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) || !lua_istable( L, 3 ) || !lua_isnumber( L, 4 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.CheckCollisionPointLine( Vector2 point, Vector2 p1, Vector2 p2, int threshold )" ); - lua_pushnil( L ); - return 1; - } Vector2 point = uluaGetVector2Index( L, 1 ); Vector2 p1 = uluaGetVector2Index( L, 2 ); Vector2 p2 = uluaGetVector2Index( L, 3 ); - int threshold = lua_tointeger( L, 4 ); + int threshold = luaL_checkinteger( L, 4 ); lua_pushboolean( L, CheckCollisionPointLine( point, p1, p2, threshold ) ); @@ -1079,15 +731,9 @@ int lshapesCheckCollisionPointLine( lua_State *L ) { Get collision rectangle for two rectangles collision -- Failure return nil - Success return Rectangle */ int lshapesGetCollisionRec( lua_State *L ) { - if ( !lua_istable( L, 1 ) || !lua_istable( L, 2 ) ) { - TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GetCollisionRec( Rectangle rec1, Rectangle rec2 )" ); - lua_pushnil( L ); - return 1; - } Rectangle rec1 = uluaGetRectangleIndex( L, 1 ); Rectangle rec2 = uluaGetRectangleIndex( L, 2 ); diff --git a/src/textures.c b/src/textures.c index 2ebf9cb..aa78ce8 100644 --- a/src/textures.c +++ b/src/textures.c @@ -276,30 +276,17 @@ int ltexturesImageFromImage( lua_State *L ) { Create an image from text (custom sprite font) -- Failure return -1 -- Success return int +- Success return Image */ int ltexturesImageText( lua_State *L ) { - // if ( !lua_isnumber( L, 1 ) || !lua_isstring( L, 2 ) || !lua_isnumber( L, 3 ) - // || !lua_isnumber( L, 4 ) || !lua_istable( L, 5 ) ) { - // TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.ImageText( Font font, string text, float fontSize, float spacing, Color tint )" ); - // lua_pushinteger( L, -1 ); - // return 1; - // } - // size_t fontId = lua_tointeger( L, 1 ); - // float fontSize = lua_tonumber( L, 3 ); - // float spacing = lua_tonumber( L, 4 ); - // Color tint = uluaGetColorIndex( L, 5 ); - - // if ( !validFont( fontId ) ) { - // lua_pushinteger( L, -1 ); - // return 1; - // } - // int i = newImage(); - // *state->images[i] = ImageTextEx( *state->fonts[ fontId ], lua_tostring( L, 2 ), fontSize, spacing, tint ); - // lua_pushinteger( L, i ); + Font *font = luaL_checkudata( L, 1, "Font" ); + float fontSize = lua_tonumber( L, 3 ); + float spacing = lua_tonumber( L, 4 ); + Color tint = uluaGetColorIndex( L, 5 ); - return 0; + uluaPushImage( L, ImageTextEx( *font, luaL_checkstring( L, 2 ), fontSize, spacing, tint ) ); + + return 1; } /* |
