Jump to content
  • Advertisement
Sign in to follow this  
Supaflyfrank

Adding Games Through DLL

This topic is 3757 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

Im working on a gaming client and I want to be able to add games to the client through dlls. For example to add a game to the client all the user needs to do is load the appropriate dll and you can play pac man. The game client would be using OpenGl and SDL so I need to run graphics,input and sound functions from dlls.

Share this post


Link to post
Share on other sites
Advertisement
why would it be a dll? could it be a file format of its own that they can just plug in ?

i think you need to tell us a bit more about what you have and what your wanting to do.

Share this post


Link to post
Share on other sites
Quote:
Original post by Supaflyfrank
Im working on a gaming client and I want to be able to add games to the client through dlls. For example to add a game to the client all the user needs to do is load the appropriate dll and you can play pac man. The game client would be using OpenGl and SDL so I need to run graphics,input and sound functions from dlls.

Uhm, Okay. And your question is ?

Share this post


Link to post
Share on other sites
I believe what you're looking for is Runtime Linking. You could dynamically load the game's DLL, then call a specific function from the DLL (say, "game_main") to act as a starting point for the game similar to the "main" function in C/C++.

Share this post


Link to post
Share on other sites
From a design perspective your core client could contain an interface pointer for example IPlugIn which has methods such as IPlugIn::Run(). When the DLL is loaded at runtime your core application would then obtain a handle to an object within the DLL which inherits from the IPlugIn class:

class CPacMan : public IPlugIn
{
};

So, your core client would execute the basic steps below:

1) Create a pointer of type IPlugIn
2) Load the DLL
3) Call into the DLL to return a pointer to a function to create the object (you can't just export the class)
4) Call the Run() method on the returned object and have the DLL handle all game logic


class IPlugIn
{
public:

IPlugIn( void );
virtual ~IPlugIn( void );

virtual void Run( void ) == 0;
};

// this would be defined in your DLL
__declspec( dllexport ) CPacMan* CrateLogic( void )
{
return new CPacMan();
}

// so would this
class CPacMan : public IPlugIn
{
CPacMan( void );
virtual ~CPacMan( void );

virtual void Run( void );
};

int main( void )
{
// define a pointer to the IPlugIn interface
IPlugIn* pGameLogic;

// go through all your steps here to load the DLL of choice

// obtain a handle to the DLLs "CreateLogic" method for example

// obtain a pointer to the CPacMan object
pGameLogic = (IPlugIn*)(DLL function here)

// run the logic
pGameLogic->Run();
};






This of course isn't perfect but just something to think about if nothing else.

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!