summaryrefslogtreecommitdiffhomepage
path: root/examples/shaders/shaders_mesh_instancing.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/shaders/shaders_mesh_instancing.c')
-rw-r--r--examples/shaders/shaders_mesh_instancing.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/examples/shaders/shaders_mesh_instancing.c b/examples/shaders/shaders_mesh_instancing.c
index 520a2d65..290a2948 100644
--- a/examples/shaders/shaders_mesh_instancing.c
+++ b/examples/shaders/shaders_mesh_instancing.c
@@ -56,7 +56,7 @@ int main(void)
camera.fovy = 45.0f;
camera.projection = CAMERA_PERSPECTIVE;
- const int instances = 10000; // Number of instances to display
+ const int instances = 10000; // Number of instances to display
Mesh cube = GenMeshCube(1.0f, 1.0f, 1.0f);
Matrix *rotations = RL_MALLOC(instances*sizeof(Matrix)); // Rotation state of instances
@@ -69,7 +69,7 @@ int main(void)
x = GetRandomValue(-50, 50);
y = GetRandomValue(-50, 50);
z = GetRandomValue(-50, 50);
- translations[i] = MatrixTranslate(x, y, z);
+ translations[i] = MatrixTranslate(x, y, z);
x = GetRandomValue(0, 360);
y = GetRandomValue(0, 360);
@@ -83,7 +83,7 @@ int main(void)
Matrix *transforms = RL_MALLOC(instances*sizeof(Matrix)); // Pre-multiplied transformations passed to rlgl
- Shader shader = LoadShader(TextFormat("resources/shaders/glsl%i/base_lighting_instanced.vs", GLSL_VERSION),
+ Shader shader = LoadShader(TextFormat("resources/shaders/glsl%i/base_lighting_instanced.vs", GLSL_VERSION),
TextFormat("resources/shaders/glsl%i/lighting.fs", GLSL_VERSION));
// Get some shader loactions
@@ -102,7 +102,7 @@ int main(void)
Material material = LoadMaterialDefault();
material.shader = shader;
material.maps[MATERIAL_MAP_DIFFUSE].color = RED;
-
+
SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode
int textPositionY = 300;
@@ -134,10 +134,10 @@ int main(void)
if (IsKeyDown(KEY_EIGHT)) groups = 8;
if (IsKeyDown(KEY_NINE)) groups = 9;
if (IsKeyDown(KEY_W)) { groups = 7; amp = 25; speed = 18; variance = 0.70f; }
-
+
if (IsKeyDown(KEY_EQUAL)) speed = (speed <= (fps*0.25f))? (fps*0.25f) : (speed*0.95f);
if (IsKeyDown(KEY_KP_ADD)) speed = (speed <= (fps*0.25f))? (fps*0.25f) : (speed*0.95f);
-
+
if (IsKeyDown(KEY_MINUS)) speed = fmaxf(speed*1.02f, speed + 1);
if (IsKeyDown(KEY_KP_SUBTRACT)) speed = fmaxf(speed*1.02f, speed + 1);
@@ -150,19 +150,19 @@ int main(void)
{
rotations[i] = MatrixMultiply(rotations[i], rotationsInc[i]);
transforms[i] = MatrixMultiply(rotations[i], translations[i]);
-
+
// Get the animation cycle's framesCounter for this instance
loop = (float)((framesCounter + (int)(((float)(i%groups)/groups)*speed))%speed)/speed;
-
+
// Calculate the y according to loop cycle
y = (sinf(loop*PI*2))*amp*((1 - variance) + (variance*(float)(i%(groups*10))/(groups*10)));
-
+
// Clamp to floor
y = (y < 0)? 0.0f : y;
-
+
transforms[i] = MatrixMultiply(transforms[i], MatrixTranslate(0.0f, y, 0.0f));
}
-
+
UpdateCamera(&camera);
//----------------------------------------------------------------------------------
@@ -179,35 +179,35 @@ int main(void)
DrawText("A CUBE OF DANCING CUBES!", 490, 10, 20, MAROON);
DrawText("PRESS KEYS:", 10, textPositionY, 20, BLACK);
-
- DrawText("1 - 9", 10, textPositionY += 25, 10, BLACK);
+
+ DrawText("1 - 9", 10, textPositionY += 25, 10, BLACK);
DrawText(": Number of groups", 50, textPositionY , 10, BLACK);
DrawText(TextFormat(": %d", groups), 160, textPositionY , 10, BLACK);
-
- DrawText("UP", 10, textPositionY += 15, 10, BLACK);
+
+ DrawText("UP", 10, textPositionY += 15, 10, BLACK);
DrawText(": increase amplitude", 50, textPositionY, 10, BLACK);
DrawText(TextFormat(": %.2f", amp), 160, textPositionY , 10, BLACK);
-
- DrawText("DOWN", 10, textPositionY += 15, 10, BLACK);
+
+ DrawText("DOWN", 10, textPositionY += 15, 10, BLACK);
DrawText(": decrease amplitude", 50, textPositionY, 10, BLACK);
-
- DrawText("LEFT", 10, textPositionY += 15, 10, BLACK);
+
+ DrawText("LEFT", 10, textPositionY += 15, 10, BLACK);
DrawText(": decrease variance", 50, textPositionY, 10, BLACK);
DrawText(TextFormat(": %.2f", variance), 160, textPositionY , 10, BLACK);
-
- DrawText("RIGHT", 10, textPositionY += 15, 10, BLACK);
+
+ DrawText("RIGHT", 10, textPositionY += 15, 10, BLACK);
DrawText(": increase variance", 50, textPositionY, 10, BLACK);
-
- DrawText("+/=", 10, textPositionY += 15, 10, BLACK);
+
+ DrawText("+/=", 10, textPositionY += 15, 10, BLACK);
DrawText(": increase speed", 50, textPositionY, 10, BLACK);
DrawText(TextFormat(": %d = %f loops/sec", speed, ((float)fps / speed)), 160, textPositionY , 10, BLACK);
-
- DrawText("-", 10, textPositionY += 15, 10, BLACK);
+
+ DrawText("-", 10, textPositionY += 15, 10, BLACK);
DrawText(": decrease speed", 50, textPositionY, 10, BLACK);
-
- DrawText("W", 10, textPositionY += 15, 10, BLACK);
+
+ DrawText("W", 10, textPositionY += 15, 10, BLACK);
DrawText(": Wild setup!", 50, textPositionY, 10, BLACK);
-
+
DrawFPS(10, 10);
EndDrawing();