<div>Hi Steve,<span style="background-color: rgb(239, 239, 239); font-size: 12px;"></span></div><div>I meet the similar question yesterday,how about use osg::texture::apply method with a new state under a new GraphicContext.</div><div><br></div><div>this is the source of my idea.</div><div><br></div><div>In osg3.6.3 osgConv application.</div><div>osgConv.cpp line 152</div><div><br></div><div><div><div>void compress()</div><div>    {</div><div>        MyGraphicsContext context;</div><div>        if (!context.valid())</div><div>        {</div><div>            osg::notify(osg::NOTICE)<<"Error: Unable to create graphis context, problem with running osgViewer-"<<osgViewerGetVersion()<<", cannot run compression."<<std::endl;</div><div>            return;</div><div>        }</div><div><br></div><div>        osg::ref_ptr<osg::State> state = new osg::State;</div><div>        state->initializeExtensionProcs();</div><div><br></div><div>        for(TextureSet::iterator itr=_textureSet.begin();</div><div>            itr!=_textureSet.end();</div><div>            ++itr)</div><div>        {</div><div>            osg::Texture* texture = const_cast<osg::Texture*>(itr->get());</div><div><br></div><div>            osg::Texture2D* texture2D = dynamic_cast<osg::Texture2D*>(texture);</div><div>            osg::Texture3D* texture3D = dynamic_cast<osg::Texture3D*>(texture);</div><div><br></div><div>            osg::ref_ptr<osg::Image> image = texture2D ? texture2D->getImage() : (texture3D ? texture3D->getImage() : 0);</div><div>            if (image.valid() &&</div><div>                (image->getPixelFormat()==GL_RGB || image->getPixelFormat()==GL_RGBA) &&</div><div>                (image->s()>=32 && image->t()>=32))</div><div>            {</div><div>                texture->setInternalFormatMode(_internalFormatMode);</div><div><br></div><div>                // need to disable the unref after apply, otherwise the image could go out of scope.</div><div>                bool unrefImageDataAfterApply = texture->getUnRefImageDataAfterApply();</div><div>                texture->setUnRefImageDataAfterApply(false);</div><div><br></div><div>                // get OpenGL driver to create texture from image.</div><div>                texture->apply(*state);</div><div><br></div><div>                // restore the original setting</div><div>                texture->setUnRefImageDataAfterApply(unrefImageDataAfterApply);</div><div><br></div><div>                image->readImageFromCurrentTexture(0,true);</div><div><br></div><div>                texture->setInternalFormatMode(osg::Texture::USE_IMAGE_DATA_FORMAT);</div><div>            }</div><div>        }</div><div>    }</div></div><div><br></div><div><br></div><div><div class="gmail_default" style="font-size: small;">Thank you!</div><div class="gmail_default" style="font-size: small;"><br></div><div class="gmail_default" style="font-size: small;">Cheers,</div><div class="gmail_default" style="font-size: small;">Qi Yu</div></div><div><br></div><div style="font-size: 12px;font-family: Arial Narrow;padding:2px 0 2px 0;">------------------ 原始邮件 ------------------</div><div style="font-size: 12px;background:#efefef;padding:8px;"><div><b>发件人:</b> "Steve Powers"<stevenapowers@gmail.com>;</div><div><b>发送时间:</b> 2019年5月9日(星期四) 晚上11:33</div><div><b>收件人:</b> "osg-users"<osg-users@lists.openscenegraph.org>;<wbr></div><div></div><div><b>主题:</b> [osg-users] Is it possible to load texture without applying to adrawable</div></div><div><br></div><div dir="ltr"><div class="gmail_default" style="font-size:small"><div class="gmail_default">I am attempting to load a Texture2D into memory in order to pass the texture ID to a 3rd party OpenGL object that will use the ID within it's own drawable class.</div><div class="gmail_default"><br></div><div class="gmail_default">The issue is that the TextureObject attached to the texture is not getting instantiated and I think this is because it is not assigned to a drawable object and thus not getting visited.</div><div class="gmail_default"><br></div><div class="gmail_default"><br></div><div class="gmail_default">Instead, I set the texture to a stateset on an osg::Group node </div><div class="gmail_default"><br></div><div class="gmail_default"><br></div><div class="gmail_default">stateset = group->getOrCreateStateSet();</div><div class="gmail_default">stateset->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);</div><div class="gmail_default"><br></div><div class="gmail_default"><br></div><div class="gmail_default">Is there a way to have this texture object instantiate without physically using the texture on a drawable?</div><div class="gmail_default"><br></div><div class="gmail_default">Thank you!</div><div class="gmail_default"><br></div><div class="gmail_default">Cheers,</div><div class="gmail_default">Steven</div></div></div></div>