Formatting review and examples review

This commit is contained in:
Ray 2025-01-12 18:02:36 +01:00
parent 4bceddd4de
commit 2f6230e366
16 changed files with 30 additions and 125 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

View file

@ -112,7 +112,7 @@ int main(void)
DrawRectangleLines(30, 400, 310, 30, Fade(DARKBLUE, 0.5f));
DrawText("MOUSE LEFT BUTTON to CYCLE PROCEDURAL MODELS", 40, 410, 10, BLUE);
switch(currentModel)
switch (currentModel)
{
case 0: DrawText("PLANE", 680, 10, 20, DARKBLUE); break;
case 1: DrawText("CUBE", 680, 10, 20, DARKBLUE); break;

View file

@ -22,7 +22,7 @@
#define MIN_POINTS 1000 // 1 thousand
// Generate mesh using points
Mesh GenMeshPoints(int numPoints);
static Mesh GenMeshPoints(int numPoints);
//------------------------------------------------------------------------------------
// Program main entry point
@ -56,7 +56,7 @@ int main()
//--------------------------------------------------------------------------------------
// Main game loop
while(!WindowShouldClose())
while (!WindowShouldClose())
{
// Update
//----------------------------------------------------------------------------------
@ -147,7 +147,7 @@ int main()
}
// Generate a spherical point cloud
Mesh GenMeshPoints(int numPoints)
static Mesh GenMeshPoints(int numPoints)
{
Mesh mesh = {
.triangleCount = 1,
@ -159,9 +159,9 @@ Mesh GenMeshPoints(int numPoints)
// https://en.wikipedia.org/wiki/Spherical_coordinate_system
for (int i = 0; i < numPoints; i++)
{
float theta = PI*rand()/RAND_MAX;
float phi = 2.0f*PI*rand()/RAND_MAX;
float r = 10.0f*rand()/RAND_MAX;
float theta = ((float)PI*rand())/RAND_MAX;
float phi = (2.0f*PI*rand())/RAND_MAX;
float r = (10.0f*rand())/RAND_MAX;
mesh.vertices[i*3 + 0] = r*sin(theta)*cos(phi);
mesh.vertices[i*3 + 1] = r*sin(theta)*sin(phi);

View file

@ -74,7 +74,7 @@ int main(void)
// Projection from XYZW to XYZ from perspective point (0, 0, 0, 3)
// NOTE: Trace a ray from (0, 0, 0, 3) > p and continue until W = 0
float c = 3/(3 - p.w);
float c = 3.0f/(3.0f - p.w);
p.x = c * p.x;
p.y = c * p.y;
p.z = c * p.z;
@ -95,7 +95,7 @@ int main(void)
for (int i = 0; i < 16; i++)
{
// Draw spheres to indicate the W value
DrawSphere(transformed[i], fabsf(wValues[i]*0.1), RED);
DrawSphere(transformed[i], fabsf(wValues[i]*0.1f), RED);
for (int j = 0; j < 16; j++)
{