Jump to content
  • Advertisement
Sign in to follow this  
sprite_hound

luabind - c++ member functions as lua non-member functions

This topic is 3507 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I may have just got this the wrong way round in my head, but is it possible to have something like this:
-- lua code:

texture_handle = resources.add_texture("t_id", "t_file")
sound_handle = resources.add_sound("s_id", "s_file")


template<class T>
class ResourceManager {
public:
	unsigned int add(const std::string& type, const std::string& file);
	//...
};

class TextureManager : public ResourceManager<Texture> {
	//...
} textureManager;

class SoundManager : public ResourceManager<Sound> {
	//...
} soundManager;


luabind::module(state) [
	// How to register textureManager.add as resources.add_texture
	// and soundManager.add as resources.add_sound?
];


?

Share this post


Link to post
Share on other sites
Advertisement

int add_texture(std::string id, std::string file)
{
textureManager.add(id, file);
}

int add_sound(std::string id, std::string file)
{
soundManager.add(id, file);
}
...

luabind::module(state,"resources") [
def("add_texture", &add_texture),
def("add_sound", &add_sound)
];




Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!