void Camera::processStateSet(const osg::StateSet *stateset, StateSet &s) { if (!stateset) return; for(int i = 15 ; i >= 0 ; --i) { const osg::StateSet::RefAttributePair *attr = stateset->getTextureAttributePair(i, StateAttribute::TEXTURE); if (!attr) continue; const Texture2D *ptex2D = dynamic_cast<const Texture2D*>(attr->first.get()); const unsigned int mode = attr->second; if (ptex2D) s.setTexture(i, GL_TEXTURE_2D, pContext->getTextureID(ptex2D), mode); else { const TextureCubeMap *ptexCM = dynamic_cast<const TextureCubeMap*>(attr->first.get()); if (ptexCM) s.setTexture(i, GL_TEXTURE_CUBE_MAP, pContext->getTextureID(ptexCM), mode); } } s.setUniforms(stateset->getUniformList()); const osg::StateSet::RefAttributePair *attr = stateset->getAttributePair(StateAttribute::PROGRAM, 0); if (attr && attr->first) { s.setProgram(pContext->getProgramID(dynamic_cast<const osg::Program*>(attr->first.get())), attr->second); } attr = stateset->getAttributePair(StateAttribute::MATERIAL); if (attr && attr->first) { s.setMaterial(dynamic_cast<const osg::Material*>(attr->first.get()), attr->second); } }