Skip to content

Commit

Permalink
photo texture load fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
vicrucann committed May 10, 2016
1 parent 29e7298 commit 61d799a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/libSGControls/AddEntityCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ AddPhotoCommand::AddPhotoCommand(entity::UserScene* scene, const std::string& fn
m_photo->setName(ename);
m_photo->loadImage(fname);

m_photo->getOrCreateStateSet()->setTextureAttributeAndModes(0, m_photo->getTextureAsAttribute());
// m_canvas->getGeodeData()->getOrCreateStateSet()->setTextureAttributeAndModes(0, m_photo->getTextureAsAttribute() );

this->setText(QObject::tr("Add photo to %1")
Expand All @@ -113,8 +114,6 @@ void AddPhotoCommand::undo()

void AddPhotoCommand::redo()
{
m_photo->getOrCreateStateSet()->setTextureAttributeAndModes(0, m_photo->getTextureAsAttribute());

if (!m_canvas->getGeodeData()->addDrawable(m_photo.get()))
outErrMsg("Could not add photo to current canvas");

Expand Down
9 changes: 8 additions & 1 deletion src/libSGEntities/RootScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,20 @@ bool RootScene::loadSceneFromFile()
/* update pointer */
m_userScene = newscene.get();

/* load the construction tools */
/* load the construction tools and set photo textures */
for (unsigned int i=0; i<m_userScene->getNumChildren(); ++i){
entity::Canvas* cnv = m_userScene->getCanvas(i);
if (!cnv){
continue;
}
cnv->initializeTools();

/* photo textures */
for (size_t i=0; i<cnv->getGeodeData()->getNumChildren(); ++i){
entity::Photo* photo = dynamic_cast<entity::Photo*>(cnv->getGeodeData()->getChild(i));
if (!photo) continue;
photo->getOrCreateStateSet()->setTextureAttributeAndModes(0, photo->getTextureAsAttribute());
}
}

/* update current/previous canvases */
Expand Down

0 comments on commit 61d799a

Please sign in to comment.