Volumes Of Fun
http://www.volumesoffun.com/phpBB3/

Volume Paging
http://www.volumesoffun.com/phpBB3/viewtopic.php?f=2&t=210
Page 1 of 1

Author:  Deedel [ Fri Apr 29, 2011 12:05 am ]
Post subject:  Volume Paging

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 :)

Author:  David Williams [ Fri Apr 29, 2011 9:31 am ]
Post subject:  Re: Volume Paging

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.

Author:  Deedel [ Mon May 02, 2011 7:11 pm ]
Post subject:  Re: Volume Paging

That worked brilliantly, thank you :)

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/