[osg-users] std::vector instances from osg::geode derived classerror

Thrall, Bryan bryan.thrall at flightsafety.com
Wed Nov 11 08:00:01 PST 2009


Thorsten Werner wrote on Wednesday, November 11, 2009 9:56 AM:
> int posX = 585;
> 	int posY = 370;
> 	std::vector<TGWidgetElement> ElementLower;
> 	for(int i=count_width; i>0; i--)
> 	{
> 		ElementLower.push_back(TGWidgetElement(posX, posY,
> 		"WidgElementSideLower.png")); posX += 15;
> 		posY += 15;
> 		//this->addChild(ElementLower[count_width]);
>  	}
> 
> 
> I'm really stuck here. What am i doing wrong???

Group and other OSG Nodes declare operator= to be non-public so they
cannot be instantiated on the stack (which would easily lead to problems
with OSG's smart pointers); you have to dynamically allocate them.

Try something like this instead:

 int posX = 585;
 	int posY = 370;
 	std::vector<osg::ref_ptr<TGWidgetElement> > ElementLower;
 	for(int i=count_width; i>0; i--)
 	{
 		ElementLower.push_back(new TGWidgetElement(posX,
posY,"WidgElementSideLower.png"));
            posX += 15;
 		posY += 15;
 		//this->addChild(ElementLower[count_width]);
  	}

-- 
Bryan Thrall
FlightSafety International
bryan.thrall at flightsafety.com


More information about the osg-users mailing list