OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

回复: Is it possible to load texture without applying to adrawable

Goto page 1, 2, 3, 4, 5, 6, 7, 8  Next
 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
GarfieldPig
Appreciator


Joined: 26 Oct 2018
Posts: 129

PostPosted: Fri May 10, 2019 4:32 pm    Post subject:
回复: Is it possible to load texture without applying to adrawable
Reply with quote

Hi Steve,
I meet the similar question yesterday,how about use osg::texture::apply method with a new state under a new GraphicContext.


this is the source of my idea.


In osg3.6.3 osgConv application.
osgConv.cpp line 152


void compress()
{
MyGraphicsContext context;
if (!context.valid())
{
osg::notify(osg::NOTICE)<<"Error: Unable to create graphis context, problem with running osgViewer-"<<osgViewerGetVersion()<<", cannot run compression."<<std::endl;
return;
}


osg::ref_ptr<osg::State> state = new osg::State;
state->initializeExtensionProcs();


for(TextureSet::iterator itr=_textureSet.begin();
itr!=_textureSet.end();
++itr)
{
osg::Texture* texture = const_cast<osg::Texture*>(itr->get());


osg::Texture2D* texture2D = dynamic_cast<osg::Texture2D*>(texture);
osg::Texture3D* texture3D = dynamic_cast<osg::Texture3D*>(texture);


osg::ref_ptr<osg::Image> image = texture2D ? texture2D->getImage() : (texture3D ? texture3D->getImage() : 0);
if (image.valid() &&
(image->getPixelFormat()==GL_RGB || image->getPixelFormat()==GL_RGBA) &&
(image->s()>=32 && image->t()>=32))
{
texture->setInternalFormatMode(_internalFormatMode);


// need to disable the unref after apply, otherwise the image could go out of scope.
bool unrefImageDataAfterApply = texture->getUnRefImageDataAfterApply();
texture->setUnRefImageDataAfterApply(false);


// get OpenGL driver to create texture from image.
texture->apply(*state);


// restore the original setting
texture->setUnRefImageDataAfterApply(unrefImageDataAfterApply);


image->readImageFromCurrentTexture(0,true);


texture->setInternalFormatMode(osg::Texture::USE_IMAGE_DATA_FORMAT);
}
}
}





Thank you!


Cheers,
Qi Yu



------------------ 原始邮件 ------------------
发件人: "Steve Powers"<>;
发送时间: 2019年5月9日(星期四) 晚上11:33
收件人: "osg-users"<>;

主题: Is it possible to load texture without applying to adrawable



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.


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.




Instead, I set the texture to a stateset on an osg::Group node




stateset = group->getOrCreateStateSet();
stateset->setTextureAttributeAndModes(0, texture, osg::StateAttribute:ShockedN);




Is there a way to have this texture object instantiate without physically using the texture on a drawable?


Thank you!


Cheers,
Steven

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
GarfieldPig
Appreciator


Joined: 26 Oct 2018
Posts: 129

PostPosted: Fri May 10, 2019 4:32 pm    Post subject:
回复: Is it possible to load texture without applying to adrawable
Reply with quote

Hi Steve,
I meet the similar question yesterday,how about use osg::texture::apply method with a new state under a new GraphicContext.


this is the source of my idea.


In osg3.6.3 osgConv application.
osgConv.cpp line 152


void compress()
{
MyGraphicsContext context;
if (!context.valid())
{
osg::notify(osg::NOTICE)<<"Error: Unable to create graphis context, problem with running osgViewer-"<<osgViewerGetVersion()<<", cannot run compression."<<std::endl;
return;
}


osg::ref_ptr<osg::State> state = new osg::State;
state->initializeExtensionProcs();


for(TextureSet::iterator itr=_textureSet.begin();
itr!=_textureSet.end();
++itr)
{
osg::Texture* texture = const_cast<osg::Texture*>(itr->get());


osg::Texture2D* texture2D = dynamic_cast<osg::Texture2D*>(texture);
osg::Texture3D* texture3D = dynamic_cast<osg::Texture3D*>(texture);


osg::ref_ptr<osg::Image> image = texture2D ? texture2D->getImage() : (texture3D ? texture3D->getImage() : 0);
if (image.valid() &&
(image->getPixelFormat()==GL_RGB || image->getPixelFormat()==GL_RGBA) &&
(image->s()>=32 && image->t()>=32))
{
texture->setInternalFormatMode(_internalFormatMode);


// need to disable the unref after apply, otherwise the image could go out of scope.
bool unrefImageDataAfterApply = texture->getUnRefImageDataAfterApply();
texture->setUnRefImageDataAfterApply(false);


// get OpenGL driver to create texture from image.
texture->apply(*state);


// restore the original setting
texture->setUnRefImageDataAfterApply(unrefImageDataAfterApply);


image->readImageFromCurrentTexture(0,true);


texture->setInternalFormatMode(osg::Texture::USE_IMAGE_DATA_FORMAT);
}
}
}





Thank you!


Cheers,
Qi Yu



------------------ 原始邮件 ------------------
发件人: "Steve Powers"<>;
发送时间: 2019年5月9日(星期四) 晚上11:33
收件人: "osg-users"<>;

主题: Is it possible to load texture without applying to adrawable



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.


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.




Instead, I set the texture to a stateset on an osg::Group node




stateset = group->getOrCreateStateSet();
stateset->setTextureAttributeAndModes(0, texture, osg::StateAttribute:ShockedN);




Is there a way to have this texture object instantiate without physically using the texture on a drawable?


Thank you!


Cheers,
Steven

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
GarfieldPig
Appreciator


Joined: 26 Oct 2018
Posts: 129

PostPosted: Fri May 10, 2019 4:32 pm    Post subject:
回复: Is it possible to load texture without applying to adrawable
Reply with quote

Hi Steve,
I meet the similar question yesterday,how about use osg::texture::apply method with a new state under a new GraphicContext.


this is the source of my idea.


In osg3.6.3 osgConv application.
osgConv.cpp line 152


void compress()
{
MyGraphicsContext context;
if (!context.valid())
{
osg::notify(osg::NOTICE)<<"Error: Unable to create graphis context, problem with running osgViewer-"<<osgViewerGetVersion()<<", cannot run compression."<<std::endl;
return;
}


osg::ref_ptr<osg::State> state = new osg::State;
state->initializeExtensionProcs();


for(TextureSet::iterator itr=_textureSet.begin();
itr!=_textureSet.end();
++itr)
{
osg::Texture* texture = const_cast<osg::Texture*>(itr->get());


osg::Texture2D* texture2D = dynamic_cast<osg::Texture2D*>(texture);
osg::Texture3D* texture3D = dynamic_cast<osg::Texture3D*>(texture);


osg::ref_ptr<osg::Image> image = texture2D ? texture2D->getImage() : (texture3D ? texture3D->getImage() : 0);
if (image.valid() &&
(image->getPixelFormat()==GL_RGB || image->getPixelFormat()==GL_RGBA) &&
(image->s()>=32 && image->t()>=32))
{
texture->setInternalFormatMode(_internalFormatMode);


// need to disable the unref after apply, otherwise the image could go out of scope.
bool unrefImageDataAfterApply = texture->getUnRefImageDataAfterApply();
texture->setUnRefImageDataAfterApply(false);


// get OpenGL driver to create texture from image.
texture->apply(*state);


// restore the original setting
texture->setUnRefImageDataAfterApply(unrefImageDataAfterApply);


image->readImageFromCurrentTexture(0,true);


texture->setInternalFormatMode(osg::Texture::USE_IMAGE_DATA_FORMAT);
}
}
}





Thank you!


Cheers,
Qi Yu



------------------ 原始邮件 ------------------
发件人: "Steve Powers"<>;
发送时间: 2019年5月9日(星期四) 晚上11:33
收件人: "osg-users"<>;

主题: Is it possible to load texture without applying to adrawable



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.


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.




Instead, I set the texture to a stateset on an osg::Group node




stateset = group->getOrCreateStateSet();
stateset->setTextureAttributeAndModes(0, texture, osg::StateAttribute:ShockedN);




Is there a way to have this texture object instantiate without physically using the texture on a drawable?


Thank you!


Cheers,
Steven

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
GarfieldPig
Appreciator


Joined: 26 Oct 2018
Posts: 129

PostPosted: Fri May 10, 2019 4:32 pm    Post subject:
回复: Is it possible to load texture without applying to adrawable
Reply with quote

Hi Steve,
I meet the similar question yesterday,how about use osg::texture::apply method with a new state under a new GraphicContext.


this is the source of my idea.


In osg3.6.3 osgConv application.
osgConv.cpp line 152


void compress()
{
MyGraphicsContext context;
if (!context.valid())
{
osg::notify(osg::NOTICE)<<"Error: Unable to create graphis context, problem with running osgViewer-"<<osgViewerGetVersion()<<", cannot run compression."<<std::endl;
return;
}


osg::ref_ptr<osg::State> state = new osg::State;
state->initializeExtensionProcs();


for(TextureSet::iterator itr=_textureSet.begin();
itr!=_textureSet.end();
++itr)
{
osg::Texture* texture = const_cast<osg::Texture*>(itr->get());


osg::Texture2D* texture2D = dynamic_cast<osg::Texture2D*>(texture);
osg::Texture3D* texture3D = dynamic_cast<osg::Texture3D*>(texture);


osg::ref_ptr<osg::Image> image = texture2D ? texture2D->getImage() : (texture3D ? texture3D->getImage() : 0);
if (image.valid() &&
(image->getPixelFormat()==GL_RGB || image->getPixelFormat()==GL_RGBA) &&
(image->s()>=32 && image->t()>=32))
{
texture->setInternalFormatMode(_internalFormatMode);


// need to disable the unref after apply, otherwise the image could go out of scope.
bool unrefImageDataAfterApply = texture->getUnRefImageDataAfterApply();
texture->setUnRefImageDataAfterApply(false);


// get OpenGL driver to create texture from image.
texture->apply(*state);


// restore the original setting
texture->setUnRefImageDataAfterApply(unrefImageDataAfterApply);


image->readImageFromCurrentTexture(0,true);


texture->setInternalFormatMode(osg::Texture::USE_IMAGE_DATA_FORMAT);
}
}
}





Thank you!


Cheers,
Qi Yu



------------------ 原始邮件 ------------------
发件人: "Steve Powers"<>;
发送时间: 2019年5月9日(星期四) 晚上11:33
收件人: "osg-users"<>;

主题: Is it possible to load texture without applying to adrawable



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.


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.




Instead, I set the texture to a stateset on an osg::Group node




stateset = group->getOrCreateStateSet();
stateset->setTextureAttributeAndModes(0, texture, osg::StateAttribute:ShockedN);




Is there a way to have this texture object instantiate without physically using the texture on a drawable?


Thank you!


Cheers,
Steven

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
GarfieldPig
Appreciator


Joined: 26 Oct 2018
Posts: 129

PostPosted: Fri May 10, 2019 4:32 pm    Post subject:
回复: Is it possible to load texture without applying to adrawable
Reply with quote

Hi Steve,
I meet the similar question yesterday,how about use osg::texture::apply method with a new state under a new GraphicContext.


this is the source of my idea.


In osg3.6.3 osgConv application.
osgConv.cpp line 152


void compress()
{
MyGraphicsContext context;
if (!context.valid())
{
osg::notify(osg::NOTICE)<<"Error: Unable to create graphis context, problem with running osgViewer-"<<osgViewerGetVersion()<<", cannot run compression."<<std::endl;
return;
}


osg::ref_ptr<osg::State> state = new osg::State;
state->initializeExtensionProcs();


for(TextureSet::iterator itr=_textureSet.begin();
itr!=_textureSet.end();
++itr)
{
osg::Texture* texture = const_cast<osg::Texture*>(itr->get());


osg::Texture2D* texture2D = dynamic_cast<osg::Texture2D*>(texture);
osg::Texture3D* texture3D = dynamic_cast<osg::Texture3D*>(texture);


osg::ref_ptr<osg::Image> image = texture2D ? texture2D->getImage() : (texture3D ? texture3D->getImage() : 0);
if (image.valid() &&
(image->getPixelFormat()==GL_RGB || image->getPixelFormat()==GL_RGBA) &&
(image->s()>=32 && image->t()>=32))
{
texture->setInternalFormatMode(_internalFormatMode);


// need to disable the unref after apply, otherwise the image could go out of scope.
bool unrefImageDataAfterApply = texture->getUnRefImageDataAfterApply();
texture->setUnRefImageDataAfterApply(false);


// get OpenGL driver to create texture from image.
texture->apply(*state);


// restore the original setting
texture->setUnRefImageDataAfterApply(unrefImageDataAfterApply);


image->readImageFromCurrentTexture(0,true);


texture->setInternalFormatMode(osg::Texture::USE_IMAGE_DATA_FORMAT);
}
}
}





Thank you!


Cheers,
Qi Yu



------------------ 原始邮件 ------------------
发件人: "Steve Powers"<>;
发送时间: 2019年5月9日(星期四) 晚上11:33
收件人: "osg-users"<>;

主题: Is it possible to load texture without applying to adrawable



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.


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.




Instead, I set the texture to a stateset on an osg::Group node




stateset = group->getOrCreateStateSet();
stateset->setTextureAttributeAndModes(0, texture, osg::StateAttribute:ShockedN);




Is there a way to have this texture object instantiate without physically using the texture on a drawable?


Thank you!


Cheers,
Steven

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
GarfieldPig
Appreciator


Joined: 26 Oct 2018
Posts: 129

PostPosted: Fri May 10, 2019 4:32 pm    Post subject:
回复: Is it possible to load texture without applying to adrawable
Reply with quote

Hi Steve,
I meet the similar question yesterday,how about use osg::texture::apply method with a new state under a new GraphicContext.


this is the source of my idea.


In osg3.6.3 osgConv application.
osgConv.cpp line 152


void compress()
{
MyGraphicsContext context;
if (!context.valid())
{
osg::notify(osg::NOTICE)<<"Error: Unable to create graphis context, problem with running osgViewer-"<<osgViewerGetVersion()<<", cannot run compression."<<std::endl;
return;
}


osg::ref_ptr<osg::State> state = new osg::State;
state->initializeExtensionProcs();


for(TextureSet::iterator itr=_textureSet.begin();
itr!=_textureSet.end();
++itr)
{
osg::Texture* texture = const_cast<osg::Texture*>(itr->get());


osg::Texture2D* texture2D = dynamic_cast<osg::Texture2D*>(texture);
osg::Texture3D* texture3D = dynamic_cast<osg::Texture3D*>(texture);


osg::ref_ptr<osg::Image> image = texture2D ? texture2D->getImage() : (texture3D ? texture3D->getImage() : 0);
if (image.valid() &&
(image->getPixelFormat()==GL_RGB || image->getPixelFormat()==GL_RGBA) &&
(image->s()>=32 && image->t()>=32))
{
texture->setInternalFormatMode(_internalFormatMode);


// need to disable the unref after apply, otherwise the image could go out of scope.
bool unrefImageDataAfterApply = texture->getUnRefImageDataAfterApply();
texture->setUnRefImageDataAfterApply(false);


// get OpenGL driver to create texture from image.
texture->apply(*state);


// restore the original setting
texture->setUnRefImageDataAfterApply(unrefImageDataAfterApply);


image->readImageFromCurrentTexture(0,true);


texture->setInternalFormatMode(osg::Texture::USE_IMAGE_DATA_FORMAT);
}
}
}





Thank you!


Cheers,
Qi Yu



------------------ 原始邮件 ------------------
发件人: "Steve Powers"<>;
发送时间: 2019年5月9日(星期四) 晚上11:33
收件人: "osg-users"<>;

主题: Is it possible to load texture without applying to adrawable



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.


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.




Instead, I set the texture to a stateset on an osg::Group node




stateset = group->getOrCreateStateSet();
stateset->setTextureAttributeAndModes(0, texture, osg::StateAttribute:ShockedN);




Is there a way to have this texture object instantiate without physically using the texture on a drawable?


Thank you!


Cheers,
Steven

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
GarfieldPig
Appreciator


Joined: 26 Oct 2018
Posts: 129

PostPosted: Fri May 10, 2019 4:32 pm    Post subject:
回复: Is it possible to load texture without applying to adrawable
Reply with quote

Hi Steve,
I meet the similar question yesterday,how about use osg::texture::apply method with a new state under a new GraphicContext.


this is the source of my idea.


In osg3.6.3 osgConv application.
osgConv.cpp line 152


void compress()
{
MyGraphicsContext context;
if (!context.valid())
{
osg::notify(osg::NOTICE)<<"Error: Unable to create graphis context, problem with running osgViewer-"<<osgViewerGetVersion()<<", cannot run compression."<<std::endl;
return;
}


osg::ref_ptr<osg::State> state = new osg::State;
state->initializeExtensionProcs();


for(TextureSet::iterator itr=_textureSet.begin();
itr!=_textureSet.end();
++itr)
{
osg::Texture* texture = const_cast<osg::Texture*>(itr->get());


osg::Texture2D* texture2D = dynamic_cast<osg::Texture2D*>(texture);
osg::Texture3D* texture3D = dynamic_cast<osg::Texture3D*>(texture);


osg::ref_ptr<osg::Image> image = texture2D ? texture2D->getImage() : (texture3D ? texture3D->getImage() : 0);
if (image.valid() &&
(image->getPixelFormat()==GL_RGB || image->getPixelFormat()==GL_RGBA) &&
(image->s()>=32 && image->t()>=32))
{
texture->setInternalFormatMode(_internalFormatMode);


// need to disable the unref after apply, otherwise the image could go out of scope.
bool unrefImageDataAfterApply = texture->getUnRefImageDataAfterApply();
texture->setUnRefImageDataAfterApply(false);


// get OpenGL driver to create texture from image.
texture->apply(*state);


// restore the original setting
texture->setUnRefImageDataAfterApply(unrefImageDataAfterApply);


image->readImageFromCurrentTexture(0,true);


texture->setInternalFormatMode(osg::Texture::USE_IMAGE_DATA_FORMAT);
}
}
}





Thank you!


Cheers,
Qi Yu



------------------ 原始邮件 ------------------
发件人: "Steve Powers"<>;
发送时间: 2019年5月9日(星期四) 晚上11:33
收件人: "osg-users"<>;

主题: Is it possible to load texture without applying to adrawable



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.


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.




Instead, I set the texture to a stateset on an osg::Group node




stateset = group->getOrCreateStateSet();
stateset->setTextureAttributeAndModes(0, texture, osg::StateAttribute:ShockedN);




Is there a way to have this texture object instantiate without physically using the texture on a drawable?


Thank you!


Cheers,
Steven

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
GarfieldPig
Appreciator


Joined: 26 Oct 2018
Posts: 129

PostPosted: Fri May 10, 2019 4:32 pm    Post subject:
回复: Is it possible to load texture without applying to adrawable
Reply with quote

Hi Steve,
I meet the similar question yesterday,how about use osg::texture::apply method with a new state under a new GraphicContext.


this is the source of my idea.


In osg3.6.3 osgConv application.
osgConv.cpp line 152


void compress()
{
MyGraphicsContext context;
if (!context.valid())
{
osg::notify(osg::NOTICE)<<"Error: Unable to create graphis context, problem with running osgViewer-"<<osgViewerGetVersion()<<", cannot run compression."<<std::endl;
return;
}


osg::ref_ptr<osg::State> state = new osg::State;
state->initializeExtensionProcs();


for(TextureSet::iterator itr=_textureSet.begin();
itr!=_textureSet.end();
++itr)
{
osg::Texture* texture = const_cast<osg::Texture*>(itr->get());


osg::Texture2D* texture2D = dynamic_cast<osg::Texture2D*>(texture);
osg::Texture3D* texture3D = dynamic_cast<osg::Texture3D*>(texture);


osg::ref_ptr<osg::Image> image = texture2D ? texture2D->getImage() : (texture3D ? texture3D->getImage() : 0);
if (image.valid() &&
(image->getPixelFormat()==GL_RGB || image->getPixelFormat()==GL_RGBA) &&
(image->s()>=32 && image->t()>=32))
{
texture->setInternalFormatMode(_internalFormatMode);


// need to disable the unref after apply, otherwise the image could go out of scope.
bool unrefImageDataAfterApply = texture->getUnRefImageDataAfterApply();
texture->setUnRefImageDataAfterApply(false);


// get OpenGL driver to create texture from image.
texture->apply(*state);


// restore the original setting
texture->setUnRefImageDataAfterApply(unrefImageDataAfterApply);


image->readImageFromCurrentTexture(0,true);


texture->setInternalFormatMode(osg::Texture::USE_IMAGE_DATA_FORMAT);
}
}
}





Thank you!


Cheers,
Qi Yu



------------------ 原始邮件 ------------------
发件人: "Steve Powers"<>;
发送时间: 2019年5月9日(星期四) 晚上11:33
收件人: "osg-users"<>;

主题: Is it possible to load texture without applying to adrawable



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.


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.




Instead, I set the texture to a stateset on an osg::Group node




stateset = group->getOrCreateStateSet();
stateset->setTextureAttributeAndModes(0, texture, osg::StateAttribute:ShockedN);




Is there a way to have this texture object instantiate without physically using the texture on a drawable?


Thank you!


Cheers,
Steven

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
GarfieldPig
Appreciator


Joined: 26 Oct 2018
Posts: 129

PostPosted: Fri May 10, 2019 4:32 pm    Post subject:
回复: Is it possible to load texture without applying to adrawable
Reply with quote

Hi Steve,
I meet the similar question yesterday,how about use osg::texture::apply method with a new state under a new GraphicContext.


this is the source of my idea.


In osg3.6.3 osgConv application.
osgConv.cpp line 152


void compress()
{
MyGraphicsContext context;
if (!context.valid())
{
osg::notify(osg::NOTICE)<<"Error: Unable to create graphis context, problem with running osgViewer-"<<osgViewerGetVersion()<<", cannot run compression."<<std::endl;
return;
}


osg::ref_ptr<osg::State> state = new osg::State;
state->initializeExtensionProcs();


for(TextureSet::iterator itr=_textureSet.begin();
itr!=_textureSet.end();
++itr)
{
osg::Texture* texture = const_cast<osg::Texture*>(itr->get());


osg::Texture2D* texture2D = dynamic_cast<osg::Texture2D*>(texture);
osg::Texture3D* texture3D = dynamic_cast<osg::Texture3D*>(texture);


osg::ref_ptr<osg::Image> image = texture2D ? texture2D->getImage() : (texture3D ? texture3D->getImage() : 0);
if (image.valid() &&
(image->getPixelFormat()==GL_RGB || image->getPixelFormat()==GL_RGBA) &&
(image->s()>=32 && image->t()>=32))
{
texture->setInternalFormatMode(_internalFormatMode);


// need to disable the unref after apply, otherwise the image could go out of scope.
bool unrefImageDataAfterApply = texture->getUnRefImageDataAfterApply();
texture->setUnRefImageDataAfterApply(false);


// get OpenGL driver to create texture from image.
texture->apply(*state);


// restore the original setting
texture->setUnRefImageDataAfterApply(unrefImageDataAfterApply);


image->readImageFromCurrentTexture(0,true);


texture->setInternalFormatMode(osg::Texture::USE_IMAGE_DATA_FORMAT);
}
}
}





Thank you!


Cheers,
Qi Yu



------------------ 原始邮件 ------------------
发件人: "Steve Powers"<>;
发送时间: 2019年5月9日(星期四) 晚上11:33
收件人: "osg-users"<>;

主题: Is it possible to load texture without applying to adrawable



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.


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.




Instead, I set the texture to a stateset on an osg::Group node




stateset = group->getOrCreateStateSet();
stateset->setTextureAttributeAndModes(0, texture, osg::StateAttribute:ShockedN);




Is there a way to have this texture object instantiate without physically using the texture on a drawable?


Thank you!


Cheers,
Steven

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
GarfieldPig
Appreciator


Joined: 26 Oct 2018
Posts: 129

PostPosted: Fri May 10, 2019 4:32 pm    Post subject:
回复: Is it possible to load texture without applying to adrawable
Reply with quote

Hi Steve,
I meet the similar question yesterday,how about use osg::texture::apply method with a new state under a new GraphicContext.


this is the source of my idea.


In osg3.6.3 osgConv application.
osgConv.cpp line 152


void compress()
{
MyGraphicsContext context;
if (!context.valid())
{
osg::notify(osg::NOTICE)<<"Error: Unable to create graphis context, problem with running osgViewer-"<<osgViewerGetVersion()<<", cannot run compression."<<std::endl;
return;
}


osg::ref_ptr<osg::State> state = new osg::State;
state->initializeExtensionProcs();


for(TextureSet::iterator itr=_textureSet.begin();
itr!=_textureSet.end();
++itr)
{
osg::Texture* texture = const_cast<osg::Texture*>(itr->get());


osg::Texture2D* texture2D = dynamic_cast<osg::Texture2D*>(texture);
osg::Texture3D* texture3D = dynamic_cast<osg::Texture3D*>(texture);


osg::ref_ptr<osg::Image> image = texture2D ? texture2D->getImage() : (texture3D ? texture3D->getImage() : 0);
if (image.valid() &&
(image->getPixelFormat()==GL_RGB || image->getPixelFormat()==GL_RGBA) &&
(image->s()>=32 && image->t()>=32))
{
texture->setInternalFormatMode(_internalFormatMode);


// need to disable the unref after apply, otherwise the image could go out of scope.
bool unrefImageDataAfterApply = texture->getUnRefImageDataAfterApply();
texture->setUnRefImageDataAfterApply(false);


// get OpenGL driver to create texture from image.
texture->apply(*state);


// restore the original setting
texture->setUnRefImageDataAfterApply(unrefImageDataAfterApply);


image->readImageFromCurrentTexture(0,true);


texture->setInternalFormatMode(osg::Texture::USE_IMAGE_DATA_FORMAT);
}
}
}





Thank you!


Cheers,
Qi Yu



------------------ 原始邮件 ------------------
发件人: "Steve Powers"<>;
发送时间: 2019年5月9日(星期四) 晚上11:33
收件人: "osg-users"<>;

主题: Is it possible to load texture without applying to adrawable



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.


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.




Instead, I set the texture to a stateset on an osg::Group node




stateset = group->getOrCreateStateSet();
stateset->setTextureAttributeAndModes(0, texture, osg::StateAttribute:ShockedN);




Is there a way to have this texture object instantiate without physically using the texture on a drawable?


Thank you!


Cheers,
Steven

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
GarfieldPig
Appreciator


Joined: 26 Oct 2018
Posts: 129

PostPosted: Fri May 10, 2019 4:32 pm    Post subject:
回复: Is it possible to load texture without applying to adrawable
Reply with quote

Hi Steve,
I meet the similar question yesterday,how about use osg::texture::apply method with a new state under a new GraphicContext.


this is the source of my idea.


In osg3.6.3 osgConv application.
osgConv.cpp line 152


void compress()
{
MyGraphicsContext context;
if (!context.valid())
{
osg::notify(osg::NOTICE)<<"Error: Unable to create graphis context, problem with running osgViewer-"<<osgViewerGetVersion()<<", cannot run compression."<<std::endl;
return;
}


osg::ref_ptr<osg::State> state = new osg::State;
state->initializeExtensionProcs();


for(TextureSet::iterator itr=_textureSet.begin();
itr!=_textureSet.end();
++itr)
{
osg::Texture* texture = const_cast<osg::Texture*>(itr->get());


osg::Texture2D* texture2D = dynamic_cast<osg::Texture2D*>(texture);
osg::Texture3D* texture3D = dynamic_cast<osg::Texture3D*>(texture);


osg::ref_ptr<osg::Image> image = texture2D ? texture2D->getImage() : (texture3D ? texture3D->getImage() : 0);
if (image.valid() &&
(image->getPixelFormat()==GL_RGB || image->getPixelFormat()==GL_RGBA) &&
(image->s()>=32 && image->t()>=32))
{
texture->setInternalFormatMode(_internalFormatMode);


// need to disable the unref after apply, otherwise the image could go out of scope.
bool unrefImageDataAfterApply = texture->getUnRefImageDataAfterApply();
texture->setUnRefImageDataAfterApply(false);


// get OpenGL driver to create texture from image.
texture->apply(*state);


// restore the original setting
texture->setUnRefImageDataAfterApply(unrefImageDataAfterApply);


image->readImageFromCurrentTexture(0,true);


texture->setInternalFormatMode(osg::Texture::USE_IMAGE_DATA_FORMAT);
}
}
}





Thank you!


Cheers,
Qi Yu



------------------ 原始邮件 ------------------
发件人: "Steve Powers"<>;
发送时间: 2019年5月9日(星期四) 晚上11:33
收件人: "osg-users"<>;

主题: Is it possible to load texture without applying to adrawable



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.


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.




Instead, I set the texture to a stateset on an osg::Group node




stateset = group->getOrCreateStateSet();
stateset->setTextureAttributeAndModes(0, texture, osg::StateAttribute:ShockedN);




Is there a way to have this texture object instantiate without physically using the texture on a drawable?


Thank you!


Cheers,
Steven

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
GarfieldPig
Appreciator


Joined: 26 Oct 2018
Posts: 129

PostPosted: Fri May 10, 2019 4:32 pm    Post subject:
回复: Is it possible to load texture without applying to adrawable
Reply with quote

Hi Steve,
I meet the similar question yesterday,how about use osg::texture::apply method with a new state under a new GraphicContext.


this is the source of my idea.


In osg3.6.3 osgConv application.
osgConv.cpp line 152


void compress()
{
MyGraphicsContext context;
if (!context.valid())
{
osg::notify(osg::NOTICE)<<"Error: Unable to create graphis context, problem with running osgViewer-"<<osgViewerGetVersion()<<", cannot run compression."<<std::endl;
return;
}


osg::ref_ptr<osg::State> state = new osg::State;
state->initializeExtensionProcs();


for(TextureSet::iterator itr=_textureSet.begin();
itr!=_textureSet.end();
++itr)
{
osg::Texture* texture = const_cast<osg::Texture*>(itr->get());


osg::Texture2D* texture2D = dynamic_cast<osg::Texture2D*>(texture);
osg::Texture3D* texture3D = dynamic_cast<osg::Texture3D*>(texture);


osg::ref_ptr<osg::Image> image = texture2D ? texture2D->getImage() : (texture3D ? texture3D->getImage() : 0);
if (image.valid() &&
(image->getPixelFormat()==GL_RGB || image->getPixelFormat()==GL_RGBA) &&
(image->s()>=32 && image->t()>=32))
{
texture->setInternalFormatMode(_internalFormatMode);


// need to disable the unref after apply, otherwise the image could go out of scope.
bool unrefImageDataAfterApply = texture->getUnRefImageDataAfterApply();
texture->setUnRefImageDataAfterApply(false);


// get OpenGL driver to create texture from image.
texture->apply(*state);


// restore the original setting
texture->setUnRefImageDataAfterApply(unrefImageDataAfterApply);


image->readImageFromCurrentTexture(0,true);


texture->setInternalFormatMode(osg::Texture::USE_IMAGE_DATA_FORMAT);
}
}
}





Thank you!


Cheers,
Qi Yu



------------------ 原始邮件 ------------------
发件人: "Steve Powers"<>;
发送时间: 2019年5月9日(星期四) 晚上11:33
收件人: "osg-users"<>;

主题: Is it possible to load texture without applying to adrawable



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.


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.




Instead, I set the texture to a stateset on an osg::Group node




stateset = group->getOrCreateStateSet();
stateset->setTextureAttributeAndModes(0, texture, osg::StateAttribute:ShockedN);




Is there a way to have this texture object instantiate without physically using the texture on a drawable?


Thank you!


Cheers,
Steven

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
GarfieldPig
Appreciator


Joined: 26 Oct 2018
Posts: 129

PostPosted: Fri May 10, 2019 4:32 pm    Post subject:
回复: Is it possible to load texture without applying to adrawable
Reply with quote

Hi Steve,
I meet the similar question yesterday,how about use osg::texture::apply method with a new state under a new GraphicContext.


this is the source of my idea.


In osg3.6.3 osgConv application.
osgConv.cpp line 152


void compress()
{
MyGraphicsContext context;
if (!context.valid())
{
osg::notify(osg::NOTICE)<<"Error: Unable to create graphis context, problem with running osgViewer-"<<osgViewerGetVersion()<<", cannot run compression."<<std::endl;
return;
}


osg::ref_ptr<osg::State> state = new osg::State;
state->initializeExtensionProcs();


for(TextureSet::iterator itr=_textureSet.begin();
itr!=_textureSet.end();
++itr)
{
osg::Texture* texture = const_cast<osg::Texture*>(itr->get());


osg::Texture2D* texture2D = dynamic_cast<osg::Texture2D*>(texture);
osg::Texture3D* texture3D = dynamic_cast<osg::Texture3D*>(texture);


osg::ref_ptr<osg::Image> image = texture2D ? texture2D->getImage() : (texture3D ? texture3D->getImage() : 0);
if (image.valid() &&
(image->getPixelFormat()==GL_RGB || image->getPixelFormat()==GL_RGBA) &&
(image->s()>=32 && image->t()>=32))
{
texture->setInternalFormatMode(_internalFormatMode);


// need to disable the unref after apply, otherwise the image could go out of scope.
bool unrefImageDataAfterApply = texture->getUnRefImageDataAfterApply();
texture->setUnRefImageDataAfterApply(false);


// get OpenGL driver to create texture from image.
texture->apply(*state);


// restore the original setting
texture->setUnRefImageDataAfterApply(unrefImageDataAfterApply);


image->readImageFromCurrentTexture(0,true);


texture->setInternalFormatMode(osg::Texture::USE_IMAGE_DATA_FORMAT);
}
}
}





Thank you!


Cheers,
Qi Yu



------------------ 原始邮件 ------------------
发件人: "Steve Powers"<>;
发送时间: 2019年5月9日(星期四) 晚上11:33
收件人: "osg-users"<>;

主题: Is it possible to load texture without applying to adrawable



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.


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.




Instead, I set the texture to a stateset on an osg::Group node




stateset = group->getOrCreateStateSet();
stateset->setTextureAttributeAndModes(0, texture, osg::StateAttribute:ShockedN);




Is there a way to have this texture object instantiate without physically using the texture on a drawable?


Thank you!


Cheers,
Steven

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
GarfieldPig
Appreciator


Joined: 26 Oct 2018
Posts: 129

PostPosted: Fri May 10, 2019 4:32 pm    Post subject:
回复: Is it possible to load texture without applying to adrawable
Reply with quote

Hi Steve,
I meet the similar question yesterday,how about use osg::texture::apply method with a new state under a new GraphicContext.


this is the source of my idea.


In osg3.6.3 osgConv application.
osgConv.cpp line 152


void compress()
{
MyGraphicsContext context;
if (!context.valid())
{
osg::notify(osg::NOTICE)<<"Error: Unable to create graphis context, problem with running osgViewer-"<<osgViewerGetVersion()<<", cannot run compression."<<std::endl;
return;
}


osg::ref_ptr<osg::State> state = new osg::State;
state->initializeExtensionProcs();


for(TextureSet::iterator itr=_textureSet.begin();
itr!=_textureSet.end();
++itr)
{
osg::Texture* texture = const_cast<osg::Texture*>(itr->get());


osg::Texture2D* texture2D = dynamic_cast<osg::Texture2D*>(texture);
osg::Texture3D* texture3D = dynamic_cast<osg::Texture3D*>(texture);


osg::ref_ptr<osg::Image> image = texture2D ? texture2D->getImage() : (texture3D ? texture3D->getImage() : 0);
if (image.valid() &&
(image->getPixelFormat()==GL_RGB || image->getPixelFormat()==GL_RGBA) &&
(image->s()>=32 && image->t()>=32))
{
texture->setInternalFormatMode(_internalFormatMode);


// need to disable the unref after apply, otherwise the image could go out of scope.
bool unrefImageDataAfterApply = texture->getUnRefImageDataAfterApply();
texture->setUnRefImageDataAfterApply(false);


// get OpenGL driver to create texture from image.
texture->apply(*state);


// restore the original setting
texture->setUnRefImageDataAfterApply(unrefImageDataAfterApply);


image->readImageFromCurrentTexture(0,true);


texture->setInternalFormatMode(osg::Texture::USE_IMAGE_DATA_FORMAT);
}
}
}





Thank you!


Cheers,
Qi Yu



------------------ 原始邮件 ------------------
发件人: "Steve Powers"<>;
发送时间: 2019年5月9日(星期四) 晚上11:33
收件人: "osg-users"<>;

主题: Is it possible to load texture without applying to adrawable



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.


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.




Instead, I set the texture to a stateset on an osg::Group node




stateset = group->getOrCreateStateSet();
stateset->setTextureAttributeAndModes(0, texture, osg::StateAttribute:ShockedN);




Is there a way to have this texture object instantiate without physically using the texture on a drawable?


Thank you!


Cheers,
Steven

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
GarfieldPig
Appreciator


Joined: 26 Oct 2018
Posts: 129

PostPosted: Fri May 10, 2019 4:32 pm    Post subject:
回复: Is it possible to load texture without applying to adrawable
Reply with quote

Hi Steve,
I meet the similar question yesterday,how about use osg::texture::apply method with a new state under a new GraphicContext.


this is the source of my idea.


In osg3.6.3 osgConv application.
osgConv.cpp line 152


void compress()
{
MyGraphicsContext context;
if (!context.valid())
{
osg::notify(osg::NOTICE)<<"Error: Unable to create graphis context, problem with running osgViewer-"<<osgViewerGetVersion()<<", cannot run compression."<<std::endl;
return;
}


osg::ref_ptr<osg::State> state = new osg::State;
state->initializeExtensionProcs();


for(TextureSet::iterator itr=_textureSet.begin();
itr!=_textureSet.end();
++itr)
{
osg::Texture* texture = const_cast<osg::Texture*>(itr->get());


osg::Texture2D* texture2D = dynamic_cast<osg::Texture2D*>(texture);
osg::Texture3D* texture3D = dynamic_cast<osg::Texture3D*>(texture);


osg::ref_ptr<osg::Image> image = texture2D ? texture2D->getImage() : (texture3D ? texture3D->getImage() : 0);
if (image.valid() &&
(image->getPixelFormat()==GL_RGB || image->getPixelFormat()==GL_RGBA) &&
(image->s()>=32 && image->t()>=32))
{
texture->setInternalFormatMode(_internalFormatMode);


// need to disable the unref after apply, otherwise the image could go out of scope.
bool unrefImageDataAfterApply = texture->getUnRefImageDataAfterApply();
texture->setUnRefImageDataAfterApply(false);


// get OpenGL driver to create texture from image.
texture->apply(*state);


// restore the original setting
texture->setUnRefImageDataAfterApply(unrefImageDataAfterApply);


image->readImageFromCurrentTexture(0,true);


texture->setInternalFormatMode(osg::Texture::USE_IMAGE_DATA_FORMAT);
}
}
}





Thank you!


Cheers,
Qi Yu



------------------ 原始邮件 ------------------
发件人: "Steve Powers"<>;
发送时间: 2019年5月9日(星期四) 晚上11:33
收件人: "osg-users"<>;

主题: Is it possible to load texture without applying to adrawable



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.


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.




Instead, I set the texture to a stateset on an osg::Group node




stateset = group->getOrCreateStateSet();
stateset->setTextureAttributeAndModes(0, texture, osg::StateAttribute:ShockedN);




Is there a way to have this texture object instantiate without physically using the texture on a drawable?


Thank you!


Cheers,
Steven

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Goto page 1, 2, 3, 4, 5, 6, 7, 8  Next
Page 1 of 8

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts How do I move a Texture in an model ... newlife958 General 4 Tue Sep 17, 2019 1:16 am View latest post
No new posts Render to Texture and osgQt (osgQOpenGL) wroos General 2 Mon Sep 16, 2019 5:47 pm View latest post
No new posts I want to move the texture to rain. H... robertosfield General 4 Thu Jul 25, 2019 12:06 am View latest post
No new posts Is it possible to load texture withou... robertosfield General 9 Thu May 09, 2019 8:29 pm View latest post
No new posts Is it possible to load texture withou... DrPowers General 0 Thu May 09, 2019 3:30 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP