Skip to content

Commit c655c31

Browse files
committed
ovis: allow up to 4 active texture units
1 parent f7e522a commit c655c31

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

modules/ovis/include/opencv2/ovis.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ enum MaterialProperty
3535
MATERIAL_POINT_SIZE,
3636
MATERIAL_OPACITY,
3737
MATERIAL_EMISSIVE,
38-
MATERIAL_TEXTURE
38+
MATERIAL_TEXTURE0,
39+
MATERIAL_TEXTURE = MATERIAL_TEXTURE0,
40+
MATERIAL_TEXTURE1,
41+
MATERIAL_TEXTURE2,
42+
MATERIAL_TEXTURE3,
3943
};
4044

4145
enum EntityProperty

modules/ovis/src/ovis.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -717,20 +717,23 @@ void setMaterialProperty(const String& name, int prop, const Scalar& val)
717717

718718
void setMaterialProperty(const String& name, int prop, const String& value)
719719
{
720-
CV_Assert(prop == MATERIAL_TEXTURE, _app);
720+
CV_Assert(prop >= MATERIAL_TEXTURE0, prop <= MATERIAL_TEXTURE3, _app);
721721

722722
MaterialPtr mat = MaterialManager::getSingleton().getByName(name, RESOURCEGROUP_NAME);
723723
CV_Assert(mat);
724724

725725
Pass* rpass = mat->getTechniques()[0]->getPasses()[0];
726726

727-
if (rpass->getTextureUnitStates().empty())
727+
size_t texUnit = prop - MATERIAL_TEXTURE0;
728+
CV_Assert(texUnit <= rpass->getTextureUnitStates().size());
729+
730+
if (rpass->getTextureUnitStates().size() <= texUnit)
728731
{
729732
rpass->createTextureUnitState(value);
730733
return;
731734
}
732735

733-
rpass->getTextureUnitStates()[0]->setTextureName(value);
736+
rpass->getTextureUnitStates()[texUnit]->setTextureName(value);
734737
}
735738

736739
static bool setShaderProperty(const GpuProgramParametersSharedPtr& params, const String& prop,

0 commit comments

Comments
 (0)