瀏覽代碼

Use a loop to set material textures.

Lasse Öörni 13 年之前
父節點
當前提交
d90dbc0b3f
共有 1 個文件被更改,包括 6 次插入10 次删除
  1. 6 10
      Engine/Graphics/Batch.cpp

+ 6 - 10
Engine/Graphics/Batch.cpp

@@ -597,16 +597,12 @@ void Batch::Prepare(Graphics* graphics, Renderer* renderer, bool setModelTransfo
         }
         
         const SharedPtr<Texture>* textures = material_->GetTextures();
-        if (graphics->HasTextureUnit(TU_DIFFUSE))
-            graphics->SetTexture(TU_DIFFUSE, textures[TU_DIFFUSE]);
-        if (graphics->HasTextureUnit(TU_NORMAL))
-            graphics->SetTexture(TU_NORMAL, textures[TU_NORMAL]);
-        if (graphics->HasTextureUnit(TU_SPECULAR))
-            graphics->SetTexture(TU_SPECULAR, textures[TU_SPECULAR]);
-        if (graphics->HasTextureUnit(TU_EMISSIVE))
-            graphics->SetTexture(TU_EMISSIVE, textures[TU_EMISSIVE]);
-        if (graphics->HasTextureUnit(TU_ENVIRONMENT))
-            graphics->SetTexture(TU_ENVIRONMENT, textures[TU_ENVIRONMENT]);
+        for (unsigned i = 0; i < MAX_MATERIAL_TEXTURE_UNITS; ++i)
+        {
+            TextureUnit unit = (TextureUnit)i;
+            if (graphics->HasTextureUnit(unit))
+                graphics->SetTexture(i, textures[i]);
+        }
     }
     
     // Set light-related textures