summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorRay <[email protected]>2020-10-31 11:48:44 +0100
committerRay <[email protected]>2020-10-31 11:48:44 +0100
commitfbc51e822be6454ec5c1ff6b6c29c48bc843d123 (patch)
tree7f57ccaad64354bfa1a5135b833d8e782d85506f /examples
parent8a1634813105906e84672d43101009e388ded407 (diff)
downloadraylib-fbc51e822be6454ec5c1ff6b6c29c48bc843d123.tar.gz
raylib-fbc51e822be6454ec5c1ff6b6c29c48bc843d123.zip
REDESIGNED: Multiple sampler2D usage on batch system
New implementation allow enabling additional textures per batch only.
Diffstat (limited to 'examples')
-rw-r--r--examples/shaders/shaders_multi_sample2d.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/examples/shaders/shaders_multi_sample2d.c b/examples/shaders/shaders_multi_sample2d.c
index 31a6af82..efb710aa 100644
--- a/examples/shaders/shaders_multi_sample2d.c
+++ b/examples/shaders/shaders_multi_sample2d.c
@@ -43,9 +43,8 @@ int main(void)
Shader shader = LoadShader(0, TextFormat("resources/shaders/glsl%i/color_mix.fs", GLSL_VERSION));
- // Set an additional sampler2D, using another texture1
- // NOTE: Additional samplers are enabled for all batch calls
- SetShaderValueTexture(shader, GetShaderLocation(shader, "texture1"), texBlue);
+ // Get an additional sampler2D location to be enabled on drawing
+ int texRedLoc = GetShaderLocation(shader, "texture1");
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@@ -66,8 +65,13 @@ int main(void)
BeginShaderMode(shader);
- // We are drawing texture using default sampler2D but
- // but additional texture units will be also enabled
+ // WARNING: Additional samplers are enabled for all draw calls in the batch,
+ // EndShaderMode() forces batch drawing and consequently resets active textures
+ // to let other sampler2D to be activated on consequent drawings (if required)
+ SetShaderValueTexture(shader, texRedLoc, texBlue);
+
+ // We are drawing texRed using default sampler2D texture0 but
+ // an additional texture units is enabled for texBlue (sampler2D texture1)
DrawTexture(texRed, 0, 0, WHITE);
EndShaderMode();