New object types for all types.

This commit is contained in:
jussi
2023-10-29 13:21:42 +02:00
parent fd49d806cf
commit 76911d45a8
16 changed files with 653 additions and 1852 deletions

329
API.md
View File

@@ -3515,12 +3515,9 @@ Draw a source image within a destination image (Tint applied to source)
--- ---
> success = RL.ImageDrawTextEx( Image dst, Font font, string text, Vector2 position, float fontSize, float spacing, Color tint ) > RL.ImageDrawTextEx( Image dst, Font font, string text, Vector2 position, float fontSize, float spacing, Color tint )
Draw text ( Custom sprite font ) within an image ( Destination ) Draw text (Custom sprite font) within an image (Destination)
- Failure return false
- Success return true
--- ---
@@ -3868,7 +3865,7 @@ Load font from file into GPU memory (VRAM)
--- ---
> font = RL.LoadFontEx( string fileName, int fontSize, int fontChars{} ) > font = RL.LoadFontEx( string fileName, int fontSize, int{} fontChars )
Load font from file with extended parameters. Loading the default character set Load font from file with extended parameters. Loading the default character set
@@ -3955,171 +3952,117 @@ Get font texture atlas containing the glyphs.
--- ---
> success = RL.DrawLine3D( Vector3 startPos, Vector3 endPos, Color color ) > RL.DrawLine3D( Vector3 startPos, Vector3 endPos, Color color )
Draw a line in 3D world space Draw a line in 3D world space
- Failure return false
- Success return true
--- ---
> success = RL.DrawPoint3D( Vector3 position, Color color ) > RL.DrawPoint3D( Vector3 position, Color color )
Draw a point in 3D space, actually a small line Draw a point in 3D space, actually a small line
- Failure return false
- Success return true
--- ---
> success = RL.DrawCircle3D( Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color ) > RL.DrawCircle3D( Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color )
Draw a circle in 3D world space Draw a circle in 3D world space
- Failure return false ---
- Success return true
> RL.DrawTriangle3D( Vector3 v1, Vector3 v2, Vector3 v3, Color color )
Draw a color-filled triangle (Vertex in counter-clockwise order!)
--- ---
> success = RL.DrawTriangle3D( Vector3 v1, Vector3 v2, Vector3 v3, Color color ) > RL.DrawCube( Vector3 position, Vector3 size, Color color )
Draw a color-filled triangle ( Vertex in counter-clockwise order! )
- Failure return false
- Success return true
---
> success = RL.DrawCube( Vector3 position, Vector3 size, Color color )
Draw cube Draw cube
- Failure return false
- Success return true
--- ---
> success = RL.DrawCubeWires( Vector3 position, Vector3 size, Color color ) > RL.DrawCubeWires( Vector3 position, Vector3 size, Color color )
Draw cube wires Draw cube wires
- Failure return false
- Success return true
--- ---
> success = RL.DrawSphere( Vector3 centerPos, float radius, Color color ) > RL.DrawSphere( Vector3 centerPos, float radius, Color color )
Draw sphere Draw sphere
- Failure return false
- Success return true
--- ---
> success = RL.DrawSphereEx( Vector3 centerPos, float radius, int rings, int slices, Color color ) > RL.DrawSphereEx( Vector3 centerPos, float radius, int rings, int slices, Color color )
Draw sphere with extended parameters Draw sphere with extended parameters
- Failure return false
- Success return true
--- ---
> success = RL.DrawSphereWires( Vector3 centerPos, float radius, int rings, int slices, Color color ) > RL.DrawSphereWires( Vector3 centerPos, float radius, int rings, int slices, Color color )
Draw sphere wires Draw sphere wires
- Failure return false
- Success return true
--- ---
> success = RL.DrawCylinder( Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color ) > RL.DrawCylinder( Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color )
Draw a cylinder/cone Draw a cylinder/cone
- Failure return false
- Success return true
--- ---
> success = RL.DrawCylinderEx( Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color color ) > RL.DrawCylinderEx( Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color color )
Draw a cylinder with base at startPos and top at endPos Draw a cylinder with base at startPos and top at endPos
- Failure return false
- Success return true
--- ---
> success = RL.DrawCylinderWires( Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color ) > RL.DrawCylinderWires( Vector3 position, float radiusTop, float radiusBottom, float height, int slices, Color color )
Draw a cylinder/cone wires Draw a cylinder/cone wires
- Failure return false
- Success return true
--- ---
> success = RL.DrawCylinderWiresEx( Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color color ) > RL.DrawCylinderWiresEx( Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color color )
Draw a cylinder wires with base at startPos and top at endPos Draw a cylinder wires with base at startPos and top at endPos
- Failure return false
- Success return true
--- ---
> success = RL.DrawCapsule( Vector3 startPos, Vector3 endPos, float radius, int slices, int rings, Color color ) > RL.DrawCapsule( Vector3 startPos, Vector3 endPos, float radius, int slices, int rings, Color color )
Draw a capsule with the center of its sphere caps at startPos and endPos Draw a capsule with the center of its sphere caps at startPos and endPos
- Failure return false
- Success return true
--- ---
> success = RL.DrawCapsuleWires( Vector3 startPos, Vector3 endPos, float radius, int slices, int rings, Color color ) > RL.DrawCapsuleWires( Vector3 startPos, Vector3 endPos, float radius, int slices, int rings, Color color )
Draw capsule wireframe with the center of its sphere caps at startPos and endPos Draw capsule wireframe with the center of its sphere caps at startPos and endPos
- Failure return false
- Success return true
--- ---
> success = RL.DrawPlane( Vector3 centerPos, Vector2 size, Color color ) > RL.DrawPlane( Vector3 centerPos, Vector2 size, Color color )
Draw a plane XZ Draw a plane XZ
- Failure return false
- Success return true
--- ---
> RL.DrawQuad3DTexture( Texture texture, Vector3{} vertices, Vector2{} texCoords, Color{} colors ) > RL.DrawQuad3DTexture( Texture texture, Vector3{} vertices, Vector2{} texCoords, Color{} colors )
Draw 3D textured quad. ( Texture coordinates opengl style 0.0 - 1.0 ). Draw 3D textured quad. (Texture coordinates opengl style 0.0 - 1.0).
--- ---
> success = RL.DrawRay( Ray ray, Color color ) > RL.DrawRay( Ray ray, Color color )
Draw a ray line Draw a ray line
- Failure return false
- Success return true
--- ---
> success = RL.DrawGrid( int slices, float spacing ) > RL.DrawGrid( int slices, float spacing )
Draw a grid ( Centered at ( 0, 0, 0 ) ) Draw a grid (Centered at ( 0, 0, 0 ))
- Failure return false
- Success return true
--- ---
@@ -4131,17 +4074,15 @@ Draw a grid ( Centered at ( 0, 0, 0 ) )
Generate polygonal mesh Generate polygonal mesh
- Failure return -1 - Success return Mesh
- Success return int
--- ---
> mesh = RL.GenMeshPlane( float width, float length, int resX, int resZ ) > mesh = RL.GenMeshPlane( float width, float length, int resX, int resZ )
Generate plane mesh ( With subdivisions ) Generate plane mesh (With subdivisions)
- Failure return -1 - Success return Mesh
- Success return int
--- ---
@@ -4149,17 +4090,15 @@ Generate plane mesh ( With subdivisions )
Generate cuboid mesh Generate cuboid mesh
- Failure return -1 - Success return Mesh
- Success return int
--- ---
> mesh = RL.GenMeshSphere( float radius, int rings, int slices ) > mesh = RL.GenMeshSphere( float radius, int rings, int slices )
Generate sphere mesh ( Standard sphere ) Generate sphere mesh (Standard sphere)
- Failure return -1 - Success return Mesh
- Success return int
--- ---
@@ -4167,8 +4106,7 @@ Generate sphere mesh ( Standard sphere )
Generate cylinder mesh Generate cylinder mesh
- Failure return -1 - Success return Mesh
- Success return int
--- ---
@@ -4176,8 +4114,7 @@ Generate cylinder mesh
Generate cone/pyramid mesh Generate cone/pyramid mesh
- Failure return -1 - Success return Mesh
- Success return int
--- ---
@@ -4185,8 +4122,7 @@ Generate cone/pyramid mesh
Generate torus mesh Generate torus mesh
- Failure return -1 - Success return Mesh
- Success return int
--- ---
@@ -4194,8 +4130,7 @@ Generate torus mesh
Generate torus mesh Generate torus mesh
- Failure return -1 - Success return Mesh
- Success return int
--- ---
@@ -4203,55 +4138,35 @@ Generate torus mesh
Generate heightmap mesh from image data Generate heightmap mesh from image data
- Failure return -1 - Success return Mesh
- Success return int
--- ---
> mesh = RL.GenMeshCustom( Mesh{} mesh, bool dynamic ) > mesh = RL.GenMeshCustom( Mesh{} meshData, bool dynamic )
Generate custom mesh from vertex attribute data and uploads it into a VAO ( if supported ) and VBO Generate custom mesh from vertex attribute data and uploads it into a VAO (if supported) and VBO
- Failure return -1 - Success return Mesh
- Success return int
--- ---
> success = RL.UpdateMesh( Mesh mesh, Mesh{} updatedMesh ) > RL.UpdateMesh( Mesh mesh, Mesh{} meshData )
Update mesh vertex data in GPU. Update mesh vertex data in GPU.
Note! Mainly intented to be used with custom meshes. Note! Mainly intented to be used with custom meshes.
- Failure return false
- Success return true
--- ---
> success = RL.UnloadMesh( Mesh mesh ) > RL.DrawMesh( Mesh mesh, Material material, Matrix transform )
Unload mesh data from CPU and GPU
- Failure return false
- Success return true
---
> success = RL.DrawMesh( Mesh mesh, Material material, Matrix transform )
Draw a 3d mesh with material and transform Draw a 3d mesh with material and transform
- Failure return false
- Success return true
--- ---
> success = RL.DrawMeshInstanced( Mesh mesh, Material material, Matrix{} transforms, int instances ) > RL.DrawMeshInstanced( Mesh mesh, Material material, Matrix{} transforms, int instances )
Draw multiple mesh instances with material and different transforms Draw multiple mesh instances with material and different transforms
- Failure return false
- Success return true
--- ---
> success = RL.SetMeshColor( Mesh mesh, Color color ) > success = RL.SetMeshColor( Mesh mesh, Color color )
@@ -4268,8 +4183,7 @@ NOTE: Currently only works on custom mesh
Export mesh data to file, returns true on success Export mesh data to file, returns true on success
- Failure return false - Success return bool
- Success return true
--- ---
@@ -4277,18 +4191,14 @@ Export mesh data to file, returns true on success
Compute mesh bounding box limits Compute mesh bounding box limits
- Failure return false
- Success return BoundingBox - Success return BoundingBox
--- ---
> success = RL.GenMeshTangents( Mesh mesh ) > RL.GenMeshTangents( Mesh mesh )
Compute mesh tangents Compute mesh tangents
- Failure return false
- Success return true
--- ---
## Models - Material ## Models - Material
@@ -4299,50 +4209,34 @@ Compute mesh tangents
Load default material Load default material
- Success return int - Success return Material
--- ---
> material = RL.CreateMaterial( Material{} material ) > material = RL.CreateMaterial( Material{} materialData )
Load material from table. See material table definition Load material from table. See material table definition
- Failure return false - Success return Material
- Success return int
---
> success = RL.UnloadMaterial( Material material )
Unload material from GPU memory ( VRAM )
- Failure return false
- Success return true
--- ---
> RL.SetMaterialTexture( Material material, int mapType, Texture2D texture ) > RL.SetMaterialTexture( Material material, int mapType, Texture2D texture )
Set texture for a material map type ( MATERIAL_MAP_ALBEDO, MATERIAL_MAP_METALNESS... ) Set texture for a material map type (MATERIAL_MAP_ALBEDO, MATERIAL_MAP_METALNESS...)
--- ---
> success = RL.SetMaterialColor( Material material, int mapType, Color color ) > RL.SetMaterialColor( Material material, int mapType, Color color )
Set color for a material map type Set color for a material map type
- Failure return false
- Success return true
--- ---
> success = RL.SetMaterialValue( Material material, int mapType, float value ) > RL.SetMaterialValue( Material material, int mapType, float value )
Set value for a material map type Set value for a material map type
- Failure return false
- Success return true
--- ---
> RL.SetMaterialShader( Material material, Shader shader ) > RL.SetMaterialShader( Material material, Shader shader )
@@ -4351,56 +4245,48 @@ Set shader for material
--- ---
> success = RL.SetMaterialParams( Material material, float{} params ) > RL.SetMaterialParams( Material material, float{} params )
Set material generic parameters ( if required ) Set material generic parameters (if required)
- Failure return false
- Success return true
--- ---
> texture = RL.GetMaterialTexture( Material material, int mapType ) > texture = RL.GetMaterialTexture( Material material, int mapType )
Get texture from material map type. Returns -1 if no texture. Get texture from material map type. Returns -1 if no texture
- Failure return false - Success return Texture
- Success return int
--- ---
> color = RL.GetMaterialColor( Material material, int mapType ) > color = RL.GetMaterialColor( Material material, int mapType )
Get color from material map type. Get color from material map type
- Failure return false
- Success return Color - Success return Color
--- ---
> value = RL.GetMaterialValue( Material material, int mapType ) > value = RL.GetMaterialValue( Material material, int mapType )
Get color from material map type. Get color from material map type
- Failure return false
- Success return float - Success return float
--- ---
> shader = RL.GetMaterialShader( Material material ) > shader = RL.GetMaterialShader( Material material )
Get material shader. Returns -1 if no shader. Get material shader
- Failure return false
- Success return Shader - Success return Shader
--- ---
> params = RL.GetMaterialParams( Material material ) > params = RL.GetMaterialParams( Material material )
Get material parameters. Get material parameters
- Failure return false
- Success return float{} - Success return float{}
--- ---
@@ -4411,64 +4297,42 @@ Get material parameters.
> model = RL.LoadModel( string fileName ) > model = RL.LoadModel( string fileName )
Load model from files ( Meshes and materials ) Load model from files (Meshes and materials)
- Failure return -1 - Failure return nil
- Success return int - Success return Model
--- ---
> model = RL.LoadModelFromMesh( Mesh mesh ) > model = RL.LoadModelFromMesh( Mesh mesh )
Load model from generated mesh ( Default material ) Load model from generated mesh (Default material)
- Failure return -1 - Success return Model
- Success return int
--- ---
> success = RL.UnloadModel( Model model ) > RL.DrawModel( Model model, Vector3 position, float scale, Color tint )
Unload model ( Including meshes ) from memory ( RAM and/or VRAM ) Draw a model (With texture if set)
- Failure return false
- Success return true
--- ---
> success = RL.DrawModel( Model model, Vector3 position, float scale, Color tint ) > RL.DrawModelEx( Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint )
Draw a model ( With texture if set )
- Failure return false
- Success return true
---
> success = RL.DrawModelEx( Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint )
Draw a model with extended parameters Draw a model with extended parameters
- Failure return false ---
- Success return true
> RL.SetModelMaterial( Model model, Material modelMaterial, Material material )
Copies material to model material. (Model material is the material id in models.)
--- ---
> success = RL.SetModelMaterial( Model model, Material modelMaterial, Material material ) > RL.SetModelMeshMaterial( Model model, int meshId, int materialId )
Copies material to model material. ( Model material is the material id in models. Material can be deleted if not used elsewhere ) Set material for a mesh (Mesh and material on this model)
- Failure return false
- Success return true
---
> success = RL.SetModelMeshMaterial( Model model, int meshId, int materialId )
Set material for a mesh ( Mesh and material on this model )
- Failure return false
- Success return true
--- ---
@@ -4490,20 +4354,16 @@ Draw a billboard texture defined by source and rotation
--- ---
> success = RL.SetModelTransform( Model model, Matrix transform ) > RL.SetModelTransform( Model model, Matrix transform )
Set model transform matrix Set model transform matrix
- Failure return false
- Success return true
--- ---
> transform = RL.GetModelTransform( Model model ) > transform = RL.GetModelTransform( Model model )
Get model transform matrix Get model transform matrix
- Failure return false
- Success return Matrix - Success return Matrix
--- ---
@@ -4512,56 +4372,41 @@ Get model transform matrix
--- ---
> animations, animationCount = RL.LoadModelAnimations( string fileName ) > animations = RL.LoadModelAnimations( string fileName )
Load model animations from file Load model animations from file
- Failure return -1 - Failure return nil
- Success return int, int - Success return ModelAnimations{}
--- ---
> success = RL.UpdateModelAnimation( Model model, ModelAnimations animations, int animation, int frame ) > RL.UpdateModelAnimation( Model model, ModelAnimation animation, int frame )
Update model animation pose Update model animation pose
- Failure return false
- Success return true
--- ---
> success = RL.UnloadModelAnimations( ModelAnimations animations ) > valid = RL.IsModelAnimationValid( Model model, ModelAnimation animation )
Unload animation data
- Failure return false
- Success return true
---
> valid = RL.IsModelAnimationValid( Model model, ModelAnimations animations )
Check model animation skeleton match Check model animation skeleton match
- Failure return nil
- Success return bool - Success return bool
--- ---
> boneCount = RL.GetModelAnimationBoneCount( ModelAnimations animations, int animation ) > boneCount = RL.GetModelAnimationBoneCount( ModelAnimation animation )
Return modelAnimation bone count Return modelAnimation bone count
- Failure return false
- Success return int - Success return int
--- ---
> frameCount = RL.GetModelAnimationFrameCount( ModelAnimations animations, int animation ) > frameCount = RL.GetModelAnimationFrameCount( ModelAnimation animation )
Return modelAnimation frame count Return modelAnimation frame count
- Failure return false
- Success return int - Success return int
--- ---
@@ -4574,7 +4419,6 @@ Return modelAnimation frame count
Check collision between two spheres Check collision between two spheres
- Failure return nil
- Success return bool - Success return bool
--- ---
@@ -4583,7 +4427,6 @@ Check collision between two spheres
Check collision between two bounding boxes Check collision between two bounding boxes
- Failure return nil
- Success return bool - Success return bool
--- ---
@@ -4592,7 +4435,6 @@ Check collision between two bounding boxes
Check collision between box and sphere Check collision between box and sphere
- Failure return nil
- Success return bool - Success return bool
--- ---
@@ -4601,7 +4443,6 @@ Check collision between box and sphere
Get collision info between ray and sphere. ( RayCollision is Lua table of { hit, distance, point, normal } ) Get collision info between ray and sphere. ( RayCollision is Lua table of { hit, distance, point, normal } )
- Failure return nil
- Success return RayCollision - Success return RayCollision
--- ---
@@ -4610,7 +4451,6 @@ Get collision info between ray and sphere. ( RayCollision is Lua table of { hit,
Get collision info between ray and box Get collision info between ray and box
- Failure return nil
- Success return RayCollision - Success return RayCollision
--- ---
@@ -4619,7 +4459,6 @@ Get collision info between ray and box
Get collision info between ray and mesh Get collision info between ray and mesh
- Failure return nil
- Success return RayCollision - Success return RayCollision
--- ---
@@ -4628,7 +4467,6 @@ Get collision info between ray and mesh
Get collision info between ray and triangle Get collision info between ray and triangle
- Failure return nil
- Success return RayCollision - Success return RayCollision
--- ---
@@ -4637,7 +4475,6 @@ Get collision info between ray and triangle
Get collision info between ray and quad Get collision info between ray and quad
- Failure return nil
- Success return RayCollision - Success return RayCollision
--- ---

View File

@@ -2503,9 +2503,7 @@ function RL.ImageDrawRectangleLines( dst, rec, thick, color ) end
---@return any RL.ImageDraw ---@return any RL.ImageDraw
function RL.ImageDraw( dst, src, srcRec, dstRec, tint ) end function RL.ImageDraw( dst, src, srcRec, dstRec, tint ) end
---Draw text ( Custom sprite font ) within an image ( Destination ) ---Draw text (Custom sprite font) within an image (Destination)
---- Failure return false
---- Success return true
---@param dst any ---@param dst any
---@param font any ---@param font any
---@param text string ---@param text string
@@ -2513,8 +2511,8 @@ function RL.ImageDraw( dst, src, srcRec, dstRec, tint ) end
---@param fontSize number ---@param fontSize number
---@param spacing number ---@param spacing number
---@param tint table ---@param tint table
---@return any success ---@return any RL.ImageDrawTextEx
function RL.ImageDrawTextEx( dst, font, text, position, fontSize, spacing, tint ) end function RL.ImageDrawTextEx( dst, font, text, position, fontSize, spacing, tint ) end
-- Textures - Image Configuration -- Textures - Image Configuration
@@ -2810,9 +2808,9 @@ function RL.LoadFont( fileName ) end
---- Success return Font ---- Success return Font
---@param fileName string ---@param fileName string
---@param fontSize integer ---@param fontSize integer
---@param fontChars{} integer ---@param fontChars any
---@return any font ---@return any font
function RL.LoadFontEx( fileName, fontSize, fontChars{} ) end function RL.LoadFontEx( fileName, fontSize, fontChars ) end
---Load font from Image ( XNA style) ---Load font from Image ( XNA style)
---- Success return Font ---- Success return Font
@@ -2889,174 +2887,142 @@ function RL.GetFontTexture( font ) end
-- Models - Basic -- Models - Basic
---Draw a line in 3D world space ---Draw a line in 3D world space
---- Failure return false
---- Success return true
---@param startPos table ---@param startPos table
---@param endPos table ---@param endPos table
---@param color table ---@param color table
---@return any success ---@return any RL.DrawLine3D
function RL.DrawLine3D( startPos, endPos, color ) end function RL.DrawLine3D( startPos, endPos, color ) end
---Draw a point in 3D space, actually a small line ---Draw a point in 3D space, actually a small line
---- Failure return false
---- Success return true
---@param position table ---@param position table
---@param color table ---@param color table
---@return any success ---@return any RL.DrawPoint3D
function RL.DrawPoint3D( position, color ) end function RL.DrawPoint3D( position, color ) end
---Draw a circle in 3D world space ---Draw a circle in 3D world space
---- Failure return false
---- Success return true
---@param center table ---@param center table
---@param radius number ---@param radius number
---@param rotationAxis table ---@param rotationAxis table
---@param rotationAngle number ---@param rotationAngle number
---@param color table ---@param color table
---@return any success ---@return any RL.DrawCircle3D
function RL.DrawCircle3D( center, radius, rotationAxis, rotationAngle, color ) end function RL.DrawCircle3D( center, radius, rotationAxis, rotationAngle, color ) end
---Draw a color-filled triangle ( Vertex in counter-clockwise order! ) ---Draw a color-filled triangle (Vertex in counter-clockwise order!)
---- Failure return false
---- Success return true
---@param v1 table ---@param v1 table
---@param v2 table ---@param v2 table
---@param v3 table ---@param v3 table
---@param color table ---@param color table
---@return any success ---@return any RL.DrawTriangle3D
function RL.DrawTriangle3D( v1, v2, v3, color ) end function RL.DrawTriangle3D( v1, v2, v3, color ) end
---Draw cube ---Draw cube
---- Failure return false
---- Success return true
---@param position table ---@param position table
---@param size table ---@param size table
---@param color table ---@param color table
---@return any success ---@return any RL.DrawCube
function RL.DrawCube( position, size, color ) end function RL.DrawCube( position, size, color ) end
---Draw cube wires ---Draw cube wires
---- Failure return false
---- Success return true
---@param position table ---@param position table
---@param size table ---@param size table
---@param color table ---@param color table
---@return any success ---@return any RL.DrawCubeWires
function RL.DrawCubeWires( position, size, color ) end function RL.DrawCubeWires( position, size, color ) end
---Draw sphere ---Draw sphere
---- Failure return false
---- Success return true
---@param centerPos table ---@param centerPos table
---@param radius number ---@param radius number
---@param color table ---@param color table
---@return any success ---@return any RL.DrawSphere
function RL.DrawSphere( centerPos, radius, color ) end function RL.DrawSphere( centerPos, radius, color ) end
---Draw sphere with extended parameters ---Draw sphere with extended parameters
---- Failure return false
---- Success return true
---@param centerPos table ---@param centerPos table
---@param radius number ---@param radius number
---@param rings integer ---@param rings integer
---@param slices integer ---@param slices integer
---@param color table ---@param color table
---@return any success ---@return any RL.DrawSphereEx
function RL.DrawSphereEx( centerPos, radius, rings, slices, color ) end function RL.DrawSphereEx( centerPos, radius, rings, slices, color ) end
---Draw sphere wires ---Draw sphere wires
---- Failure return false
---- Success return true
---@param centerPos table ---@param centerPos table
---@param radius number ---@param radius number
---@param rings integer ---@param rings integer
---@param slices integer ---@param slices integer
---@param color table ---@param color table
---@return any success ---@return any RL.DrawSphereWires
function RL.DrawSphereWires( centerPos, radius, rings, slices, color ) end function RL.DrawSphereWires( centerPos, radius, rings, slices, color ) end
---Draw a cylinder/cone ---Draw a cylinder/cone
---- Failure return false
---- Success return true
---@param position table ---@param position table
---@param radiusTop number ---@param radiusTop number
---@param radiusBottom number ---@param radiusBottom number
---@param height number ---@param height number
---@param slices integer ---@param slices integer
---@param color table ---@param color table
---@return any success ---@return any RL.DrawCylinder
function RL.DrawCylinder( position, radiusTop, radiusBottom, height, slices, color ) end function RL.DrawCylinder( position, radiusTop, radiusBottom, height, slices, color ) end
---Draw a cylinder with base at startPos and top at endPos ---Draw a cylinder with base at startPos and top at endPos
---- Failure return false
---- Success return true
---@param startPos table ---@param startPos table
---@param endPos table ---@param endPos table
---@param startRadius number ---@param startRadius number
---@param endRadius number ---@param endRadius number
---@param sides integer ---@param sides integer
---@param color table ---@param color table
---@return any success ---@return any RL.DrawCylinderEx
function RL.DrawCylinderEx( startPos, endPos, startRadius, endRadius, sides, color ) end function RL.DrawCylinderEx( startPos, endPos, startRadius, endRadius, sides, color ) end
---Draw a cylinder/cone wires ---Draw a cylinder/cone wires
---- Failure return false
---- Success return true
---@param position table ---@param position table
---@param radiusTop number ---@param radiusTop number
---@param radiusBottom number ---@param radiusBottom number
---@param height number ---@param height number
---@param slices integer ---@param slices integer
---@param color table ---@param color table
---@return any success ---@return any RL.DrawCylinderWires
function RL.DrawCylinderWires( position, radiusTop, radiusBottom, height, slices, color ) end function RL.DrawCylinderWires( position, radiusTop, radiusBottom, height, slices, color ) end
---Draw a cylinder wires with base at startPos and top at endPos ---Draw a cylinder wires with base at startPos and top at endPos
---- Failure return false
---- Success return true
---@param startPos table ---@param startPos table
---@param endPos table ---@param endPos table
---@param startRadius number ---@param startRadius number
---@param endRadius number ---@param endRadius number
---@param sides integer ---@param sides integer
---@param color table ---@param color table
---@return any success ---@return any RL.DrawCylinderWiresEx
function RL.DrawCylinderWiresEx( startPos, endPos, startRadius, endRadius, sides, color ) end function RL.DrawCylinderWiresEx( startPos, endPos, startRadius, endRadius, sides, color ) end
---Draw a capsule with the center of its sphere caps at startPos and endPos ---Draw a capsule with the center of its sphere caps at startPos and endPos
---- Failure return false
---- Success return true
---@param startPos table ---@param startPos table
---@param endPos table ---@param endPos table
---@param radius number ---@param radius number
---@param slices integer ---@param slices integer
---@param rings integer ---@param rings integer
---@param color table ---@param color table
---@return any success ---@return any RL.DrawCapsule
function RL.DrawCapsule( startPos, endPos, radius, slices, rings, color ) end function RL.DrawCapsule( startPos, endPos, radius, slices, rings, color ) end
---Draw capsule wireframe with the center of its sphere caps at startPos and endPos ---Draw capsule wireframe with the center of its sphere caps at startPos and endPos
---- Failure return false
---- Success return true
---@param startPos table ---@param startPos table
---@param endPos table ---@param endPos table
---@param radius number ---@param radius number
---@param slices integer ---@param slices integer
---@param rings integer ---@param rings integer
---@param color table ---@param color table
---@return any success ---@return any RL.DrawCapsuleWires
function RL.DrawCapsuleWires( startPos, endPos, radius, slices, rings, color ) end function RL.DrawCapsuleWires( startPos, endPos, radius, slices, rings, color ) end
---Draw a plane XZ ---Draw a plane XZ
---- Failure return false
---- Success return true
---@param centerPos table ---@param centerPos table
---@param size table ---@param size table
---@param color table ---@param color table
---@return any success ---@return any RL.DrawPlane
function RL.DrawPlane( centerPos, size, color ) end function RL.DrawPlane( centerPos, size, color ) end
---Draw 3D textured quad. ( Texture coordinates opengl style 0.0 - 1.0 ). ---Draw 3D textured quad. (Texture coordinates opengl style 0.0 - 1.0).
---@param texture any ---@param texture any
---@param vertices any ---@param vertices any
---@param texCoords any ---@param texCoords any
@@ -3065,34 +3031,28 @@ function RL.DrawPlane( centerPos, size, color ) end
function RL.DrawQuad3DTexture( texture, vertices, texCoords, colors ) end function RL.DrawQuad3DTexture( texture, vertices, texCoords, colors ) end
---Draw a ray line ---Draw a ray line
---- Failure return false
---- Success return true
---@param ray any ---@param ray any
---@param color table ---@param color table
---@return any success ---@return any RL.DrawRay
function RL.DrawRay( ray, color ) end function RL.DrawRay( ray, color ) end
---Draw a grid ( Centered at ( 0, 0, 0 ) ) ---Draw a grid (Centered at ( 0, 0, 0 ))
---- Failure return false
---- Success return true
---@param slices integer ---@param slices integer
---@param spacing number ---@param spacing number
---@return any success ---@return any RL.DrawGrid
function RL.DrawGrid( slices, spacing ) end function RL.DrawGrid( slices, spacing ) end
-- Models - Mesh -- Models - Mesh
---Generate polygonal mesh ---Generate polygonal mesh
---- Failure return -1 ---- Success return Mesh
---- Success return int
---@param sides integer ---@param sides integer
---@param radius number ---@param radius number
---@return any mesh ---@return any mesh
function RL.GenMeshPoly( sides, radius ) end function RL.GenMeshPoly( sides, radius ) end
---Generate plane mesh ( With subdivisions ) ---Generate plane mesh (With subdivisions)
---- Failure return -1 ---- Success return Mesh
---- Success return int
---@param width number ---@param width number
---@param length number ---@param length number
---@param resX integer ---@param resX integer
@@ -3101,15 +3061,13 @@ function RL.GenMeshPoly( sides, radius ) end
function RL.GenMeshPlane( width, length, resX, resZ ) end function RL.GenMeshPlane( width, length, resX, resZ ) end
---Generate cuboid mesh ---Generate cuboid mesh
---- Failure return -1 ---- Success return Mesh
---- Success return int
---@param size table ---@param size table
---@return any mesh ---@return any mesh
function RL.GenMeshCube( size ) end function RL.GenMeshCube( size ) end
---Generate sphere mesh ( Standard sphere ) ---Generate sphere mesh (Standard sphere)
---- Failure return -1 ---- Success return Mesh
---- Success return int
---@param radius number ---@param radius number
---@param rings integer ---@param rings integer
---@param slices integer ---@param slices integer
@@ -3117,8 +3075,7 @@ function RL.GenMeshCube( size ) end
function RL.GenMeshSphere( radius, rings, slices ) end function RL.GenMeshSphere( radius, rings, slices ) end
---Generate cylinder mesh ---Generate cylinder mesh
---- Failure return -1 ---- Success return Mesh
---- Success return int
---@param radius number ---@param radius number
---@param height number ---@param height number
---@param slices integer ---@param slices integer
@@ -3126,8 +3083,7 @@ function RL.GenMeshSphere( radius, rings, slices ) end
function RL.GenMeshCylinder( radius, height, slices ) end function RL.GenMeshCylinder( radius, height, slices ) end
---Generate cone/pyramid mesh ---Generate cone/pyramid mesh
---- Failure return -1 ---- Success return Mesh
---- Success return int
---@param radius number ---@param radius number
---@param height number ---@param height number
---@param slices integer ---@param slices integer
@@ -3135,8 +3091,7 @@ function RL.GenMeshCylinder( radius, height, slices ) end
function RL.GenMeshCone( radius, height, slices ) end function RL.GenMeshCone( radius, height, slices ) end
---Generate torus mesh ---Generate torus mesh
---- Failure return -1 ---- Success return Mesh
---- Success return int
---@param radius number ---@param radius number
---@param size number ---@param size number
---@param radSeg integer ---@param radSeg integer
@@ -3145,8 +3100,7 @@ function RL.GenMeshCone( radius, height, slices ) end
function RL.GenMeshTorus( radius, size, radSeg, sides ) end function RL.GenMeshTorus( radius, size, radSeg, sides ) end
---Generate torus mesh ---Generate torus mesh
---- Failure return -1 ---- Success return Mesh
---- Success return int
---@param radius number ---@param radius number
---@param size number ---@param size number
---@param radSeg integer ---@param radSeg integer
@@ -3155,55 +3109,40 @@ function RL.GenMeshTorus( radius, size, radSeg, sides ) end
function RL.GenMeshKnot( radius, size, radSeg, sides ) end function RL.GenMeshKnot( radius, size, radSeg, sides ) end
---Generate heightmap mesh from image data ---Generate heightmap mesh from image data
---- Failure return -1 ---- Success return Mesh
---- Success return int
---@param heightmap any ---@param heightmap any
---@param size table ---@param size table
---@return any mesh ---@return any mesh
function RL.GenMeshHeightmap( heightmap, size ) end function RL.GenMeshHeightmap( heightmap, size ) end
---Generate custom mesh from vertex attribute data and uploads it into a VAO ( if supported ) and VBO ---Generate custom mesh from vertex attribute data and uploads it into a VAO (if supported) and VBO
---- Failure return -1 ---- Success return Mesh
---- Success return int ---@param meshData any
---@param mesh any
---@param dynamic boolean ---@param dynamic boolean
---@return any mesh ---@return any mesh
function RL.GenMeshCustom( mesh, dynamic ) end function RL.GenMeshCustom( meshData, dynamic ) end
---Update mesh vertex data in GPU. ---Update mesh vertex data in GPU.
---Note! Mainly intented to be used with custom meshes. ---Note! Mainly intented to be used with custom meshes.
---- Failure return false
---- Success return true
---@param mesh any ---@param mesh any
---@param updatedMesh any ---@param meshData any
---@return any success ---@return any RL.UpdateMesh
function RL.UpdateMesh( mesh, updatedMesh ) end function RL.UpdateMesh( mesh, meshData ) end
---Unload mesh data from CPU and GPU
---- Failure return false
---- Success return true
---@param mesh any
---@return any success
function RL.UnloadMesh( mesh ) end
---Draw a 3d mesh with material and transform ---Draw a 3d mesh with material and transform
---- Failure return false
---- Success return true
---@param mesh any ---@param mesh any
---@param material any ---@param material any
---@param transform table ---@param transform table
---@return any success ---@return any RL.DrawMesh
function RL.DrawMesh( mesh, material, transform ) end function RL.DrawMesh( mesh, material, transform ) end
---Draw multiple mesh instances with material and different transforms ---Draw multiple mesh instances with material and different transforms
---- Failure return false
---- Success return true
---@param mesh any ---@param mesh any
---@param material any ---@param material any
---@param transforms any ---@param transforms any
---@param instances integer ---@param instances integer
---@return any success ---@return any RL.DrawMeshInstanced
function RL.DrawMeshInstanced( mesh, material, transforms, instances ) end function RL.DrawMeshInstanced( mesh, material, transforms, instances ) end
---Updades mesh color vertex attribute buffer ---Updades mesh color vertex attribute buffer
---NOTE: Currently only works on custom mesh ---NOTE: Currently only works on custom mesh
@@ -3215,49 +3154,37 @@ function RL.DrawMeshInstanced( mesh, material, transforms, instances ) end
function RL.SetMeshColor( mesh, color ) end function RL.SetMeshColor( mesh, color ) end
---Export mesh data to file, returns true on success ---Export mesh data to file, returns true on success
---- Failure return false ---- Success return bool
---- Success return true
---@param mesh any ---@param mesh any
---@param fileName string ---@param fileName string
---@return any success ---@return any success
function RL.ExportMesh( mesh, fileName ) end function RL.ExportMesh( mesh, fileName ) end
---Compute mesh bounding box limits ---Compute mesh bounding box limits
---- Failure return false
---- Success return BoundingBox ---- Success return BoundingBox
---@param mesh any ---@param mesh any
---@return any boundingBox ---@return any boundingBox
function RL.GetMeshBoundingBox( mesh ) end function RL.GetMeshBoundingBox( mesh ) end
---Compute mesh tangents ---Compute mesh tangents
---- Failure return false
---- Success return true
---@param mesh any ---@param mesh any
---@return any success ---@return any RL.GenMeshTangents
function RL.GenMeshTangents( mesh ) end function RL.GenMeshTangents( mesh ) end
-- Models - Material -- Models - Material
---Load default material ---Load default material
---- Success return int ---- Success return Material
---@return any material ---@return any material
function RL.LoadMaterialDefault() end function RL.LoadMaterialDefault() end
---Load material from table. See material table definition ---Load material from table. See material table definition
---- Failure return false ---- Success return Material
---- Success return int ---@param materialData any
---@param material any
---@return any material ---@return any material
function RL.CreateMaterial( material ) end function RL.CreateMaterial( materialData ) end
---Unload material from GPU memory ( VRAM ) ---Set texture for a material map type (MATERIAL_MAP_ALBEDO, MATERIAL_MAP_METALNESS...)
---- Failure return false
---- Success return true
---@param material any
---@return any success
function RL.UnloadMaterial( material ) end
---Set texture for a material map type ( MATERIAL_MAP_ALBEDO, MATERIAL_MAP_METALNESS... )
---@param material any ---@param material any
---@param mapType integer ---@param mapType integer
---@param texture any ---@param texture any
@@ -3265,22 +3192,18 @@ function RL.UnloadMaterial( material ) end
function RL.SetMaterialTexture( material, mapType, texture ) end function RL.SetMaterialTexture( material, mapType, texture ) end
---Set color for a material map type ---Set color for a material map type
---- Failure return false
---- Success return true
---@param material any ---@param material any
---@param mapType integer ---@param mapType integer
---@param color table ---@param color table
---@return any success ---@return any RL.SetMaterialColor
function RL.SetMaterialColor( material, mapType, color ) end function RL.SetMaterialColor( material, mapType, color ) end
---Set value for a material map type ---Set value for a material map type
---- Failure return false
---- Success return true
---@param material any ---@param material any
---@param mapType integer ---@param mapType integer
---@param value number ---@param value number
---@return any success ---@return any RL.SetMaterialValue
function RL.SetMaterialValue( material, mapType, value ) end function RL.SetMaterialValue( material, mapType, value ) end
---Set shader for material ---Set shader for material
---@param material any ---@param material any
@@ -3288,47 +3211,40 @@ function RL.SetMaterialValue( material, mapType, value ) end
---@return any RL.SetMaterialShader ---@return any RL.SetMaterialShader
function RL.SetMaterialShader( material, shader ) end function RL.SetMaterialShader( material, shader ) end
---Set material generic parameters ( if required ) ---Set material generic parameters (if required)
---- Failure return false
---- Success return true
---@param material any ---@param material any
---@param params any ---@param params any
---@return any success ---@return any RL.SetMaterialParams
function RL.SetMaterialParams( material, params ) end function RL.SetMaterialParams( material, params ) end
---Get texture from material map type. Returns -1 if no texture. ---Get texture from material map type. Returns -1 if no texture
---- Failure return false ---- Success return Texture
---- Success return int
---@param material any ---@param material any
---@param mapType integer ---@param mapType integer
---@return any texture ---@return any texture
function RL.GetMaterialTexture( material, mapType ) end function RL.GetMaterialTexture( material, mapType ) end
---Get color from material map type. ---Get color from material map type
---- Failure return false
---- Success return Color ---- Success return Color
---@param material any ---@param material any
---@param mapType integer ---@param mapType integer
---@return any color ---@return any color
function RL.GetMaterialColor( material, mapType ) end function RL.GetMaterialColor( material, mapType ) end
---Get color from material map type. ---Get color from material map type
---- Failure return false
---- Success return float ---- Success return float
---@param material any ---@param material any
---@param mapType integer ---@param mapType integer
---@return any value ---@return any value
function RL.GetMaterialValue( material, mapType ) end function RL.GetMaterialValue( material, mapType ) end
---Get material shader. Returns -1 if no shader. ---Get material shader
---- Failure return false
---- Success return Shader ---- Success return Shader
---@param material any ---@param material any
---@return any shader ---@return any shader
function RL.GetMaterialShader( material ) end function RL.GetMaterialShader( material ) end
---Get material parameters. ---Get material parameters
---- Failure return false
---- Success return float{} ---- Success return float{}
---@param material any ---@param material any
---@return any params ---@return any params
@@ -3336,66 +3252,50 @@ function RL.GetMaterialParams( material ) end
-- Models - Model -- Models - Model
---Load model from files ( Meshes and materials ) ---Load model from files (Meshes and materials)
---- Failure return -1 ---- Failure return nil
---- Success return int ---- Success return Model
---@param fileName string ---@param fileName string
---@return any model ---@return any model
function RL.LoadModel( fileName ) end function RL.LoadModel( fileName ) end
---Load model from generated mesh ( Default material ) ---Load model from generated mesh (Default material)
---- Failure return -1 ---- Success return Model
---- Success return int
---@param mesh any ---@param mesh any
---@return any model ---@return any model
function RL.LoadModelFromMesh( mesh ) end function RL.LoadModelFromMesh( mesh ) end
---Unload model ( Including meshes ) from memory ( RAM and/or VRAM ) ---Draw a model (With texture if set)
---- Failure return false
---- Success return true
---@param model any
---@return any success
function RL.UnloadModel( model ) end
---Draw a model ( With texture if set )
---- Failure return false
---- Success return true
---@param model any ---@param model any
---@param position table ---@param position table
---@param scale number ---@param scale number
---@param tint table ---@param tint table
---@return any success ---@return any RL.DrawModel
function RL.DrawModel( model, position, scale, tint ) end function RL.DrawModel( model, position, scale, tint ) end
---Draw a model with extended parameters ---Draw a model with extended parameters
---- Failure return false
---- Success return true
---@param model any ---@param model any
---@param position table ---@param position table
---@param rotationAxis table ---@param rotationAxis table
---@param rotationAngle number ---@param rotationAngle number
---@param scale table ---@param scale table
---@param tint table ---@param tint table
---@return any success ---@return any RL.DrawModelEx
function RL.DrawModelEx( model, position, rotationAxis, rotationAngle, scale, tint ) end function RL.DrawModelEx( model, position, rotationAxis, rotationAngle, scale, tint ) end
---Copies material to model material. ( Model material is the material id in models. Material can be deleted if not used elsewhere ) ---Copies material to model material. (Model material is the material id in models.)
---- Failure return false
---- Success return true
---@param model any ---@param model any
---@param modelMaterial any ---@param modelMaterial any
---@param material any ---@param material any
---@return any success ---@return any RL.SetModelMaterial
function RL.SetModelMaterial( model, modelMaterial, material ) end function RL.SetModelMaterial( model, modelMaterial, material ) end
---Set material for a mesh ( Mesh and material on this model ) ---Set material for a mesh (Mesh and material on this model)
---- Failure return false
---- Success return true
---@param model any ---@param model any
---@param meshId integer ---@param meshId integer
---@param materialId integer ---@param materialId integer
---@return any success ---@return any RL.SetModelMeshMaterial
function RL.SetModelMeshMaterial( model, meshId, materialId ) end function RL.SetModelMeshMaterial( model, meshId, materialId ) end
---Draw a billboard texture ---Draw a billboard texture
---@param camera any ---@param camera any
@@ -3430,15 +3330,12 @@ function RL.DrawBillboardRec( camera, texture, source, position, size, tint ) e
function RL.DrawBillboardPro( camera, texture, source, position, up, size, origin, rotation, tint ) end function RL.DrawBillboardPro( camera, texture, source, position, up, size, origin, rotation, tint ) end
---Set model transform matrix ---Set model transform matrix
---- Failure return false
---- Success return true
---@param model any ---@param model any
---@param transform table ---@param transform table
---@return any success ---@return any RL.SetModelTransform
function RL.SetModelTransform( model, transform ) end function RL.SetModelTransform( model, transform ) end
---Get model transform matrix ---Get model transform matrix
---- Failure return false
---- Success return Matrix ---- Success return Matrix
---@param model any ---@param model any
---@return any transform ---@return any transform
@@ -3447,58 +3344,41 @@ function RL.GetModelTransform( model ) end
-- Model - Animations -- Model - Animations
---Load model animations from file ---Load model animations from file
---- Failure return -1 ---- Failure return nil
---- Success return int, int ---- Success return ModelAnimations{}
---@param fileName string ---@param fileName string
---@return any animations ---@return any animations
---@return any animationCount
function RL.LoadModelAnimations( fileName ) end function RL.LoadModelAnimations( fileName ) end
---Update model animation pose ---Update model animation pose
---- Failure return false
---- Success return true
---@param model any ---@param model any
---@param animations any ---@param animation any
---@param animation integer
---@param frame integer ---@param frame integer
---@return any success ---@return any RL.UpdateModelAnimation
function RL.UpdateModelAnimation( model, animations, animation, frame ) end function RL.UpdateModelAnimation( model, animation, frame ) end
---Unload animation data
---- Failure return false
---- Success return true
---@param animations any
---@return any success
function RL.UnloadModelAnimations( animations ) end
---Check model animation skeleton match ---Check model animation skeleton match
---- Failure return nil
---- Success return bool ---- Success return bool
---@param model any ---@param model any
---@param animations any ---@param animation any
---@return any valid ---@return any valid
function RL.IsModelAnimationValid( model, animations ) end function RL.IsModelAnimationValid( model, animation ) end
---Return modelAnimation bone count ---Return modelAnimation bone count
---- Failure return false
---- Success return int ---- Success return int
---@param animations any ---@param animation any
---@param animation integer
---@return any boneCount ---@return any boneCount
function RL.GetModelAnimationBoneCount( animations, animation ) end function RL.GetModelAnimationBoneCount( animation ) end
---Return modelAnimation frame count ---Return modelAnimation frame count
---- Failure return false
---- Success return int ---- Success return int
---@param animations any ---@param animation any
---@param animation integer
---@return any frameCount ---@return any frameCount
function RL.GetModelAnimationFrameCount( animations, animation ) end function RL.GetModelAnimationFrameCount( animation ) end
-- Model - Collision -- Model - Collision
---Check collision between two spheres ---Check collision between two spheres
---- Failure return nil
---- Success return bool ---- Success return bool
---@param center1 table ---@param center1 table
---@param radius1 number ---@param radius1 number
@@ -3508,7 +3388,6 @@ function RL.GetModelAnimationFrameCount( animations, animation ) end
function RL.CheckCollisionSpheres( center1, radius1, center2, radius2 ) end function RL.CheckCollisionSpheres( center1, radius1, center2, radius2 ) end
---Check collision between two bounding boxes ---Check collision between two bounding boxes
---- Failure return nil
---- Success return bool ---- Success return bool
---@param box1 any ---@param box1 any
---@param box2 any ---@param box2 any
@@ -3516,7 +3395,6 @@ function RL.CheckCollisionSpheres( center1, radius1, center2, radius2 ) end
function RL.CheckCollisionBoxes( box1, box2 ) end function RL.CheckCollisionBoxes( box1, box2 ) end
---Check collision between box and sphere ---Check collision between box and sphere
---- Failure return nil
---- Success return bool ---- Success return bool
---@param box any ---@param box any
---@param center table ---@param center table
@@ -3525,7 +3403,6 @@ function RL.CheckCollisionBoxes( box1, box2 ) end
function RL.CheckCollisionBoxSphere( box, center, radius ) end function RL.CheckCollisionBoxSphere( box, center, radius ) end
---Get collision info between ray and sphere. ( RayCollision is Lua table of { hit, distance, point, normal } ) ---Get collision info between ray and sphere. ( RayCollision is Lua table of { hit, distance, point, normal } )
---- Failure return nil
---- Success return RayCollision ---- Success return RayCollision
---@param ray any ---@param ray any
---@param center table ---@param center table
@@ -3534,7 +3411,6 @@ function RL.CheckCollisionBoxSphere( box, center, radius ) end
function RL.GetRayCollisionSphere( ray, center, radius ) end function RL.GetRayCollisionSphere( ray, center, radius ) end
---Get collision info between ray and box ---Get collision info between ray and box
---- Failure return nil
---- Success return RayCollision ---- Success return RayCollision
---@param ray any ---@param ray any
---@param box any ---@param box any
@@ -3542,7 +3418,6 @@ function RL.GetRayCollisionSphere( ray, center, radius ) end
function RL.GetRayCollisionBox( ray, box ) end function RL.GetRayCollisionBox( ray, box ) end
---Get collision info between ray and mesh ---Get collision info between ray and mesh
---- Failure return nil
---- Success return RayCollision ---- Success return RayCollision
---@param ray any ---@param ray any
---@param mesh any ---@param mesh any
@@ -3551,7 +3426,6 @@ function RL.GetRayCollisionBox( ray, box ) end
function RL.GetRayCollisionMesh( ray, mesh, transform ) end function RL.GetRayCollisionMesh( ray, mesh, transform ) end
---Get collision info between ray and triangle ---Get collision info between ray and triangle
---- Failure return nil
---- Success return RayCollision ---- Success return RayCollision
---@param ray any ---@param ray any
---@param p1 table ---@param p1 table
@@ -3561,7 +3435,6 @@ function RL.GetRayCollisionMesh( ray, mesh, transform ) end
function RL.GetRayCollisionTriangle( ray, p1, p2, p3 ) end function RL.GetRayCollisionTriangle( ray, p1, p2, p3 ) end
---Get collision info between ray and quad ---Get collision info between ray and quad
---- Failure return nil
---- Success return RayCollision ---- Success return RayCollision
---@param ray any ---@param ray any
---@param p1 table ---@param p1 table

View File

@@ -5,6 +5,7 @@ KEY CHANGES:
- CHANGED: Switch from ID based objects to userdata. - CHANGED: Switch from ID based objects to userdata.
- CHANGED: Wrong arguments now largely crash the application instead of TraceLog state->logLevelInvalid. - CHANGED: Wrong arguments now largely crash the application instead of TraceLog state->logLevelInvalid.
- CHANGED: Rely mostly on luaL_check* functions for arg checking. - CHANGED: Rely mostly on luaL_check* functions for arg checking.
- CHANGED: ModelAnimations are changed to separate ModelAnimation types as in Raylib.
DETAILED CHANGES: DETAILED CHANGES:
- CHANGED: GenImageColor now takes Vector2 as size. - CHANGED: GenImageColor now takes Vector2 as size.
@@ -17,6 +18,7 @@ DETAILED CHANGES:
- REMOVED: UnloadFont. - REMOVED: UnloadFont.
- ADDED: LoadFontEx takes also fontChars. - ADDED: LoadFontEx takes also fontChars.
- REMOVED: UnloadWave and UnloadSound. - REMOVED: UnloadWave and UnloadSound.
- REMOVED: UnloadMesh, UnloadMaterial, UnloadModel and UnloadModelAnimations.
------------------------------------------------------------------------ ------------------------------------------------------------------------
Release: ReiLua version 0.5.0 Using Raylib 4.5 Release: ReiLua version 0.5.0 Using Raylib 4.5

View File

@@ -136,5 +136,5 @@ function RL.draw()
camera:endMode3D() camera:endMode3D()
RL.DrawText( 0, "Use keys [Y][R][G][B] to toggle lights", { 10, 10 }, 20, 4, RL.DARKGRAY ) RL.DrawText( RL.defaultFont, "Use keys [Y][R][G][B] to toggle lights", { 10, 10 }, 20, 4, RL.DARKGRAY )
end end

View File

@@ -9,6 +9,7 @@ local TILE_SIZE = 32
local monitor = 0 local monitor = 0
local camera = {} local camera = {}
local groundRenderTexture = -1
local groundTexture = -1 local groundTexture = -1
local tilesetTex = -1 local tilesetTex = -1
local heigthImage = -1 local heigthImage = -1
@@ -47,10 +48,11 @@ function RL.init()
mesh = RL.GenMeshHeightmap( heigthImage, { 16, 4, 16 } ) mesh = RL.GenMeshHeightmap( heigthImage, { 16, 4, 16 } )
tilesetTex = RL.LoadTexture( RL.GetBasePath().."../resources/images/tiles.png" ) tilesetTex = RL.LoadTexture( RL.GetBasePath().."../resources/images/tiles.png" )
groundTexture = RL.LoadRenderTexture( { TILE_SIZE * 16, TILE_SIZE * 16 } ) groundRenderTexture = RL.LoadRenderTexture( { TILE_SIZE * 16, TILE_SIZE * 16 } )
groundTexture = RL.GetRenderTextureTexture( groundRenderTexture )
-- Draw to ground texture. -- Draw to ground texture.
RL.BeginTextureMode( groundTexture ) RL.BeginTextureMode( groundRenderTexture )
for x = 1, 16 do for x = 1, 16 do
for y = 1, 16 do for y = 1, 16 do

View File

@@ -2,10 +2,10 @@
local monitor = 0 local monitor = 0
local camera = -1 local camera = -1
local texture = nil
local material = -1 local material = -1
local model = -1 local model = -1
local animations = -1 local animations = {}
local animationCount = 0
local frame = 0 local frame = 0
local curAnim = 0 local curAnim = 0
local frameCount = 0 local frameCount = 0
@@ -24,12 +24,14 @@ function RL.init()
RL.SetCamera3DTarget( camera, { 0, 0, 0 } ) RL.SetCamera3DTarget( camera, { 0, 0, 0 } )
RL.SetCamera3DUp( camera, { 0, 1, 0 } ) RL.SetCamera3DUp( camera, { 0, 1, 0 } )
texture = RL.LoadTexture( RL.GetBasePath().."../resources/images/monkey_tex.png" )
material = RL.CreateMaterial( { material = RL.CreateMaterial( {
maps = { maps = {
{ {
RL.MATERIAL_MAP_ALBEDO, RL.MATERIAL_MAP_ALBEDO,
{ {
texture = RL.LoadTexture( RL.GetBasePath().."../resources/images/monkey_tex.png" ), texture = texture,
color = RL.WHITE, color = RL.WHITE,
}, },
}, },
@@ -38,21 +40,19 @@ function RL.init()
model = RL.LoadModel( RL.GetBasePath().."../resources/iqm/monkey.iqm" ) model = RL.LoadModel( RL.GetBasePath().."../resources/iqm/monkey.iqm" )
RL.SetModelMaterial( model, 0, material ) RL.SetModelMaterial( model, 0, material )
animations, animationCount = RL.LoadModelAnimations( RL.GetBasePath().."../resources/iqm/monkey.iqm" ) animations = RL.LoadModelAnimations( RL.GetBasePath().."../resources/iqm/monkey.iqm" )
print( "animationCount", animationCount )
end end
function RL.process( delta ) function RL.process( delta )
if RL.IsKeyPressed( RL.KEY_ENTER ) then if RL.IsKeyPressed( RL.KEY_ENTER ) then
curAnim = curAnim + 1 curAnim = curAnim + 1
if animationCount <= curAnim then if #animations <= curAnim then
curAnim = 0 curAnim = 0
end end
frame = 0.0 frame = 0.0
frameCount = RL.GetModelAnimationFrameCount( animations, curAnim ) frameCount = RL.GetModelAnimationFrameCount( animations[ curAnim + 1 ] )
elseif RL.IsKeyPressed( RL.KEY_UP ) then elseif RL.IsKeyPressed( RL.KEY_UP ) then
animSpeed = animSpeed + 5 animSpeed = animSpeed + 5
elseif RL.IsKeyPressed( RL.KEY_DOWN ) then elseif RL.IsKeyPressed( RL.KEY_DOWN ) then
@@ -60,7 +60,7 @@ function RL.process( delta )
end end
if RL.IsKeyDown( RL.KEY_SPACE ) then if RL.IsKeyDown( RL.KEY_SPACE ) then
RL.UpdateModelAnimation( model, animations, curAnim, math.floor( frame ) ) RL.UpdateModelAnimation( model, animations[ curAnim + 1 ], math.floor( frame ) )
frame = frame + animSpeed * delta frame = frame + animSpeed * delta
if frameCount < frame then if frameCount < frame then
@@ -80,7 +80,7 @@ function RL.draw()
RL.DrawModelEx( model, { 0, 0, 0 }, { 1.0, 0.0, 0.0 }, -90.0, { 1.0, 1.0, 1.0 }, RL.WHITE ) RL.DrawModelEx( model, { 0, 0, 0 }, { 1.0, 0.0, 0.0 }, -90.0, { 1.0, 1.0, 1.0 }, RL.WHITE )
RL.EndMode3D() RL.EndMode3D()
RL.DrawText( 0, RL.DrawText( RL.defaultFont,
"Enter: Change animation\ "Enter: Change animation\
Space: Play animation\ Space: Play animation\
Up arrow: Inreace animation speed\ Up arrow: Inreace animation speed\

View File

@@ -55,6 +55,8 @@ function RL.init()
shader = RL.LoadShader( RL.GetBasePath().."../resources/shaders/glsl330/lightmap.vs", shader = RL.LoadShader( RL.GetBasePath().."../resources/shaders/glsl330/lightmap.vs",
RL.GetBasePath().."../resources/shaders/glsl330/lightmap.fs" ) RL.GetBasePath().."../resources/shaders/glsl330/lightmap.fs" )
print( "shader", shader )
local materialData = { local materialData = {
shader = shader, shader = shader,
maps = { maps = {
@@ -77,6 +79,9 @@ function RL.init()
}, },
} }
material = RL.CreateMaterial( materialData ) material = RL.CreateMaterial( materialData )
print( "material", material )
matrix = RL.MatrixMultiply( RL.MatrixIdentity(), RL.MatrixTranslate( { -4, 0, -4 } ) ) matrix = RL.MatrixMultiply( RL.MatrixIdentity(), RL.MatrixTranslate( { -4, 0, -4 } ) )
end end
@@ -102,3 +107,10 @@ function RL.draw()
RL.DrawMesh( mesh, material, matrix ) RL.DrawMesh( mesh, material, matrix )
camera:endMode3D() camera:endMode3D()
end end
function RL.exit()
material = nil
collectgarbage( "collect" )
tileTexture = nil
collectgarbage( "collect" )
end

View File

@@ -32,5 +32,5 @@ end
function RL.draw() function RL.draw()
RL.ClearBackground( RL.RAYWHITE ) RL.ClearBackground( RL.RAYWHITE )
RL.DrawTexture( texture, { 20, 20 }, RL.WHITE ) RL.DrawTexture( texture, { 20, 20 }, RL.WHITE )
RL.DrawText( RL.fontDefault, text, textPos, 20, 2, textColor ) RL.DrawText( RL.defaultFont, text, textPos, 20, 2, textColor )
end end

View File

@@ -79,6 +79,10 @@ void uluaPushWave( lua_State *L, Wave wave );
void uluaPushSound( lua_State *L, Sound sound ); void uluaPushSound( lua_State *L, Sound sound );
void uluaPushMusic( lua_State *L, Music music ); void uluaPushMusic( lua_State *L, Music music );
void uluaPushLight( lua_State *L, Light light ); void uluaPushLight( lua_State *L, Light light );
void uluaPushMaterial( lua_State *L, Material material );
void uluaPushMesh( lua_State *L, Mesh mesh );
void uluaPushModel( lua_State *L, Model model );
void uluaPushModelAnimation( lua_State *L, ModelAnimation modelAnimation );
int uluaGetTableLen( lua_State *L ); int uluaGetTableLen( lua_State *L );
int uluaGetTableLenIndex( lua_State *L, int index ); int uluaGetTableLenIndex( lua_State *L, int index );

View File

@@ -38,7 +38,6 @@ int lmodelsGenMeshKnot( lua_State *L );
int lmodelsGenMeshHeightmap( lua_State *L ); int lmodelsGenMeshHeightmap( lua_State *L );
int lmodelsGenMeshCustom( lua_State *L ); int lmodelsGenMeshCustom( lua_State *L );
int lmodelsUpdateMesh( lua_State *L ); int lmodelsUpdateMesh( lua_State *L );
int lmodelsUnloadMesh( lua_State *L );
int lmodelsDrawMesh( lua_State *L ); int lmodelsDrawMesh( lua_State *L );
int lmodelsDrawMeshInstanced( lua_State *L ); int lmodelsDrawMeshInstanced( lua_State *L );
int lmodelsSetMeshColor( lua_State *L ); int lmodelsSetMeshColor( lua_State *L );
@@ -48,7 +47,6 @@ int lmodelsGenMeshTangents( lua_State *L );
/* Material. */ /* Material. */
int lmodelsLoadMaterialDefault( lua_State *L ); int lmodelsLoadMaterialDefault( lua_State *L );
int lmodelsCreateMaterial( lua_State *L ); int lmodelsCreateMaterial( lua_State *L );
int lmodelsUnloadMaterial( lua_State *L );
int lmodelsSetMaterialTexture( lua_State *L ); int lmodelsSetMaterialTexture( lua_State *L );
int lmodelsSetMaterialColor( lua_State *L ); int lmodelsSetMaterialColor( lua_State *L );
int lmodelsSetMaterialValue( lua_State *L ); int lmodelsSetMaterialValue( lua_State *L );
@@ -62,7 +60,6 @@ int lmodelsGetMaterialParams( lua_State *L );
/* Model. */ /* Model. */
int lmodelsLoadModel( lua_State *L ); int lmodelsLoadModel( lua_State *L );
int lmodelsLoadModelFromMesh( lua_State *L ); int lmodelsLoadModelFromMesh( lua_State *L );
int lmodelsUnloadModel( lua_State *L );
int lmodelsDrawModel( lua_State *L ); int lmodelsDrawModel( lua_State *L );
int lmodelsDrawModelEx( lua_State *L ); int lmodelsDrawModelEx( lua_State *L );
int lmodelsSetModelMaterial( lua_State *L ); int lmodelsSetModelMaterial( lua_State *L );
@@ -75,7 +72,6 @@ int lmodelsGetModelTransform( lua_State *L );
/* Animations. */ /* Animations. */
int lmodelsLoadModelAnimations( lua_State *L ); int lmodelsLoadModelAnimations( lua_State *L );
int lmodelsUpdateModelAnimation( lua_State *L ); int lmodelsUpdateModelAnimation( lua_State *L );
int lmodelsUnloadModelAnimations( lua_State *L );
int lmodelsIsModelAnimationValid( lua_State *L ); int lmodelsIsModelAnimationValid( lua_State *L );
int lmodelsGetModelAnimationBoneCount( lua_State *L ); int lmodelsGetModelAnimationBoneCount( lua_State *L );
int lmodelsGetModelAnimationFrameCount( lua_State *L ); int lmodelsGetModelAnimationFrameCount( lua_State *L );

View File

@@ -2,11 +2,6 @@
#define ALLOC_PAGE_SIZE 256 #define ALLOC_PAGE_SIZE 256
typedef struct {
ModelAnimation *animations;
unsigned int animCount;
} ModelAnimations;
typedef struct { typedef struct {
char *exePath; char *exePath;
bool hasWindow; bool hasWindow;
@@ -14,23 +9,6 @@ typedef struct {
lua_State *luaState; lua_State *luaState;
Vector2 resolution; Vector2 resolution;
int logLevelInvalid; int logLevelInvalid;
/* Resources. */
/* Meshes. */
Mesh **meshes;
size_t meshCount;
size_t meshAlloc;
/* Materials. */
Material **materials;
size_t materialCount;
size_t materialAlloc;
/* Models. */
Model **models;
size_t modelCount;
size_t modelAlloc;
/* ModelAnimations. */
ModelAnimations **animations;
size_t animationCount;
size_t animationAlloc;
/* Raylib GLFW input callback events. */ /* Raylib GLFW input callback events. */
/* Window events. */ /* Window events. */
GLFWwindowsizefun raylibWindowSizeCallback; GLFWwindowsizefun raylibWindowSizeCallback;

View File

@@ -194,7 +194,7 @@ static void defineMusic() {
lua_setfield( L, -2, "__gc" ); lua_setfield( L, -2, "__gc" );
} }
/* Music. */ /* Light. */
static void defineLight() { static void defineLight() {
lua_State *L = state->luaState; lua_State *L = state->luaState;
@@ -203,6 +203,93 @@ static void defineLight() {
lua_setfield( L, -2, "__index" ); lua_setfield( L, -2, "__index" );
} }
/* Material. */
static int gcMaterial( lua_State *L ) {
Material *material = luaL_checkudata ( L, 1, "Material" );
printf( "gcMaterial\n" );
// int MAX_MATERIAL_MAPS = 12;
// Unload loaded texture maps (avoid unloading default texture, managed by raylib)
// if ( material->maps != NULL ) {
// for ( int i = 0; i < MAX_MATERIAL_MAPS; i++ ) {
// if ( material->maps[i].texture.id != rlGetTextureIdDefault() ) {
// printf( "gcMaterial material->maps[i].texture.id = %d\n", material->maps[i].texture.id );
// rlUnloadTexture( material->maps[i].texture.id );
// }
// }
// }
/* Custom UnloadMaterial since we don't want to free Shaders or Textures. */
RL_FREE( material->maps );
}
static void defineMaterial() {
lua_State *L = state->luaState;
luaL_newmetatable( L, "Material" );
lua_pushvalue( L, -1 );
lua_setfield( L, -2, "__index" );
lua_pushcfunction( L, gcMaterial );
lua_setfield( L, -2, "__gc" );
}
/* Mesh. */
static int gcMesh( lua_State *L ) {
Mesh *mesh = luaL_checkudata ( L, 1, "Mesh" );
printf( "gcMesh\n" );
UnloadMesh( *mesh );
}
static void defineMesh() {
lua_State *L = state->luaState;
luaL_newmetatable( L, "Mesh" );
lua_pushvalue( L, -1 );
lua_setfield( L, -2, "__index" );
lua_pushcfunction( L, gcMesh );
lua_setfield( L, -2, "__gc" );
}
/* Model. */
static int gcModel( lua_State *L ) {
Model *model = luaL_checkudata ( L, 1, "Model" );
printf( "gcModel\n" );
UnloadModel( *model );
// UnloadModelKeepMeshes( *model );
}
static void defineModel() {
lua_State *L = state->luaState;
luaL_newmetatable( L, "Model" );
lua_pushvalue( L, -1 );
lua_setfield( L, -2, "__index" );
lua_pushcfunction( L, gcModel );
lua_setfield( L, -2, "__gc" );
}
/* ModelAnimation. */
static int gcModelAnimation( lua_State *L ) {
ModelAnimation *modelAnimation = luaL_checkudata ( L, 1, "ModelAnimation" );
printf( "gcModelAnimation\n" );
UnloadModelAnimation( *modelAnimation );
}
static void defineModelAnimation() {
lua_State *L = state->luaState;
luaL_newmetatable( L, "ModelAnimation" );
lua_pushvalue( L, -1 );
lua_setfield( L, -2, "__index" );
lua_pushcfunction( L, gcModelAnimation );
lua_setfield( L, -2, "__gc" );
}
/* Assing globals. */ /* Assing globals. */
static void assignGlobalInt( int value, const char *name ) { static void assignGlobalInt( int value, const char *name ) {
@@ -243,7 +330,10 @@ static void defineGlobals() {
lua_getglobal( L, "RL" ); lua_getglobal( L, "RL" );
uluaPushFont( L, GetFontDefault() ); uluaPushFont( L, GetFontDefault() );
lua_setfield( L, -2, "fontDefault" ); lua_setfield( L, -2, "defaultFont" );
uluaPushMaterial( L, LoadMaterialDefault() );
lua_setfield( L, -2, "defaultMaterial" );
/*DOC_START*/ /*DOC_START*/
/* ConfigFlags */ /* ConfigFlags */
@@ -1229,6 +1319,10 @@ bool luaInit( int argn, const char **argc ) {
defineSound(); defineSound();
defineMusic(); defineMusic();
defineLight(); defineLight();
defineMaterial();
defineMesh();
defineModel();
defineModelAnimation();
/* Define globals. */ /* Define globals. */
defineGlobals(); defineGlobals();
@@ -1769,7 +1863,6 @@ void luaRegister() {
assingGlobalFunction( "GenMeshHeightmap", lmodelsGenMeshHeightmap ); assingGlobalFunction( "GenMeshHeightmap", lmodelsGenMeshHeightmap );
assingGlobalFunction( "GenMeshCustom", lmodelsGenMeshCustom ); assingGlobalFunction( "GenMeshCustom", lmodelsGenMeshCustom );
assingGlobalFunction( "UpdateMesh", lmodelsUpdateMesh ); assingGlobalFunction( "UpdateMesh", lmodelsUpdateMesh );
assingGlobalFunction( "UnloadMesh", lmodelsUnloadMesh );
assingGlobalFunction( "DrawMesh", lmodelsDrawMesh ); assingGlobalFunction( "DrawMesh", lmodelsDrawMesh );
assingGlobalFunction( "DrawMeshInstanced", lmodelsDrawMeshInstanced ); assingGlobalFunction( "DrawMeshInstanced", lmodelsDrawMeshInstanced );
assingGlobalFunction( "SetMeshColor", lmodelsSetMeshColor ); assingGlobalFunction( "SetMeshColor", lmodelsSetMeshColor );
@@ -1779,7 +1872,6 @@ void luaRegister() {
/* Material. */ /* Material. */
assingGlobalFunction( "LoadMaterialDefault", lmodelsLoadMaterialDefault ); assingGlobalFunction( "LoadMaterialDefault", lmodelsLoadMaterialDefault );
assingGlobalFunction( "CreateMaterial", lmodelsCreateMaterial ); assingGlobalFunction( "CreateMaterial", lmodelsCreateMaterial );
assingGlobalFunction( "UnloadMaterial", lmodelsUnloadMaterial );
assingGlobalFunction( "SetMaterialTexture", lmodelsSetMaterialTexture ); assingGlobalFunction( "SetMaterialTexture", lmodelsSetMaterialTexture );
assingGlobalFunction( "SetMaterialColor", lmodelsSetMaterialColor ); assingGlobalFunction( "SetMaterialColor", lmodelsSetMaterialColor );
assingGlobalFunction( "SetMaterialValue", lmodelsSetMaterialValue ); assingGlobalFunction( "SetMaterialValue", lmodelsSetMaterialValue );
@@ -1793,7 +1885,6 @@ void luaRegister() {
/* Model. */ /* Model. */
assingGlobalFunction( "LoadModel", lmodelsLoadModel ); assingGlobalFunction( "LoadModel", lmodelsLoadModel );
assingGlobalFunction( "LoadModelFromMesh", lmodelsLoadModelFromMesh ); assingGlobalFunction( "LoadModelFromMesh", lmodelsLoadModelFromMesh );
assingGlobalFunction( "UnloadModel", lmodelsUnloadModel );
assingGlobalFunction( "DrawModel", lmodelsDrawModel ); assingGlobalFunction( "DrawModel", lmodelsDrawModel );
assingGlobalFunction( "DrawModelEx", lmodelsDrawModelEx ); assingGlobalFunction( "DrawModelEx", lmodelsDrawModelEx );
assingGlobalFunction( "SetModelMaterial", lmodelsSetModelMaterial ); assingGlobalFunction( "SetModelMaterial", lmodelsSetModelMaterial );
@@ -1806,7 +1897,6 @@ void luaRegister() {
/* Animations. */ /* Animations. */
assingGlobalFunction( "LoadModelAnimations", lmodelsLoadModelAnimations ); assingGlobalFunction( "LoadModelAnimations", lmodelsLoadModelAnimations );
assingGlobalFunction( "UpdateModelAnimation", lmodelsUpdateModelAnimation ); assingGlobalFunction( "UpdateModelAnimation", lmodelsUpdateModelAnimation );
assingGlobalFunction( "UnloadModelAnimations", lmodelsUnloadModelAnimations );
assingGlobalFunction( "IsModelAnimationValid", lmodelsIsModelAnimationValid ); assingGlobalFunction( "IsModelAnimationValid", lmodelsIsModelAnimationValid );
assingGlobalFunction( "GetModelAnimationBoneCount", lmodelsGetModelAnimationBoneCount ); assingGlobalFunction( "GetModelAnimationBoneCount", lmodelsGetModelAnimationBoneCount );
assingGlobalFunction( "GetModelAnimationFrameCount", lmodelsGetModelAnimationFrameCount ); assingGlobalFunction( "GetModelAnimationFrameCount", lmodelsGetModelAnimationFrameCount );
@@ -2988,6 +3078,30 @@ void uluaPushLight( lua_State *L, Light light ) {
luaL_setmetatable( L, "Light" ); luaL_setmetatable( L, "Light" );
} }
void uluaPushMaterial( lua_State *L, Material material ) {
Material *materialP = lua_newuserdata( L, sizeof( Material ) );
*materialP = material;
luaL_setmetatable( L, "Material" );
}
void uluaPushMesh( lua_State *L, Mesh mesh ) {
Mesh *meshP = lua_newuserdata( L, sizeof( Mesh ) );
*meshP = mesh;
luaL_setmetatable( L, "Mesh" );
}
void uluaPushModel( lua_State *L, Model model ) {
Model *modelP = lua_newuserdata( L, sizeof( Model ) );
*modelP = model;
luaL_setmetatable( L, "Model" );
}
void uluaPushModelAnimation( lua_State *L, ModelAnimation modelAnimation ) {
ModelAnimation *modelAnimationP = lua_newuserdata( L, sizeof( ModelAnimation ) );
*modelAnimationP = modelAnimation;
luaL_setmetatable( L, "ModelAnimation" );
}
int uluaGetTableLen( lua_State *L ) { int uluaGetTableLen( lua_State *L ) {
return uluaGetTableLenIndex( L, lua_gettop( L ) ); return uluaGetTableLenIndex( L, lua_gettop( L ) );
} }

File diff suppressed because it is too large Load Diff

View File

@@ -17,37 +17,8 @@ bool stateInit( int argn, const char **argc, const char *exePath ) {
state->resolution = (Vector2){ 800, 600 }; state->resolution = (Vector2){ 800, 600 };
state->luaState = NULL; state->luaState = NULL;
state->logLevelInvalid = LOG_ERROR; state->logLevelInvalid = LOG_ERROR;
/* Meshes. */
state->meshAlloc = ALLOC_PAGE_SIZE;
state->meshCount = 0;
state->meshes = malloc( state->meshAlloc * sizeof( Mesh* ) );
/* Materials. */
state->materialAlloc = ALLOC_PAGE_SIZE;
state->materialCount = 1;
state->materials = malloc( state->materialAlloc * sizeof( Material* ) );
/* Models. */
state->modelAlloc = ALLOC_PAGE_SIZE;
state->modelCount = 0;
state->models = malloc( state->modelAlloc * sizeof( Model* ) );
/* ModelsAnimations. */
state->animationAlloc = ALLOC_PAGE_SIZE;
state->animationCount = 0;
state->animations = malloc( state->animationAlloc * sizeof( ModelAnimations* ) );
for ( int i = 0; i < ALLOC_PAGE_SIZE; i++ ) {
state->meshes[i] = NULL;
state->models[i] = NULL;
state->animations[i] = NULL;
/* The ones we want to save the first. */
if ( 0 < i ) {
state->materials[i] = NULL;
}
}
InitWindow( state->resolution.x, state->resolution.y, "ReiLua" ); InitWindow( state->resolution.x, state->resolution.y, "ReiLua" );
/* Has to be after InitWindod where opengl context is created. */
state->materials[0] = malloc( sizeof( Material ) );
*state->materials[0] = LoadMaterialDefault();
if ( !IsWindowReady() ) { if ( !IsWindowReady() ) {
state->hasWindow = false; state->hasWindow = false;
@@ -67,36 +38,6 @@ void stateInitInterpret( int argn, const char **argc ) {
} }
void stateFree() { void stateFree() {
for ( int i = 0; i < state->modelCount; ++i ) {
if ( state->models[i] != NULL ) {
//TODO Test if UnloadModel causes segfaults on exit.
UnloadModelKeepMeshes( *state->models[i] );
// UnloadModel( *state->models[i] );
free( state->models[i] );
}
}
for ( int i = 0; i < state->meshCount; ++i ) {
if ( state->meshes[i] != NULL ) {
UnloadMesh( *state->meshes[i] );
free( state->meshes[i] );
}
}
for ( int i = 0; i < state->materialCount; ++i ) {
if ( state->materials[i] != NULL ) {
/* Prevent unloading shader that would result in double free when freeing shaders. */
state->materials[i]->shader.id = rlGetShaderIdDefault();
UnloadMaterial( *state->materials[i] );
free( state->materials[i] );
}
}
for ( int i = 0; i < state->animationCount; ++i ) {
if ( state->animations[i] != NULL ) {
UnloadModelAnimations( state->animations[i]->animations, state->animations[i]->animCount );
free( state->animations[i] );
}
}
if ( IsAudioDeviceReady() ) { if ( IsAudioDeviceReady() ) {
CloseAudioDevice(); CloseAudioDevice();
} }
@@ -107,10 +48,6 @@ void stateFree() {
if ( state->hasWindow ) { if ( state->hasWindow ) {
CloseWindow(); CloseWindow();
} }
free( state->meshes );
free( state->materials );
free( state->models );
free( state->animations );
free( state->exePath ); free( state->exePath );
free( state ); free( state );
} }

View File

@@ -40,7 +40,7 @@ int ltextLoadFont( lua_State *L ) {
} }
/* /*
> font = RL.LoadFontEx( string fileName, int fontSize, int fontChars{} ) > font = RL.LoadFontEx( string fileName, int fontSize, int{} fontChars )
Load font from file with extended parameters. Loading the default character set Load font from file with extended parameters. Loading the default character set

View File

@@ -831,35 +831,21 @@ int ltexturesImageDraw( lua_State *L ) {
} }
/* /*
> success = RL.ImageDrawTextEx( Image dst, Font font, string text, Vector2 position, float fontSize, float spacing, Color tint ) > RL.ImageDrawTextEx( Image dst, Font font, string text, Vector2 position, float fontSize, float spacing, Color tint )
Draw text ( Custom sprite font ) within an image ( Destination ) Draw text (Custom sprite font) within an image (Destination)
- Failure return false
- Success return true
*/ */
int ltexturesImageDrawTextEx( lua_State *L ) { int ltexturesImageDrawTextEx( lua_State *L ) {
// if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isstring( L, 3 ) || !lua_istable( L, 4 ) Image *image = luaL_checkudata( L, 1, "Image" );
// || !lua_isnumber( L, 5 ) || !lua_isnumber( L, 6 ) || !lua_istable( L, 7 ) ) { Font *font = luaL_checkudata( L, 2, "Font" );
// TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.ImageDrawTextEx( Image dst, Font font, string text, Vector2 position, float fontSize, float spacing, Color tint )" ); Vector2 position = uluaGetVector2Index( L, 4 );
// lua_pushboolean( L, false ); float fontSize = luaL_checknumber( L, 5 );
// return 1; float spacing = luaL_checknumber( L, 6 );
// } Color tint = uluaGetColorIndex( L, 7 );
// size_t imageId = lua_tointeger( L, 1 );
// size_t fontId = lua_tointeger( L, 2 );
// Vector2 position = uluaGetVector2Index( L, 4 );
// float fontSize = lua_tonumber( L, 5 );
// float spacing = lua_tonumber( L, 6 );
// Color tint = uluaGetColorIndex( L, 7 );
// if ( !validImage( imageId ) || !validFont( fontId ) ) { ImageDrawTextEx( image, *font, luaL_checkstring( L, 3 ), position, fontSize, spacing, tint );
// lua_pushboolean( L, false );
// return 1;
// }
// ImageDrawTextEx( state->images[ imageId ], *state->fonts[ fontId ], lua_tostring( L, 3 ), position, fontSize, spacing, tint );
// lua_pushboolean( L, true );
return 1; return 0;
} }
/* /*