🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

How to start making a game engine?

Started by
6 comments, last by FoolishWasTaken 4 years, 1 month ago

Hey, I want to create my own 3D game engine, but I am CLUELESS on how to start. I don't want to make games, I just want to create a game engine for myself. I know it's hard, but it is what I am interested in. I've read Game Engine Architecture by Jason Gregory, and I am proficient in C++. I have some knowledge in modern OpenGL, and I am hoping to learn more as I go on. I just have no idea on how to make a game engine. All the sources online are very vague and broad about the topic, and I am wondering how to proceed. I have good software engineering knowledge as I have a degree in Software Engineering. I have good math knowledge as well.

I am mostly struggling with the whole layout and structure of the renderer, and all the objects to be rendered. What are the essential components of these objects? If you have any resource on building a game engine from scratch they would be helpful. Every book I've read so far gives an abstract overview of how a game engine works, but no code or structure of how to do it. Thank you!

Advertisement

I doubt there are many resources online that tell you how to structure an engine codewise, as those are very complicated topics with lots of code involved, and also there are like 200 ways how you could structure things. There are some great resources spreat around for the different topics, for example I based my renderer on this thread:

https://www.gamedev.net/forums/topic/604899-frostbite-rendering-architecture-question/page-2?page=1

Other than that, you should get yourself familiar with popular engines, like Unity and Unreal. Even if you intend to make your own, you are going to learn lots of things from working with a different engine. I would say its essential if you want to make your own to look at what others are doing. I drew lots of influence from other engines. Rpg-Maker taught me a whole lot of how not to do things. Unreal had some neat things that I liked (their visual scripting, etc…) but also some things I wouldn't do (their messy inheritance-structure, etc…). Unity I personally despise, though even there I took a few things that I liked (a variance on their composition-structure and some features from C# that I adapted as far as possible to C++.

One last thing to mention: You just need to get going. Thats the most important part. Building an engine, even rudimentary is a daunting task, and you are never going to get it done if you do not get medias res and come up with some solutions. It doesn't have to be perfect, by god I refactored the entire codebase of my engine like 3-4 times by now. But if you add piece by piece you can end up with something useful.

Oh, forgot one thing: Have a game to work on with your engine. That helps as well. Even if you do not want to make a game, pick some sample project like breakout or pong that you want to realize. If you have no game driving your development, its way harder to come up with things to implement, and you will end up working rudderless.

Thank you for the advice! I guess it's only time for me to actually begin this journey =)

@foolishwastaken I already wrote a large post onto another, similar question here

https://gamedev.net/forums/topic/706193-making-a-2d-game-engine-from-scratch/5423023/

It describes my experience with exactly asking these questions, how should I manage my project, what tools do I need, what else except fancy graphics is essential for creating a game engine and so on. Worth a reading ?

You could always try writing your first engine following some tutorials like The Cherno. Then when you know more you could create your own.

I am in the same position as you and I decided to just get started. I need to learn some more c++ though, but I am experienced in coding at least ?

I too wanted to make my own engine, even knowing it would likely be wasted effort. I've spent like the past 7 years experimenting with various APIs and frameworks, and then also switching back to mainstays like Unity and Unreal in between. I don't actually know what the right answer is, as it will depend on what you want to accomplish and learn. So I do think there is value in custom engines in very specific cases. But I realize you just want advice and not discouragement, so I'll leave that as an open question.

My advice would be to download and play with as many engines as possible. Big ones like Unity and Unreal (or course), open source engines like Godot. Maybe look at OGRE or Panda3D or other programming only APIs. Get a feel for how to design a good API, what intuitively makes sense, what people in the scene are familiar with. You can borrow ideas from other projects, not stealing code, but reusing concepts like an entity component model, or scene graph, or things like that. Even if you don't actually build anything with them, read a few tutorials just to see how to load up a spinning cube so you get an idea. Or maybe just peek at the source code if available. At the very least you can see how vast a game engine code-base can be.

I would even go as far as saying you should try to write a simple game using your engine, before you write the engine. At least code up something simple like PONG or Super Mario Bros. (first level) in a “mock” API and imagine what the best design would be. Then you can work backwards and think what modules specifically would need to exist to support that interface. Granted, it won't be exact, but it will get your mind working on the right track and also inform the design based on the client needs (you being the client with a “fake” game already written). Otherwise you can get lost and start coding things that aren't necessary at first, or designing an obtuse API.

If you start with that you can probably learn a lot. You don't want to start by replicating Unity. That would be almost impossible, or at least a daunting forever project. But something more focused, like for one specific genre or even one game (think like a level editor on commercial games), that can be possible even for 1 person. But start as simple as you can and limit the scope as much as possible.

Also, don't try to reinvent the wheel on everything. There are lots of good small libraries for doing things like loading PNG graphics files or writing XML files, or playing sound effects, etc. Even big engines like Unity and Unreal didn't code everything from scratch. They still use PhysX for physics, or Wwise for audio, or all sorts of open-source libraries. So don't do everything from scratch. You'll find that your “engine” may do very little to no actual “work”. You can think of it like mortar that holds a wall of bricks together. It's more about creating an easy to use API and abstracting away the complexities of using each library on it's own. Though, you can then replace components of the engine later (if you design it correctly), for example if you wish to write your own physics engine or update to a new graphics API.

That said, what tools or libraries you pick could drastically alter how you design the API. For example, between going with OpenGL or Vulkan, I imagine could look very different. Or if it's C++ only, or you use a scripting language. Or if you want an editor or programming only interface. Or if you want cross-platform from the start, and also which platforms you are targeting. This can have a huge impact on even what IDE or programming language or OS you choose (for example Apple versus Microsoft ecosystems). So do research, it's not set in stone, but it can make your life harder if there are surprises later on in development and you spent 1 year going in the wrong direction (I've done this).

But don't let that stop you from taking action. The most important thing is constant practice and progress. So just get in there and start coding after you've done the other things I mentioned. It's actually not as hard as you think to get started. If you have programming experience, you can pretty quickly get stuff moving on the screen. It gets more complex as you get further, but you can learn as you go (and refactor, or remake things as you need). Good luck.

SibylSystem said:
Then you can work backwards and think what modules specifically would need to exist to support that interface.

I actually noticed that this method is how I mainly started learning OpenGL. I created a quad and then abstracted some of the things that I thought were necessary in creating just a single quad (Vertex buffers, element buffers, etc.). I really appreciate your advice and I am going to start as soon as possible creating something. I am planning on making it windows only as that in itself seems pretty big scope.

This topic is closed to new replies.

Advertisement