PDA

View Full Version : Engine Design


laslego
03-21-2005, 09:34 AM
Hi all,

I've recently been working on an engine for a game I'm working on. I have chosen to make the layout the engine, in such a way that the engine is in an exe and the gamecode is in a DLL. The way it is now, is that the engine calls an entrypoint in the DLL. Problem is that if the entrypoint has a loop in it(Infinite or not), the engine will hang, waiting for the DLL's entrypoint to return. How can I avoid this ? I thought of creating a thread to run the DLL in, but I'm not sure if it going to work. Thanks in advance.

Btw. I'm using Delphi/Pascal

anubis
03-21-2005, 11:11 AM
what's the problem ? just don't run infinite loops in the dll. if you run an infinite loop anywhere in your engine it will hang

laslego
03-21-2005, 11:20 AM
In the rest of the engine I can do Application.ProcessMessages. I can't do this in the DLL since the Application object is not the same as in the exe!

I need to run an infinite loop in the DLL, since the DLL is going to be the game code, which calls the engine, and not the other way round!

anubis
03-21-2005, 11:40 AM
well... the game still doesn't need to run the loop. by design the engine should run the loop when you place the game in the dll. just provide some form of update mechanism in the dll. you might even generalize this in a way that allows you to handle all the updateable things in your engine. just provide one common base class with a virtual update method and register them upon dll oading with the engine. then the engine can conveniently call all the update methods (input and whatnot) each frame.

a problem that migth arise is calling the update methods in the correct order. either you just reigster them in the correct order or you introduce some priority or dependency system.

laslego
03-21-2005, 03:31 PM
Yeah, I see your point. Thanks for the help.