Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ShockBoy99

Dynamic class creation

This topic is 5863 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''m trying to create a class based on a string. For example in my engine: CRenderSystem* rs = CRenderSystemManager::GetClass ("OGLRenderSystem"); All of the classes I want do dynamically create like this are subclasses of CRenderSystem. Is this possible or is there a different way of creating classes based on strings? Thanks in advance. --------------------------------------------------------------------------------------- Before I couldn''t spell engineer, now I are one.

Share this post


Link to post
Share on other sites
Advertisement
You can do something like the following

CRenderSystem*
CRenderSystemManager::GetClass(const std::string& rendererName)
{
if (rendererName == "OGLRendererSystem")
{
// return OGL renderer
}
else (rendererName == "D3DRendererSystem")
{
// return D3D renderer
}
else
{
// . . .
}

return 0;
}



















Share this post


Link to post
Share on other sites
I would like something a little more dynamic. I want to be able to add the OGLRenderSystem.cpp/h files to the project and be able to create them automatically. I was thinking of having a static member function to call to register the class into the CRenderSystemManager class kind of like a pluggable factory.

---------------------------------------------------------------------------------------
Before I couldn''t spell engineer, now I are one.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!