summaryrefslogtreecommitdiffhomepage
path: root/src/models.c
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2021-04-02 15:56:35 +0200
committerraysan5 <[email protected]>2021-04-02 15:56:35 +0200
commitc21baf0d92c9a3ad44d46b698fb87d739dd64dc6 (patch)
tree2b80d64e8bcf576986433a643afcac9c4f1a2b21 /src/models.c
parent46650b5fb12ea3e350c0a2160d05b895260e87e3 (diff)
downloadraylib-c21baf0d92c9a3ad44d46b698fb87d739dd64dc6.tar.gz
raylib-c21baf0d92c9a3ad44d46b698fb87d739dd64dc6.zip
ADDED: GenMeshDefault() #1556
Diffstat (limited to 'src/models.c')
-rw-r--r--src/models.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/models.c b/src/models.c
index ec7e5f86..3d667944 100644
--- a/src/models.c
+++ b/src/models.c
@@ -1501,6 +1501,25 @@ bool IsModelAnimationValid(Model model, ModelAnimation anim)
}
#if defined(SUPPORT_MESH_GENERATION)
+Mesh GenMeshDefault(int vertexCount)
+{
+ Mesh mesh = { 0 };
+
+ mesh.vertexCount = vertexCount;
+ mesh.triangleCount = vertexCount/3;
+
+ mesh.vertices = (float *)RL_CALLOC(mesh.vertexCount*3, sizeof(float));
+ mesh.texcoords = (float *)RL_CALLOC(mesh.vertexCount*2, sizeof(float));
+ mesh.normals = (float *)RL_CALLOC(mesh.vertexCount*3, sizeof(float));
+ mesh.colors = (unsigned char *)RL_CALLOC(mesh.vertexCount*4, sizeof(unsigned char));
+
+ // Upload vertex data to GPU (static mesh)
+ // NOTE: mesh.vboId array is allocated inside UploadMesh()
+ UploadMesh(&mesh, false);
+
+ return mesh;
+}
+
// Generate polygonal mesh
Mesh GenMeshPoly(int sides, float radius)
{
@@ -1869,7 +1888,7 @@ par_shapes_mesh* par_shapes_create_icosahedron(); // 20 sides polyhedron
}
// Generate sphere mesh (standard sphere)
-RLAPI Mesh GenMeshSphere(float radius, int rings, int slices)
+Mesh GenMeshSphere(float radius, int rings, int slices)
{
Mesh mesh = { 0 };
@@ -1911,7 +1930,7 @@ RLAPI Mesh GenMeshSphere(float radius, int rings, int slices)
}
// Generate hemi-sphere mesh (half sphere, no bottom cap)
-RLAPI Mesh GenMeshHemiSphere(float radius, int rings, int slices)
+Mesh GenMeshHemiSphere(float radius, int rings, int slices)
{
Mesh mesh = { 0 };