Commit c655c310 authored by Pavel Rojtberg's avatar Pavel Rojtberg

ovis: allow up to 4 active texture units

parent f7e522a1
...@@ -35,7 +35,11 @@ enum MaterialProperty ...@@ -35,7 +35,11 @@ enum MaterialProperty
MATERIAL_POINT_SIZE, MATERIAL_POINT_SIZE,
MATERIAL_OPACITY, MATERIAL_OPACITY,
MATERIAL_EMISSIVE, MATERIAL_EMISSIVE,
MATERIAL_TEXTURE MATERIAL_TEXTURE0,
MATERIAL_TEXTURE = MATERIAL_TEXTURE0,
MATERIAL_TEXTURE1,
MATERIAL_TEXTURE2,
MATERIAL_TEXTURE3,
}; };
enum EntityProperty enum EntityProperty
......
...@@ -717,20 +717,23 @@ void setMaterialProperty(const String& name, int prop, const Scalar& val) ...@@ -717,20 +717,23 @@ void setMaterialProperty(const String& name, int prop, const Scalar& val)
void setMaterialProperty(const String& name, int prop, const String& value) void setMaterialProperty(const String& name, int prop, const String& value)
{ {
CV_Assert(prop == MATERIAL_TEXTURE, _app); CV_Assert(prop >= MATERIAL_TEXTURE0, prop <= MATERIAL_TEXTURE3, _app);
MaterialPtr mat = MaterialManager::getSingleton().getByName(name, RESOURCEGROUP_NAME); MaterialPtr mat = MaterialManager::getSingleton().getByName(name, RESOURCEGROUP_NAME);
CV_Assert(mat); CV_Assert(mat);
Pass* rpass = mat->getTechniques()[0]->getPasses()[0]; Pass* rpass = mat->getTechniques()[0]->getPasses()[0];
if (rpass->getTextureUnitStates().empty()) size_t texUnit = prop - MATERIAL_TEXTURE0;
CV_Assert(texUnit <= rpass->getTextureUnitStates().size());
if (rpass->getTextureUnitStates().size() <= texUnit)
{ {
rpass->createTextureUnitState(value); rpass->createTextureUnitState(value);
return; return;
} }
rpass->getTextureUnitStates()[0]->setTextureName(value); rpass->getTextureUnitStates()[texUnit]->setTextureName(value);
} }
static bool setShaderProperty(const GpuProgramParametersSharedPtr& params, const String& prop, static bool setShaderProperty(const GpuProgramParametersSharedPtr& params, const String& prop,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment