It is currently Sat Aug 22, 2020 4:13 am


All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Volume Paging
PostPosted: Fri Apr 29, 2011 12:05 am 

Joined: Sat Apr 23, 2011 11:13 pm
Posts: 7
Hiya all,

I'm currently trying to implement paging with the Volume class using the required and overflow functions. I use a pointer to construct the Volume but whenever I try to point the constructor to the two functions it fails with the error message:

Quote:
Error 1 error C2064: term does not evaluate to a function taking 2 arguments c:\program files\microsoft visual studio 10.0\vc\include\xxcallobj 13


I'm referencing these functions via &Object::FunctionName and that's what causes this error. When the functions are outside a class it works perfectly fine, but this is, of course, very impractical.

Is there any way to allow use of the functions when they are in the same or a different class? I've tried pointers to classes, this methods, and various other things but it just doesn't seem to work.

The two functions are currently in LevelHandler and this is the constructor of the volume:

Quote:
volume_data_ = new PolyVox::Volume<PolyVox::MaterialDensityPair44>(&LevelHandler::DataRequiredHandler, &LevelHandler::DataOverflowHandler, 32);


Thanks :)


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Volume Paging
PostPosted: Fri Apr 29, 2011 9:31 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Are you using a C++0X complient compiler? If so you can use:

Code:
Loader loader;

std::function<void(const ConstVolumeProxy<MaterialDensityPair44>&, const Region&)> loadFunction = std::bind(&Loader::load, &loader, std::placeholders::_1, std::placeholders::_2);

std::function<void(const ConstVolumeProxy<MaterialDensityPair44>&, const Region&)> unloadFunction = std::bind(&Loader::unload, &loader, std::placeholders::_1, std::placeholders::_2);

Volume<MaterialDensityPair44> volData(loadFunction, unloadFunction, 32);


If not then you need to look at boost::bind instead.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Volume Paging
PostPosted: Mon May 02, 2011 7:11 pm 

Joined: Sat Apr 23, 2011 11:13 pm
Posts: 7
That worked brilliantly, thank you :)


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


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 post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net