summaryrefslogtreecommitdiffhomepage
path: root/src
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
parent46650b5fb12ea3e350c0a2160d05b895260e87e3 (diff)
downloadraylib-c21baf0d92c9a3ad44d46b698fb87d739dd64dc6.tar.gz
raylib-c21baf0d92c9a3ad44d46b698fb87d739dd64dc6.zip
ADDED: GenMeshDefault() #1556
Diffstat (limited to 'src')
-rw-r--r--src/models.c23
-rw-r--r--src/raylib.h13
-rw-r--r--src/rlgl.h3
3 files changed, 23 insertions, 16 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 };
diff --git a/src/raylib.h b/src/raylib.h
index c6adb2ec..3ad0bd82 100644
--- a/src/raylib.h
+++ b/src/raylib.h
@@ -701,17 +701,6 @@ typedef enum {
GAMEPAD_AXIS_RIGHT_TRIGGER = 5 // [1..-1] (pressure-level)
} GamepadAxis;
-// Mesh vertex attributes
-typedef enum {
- MESH_VERTEX_POSITION = 1,
- MESH_VERTEX_TEXCOORD1 = 2,
- MESH_VERTEX_TEXCOORD2 = 4,
- MESH_VERTEX_NORMAL = 8,
- MESH_VERTEX_TANGENT = 16,
- MESH_VERTEX_COLOR = 32,
- MESH_VERTEX_INDEX = 64
-} MeshVertexAttributes;
-
// Material map index
typedef enum {
MATERIAL_MAP_ALBEDO = 0, // MATERIAL_MAP_DIFFUSE
@@ -1398,7 +1387,7 @@ RLAPI void UnloadModelAnimations(ModelAnimation* animations, unsigned int count)
RLAPI bool IsModelAnimationValid(Model model, ModelAnimation anim); // Check model animation skeleton match
// Mesh generation functions
-RLAPI Mesh GenMeshCustom(int vertexCount, int flags); // Generate custom empty mesh (data initialized to 0)
+RLAPI Mesh GenMeshDefault(int vertexCount); // Generate an empty mesh with vertex: position, texcoords, normals, colors
RLAPI Mesh GenMeshPoly(int sides, float radius); // Generate polygonal mesh
RLAPI Mesh GenMeshPlane(float width, float length, int resX, int resZ); // Generate plane mesh (with subdivisions)
RLAPI Mesh GenMeshCube(float width, float height, float length); // Generate cuboid mesh
diff --git a/src/rlgl.h b/src/rlgl.h
index f6de9ec2..571ebeb9 100644
--- a/src/rlgl.h
+++ b/src/rlgl.h
@@ -92,7 +92,7 @@
#define RL_FREE(p) free(p)
#endif
#else
- #include "raylib.h" // Required for: Model, Mesh, Material, Shader, Texture2D
+ #include "raylib.h" // Required for: Shader, Texture2D
#endif
#include "raymath.h" // Required for: Vector3, Matrix
@@ -2772,7 +2772,6 @@ void rlUnloadTexture(unsigned int id)
glDeleteTextures(1, &id);
}
-
// Generate mipmap data for selected texture
void rlGenerateMipmaps(Texture2D *texture)
{