Ogre::MaterialPtr matPtr; if(matPtr.isNull()) { // Material pointer is null } else { // Material pointer is not null }
Ogre::MaterialPtr matPtr = Ogre::MaterialManager::getSingleton().getByName("MyMaterial"); if(matPtr.isNull()) { // Material pointer is null } else { // Material pointer is not null }In this example, we retrieve an already created Material object from the MaterialManager and assign it to our matPtr variable. We then check whether the pointer is null using the isNull() function. The cpp ogre library can be determined by the namespace used in the code examples, which is Ogre.