have the engine in the .exe or .dll file?

Started by
48 comments, last by SuperDre 19 years, 7 months ago
Quote:Original post by Nemesis2k2
I need to clarify what you mean by having the engine "as an executable". Would this include the engine being in a seperate static lib which is included as part of the executable? If so, I'll agree. If not, you're totally wrong.


I don't necessarily mean in a static library. I have my engine compiled directly into an executable. The difference is that I have some shared components, such as the renderer, which can be compiled into any of my other projects (such as the map editor).

Quote:Just because something is in wide use doesn't mean it's good. There are a few "traditional" things about game engine design I think could be done a lot better (eg, engine "modes". *shudder*), but they're still widely used today. Why? Because most people will just default to tried and tested rather than trying to invent new approaches.


The "engine in a dynamic library and game in an executable" approach is tried and tested. Its not practical.

Looking for a serious game project?
www.xgameproject.com
Advertisement
Quote:Original post by Max_Payne
The "engine in a dynamic library and game in an executable" approach is tried and tested. Its not practical.


Worked for FarCry.
Quote:Original post by Anonymous Poster
Quote:Original post by Max_Payne
The "engine in a dynamic library and game in an executable" approach is tried and tested. Its not practical.


Worked for FarCry.


and a little thing called "Unreal"

-neurokaotix
Quote:Original post by Anonymous Poster
-neurokaotix

and he continues to leave his mark on gamedev....

In my opinion its just personal prefrence. They both work for diffrent magor companies. I personally Im doing game in .lib
(I hate dll files to my core, they had hurt me deep last time I used them) and engine in exe.
______________________________________________________________________________________With the flesh of a cow.
Quote:I don't necessarily mean in a static library. I have my engine compiled directly into an executable. The difference is that I have some shared components, such as the renderer, which can be compiled into any of my other projects (such as the map editor).

Well in that case, no, you can't do everything you could with it as if it was in a dll, or even a lib for that matter. It goes back to my original point. When you put the engine in charge of creating its own drawing surface and initializing itself, then have it only call any of your code when it's all ready to go, you can't really do anything with it anymore, other than run the game. In my editor, the engine is going to be running in a child window of my editor. How can I do that if the engine is responsible for creating its own window? Sould I now bloat out that engine basecode and add a thousand functions for overriding the default window creation options, for every situation in which I might want to create that window? What if I decide I want to do something slightly different with my engine, such as render to a movie instead? If I control the drawing surface, both of those are dead easy. If I don't, they're nigh impossible.

Quote:The "engine in a dynamic library and game in an executable" approach is tried and tested. Its not practical.

What makes it impractical? You're gonna have to qualify this one, because IMO it's totally baseless. You can implement all three of these systems (in the exe, static lib, dynamic lib) in about 5 minutes, and all three of them appear the exact same way when the engine source is bound to your application. You just call a function, you don't know or care if that comes from a lib, dll, or attached source. All you do is include a header. The differences are organisational.



And once again, the real issue here is the word "as". You're saying you should have the engine as the exe, not just in the exe. Hell, if the engine I was using came as 300 uncompiled source files I had to dump into my project, it would still give me all the flexability I would need, it would just be messy. Having the engine as the exe however would make it virtually impossible to use that engine outside the context of just playing the actual game, and that is the problem I have with that approach. I now have no choice over how I can use the engine, it decides that for me. Would you use something like OpenGL or DirectX if they were actual programs that had to launch in a seperate window, the creation poroperties of which you had no control over, and you had no chance to run any code before that window was created? Suppose I wanted to render to a small pane of my windows app instead. I couldn't, unless the afore mentioned million extra functions were added to get around the fact it was too inflexible to start with. That would not be suitable for a rendering API, and it's not suitable for a 3D engine.
Quote:Original post by Ainokea
Quote:Original post by Anonymous Poster
-neurokaotix

and he continues to leave his mark on gamedev....


Just trying to contribute friend, no bad intentions
It would be nice if someone got Yann to give us a closing word on the topic.
Why do you need Yann to make a closing comment? He can't tell you which is the better approach because -it depends- as does most things in programming.

My suggestion: Using DLLs allows to separate the issues. You can split the tasks on different parts and focus on the things that matters. Not to mention that you get something reusable (i.e bink, fmod, sdl, glut and the list goes on) for the future.

I just happen to prefer DLLs but that is just me. You really need to evaluate what works best for your particular project.
No no no no! :)
Quote:Original post by Nemesis2k2Well in that case, no, you can't do everything you could with it as if it was in a dll, or even a lib for that matter. It goes back to my original point. When you put the engine in charge of creating its own drawing surface and initializing itself, then have it only call any of your code when it's all ready to go, you can't really do anything with it anymore, other than run the game. In my editor, the engine is going to be running in a child window of my editor. How can I do that if the engine is responsible for creating its own window?


Its simple, the engine does not create the window, the renderer does. And the renderer is a common component shared by both the engine and the editor. Why the hell should the editor have to bother with a bulky engine, when it can just use the renderer. Simple enough?

Quote:What if I decide I want to do something slightly different with my engine, such as render to a movie instead?


Implement that feature in your engine. Where do you want the problem to be?

Quote:What makes it impractical? You're gonna have to qualify this one, because IMO it's totally baseless.


Its impractical because it forces each game to create its own executable and worry about such irrelevant details as the initialization of the engine (and often alot more than that).

The "engine in executable, game in dynamic library" is also the most logical layout. The engine is a "game operating system". And it works like the stages of a rocket. The engine runs on top of your operating system, taking care of all system specifics. The game runs on top of the engine, and only has to worry about the behavior of the game. The game does not "use" the engine, it runs on top of the engine.

This approach also has some added benefits. Such as the fact that the engine can load a different game without having to restart. And of course, if you were to have your engine in an executable, and your game in script files... You could run your game on multiple platforms, with no modifications, simply by running it on the engine binary that is specific to your platform.

Looking for a serious game project?
www.xgameproject.com
Quote:Its simple, the engine does not create the window, the renderer does. And the renderer is a common component shared by both the engine and the editor. Why the hell should the editor have to bother with a bulky engine, when it can just use the renderer. Simple enough?

Simple, but totally useless. All my renderer does is render the portion of my scene graph I tell it to. More accurately, it's passed a render list from my sorter. That render list referances nodes that are part of my scene graph. My scene graph is the heart of my engine. After all, the job of my editor is to generate a scene graoph file which I can load back as a level. How can I do that without access to the engine components that actually define my scene graph?

That aside, I want to avoid interaction between my renderer and anythhing outside my 3D engine. Hell, I'm even trying to keep interaction between it and the rest of my 3D engine to a minimum. Any renderer state information I need to set can be set through global settings for my scene graph. That's what they're there for.

Quote:Implement that feature in your engine. Where do you want the problem to be?

Yeah, that could work. Or, I could just give the developer control over that 5 function main loop in the base application, and they can do whatever they want. You realize that this little bit of code that's causing all the problems, namely the window creation code and main loop, is a couple of pages of source, right? If I let them write that themselves, all these problems disappear.

Quote:Its impractical because it forces each game to create its own executable and worry about such irrelevant details as the initialization of the engine (and often alot more than that).

So, what's so much harder about compiling 3 pages of source into an executable? And these "details" are far from irrelivent, or they wouldn't cause so many problems if you couldn't control them. Besides, as I said, this is a few pages of code we're talking about here. A few pages that could well save me from writing an extra few hundred, and in the end, this method would still be better.

Quote:The "engine in executable, game in dynamic library" is also the most logical layout. The engine is a "game operating system". And it works like the stages of a rocket. The engine runs on top of your operating system, taking care of all system specifics. The game runs on top of the engine, and only has to worry about the behavior of the game. The game does not "use" the engine, it runs on top of the engine.

I agree, the 3D engine should call the game content. I'm not talking about the game content though. There should be a third layer of abstraction here at the base. You should have your window creation code and your main loop in the executable. On top of that sits the engine, and on top of the engine sits your game code, be it in scripts or a dll or whatever. That's unimportant here. The issue is the 3D engine and where it starts, and I don't think it should handle window creation, or control the main loop of the application. It makes it too inflexible. As I said before, this application at the base is only going to be a few pages of source, but it's vital if you want the engine to be flexible in any way.

Quote:This approach also has some added benefits. Such as the fact that the engine can load a different game without having to restart. And of course, if you were to have your engine in an executable, and your game in script files... You could run your game on multiple platforms, with no modifications, simply by running it on the engine binary that is specific to your platform.

All of that is still perfectly possible with the way I'm describing, and I don't know where you got the idea I'd have to restart the engine from for this approach. During the game, the base application will be doing little more than:
while(!done){	engine.update(time)	SwapBuffers()	engine.draw()	CheckMessages()}


[Edited by - Nemesis2k2 on September 6, 2004 4:24:50 PM]

This topic is closed to new replies.

Advertisement