Tue, 05/17/2022 - 20:32
Forums:
Hello all, I am creating objects and assign textures like this:
QFileInfo textureFilename(validPathToTextureFile);
if (textureFilename.exists())
{
TCollection_AsciiString aFile(textureFilename.absoluteFilePath().toStdString().c_str());
m_aisDisplay->SetTextureFileName(aFile);
m_aisDisplay->SetTextureRepeat(true,1.0,1.0);
m_aisDisplay->SetTextureScale(true,1.0,1.0);
m_aisDisplay->SetTextureOrigin(1.0,1.0);
m_aisDisplay->EnableTextureModulate();
m_aisDisplay->DisableTextureModulate();
m_aisDisplay->SetTextureMapOn();
}
This works great to a certain amount (~20 - see attached picture) of objects and when this limit is reached no textures are shown on the new ones anymore.
Is there a parameter to give some memory to textures or so? I run it on a nvidia-rtx with plenty of memory.
Thanks!
Attachments:
Wed, 05/18/2022 - 01:09
I'm curios what kind of limit you may hit here - 20 doesn't look like a big number to me (as long as this is not 16384x16384 images easily occupying tremendous amount of memory). Practically speaking, OpenGL doesn't normally fail for 64-bit applications due to GPU memory limits - instead, rendering becomes just painfully too slow.
As for your screenshot, I don't see 20 textures there, only a couple. When you assign textures to presentation like that, each presentation would load a copy. This is not what you normally expect when mapping the same texture to many objects. To do this in optimal way, it is better creating a single Graphic3d_Texture2D instance and reuse it across presentations, or utilize implicit sharing mechanism based on unique texture id (Graphic3d_TextureRoot::GetId()).
For instance, when displaying an XCAF document using XCAFPrs_AISObject, it creates XCAFPrs_Texture/Image_Texture out of visualization styles with texture id generated from file name.
Wed, 05/18/2022 - 21:13
Thanks Kyrill, it works perfect now!
I read somewhere that AIS_TextureShape is obsolete and changed m_aisDisplayfrom AIS_TextureShape to AIS_Shape
Getting the texture from a single instance and all seems to work now.
Thanks again - you made my day (again)
Cheers!