summaryrefslogtreecommitdiffhomepage
path: root/examples/shaders/shaders_multi_sample2d.c
diff options
context:
space:
mode:
authorRay <[email protected]>2021-03-17 19:03:51 +0100
committerRay <[email protected]>2021-03-17 19:03:51 +0100
commitff6d5c8ddbc3e49ee24a077086df5b2d6af52a5e (patch)
tree59cf266498981f4ac84ac16967a15532e05e9c42 /examples/shaders/shaders_multi_sample2d.c
parentaba69146f2eb4cb4bcd511f508cd702bfb81577b (diff)
downloadraylib-ff6d5c8ddbc3e49ee24a077086df5b2d6af52a5e.tar.gz
raylib-ff6d5c8ddbc3e49ee24a077086df5b2d6af52a5e.zip
REVIEWED: shaders_multi_sample2d
Diffstat (limited to 'examples/shaders/shaders_multi_sample2d.c')
-rw-r--r--examples/shaders/shaders_multi_sample2d.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/examples/shaders/shaders_multi_sample2d.c b/examples/shaders/shaders_multi_sample2d.c
index 2e545981..2ff6f200 100644
--- a/examples/shaders/shaders_multi_sample2d.c
+++ b/examples/shaders/shaders_multi_sample2d.c
@@ -45,6 +45,10 @@ int main(void)
// Get an additional sampler2D location to be enabled on drawing
int texBlueLoc = GetShaderLocation(shader, "texture1");
+
+ // Get shader uniform for divider
+ int dividerLoc = GetShaderLocation(shader, "divider");
+ float dividerValue = 0.5f;
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@@ -54,7 +58,13 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
- // ...
+ if (IsKeyDown(KEY_RIGHT)) dividerValue += 0.01f;
+ else if (IsKeyDown(KEY_LEFT)) dividerValue -= 0.01f;
+
+ if (dividerValue < 0.0f) dividerValue = 0.0f;
+ else if (dividerValue > 1.0f) dividerValue = 1.0f;
+
+ SetShaderValue(shader, dividerLoc, &dividerValue, SHADER_UNIFORM_FLOAT);
//----------------------------------------------------------------------------------
// Draw
@@ -75,6 +85,8 @@ int main(void)
DrawTexture(texRed, 0, 0, WHITE);
EndShaderMode();
+
+ DrawText("Use KEY_LEFT/KEY_RIGHT to move texture mixing in shader!", 80, GetScreenHeight() - 40, 20, RAYWHITE);
EndDrawing();
//----------------------------------------------------------------------------------