3D shapes, models, meshes, materials and animation. 73 functions, from raylib's rmodels.
Basic geometric 3D shapes drawing functions
Draw a line in 3D world space
Zigfn drawLine3D(startPos: Vector3, endPos: Vector3, color: Color) void
Cvoid DrawLine3D(Vector3 startPos, Vector3 endPos, Color color);
Used in textures_framebuffer_rendering, models_mesh_picking, models_loading_m3d, models_tesseract_view.
Draw a point in 3D space, actually a small line
Zigfn drawPoint3D(position: Vector3, color: Color) void
Cvoid DrawPoint3D(Vector3 position, Color color);
Used in models_point_rendering.
Draw a circle in 3D world space
Zigfn drawCircle3D(center: Vector3, radius: f32, rotationAxis: Vector3, rotationAngle: f32, color: Color) void
Cvoid DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, float rotationAngle, Color color);
Used in models_rlgl_solar_system.
Draw a color-filled triangle, counter-clockwise vertex order
Zigfn drawTriangle3D(v1: Vector3, v2: Vector3, v3: Vector3, color: Color) void
Cvoid DrawTriangle3D(Vector3 v1, Vector3 v2, Vector3 v3, Color color);
Draw a triangle strip defined by points
Zigfn drawTriangleStrip3D(points: []const Vector3, color: Color) void
Cvoid DrawTriangleStrip3D(const Vector3 *points, int pointCount, Color color);
Draw cube
Zigfn drawCube(position: Vector3, width: f32, height: f32, length: f32, color: Color) void
Cvoid DrawCube(Vector3 position, float width, float height, float length, Color color);
Used in core_3d_camera_mode, core_3d_camera_free, core_3d_camera_first_person, core_3d_camera_split_screen, core_3d_picking, core_world_screen and 10 more.
Draw cube (Vector version)
Zigfn drawCubeV(position: Vector3, size: Vector3, color: Color) void
Cvoid DrawCubeV(Vector3 position, Vector3 size, Color color);
Used in core_3d_camera_fps, text_3d_drawing, models_box_collisions, shaders_hybrid_rendering, shaders_depth_writing.
Draw cube wires
Zigfn drawCubeWires(position: Vector3, width: f32, height: f32, length: f32, color: Color) void
Cvoid DrawCubeWires(Vector3 position, float width, float height, float length, Color color);
Used in core_3d_camera_mode, core_3d_camera_free, core_3d_camera_first_person, core_3d_picking, core_world_screen, core_vr_simulator and 8 more.
Draw cube wires (Vector version)
Zigfn drawCubeWiresV(position: Vector3, size: Vector3, color: Color) void
Cvoid DrawCubeWiresV(Vector3 position, Vector3 size, Color color);
Used in core_3d_camera_fps, text_3d_drawing, shaders_hybrid_rendering, shaders_depth_writing.
Draw sphere
Zigfn drawSphere(centerPos: Vector3, radius: f32, color: Color) void
Cvoid DrawSphere(Vector3 centerPos, float radius, Color color);
Used in core_3d_camera_fps, textures_portal_window, models_box_collisions, models_geometric_shapes, models_orthographic_projection, models_tesseract_view and 2 more.
Draw sphere with defined rings and slices
Zigfn drawSphereEx(centerPos: Vector3, radius: f32, rings: i32, slices: i32, color: Color) void
Cvoid DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color color);
Used in models_loading_vox, shaders_basic_lighting, shaders_deferred_rendering, shaders_basic_pbr, shaders_cel_shading.
Draw sphere wires
Zigfn drawSphereWires(centerPos: Vector3, radius: f32, rings: i32, slices: i32, color: Color) void
Cvoid DrawSphereWires(Vector3 centerPos, float radius, int rings, int slices, Color color);
Used in textures_portal_window, models_box_collisions, models_geometric_shapes, models_mesh_picking, models_loading_vox, models_orthographic_projection and 5 more.
Draw a cylinder/cone
Zigfn drawCylinder(position: Vector3, radiusTop: f32, radiusBottom: f32, height: f32, sides: i32, color: Color) void
Cvoid DrawCylinder(Vector3 position, float radiusTop, float radiusBottom, float height, int sides, Color color);
Used in models_geometric_shapes, models_orthographic_projection.
Draw a cylinder with base at startPos and top at endPos
Zigfn drawCylinderEx(startPos: Vector3, endPos: Vector3, startRadius: f32, endRadius: f32, sides: i32, color: Color) void
Cvoid DrawCylinderEx(Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color color);
Draw a cylinder/cone wires
Zigfn drawCylinderWires(position: Vector3, radiusTop: f32, radiusBottom: f32, height: f32, sides: i32, color: Color) void
Cvoid DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, float height, int sides, Color color);
Used in models_geometric_shapes, models_orthographic_projection.
Draw a cylinder wires with base at startPos and top at endPos
Zigfn drawCylinderWiresEx(startPos: Vector3, endPos: Vector3, startRadius: f32, endRadius: f32, sides: i32, color: Color) void
Cvoid DrawCylinderWiresEx(Vector3 startPos, Vector3 endPos, float startRadius, float endRadius, int sides, Color color);
Draw a capsule with the center of its sphere caps at startPos and endPos
Zigfn drawCapsule(startPos: Vector3, endPos: Vector3, radius: f32, rings: i32, slices: i32, color: Color) void
Cvoid DrawCapsule(Vector3 startPos, Vector3 endPos, float radius, int rings, int slices, Color color);
Used in models_geometric_shapes.
Draw capsule wireframe with the center of its sphere caps at startPos and endPos
Zigfn drawCapsuleWires(startPos: Vector3, endPos: Vector3, radius: f32, rings: i32, slices: i32, color: Color) void
Cvoid DrawCapsuleWires(Vector3 startPos, Vector3 endPos, float radius, int rings, int slices, Color color);
Used in models_geometric_shapes.
Draw a plane XZ
Zigfn drawPlane(centerPos: Vector3, size: Vector2, color: Color) void
Cvoid DrawPlane(Vector3 centerPos, Vector2 size, Color color);
Used in core_3d_camera_first_person, core_3d_camera_split_screen, core_3d_camera_fps, shaders_basic_lighting.
Draw a ray line
Zigfn drawRay(ray: Ray, color: Color) void
Cvoid DrawRay(Ray ray, Color color);
Used in core_3d_picking, models_mesh_picking.
Draw a grid (centered at (0, 0, 0))
Zigfn drawGrid(slices: i32, spacing: f32) void
Cvoid DrawGrid(int slices, float spacing);
Used in core_2d_camera_mouse_zoom, core_3d_camera_mode, core_3d_camera_free, core_3d_picking, core_world_screen, core_vr_simulator and 42 more.
Model drawing functions
Draw a model (with texture if set)
Zigfn drawModel(model: Model, position: Vector3, scale: f32, tint: Color) void
Cvoid DrawModel(Model model, Vector3 position, float scale, Color tint);
Used in models_cubicmap_rendering, models_first_person_maze, models_mesh_generation, models_mesh_picking, models_loading, models_loading_gltf and 27 more.
Draw a model with custom transform
Zigfn drawModelEx(model: Model, position: Vector3, rotationAxis: Vector3, rotationAngle: f32, scale: Vector3, tint: Color) void
Cvoid DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint);
Used in models_loading_iqm, models_point_rendering, models_rotating_cube, shaders_simple_mask, shaders_deferred_rendering, shaders_shadowmap_rendering.
Draw a model wires (with texture if set)
Zigfn drawModelWires(model: Model, position: Vector3, scale: f32, tint: Color) void
Cvoid DrawModelWires(Model model, Vector3 position, float scale, Color tint);
Draw a model wires with custom transform
Zigfn drawModelWiresEx(model: Model, position: Vector3, rotationAxis: Vector3, rotationAngle: f32, scale: Vector3, tint: Color) void
Cvoid DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis, float rotationAngle, Vector3 scale, Color tint);
Draw bounding box (wires)
Zigfn drawBoundingBox(box: BoundingBox, color: Color) void
Cvoid DrawBoundingBox(BoundingBox box, Color color);
Used in models_mesh_picking, models_loading.
Draw a billboard texture
Zigfn drawBillboard(camera: Camera, texture: Texture2D, position: Vector3, scale: f32, tint: Color) void
Cvoid DrawBillboard(Camera camera, Texture2D texture, Vector3 position, float scale, Color tint);
Used in models_billboard_rendering.
Draw a billboard texture defined by rectangle
Zigfn drawBillboardRec(camera: Camera, texture: Texture2D, rec: Rectangle, position: Vector3, size: Vector2, tint: Color) void
Cvoid DrawBillboardRec(Camera camera, Texture2D texture, Rectangle rec, Vector3 position, Vector2 size, Color tint);
Draw a billboard texture defined by source rectangle with scaling and rotation
Zigfn drawBillboardPro(camera: Camera, texture: Texture2D, rec: Rectangle, position: Vector3, up: Vector3, size: Vector2, origin: Vector2, rotation: f32, tint: Color) void
Cvoid DrawBillboardPro(Camera camera, Texture2D texture, Rectangle rec, Vector3 position, Vector3 up, Vector2 size, Vector2 origin, float rotation, Color tint);
Used in models_billboard_rendering, models_directional_billboard.
Mesh management functions
Upload mesh vertex data in GPU and provide VAO/VBO ids
Zigfn uploadMesh(mesh: *Mesh, dynamic: bool) void
Cvoid UploadMesh(Mesh *mesh, bool dynamic);
Used in models_mesh_generation, models_point_rendering, models_decals, models_procedural_decals.
Update mesh vertex data in GPU for a specific buffer index
Zigfn updateMeshBuffer(mesh: Mesh, index: i32, data: []const u8, offset: i32) void
Cvoid UpdateMeshBuffer(Mesh mesh, int index, const void *data, int dataSize, int offset);
Unload mesh data from CPU and GPU
Zigfn unloadMesh(mesh: Mesh) void
Cvoid UnloadMesh(Mesh mesh);
Used in shaders_mesh_instancing, shaders_lightmap_rendering.
Draw a 3d mesh with material and transform
Zigfn drawMesh(mesh: Mesh, material: Material, transform: Matrix) void
Cvoid DrawMesh(Mesh mesh, Material material, Matrix transform);
Used in models_bone_socket, shaders_mesh_instancing, shaders_lightmap_rendering.
Draw multiple mesh instances with material and different transforms
Zigfn drawMeshInstanced(mesh: Mesh, material: Material, transforms: []const Matrix) void
Cvoid DrawMeshInstanced(Mesh mesh, Material material, const Matrix *transforms, int instances);
Used in shaders_mesh_instancing.
Compute mesh bounding box limits
Zigfn getMeshBoundingBox(mesh: Mesh) BoundingBox
CBoundingBox GetMeshBoundingBox(Mesh mesh);
Used in models_mesh_picking, models_loading, models_decals, models_mesh_uv_painting, models_procedural_decals.
Compute mesh tangents
Zigfn genMeshTangents(mesh: *Mesh) void
Cvoid GenMeshTangents(Mesh *mesh);
Used in shaders_basic_pbr.
Export mesh data to file, returns true on success
Zigfn exportMesh(mesh: Mesh, fileName: [:0]const u8) bool
Cbool ExportMesh(Mesh mesh, const char *fileName);
Export mesh as code file (.h) defining multiple arrays of vertex attributes
Zigfn exportMeshAsCode(mesh: Mesh, fileName: [:0]const u8) bool
Cbool ExportMeshAsCode(Mesh mesh, const char *fileName);
Mesh generation functions
Generate polygonal mesh
Zigfn genMeshPoly(sides: i32, radius: f32) Mesh
CMesh GenMeshPoly(int sides, float radius);
Used in models_mesh_generation.
Generate plane mesh (with subdivisions)
Zigfn genMeshPlane(width: f32, length: f32, resX: i32, resZ: i32) Mesh
CMesh GenMeshPlane(float width, float length, int resX, int resZ);
Used in models_mesh_generation, shaders_deferred_rendering, shaders_vertex_displacement, shaders_basic_pbr, shaders_lightmap_rendering, shaders_depth_rendering and 1 more.
Generate cuboid mesh
Zigfn genMeshCube(width: f32, height: f32, length: f32) Mesh
CMesh GenMeshCube(float width, float height, float length);
Used in models_mesh_generation, models_skybox_rendering, models_basic_voxel, models_rotating_cube, models_decals, models_mesh_uv_painting and 9 more.
Generate sphere mesh (standard sphere)
Zigfn genMeshSphere(radius: f32, rings: i32, slices: i32) Mesh
CMesh GenMeshSphere(float radius, int rings, int slices);
Used in models_mesh_generation, models_mesh_uv_painting, shaders_fog_rendering, shaders_simple_mask.
Generate half-sphere mesh (no bottom cap)
Zigfn genMeshHemiSphere(radius: f32, rings: i32, slices: i32) Mesh
CMesh GenMeshHemiSphere(float radius, int rings, int slices);
Used in models_mesh_generation.
Generate cylinder mesh
Zigfn genMeshCylinder(radius: f32, height: f32, slices: i32) Mesh
CMesh GenMeshCylinder(float radius, float height, int slices);
Used in models_mesh_generation, models_mesh_uv_painting.
Generate cone/pyramid mesh
Zigfn genMeshCone(radius: f32, height: f32, slices: i32) Mesh
CMesh GenMeshCone(float radius, float height, int slices);
Generate torus mesh
Zigfn genMeshTorus(radius: f32, size: f32, radSeg: i32, sides: i32) Mesh
CMesh GenMeshTorus(float radius, float size, int radSeg, int sides);
Used in models_mesh_generation, models_mesh_uv_painting, models_procedural_decals, shaders_fog_rendering, shaders_simple_mask.
Generate trefoil knot mesh
Zigfn genMeshKnot(radius: f32, size: f32, radSeg: i32, sides: i32) Mesh
CMesh GenMeshKnot(float radius, float size, int radSeg, int sides);
Used in models_mesh_generation.
Generate heightmap mesh from image data
Zigfn genMeshHeightmap(heightmap: Image, size: Vector3) Mesh
CMesh GenMeshHeightmap(Image heightmap, Vector3 size);
Used in models_heightmap_rendering.
Generate cubes-based map mesh from image data
Zigfn genMeshCubicmap(cubicmap: Image, cubeSize: Vector3) Mesh
CMesh GenMeshCubicmap(Image cubicmap, Vector3 cubeSize);
Used in models_cubicmap_rendering, models_first_person_maze.
Material loading/unloading functions
Load materials from model file
Load materials from model file. Free each with `unloadMaterial`, then the array with `memFree`.
Zigfn loadMaterials(fileName: [:0]const u8) error{LoadFailed}![]Material
CMaterial *LoadMaterials(const char *fileName, int *materialCount);
Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps)
Zigfn loadMaterialDefault() Material
CMaterial LoadMaterialDefault(void);
Used in models_decals, models_procedural_decals, shaders_mesh_instancing, shaders_lightmap_rendering.
Check if material is valid (shader assigned, map textures loaded in GPU)
Zigfn isMaterialValid(material: Material) bool
Cbool IsMaterialValid(Material material);
Unload material from GPU memory (VRAM)
Zigfn unloadMaterial(material: Material) void
Cvoid UnloadMaterial(Material material);
Used in models_decals, models_procedural_decals, shaders_mesh_instancing, shaders_basic_pbr.
Set texture for a material map type (MATERIAL_MAP_DIFFUSE, MATERIAL_MAP_SPECULAR...)
Zigfn setMaterialTexture(material: *Material, mapType: MaterialMapIndex, texture: Texture2D) void
Cvoid SetMaterialTexture(Material *material, int mapType, Texture2D texture);
Used in models_loading_iqm.
Set material for a mesh
Zigfn setModelMeshMaterial(model: *Model, meshId: i32, materialId: i32) void
Cvoid SetModelMeshMaterial(Model *model, int meshId, int materialId);
Model animations loading/unloading functions
Load model animations from file
Load model animations from file. Free with `unloadModelAnimations`.
Zigfn loadModelAnimations(fileName: [:0]const u8) error{LoadFailed}![]ModelAnimation
CModelAnimation *LoadModelAnimations(const char *fileName, int *animCount);
Used in models_loading_iqm, models_loading_gltf, models_loading_m3d, models_animation_gpu_skinning, models_bone_socket, models_animation_blend_custom and 3 more.
Update model animation pose (vertex buffers and bone matrices)
Zigfn updateModelAnimation(model: Model, anim: ModelAnimation, frame: f32) void
Cvoid UpdateModelAnimation(Model model, ModelAnimation anim, float frame);
Used in models_loading_iqm, models_loading_gltf, models_loading_m3d, models_animation_gpu_skinning, models_bone_socket, models_animation_blending and 2 more.
Update model animation pose, blending two animations
Zigfn updateModelAnimationEx(model: Model, animA: ModelAnimation, frameA: f32, animB: ModelAnimation, frameB: f32, blend: f32) void
Cvoid UpdateModelAnimationEx(Model model, ModelAnimation animA, float frameA, ModelAnimation animB, float frameB, float blend);
Used in models_animation_blend_custom, models_animation_blending.
Unload animation array data
Zigfn unloadModelAnimations(animations: []ModelAnimation) void
Cvoid UnloadModelAnimations(ModelAnimation *animations, int animCount);
Used in models_loading_iqm, models_loading_gltf, models_loading_m3d, models_animation_gpu_skinning, models_bone_socket, models_animation_blend_custom and 3 more.
Check model animation skeleton match
Zigfn isModelAnimationValid(model: Model, anim: ModelAnimation) bool
Cbool IsModelAnimationValid(Model model, ModelAnimation anim);
Collision detection functions
Check collision between two spheres
Zigfn checkCollisionSpheres(center1: Vector3, radius1: f32, center2: Vector3, radius2: f32) bool
Cbool CheckCollisionSpheres(Vector3 center1, float radius1, Vector3 center2, float radius2);
Check collision between two bounding boxes
Zigfn checkCollisionBoxes(box1: BoundingBox, box2: BoundingBox) bool
Cbool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2);
Used in models_box_collisions.
Check collision between box and sphere
Zigfn checkCollisionBoxSphere(box: BoundingBox, center: Vector3, radius: f32) bool
Cbool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius);
Used in models_box_collisions.
Get collision info between ray and sphere
Zigfn getRayCollisionSphere(ray: Ray, center: Vector3, radius: f32) RayCollision
CRayCollision GetRayCollisionSphere(Ray ray, Vector3 center, float radius);
Used in models_mesh_picking.
Get collision info between ray and box
Zigfn getRayCollisionBox(ray: Ray, box: BoundingBox) RayCollision
CRayCollision GetRayCollisionBox(Ray ray, BoundingBox box);
Used in core_3d_picking, text_3d_drawing, models_mesh_picking, models_loading, models_basic_voxel, models_decals and 2 more.
Get collision info between ray and mesh
Zigfn getRayCollisionMesh(ray: Ray, mesh: Mesh, transform: Matrix) RayCollision
CRayCollision GetRayCollisionMesh(Ray ray, Mesh mesh, Matrix transform);
Used in models_mesh_picking, models_decals, models_procedural_decals.
Get collision info between ray and triangle
Zigfn getRayCollisionTriangle(ray: Ray, p1: Vector3, p2: Vector3, p3: Vector3) RayCollision
CRayCollision GetRayCollisionTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3);
Used in models_mesh_picking, models_mesh_uv_painting.
Get collision info between ray and quad
Zigfn getRayCollisionQuad(ray: Ray, p1: Vector3, p2: Vector3, p3: Vector3, p4: Vector3) RayCollision
CRayCollision GetRayCollisionQuad(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4);
Used in models_mesh_picking.