ソースを参照

Update shaders_multi_sample2d.c

Ray 1 ヶ月 前
コミット
414235dd17
1 ファイル変更8 行追加6 行削除
  1. 8 6
      examples/shaders/shaders_multi_sample2d.c

+ 8 - 6
examples/shaders/shaders_multi_sample2d.c

@@ -82,16 +82,18 @@ int main(void)
 
             BeginShaderMode(shader);
 
-                // 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)
+                // WARNING: Additional textures (sampler2D) are enabled for ALL draw calls in the batch,
+                // but EndShaderMode() forces batch drawing and resets active textures, this way
+                // other textures (sampler2D) can be activated on consequent drawings (if required)
+                // The downside of this approach is that SetShaderValue() must be called inside the loop,
+                // to be set again after every EndShaderMode() reset
                 SetShaderValueTexture(shader, texBlueLoc, texBlue);
 
-                // We are drawing texRed using default sampler2D texture0 but
-                // an additional texture units is enabled for texBlue (sampler2D texture1)
+                // 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();
+            EndShaderMode(); // Texture sampler2D is reseted, needs to be set again for next frame 
 
             DrawText("Use KEY_LEFT/KEY_RIGHT to move texture mixing in shader!", 80, GetScreenHeight() - 40, 20, RAYWHITE);