Engine Design

D0a82d7acd5eb901221fa0011154c8e9
0
laslego 101 Mar 21, 2005 at 16:34

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

4 Replies

Please log in or register to post a reply.

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Mar 21, 2005 at 18:11

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

D0a82d7acd5eb901221fa0011154c8e9
0
laslego 101 Mar 21, 2005 at 18:20

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!

F7a4a748ecf664f189bb704a660b3573
0
anubis 101 Mar 21, 2005 at 18:40

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.

D0a82d7acd5eb901221fa0011154c8e9
0
laslego 101 Mar 21, 2005 at 22:31

Yeah, I see your point. Thanks for the help.